var slides;
var fades = new Array();
var fadeDuration = 1000;
var MODULES_URL = "/includes/modules";
var BASE_IMAGES = "/includes/modules/base/images";
var mouseX, mouseY;

function evaluate_js(response) {
	var startTag = "<script type='text/javascript'>";
	var endTag = "<\/script>";
	var pos = response.indexOf(startTag);
	while (pos > -1) {
		var endPos = response.indexOf(endTag, pos + 1);
		if (endPos > -1) {
			var start = pos + startTag.length;
			var js = response.substr(start, endPos - start);
			eval(js);
			pos = response.indexOf(startTag, endPos)
		}
	}
}

function evaluate_js_headers(b) {
	var f = "<script type='text/javascript' src='";
	var e = "' />";
	var h = b.indexOf(f);
	while (h > -1) {
		var c = b.indexOf(e, h + 1);
		if (c > -1) {
			var g = h + f.length;
			var d = b.substr(g, c - g);
			alert(d);
			var a = document.createElement("script");
			a.type = "text/javascript";
			a.src = d;
			document.getElementsByTagName("head")[0].appendChild(a);
			h = b.indexOf(f, c)
		}
	}
}

function get_cookie(b) {
	var c = document.cookie;
	var f = c.indexOf(b + "=");
	if (f != -1) {
		var e = f + (b.length + 1);
		var a = c.indexOf(";", e);
		if (a == -1) {
			a = c.length
		}
		var d = c.substring(e, a);
		d = unescape(d);
		return d
	} else {
		return false
	}
}

function get_cookie_filter(a) {
	return get_cookie("cms_" + a + "_filter")
}

function get_list_order(a, c) {
	var b = new Array();
	var d = $(a).childNodes;
	for (i = 0; i < d.length; i++) {
		if (d[i].nodeName == "LI") {
			if (d[i].getAttribute(c) != null) {
				b.push(d[i].getAttribute(c))
			}
		}
	}
	return b
}

function get_mouse_xy(a) {
	if (BrowserDetect.browser == "Explorer") {
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop
	} else {
		mouseX = a.pageX;
		mouseY = a.pageY
	}
	if (mouseX < 0) {
		mouseX = 0
	}
	if (mouseY < 0) {
		mouseY = 0
	}
	return true
}

function get_selection_parts(d) {
	if (document.selection) {
		var a = document.selection.createRange();
		var b = a.duplicate();
		b.moveToElementText(d);
		b.setEndPoint("EndToEnd", a);
		d.selectionStart = b.text.length - a.text.length;
		d.selectionEnd = d.selectionStart + a.text.length
	}
	var c = d.value.substr(0, d.selectionStart);
	var f = d.value.substr(d.selectionStart, d.selectionEnd - d.selectionStart);
	var g = d.value.substr(d.selectionEnd);
	if (f == "") {
		return false
	} else {
		return {
			start: c,
			selected: f,
			end: g
		}
	}
}

function popUp(b, d, a) {
	var f = (screen.width - d) / 2;
	var e = (screen.height - a) / 2;
	var c = "width=" + d + ", height=" + a + " ,left=" + f + " ,top=" + e;
	insert_window = window.open(b, "popup", "toolbar=0,scrollbars=1,statusbar=0,menubar=0,resizable=1," + c);
	insert_window.focus()
}

function pod_accordion_click(b, a) {
	if (typeof(pageTracker) != "undefined") {
		var c = b + " - [" + a + "]";
		pageTracker._trackEvent("Pod-Accordion", "click", c)
	}
}

function say_hi() {
	alert("hi")
}

function set_cookie(b, d, c, a) {
	var f;
	if (a == undefined || a == -1) {
		f = a == -1 ? -1 : 1
	} else {
		f = a
	}
	a = new Date();
	a.setTime(a.getTime() + (f * 1000 * 60 * 60 * 24));
	var e = b + "=" + d + "; path=/; expires=" + a.toGMTString();
	e += ((c != "" && c != undefined) ? "; domain=" + c : "");
	document.cookie = e
}

function set_cookie_filter(a, b) {
	set_cookie("cms_" + a + "_filter", b)
}

function set_height(b, a) {
	$(b).style.height = a + "px"
}

function set_left(b, a) {
	$(b).style.left = a + "px"
}

function set_top(b, a) {
	$(b).style.top = a + "px"
}

function set_width(b, a) {
	$(b).style.width = a + "px"
}


function reveal_email(c, b, a) {
	if (c != "" && b != "") {
		document.location = "mailto:" + b.reverse() + "@" + c.reverse() + a
	}
}

function showHide(b) {
	var a = $(b);
	if (a.style.display == "none" || a.style.display == "") {
		showHideDivs(b, "show")
	} else {
		showHideDivs(b, "hide")
	}
}

function hideShow(b) {
	var a = $(b);
	if (a.style.display == "block" || a.style.display == "") {
		showHideDivs(b, "hide")
	} else {
		showHideDivs(b, "block")
	}
}

function showHideDivs() {
	var c, e, a, d, b = showHideDivs.arguments;
	for (c = 0; c < (b.length - 1); c += 2) {
		if ((d = $(b[c])) != undefined) {
			a = b[c + 1];
			if (d.style) {
				d = d.style;
				a = (a == "show") ? "block" : (a == "hide") ? "none" : a
			}
			d.display = a
		}
	}
}

function switch_to_https() {
	var a = window.location.href;
	if (a.indexOf("https") == -1 && a.indexOf("/admin/") < 0) {
		p = a.indexOf("p");
		window.location = "https" + a.substr(p + 1)
	}
}

function submit_form(a) {
	$(a).submit()
}

function try_text_focus(form, field) {
	if ($defined($(form))) {
		eval("var field = $('" + form + "')." + field + ";");
		if (field != undefined) {
			field.focus()
		}
	}
}

function upper_case_first(a) {
	return a.substr(0, 1).toUpperCase() + a.substr(1)
}

function validate_require_all(a) {
	var b = true;
	for (i = 0; i < a.elements.length; i++) {
		if (a.elements[i].type != "hidden" && a.elements[i].type != "submit") {
			if (a.elements[i].value == "") {
				a.elements[i].parentNode.className += " warning";
				b = false
			}
		}
	}
	return b
}
String.prototype.reverse = function () {
	var c = "";
	var a = this.length;
	for (var b = a; b > 0; b--) {
		c += this.substring(b - 1, b)
	}
	return c
};
Array.prototype.find = function (b) {
	for (var a = 0; a < this.length; a++) {
		if (this[a] == b) {
			return true
		}
	}
	return false
};
Function.prototype.closure = function (c) {
	if (!window.__objs) {
		window.__objs = [];
		window.__funs = []
	}
	var a = this;
	var b = c.__objId;
	if (!b) {
		__objs[b = c.__objId = __objs.length] = c
	}
	var d = a.__funId;
	if (!d) {
		__funs[d = a.__funId = __funs.length] = a
	}
	if (!c.__closures) {
		c.__closures = []
	}
	var e = c.__closures[d];
	if (e) {
		return e
	}
	c = null;
	a = null;
	return __objs[b].__closures[d] = function () {
		return __funs[d].apply(__objs[b], arguments)
	}
};

function direction_change(a) {
	temp = document.forms.stopViewForm.direction.value;
	if ($defined(a)) {
		route_stop_ajax(temp, a)
	}
}

function get_stop_json_info(a) {
	var c = Json.evaluate(a);
	var b = c.stop;
	track_stop_event("NextBus", b.id, b.name)
}

function track_stop_event(c, b, a) {
	var d = get_url_no_domain();
	if (b != -1) {
		pageTracker._trackEvent("Stops", c, d + " : " + b + " - " + a)
	}
}

function get_url_no_domain() {
	var a = window.location.href;
	a = a.replace("http://ridetherapid.ddmnet.com", "");
	return a.replace("http://www.ridetherapid.org", "")
}

function navigation_route_change() {
	$("routeNavigationOptions").style.display = $("routeNavigationForm").routeID.value == "" ? "none" : "block"
}

function navigate_route_info(a) {
	var b = $("routeNavigationForm");
	if (b.routeID.value != "") {
		b.pageType.value = a;
		b.submit()
	} else {
		alert("You must selecte a route first.")
	}
}

function set_header_position() {
	var b = 0;
	var a = $("mainStops");
	scrollY = getScrollY();
	if (257 < scrollY) {
		a.style.top = (scrollY - 258) + "px"
	} else {
		a.style.top = b + "px"
	}
}

function StopIcon() {
	var a = new GIcon();
	a.shadow = "";
	a.image = "/includes/modules/routes/images/stop.png";
	a.iconSize = new GSize(7, 7);
	a.iconAnchor = new GPoint(3, 3);
	return a
}

function TimepointIcon() {
	var a = new GIcon();
	a.shadow = "";
	a.image = "/includes/modules/routes/images/timepoint.png";
	a.iconSize = new GSize(12, 12);
	a.iconAnchor = new GPoint(6, 6);
	return a
}

function create_marker(a) {
	var c = new GIcon(baseIcon);
	var b = new GMarker(a, c);
	GEvent.addListener(b, "click", function () {
		b.openInfoWindowHtml("<div class='bubble'>" + a + "</div>")
	});
	return b
}

function add_ajax_stops(b) {
	var c = Json.evaluate(b);
	for (var a = 0; a < c.stops.length; a++) {
		map.addOverlay(create_marker(new GLatLng(c.stops[a].lat, c.stops[a].lng)))
	}
}

function stopID_form_action() {
	var a = $("stopIDForm").stopID.value;
	a = a.trim();
	a = a.replace("#", "");
	if (isNaN(a)) {
		$("stopIDMessage").innerHTML = "Stop IDs are numeric, please try entering a number."
	} else {
		if (a != "") {
			show_stopID_popup(a);
			$("stopIDMessage").innerHTML = "";
			base_ajax("", "/includes/modules/stops/controllers/jsonObj.php", "stopID=" + a, "get_stop_json_info(response)")
		} else {
			$("stopIDMessage").innerHTML = "Please enter a stop ID above."
		}
	}
}

function stopID_verboseform_action() {
	var c = document.getElementById("routeStopSelect").value;
	var a = $("routeSelect").value;
	var b = a.split("-");
	show_stopID_popup(c, b[0]);
	base_ajax("", "/curls/jsonStopObject.php", "stopID=" + c + "&routeNumber=" + b[0], "get_stop_json_info(response)")
}

function stopID_updateDirection() {
	document.getElementById("routeDirectionSelect").disabled = false;
	$("routeStopSelect").disabled = true;
	var b = "<select onchange='javascript:stopID_updateRoutes()' id='routeDirectionSelect'  style='width:200px;'>";
	var a = document.getElementById("routeSelect").value.split("-");
	if (a[1] == "EW") {
		document.getElementById("routeDirectionSelectID").innerHTML = b + '<option value="" >- Select Direction -</option><option value="W">Westbound</option><option value="E">Eastbound</option></select>'
	} else {
		if (a[1] == "NS") {
			$("routeDirectionSelectID").innerHTML = b + "<option value=''>- Select Direction -</option><option value='N'>Northbound</option><option value='S'>Southbound</option></select>"
		} else {
			if (a[1] == "Loop") {
				document.getElementById("routeDirectionSelectID").innerHTML = b + '<option value="" >- Select Direction -</option><option value="L">Loop</option></select>'
			} else {
				document.getElementById("routeDirectionSelect").disabled = "disabled";
				document.getElementById("routeStopSelect").disabled = "disabled";
				document.getElementById("routeDirectionSelectID").innerHTML = b + '<option value="">- Select Direction -</option></select>'
			}
		}
	}
	document.getElementById("routeStopSelect").value = ""
}

function stopID_updateRoutes() {
	var b = document.getElementById("routeDirectionSelect").value;
	var a = document.getElementById("routeSelect").value;
	if (b == "") {
		document.getElementById("routeStopSelect").disabled = "disabled";
		document.getElementById("routeStopSelect").innerHTML = '<option value="">- Select Stop -</option>'
	} else {
		base_ajax("routeStop", "/curls/stopSelectFormElements.php", "mode=genStops&routeDirectionSelect=" + b + "&routeSelect=" + a, "$('routeStopSelect').disabled = false;")
	}
}
var stopIdPopUpID = "stopIDPopUp";

function create_stopID_popup() {
	var a = document.getElementById(stopIdPopUpID);
	if (a == null) {
		var b = document.createElement("div");
		b.setAttribute("id", stopIdPopUpID);
		document.getElementsByTagName("BODY")[0].appendChild(b)
	}
}

function show_stopID_popup(b, f) {
	var c = document.getElementById(stopIdPopUpID);
	if (c == null) {
		var h = document.createElement("div");
		h.setAttribute("id", stopIdPopUpID);
		document.getElementsByTagName("BODY")[0].appendChild(h)
	}
	base_ajax(stopIdPopUpID, "/curls/routeStopInfo.php", "stopID=" + b + "&routeNumber=" + f, "add_stopID_popup_closer();");
	var e = 400;
	var c = document.getElementById(stopIdPopUpID);
	var g = 600;
	var a = 600;
	var d = Window.getSize();
	c.style.zIndex = "10000";
	c.style.position = "absolute";
	c.className = "stopPopUp";
	c.style.top = ((d.size.y / 2) - (e / 2)) + d.scroll.y + "px";
	c.style.left = ((d.size.x / 2) - (e / 2)) + "px";
	c.style.width = e + "px";
	c.innerHTML = "<h3>Loading...</h3>";
	c.style.display = "block"
}

function add_stopID_popup_closer() {
	var a = $(stopIdPopUpID).innerHTML;
	$(stopIdPopUpID).innerHTML = "<div class='header'><a href=\"javascript:showHideDivs('" + stopIdPopUpID + "','hide')\" title='Close Stop Information Window'><img src='http://www.ridetherapid.org/includes/modules/stops/images/close.gif' alt='Close' /></a><h2>Next Bus</h2></div>" + a
}

function stopID_select_your_stop() {
	var b = document.getElementById(stopIdPopUpID);
	if (b == null) {
		var f = document.createElement("div");
		f.setAttribute("id", stopIdPopUpID);
		document.getElementsByTagName("BODY")[0].appendChild(f)
	}
	base_ajax(stopIdPopUpID, "/includes/modules/stops/controllers/stopSelectFormElements.php", "", "add_stopID_popup_closer();");
	var d = 400;
	var b = document.getElementById(stopIdPopUpID);
	var e = 600;
	var a = 600;
	var c = Window.getSize();
	b.style.zIndex = "10000";
	b.style.position = "absolute";
	b.className = "stopPopUp";
	b.style.top = ((c.size.y / 2) - (d / 2)) + c.scroll.y + "px";
	b.style.left = ((c.size.x / 2) - (d / 2)) + "px";
	b.style.width = d + "px";
	b.innerHTML = "<h3>Loading...</h3>";
	b.style.display = "block"
}

function position_stopID_popup() {
	var c = 400;
	var b = document.getElementById(stopIdPopUpID);
	var d = 600;
	var a = 600;
	b.style.zIndex = "10000";
	b.style.position = "absolute";
	b.className = "stopPopUp";
	b.style.top = ((d / 2) - (c / 2)) + 0 + "px";
	b.style.left = ((a / 2) - (c / 2)) + "px";
	b.style.width = c + "px";
	b.innerHTML = "<h3>Loading...</h3>";
	b.style.display = "block";
	position_stopID_popup()
};

var ajaxIndication = "&AJAXED=true";

function create_request() {
	var a;
	if (window.XMLHttpRequest) {
		a = new XMLHttpRequest()
	} else {
		if (window.ActiveXObject) {
			a = new ActiveXObject("Microsoft.XMLHTTP")
		}
	}
	if (!a) {
		alert("Cannot create an XMLHTTP instance");
		return false
	} else {
		return a
	}
}

function base_ajax(tagID, url, sendStr, callback) {
	var req = create_request();
	if (req) {
		req.open("POST", url, true);
		req.onreadystatechange = function () {
			if (req.readyState == 4 && req.status == 200) {
				var response = req.responseText;
				if (tagID != "") {
					var elem = document.getElementById(tagID);
					elem.innerHTML = response
				} else {} if (callback != "" && callback != undefined) {
					eval(callback)
				}
			}
		};
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		req.send(sendStr + ajaxIndication)
	}
}
