// JavaScript Document

var hover_visitors = false;
var hover_residents = false;
var hover_planners = false;
var hover_media = false;
var hover_members = false;
var hover_button_hotel = false;
var hover_button_social = false;
var activeField;
var activeDiv;
var todayInt;
var usingIE = false;

$(document).ready(function() {
						   
	if (navigator.appName == "Microsoft Internet Explorer") {
		usingIE = true;
		$('#browser').show(0);
		}
	
	// Menu Item Hover Functions
	$('#menuItem_visitors').hover(
		function() {
			if (!hover_visitors) {
				closeMenu("closeAll");
				hover_visitors = true;
				$('#menuDiv_visitors').show();
				$('#menuItem_visitors').addClass("menuItemHover");
				$('#menuItem_visitors').css("color","#1f5eff");
			}
		},
		function() {
			hover_visitors = false;
			setTimeout("closeMenu('visitors')",1000);
		}
	);

	$('#menuItem_residents').hover(
		function() {
			closeMenu("closeAll");
			hover_residents = true;
			$('#menuDiv_residents').show();
			$('#menuItem_residents').addClass("menuItemHover");
			$('#menuItem_residents').css("color","#1f5eff");
		},
		function() {
			hover_residents = false;
			setTimeout("closeMenu('residents')",1000);
		}
	);
	
	$('#menuItem_planners').hover(
		function() {
			closeMenu("closeAll");
			hover_planners = true;
			$('#menuDiv_planners').show();
			$('#menuItem_planners').addClass("menuItemHover");
			$('#menuItem_planners').css("color","#1f5eff");
		},
		function() {
			hover_planners = false;
			setTimeout("closeMenu('planners')",1000);
		}
	);

	$('#menuItem_media').hover(
		function() {
			closeMenu("closeAll");
			hover_media = true;
			$('#menuDiv_media').show();
			$('#menuItem_media').addClass("menuItemHover");
			$('#menuItem_media').css("color","#1f5eff");
		},
		function() {
			hover_media = false;
			setTimeout("closeMenu('media')",1000);
		}
	);
	
	$('#menuItem_members').hover(
		function() {
			closeMenu("closeAll");
			hover_members = true;
			$('#menuDiv_members').show();
			$('#menuItem_members').addClass("menuItemHover");
			$('#menuItem_members').css("color","#1f5eff");
		},
		function() {
			hover_members = false;
			setTimeout("closeMenu('members')",1000);
		}
	);
	
	// Menu Div Hover Functions
	$('#menuDiv_visitors').hover (
		function() { hover_visitors = true; },
		function() {
			hover_visitors = false;
			setTimeout("closeMenu('visitors')",1000);
		}
	);
	
	$('#menuDiv_residents').hover (
		function() { hover_residents = true; },
		function() {
			hover_residents = false;
			setTimeout("closeMenu('residents')",1000);
		}
	);
	
	$('#menuDiv_planners').hover (
		function() { hover_planners = true; },
		function() {
			hover_planners = false;
			setTimeout("closeMenu('planners')",1000);
		}
	);
	
	$('#menuDiv_media').hover (
		function() { hover_media = true; },
		function() {
			hover_media = false;
			setTimeout("closeMenu('media')",1000);
		}
	);
	
	$('#menuDiv_members').hover (
		function() { hover_members = true; },
		function() {
			hover_members = false;
			setTimeout("closeMenu('members')",1000);
		}
	);
	
	var todayDate = new Date();
	todayInt = mktime(0,0,0,todayDate.getMonth() + 1,todayDate.getDate(),todayDate.getFullYear());
	FB.init("c554b2f0f887292af7944addf511898d");
	
	// Google Analytics viewport measuring
	if (typeof pageTracker != 'undefined') {
		pageTracker._trackEvent(
			'Browser Dimensions',
			'load',
			$(window).width() + 'x' + $(window).height(),
			$(window).width()
		);
		
		$(window).resize(function () {
			if ($(this).data('gatimer')) {
				clearTimeout($(this).data('gatimer'));
				$(this).data('gatimer', null);
			}
			
			$(this).data(
				'gatimer',
				setTimeout(function () {
					pageTracker._trackEvent(
						'Browser Dimensions',
						'resize',
						$(window).width() + 'x' + $(window).height(),
						$(window).width()
					);
				}, 500 )
			);
		});
	}
});

function closeMenu(menu) {
	if ((menu == "visitors" && !hover_visitors) || menu == "closeAll") {
		$('#menuDiv_visitors').hide();
		$('#menuItem_visitors').removeClass("menuItemHover");
		$('#menuItem_visitors').css("color","white");
		hover_visitors = false;
	}
	if ((menu == "residents" && !hover_residents) || menu == "closeAll") {
		$('#menuDiv_residents').hide();
		$('#menuItem_residents').removeClass("menuItemHover");
		$('#menuItem_residents').css("color","white");
		hover_residents = false;
	}
	if ((menu == "planners" && !hover_planners) || menu == "closeAll") {
		$('#menuDiv_planners').hide();
		$('#menuItem_planners').removeClass("menuItemHover");
		$('#menuItem_planners').css("color","white");
		hover_planners = false;
	}
	if ((menu == "media" && !hover_media) || menu == "closeAll") {
		$('#menuDiv_media').hide();
		$('#menuItem_media').removeClass("menuItemHover");
		$('#menuItem_media').css("color","white");
		hover_media = false;
	}
	if ((menu == "members" && !hover_members) || menu == "closeAll") {
		$('#menuDiv_members').hide();
		$('#menuItem_members').removeClass("menuItemHover");
		$('#menuItem_members').css("color","white");
		hover_members = false;
	}
}

function overlayControl(overlay) {
	$('#overlay_red').fadeOut(250);
	$('#overlay_blue').fadeOut(250);
	$('#overlay_yellow').fadeOut(250);
	$('#overlay_green').fadeOut(250);
	$('#overlay_' + overlay).fadeIn(250, function () { if (overlay == "red") {
		$('#startDateInput').datepicker({ showAnim: "slideDown", dateFormat: "mm-dd-yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#endDateInput').datepicker({ showAnim: "slideDown", dateFormat: "mm-dd-yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#airStartInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#airEndInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#airHotelStartInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#airHotelEndInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#carStartInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
		$('#carEndInput').datepicker({ showAnim: "slideDown", dateFormat: "mm/dd/yy", minDate: 0, maxDate: 300, numberOfMonths: 2 });
	}});
}


function changeTravel(type) {
	$('#hotel').hide();
	$('#hotelA').removeClass('selected');
	$('#air').hide();
	$('#airA').removeClass('selected');
	$('#airhotel').hide();
	$('#airhotelA').removeClass('selected');
	$('#car').hide();
	$('#carA').removeClass('selected');
	$('#' + type).show();
	$('#' + type + 'A').addClass('selected');
}

function updateChildren(num, addon) {
	if (!addon) var addon = "";
	$('#numChildren' + addon).hide();
	$('#child1' + addon).hide();
	$('#child2' + addon).hide();
	$('#child3' + addon).hide();
	$('#child4' + addon).hide();
	if (parseInt(num) > 0) $('#numChildren' + addon).show();
	if (parseInt(num) >= 1) $('#child1' + addon).show();
	if (parseInt(num) >= 2) $('#child2' + addon).show();
	if (parseInt(num) >= 3) $('#child3' + addon).show();
	if (parseInt(num) >= 4) $('#child4' + addon).show();
}

function processHotel() {
	$('#errorIn').hide();
	$('#errorOut').hide();
	$('#errorCity').hide();
	$('#errorDates').hide();
	$('#hotelButton').html("<p><img src='/images/icons/ajax.gif' alt='Processing'> <b>Processing...</b></p>");
	var error = false;
	var field = document.hotelForm.startDate.value;
	if (field == "") {
		error = true;
		$('#errorIn').show();
	}
	var checkinInt = mktime(0,0,0,field.substring(0,2),field.substring(3,5),field.substring(6));
	field = document.hotelForm.endDate.value;
	if (field == "") {
		error = true;
		$('#errorOut').show();
	}
	var checkoutInt = mktime(0,0,0,field.substring(0,2),field.substring(3,5),field.substring(6));
	if (!error && checkoutInt < checkinInt) {
		error = true;
		$('#errorDates').show();
	}
	field = document.hotelForm.city.value;
	if (field == "" || field == "ia" || field == "il") {
		error = true;
		$('#errorCity').show();
	}
	if (error) $('#hotelButton').html("<p><a class='button redButton' href='#' onclick='processHotel();return false;'>Search rooms &raquo;</a></p>");
	else {
		var url = "http://www.res99.com/nexres/search/search_results.cgi?src=10027997&tab=tab0&src_aid=&avail=Y&currency_id=USD&city=";
		var city = document.hotelForm.city.value;
		if (city == "bettendorf") url += "Bettendorf,+IA";
		else if (city == "davenport") url += "Davenport,+IA";
		else if (city == "eldridge") url += "Eldridge,+IA";
		else if (city == "leclaire") url += "Le+Claire,+IA";
		else if (city == "eastmoline") url += "East+Moline,+IL";
		else if (city == "rockisland") url += "Rock+Island,+IL";
		else url += "Moline,+IL";
		url += "&chk_in=" + document.hotelForm.startDate.value;
		url += "&doa_mm=" + document.hotelForm.startDate.value.substring(0,2);
		url += "&doa_dd=" + document.hotelForm.startDate.value.substring(3,5);
		url += "&doa_yy=" + document.hotelForm.startDate.value.substring(6);
		url += "&chk_out=" + document.hotelForm.endDate.value;
		url += "&dod_mm=" + document.hotelForm.endDate.value.substring(0,2);
		url += "&dod_dd=" + document.hotelForm.endDate.value.substring(3,5);
		url += "&dod_yy=" + document.hotelForm.endDate.value.substring(6);
		url += "&num_rooms=" + document.hotelForm.rooms.value;
		url += "&num_adults=" + document.hotelForm.adults.value;
		var numChildren = parseInt(document.hotelForm.children.value);
		url += "&num_children=" + numChildren;
		url += "&minorsAge1=";
		if (numChildren < 1) url += "-%3F-";
		else url += document.hotelForm.child1age.value;
		url += "&minorsAge2=";
		if (numChildren < 2) url += "-%3F-";
		else url += document.hotelForm.child2age.value;
		url += "&minorsAge3=";
		if (numChildren < 3) url += "-%3F-";
		else url += document.hotelForm.child3age.value;
		url += "&minorsAge4=";
		if (numChildren < 4) url += "-%3F-";
		else url += document.hotelForm.child4age.value;
		url += "&SearchNow=search";
		var params = "hotel=" + document.hotelForm.city.value;
		$.get("/include/ajax.php", params);
		window.location = url;
	}
}

function roundtrip(input) {
	if (input == "round") {
		document.airForm.typeHidden.value = 'round';
		$('#airReturn').show();
	} else {
		document.airForm.typeHidden.value = 'one';
		$('#airReturn').hide();
	}
}

function processAir() {
	$('#errorAirDep').hide();
	$('#errorAirArr').hide();
	$('#errorDep').hide();
	$('#errorRet').hide();
	$('#errorAirDates').hide();
	$('#airButton').html("<p><img src='/images/icons/ajax.gif' alt='Processing'> <b>Processing...</b></p>");
	var error = false;
	var form = document.airForm;
	if (form.airDep.value == "") {
		error = true;
		$('#errorAirDep').show();
	}
	if (form.airArr.value == "") {
		error = true;
		$('#errorAirArr').show();
	}
	if (form.startDate.value == "") {
		error = true;
		$('#errorDep').show();
	}
	if (form.typeHidden.value == "round") {
		if (form.endDate.value == "") {
			error = true;
			$('#errorRet').show();
		}
		var depInt = mktime(0,0,0,form.startDate.value.substring(0,2),form.startDate.value.substring(3,5),form.startDate.value.substring(6));
		var arrInt = mktime(0,0,0,form.endDate.value.substring(0,2),form.endDate.value.substring(3,5),form.endDate.value.substring(6));
		if (!error && arrInt < depInt) {
			error = true;
			$('#errorAirDates').show();
		}
	}
	if (error) $('#airButton').html("<p><a class='button redButton' href='#' onclick='processAir();return false;'>Search flights &raquo;</a></p>");
	else {
		var url = "http://go.travelpn.com/flights/InitialSearch.do?Service=TPN&affiliateId=10027997&subAffiliateId=&aspHeader=air&aspFooter=air&flightType=";
		if (form.typeHidden.value == "round") url += "roundtrip";
		else url += "oneway";
		url += "&airlineSearchPref=searchAll&classOfService=Economy&fareType=all";
		url += "&adults=" + form.adults.value;
		url += "&children=" + form.children.value;
		url += "&seniors=" + form.seniors.value;
		var numChildren = parseInt(document.airForm.children.value);
		if (numChildren >= 1) url += "&minorsAge0=" + form.child1age.value;
		if (numChildren >= 2) url += "&minorsAge1=" + form.child2age.value;
		if (numChildren >= 3) url += "&minorsAge2=" + form.child3age.value;
		if (numChildren >= 4) url += "&minorsAge3=" + form.child4age.value;
		url += "&dateTypeSelect=exactDates";
		url += "&leavingFrom=" + form.airDep.value;
		url += "&goingTo=" + form.airArr.value;
		url += "&leavingDate=" + form.startDate.value;
		url += "&returningDate=" + form.endDate.value;
		url += "&dateLeavingTime=" + form.airStartTime.value;
		url += "&dateReturningTime=" + form.airEndTime.value;
		window.location = url;
	}
}

function processAirHotel() {
	$('#errorAirHotelDep').hide();
	$('#errorAirHotelDepDate').hide();
	$('#errorAirHotelRet').hide();
	$('#errorAirHotelDates').hide();
	$('#airHotelButton').html("<p><img src='/images/icons/ajax.gif' alt='Processing'> <b>Processing...</b></p>");
	var error = false;
	var form = document.airHotelForm;
	if (form.airHotelDep.value == "") {
		error = true;
		$('#errorAirHotelDep').show();
	}
	if (form.startDate.value == "") {
		error = true;
		$('#errorAirHotelDepDate').show();
	}
	if (form.endDate.value == "") {
		error = true;
		$('#errorAirHotelRet').show();
	}
	var depInt = mktime(0,0,0,form.startDate.value.substring(0,2),form.startDate.value.substring(3,5),form.startDate.value.substring(6));
	var arrInt = mktime(0,0,0,form.endDate.value.substring(0,2),form.endDate.value.substring(3,5),form.endDate.value.substring(6));
	if (!error && arrInt < depInt) {
		error = true;
		$('#errorAirHotelDates').show();
	}
	if (error) $('#airHotelButton').html("<p><a class='button redButton' href='#' onclick='processAirHotel();return false;'>Search &raquo;</a></p>");
	else {
		var url = "http://go.travelpn.com/trips/ClarifySearchTimekeeper.do?Service=TPN&searchType=hotel&affiliateId=10027997&subAffiliateId=none&aspHeader=customtrip&aspFooter=customtrip";
		url += "&leavingFrom=" + form.airHotelDep.value;
		url += "&userTypedFrom=" + form.airHotelDep.value;
		url += "&goingTo=MLI&userTypedTo=MLI";
		url += "&dateLeavingMonth=" + form.startDate.value.substring(0,2);
		url += "&dateLeavingDay=" + form.startDate.value.substring(3,5);
		url += "&dateLeavingTime=" + form.startTime.value;
		url += "&dateReturningMonth=" + form.endDate.value.substring(0,2);
		url += "&dateReturningDay=" + form.endDate.value.substring(3,5);
		url += "&dateReturningTime=" + form.endTime.value;
		url += "&adults=" + form.adults.value;
		url += "&children=" + form.children.value;
		url += "&seniors=" + form.seniors.value;
		url += "&stops=0&total_rooms=&hotelChain=";
		url += "&minorsAge1Room1=";
		var numChildren = parseInt(document.airHotelForm.children.value);
		if (numChildren < 1) url += "-?-";
		else url += form.child1age.value;
		url += "&minorsAge2Room1=";
		if (numChildren < 2) url += "-?-";
		else url += form.child2age.value;
		url += "&minorsAge3Room1=";
		if (numChildren < 3) url += "-?-";
		else url += form.child3age.value;
		url += "&minorsAge4Room1=";
		if (numChildren < 4) url += "-?-";
		else url += form.child4age.value;
		window.location = url;
	}
}

function processCar() {
	$('#errorCarDepDate').hide();
	$('#errorCarRet').hide();
	$('#errorCarDates').hide();
	$('#carButton').html("<p><img src='/images/icons/ajax.gif' alt='Processing'> <b>Processing...</b></p>");
	var error = false;
	var form = document.carForm;
	if (form.startDate.value == "") {
		error = true;
		$('#errorCarDepDate').show();
	}
	if (form.endDate.value == "") {
		error = true;
		$('#errorCarRet').show();
	}
	var depInt = mktime(0,0,0,form.startDate.value.substring(0,2),form.startDate.value.substring(3,5),form.startDate.value.substring(6));
	var arrInt = mktime(0,0,0,form.endDate.value.substring(0,2),form.endDate.value.substring(3,5),form.endDate.value.substring(6));
	if (!error && arrInt < depInt) {
		error = true;
		$('#errorCarDates').show();
	}
	if (error) $('#carButton').html("<p><a class='button redButton' href='#' onclick='processCar();return false;'>Search &raquo;</a></p>");
	else {
		var url = "http://go.travelpn.com/car/PostFrontDoor.do?Service=TPN&affiliateId=10027997&subAffiliateId=&aspHeader=car&aspFooter=car&rdoLocPickup=pu_air&pickupCity=MLI&dropoffCity=&rdoChkDropoff=OW&dateFormat=MM/dd/yyyy";
		url += "&dropoffDate=" + form.endDate.value;
		url += "&dropoffTime=" + form.endTime.value;
		url += "&pickupDate=" + form.startDate.value;
		url += "&pickupTime=" + form.startTime.value;
		url += "&carTypeGroup=" + form.carType.value;
		window.location = url;
	}
}

function processSearch() {
	$('#searchButton').html("<img src='/images/icons/ajax.gif' alt='Processing'><span class='ajaxMessage'>Processing...</span>");
	if (document.searchForm.type[1].checked) window.location = "page.php?page_id=93#search=" + document.searchForm.q.value;
	else if (document.searchForm.type[2].checked) window.location = "search.php?members&search=" + document.searchForm.q.value;
	else document.searchForm.submit();
}

function startAJAX() {
	var ajaxRequest;
	try { ajaxRequest = new XMLHttpRequest(); }
	catch (e) {
		try { ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e){
				alert("Sorry, AJAX could be initialized. Please try again.");
				return false;
			}
		}
	}
	return ajaxRequest;
}

function openBox(content) {
	$('#box_content').html("<img src='/images/icons/ajax.gif'> <b>Loading...</b>");
	$('#box_back').fadeIn(250);
	$('#box_back').stop();
	$('#box_back').fadeTo(250,0.5);
	$('#box').slideDown(250);
	var ajax = startAJAX();
	ajax.open("GET", "../include/boxOpener.php?file="+content, true);
	ajax.send(null);
	ajax.onreadystatechange = function() { if (ajax.readyState == 4) $('#box_content').html(ajax.responseText); }
}

function closeBox() {
	$('#box').slideUp(250);
	$('#box_back').fadeOut(250);
}

function openAd(id) {
	$('#box_content').html("<img src='/images/icons/ajax.gif'> <b>Loading...</b>");
	$('#box_back').fadeIn(250);
	$('#box_back').stop();
	$('#box_back').fadeTo(250,0.5);
	$('#box').slideDown(250);
	var ajax = startAJAX();
	ajax.open("GET", "../include/boxOpener.php?ad="+id, true);
	ajax.send(null);
	ajax.onreadystatechange = function() { if (ajax.readyState == 4) $('#box_content').html(ajax.responseText); }
}

function addToList(toAdd) {
	var ajax = startAJAX();
	ajax.open("GET", "/pages/36/ajax.php?add="+toAdd, true);
	ajax.send(null);
	ajax.onreadystatechange = function() {
		if(ajax.readyState == 4) {
			var spanID = "span"+toAdd;
			$("#"+spanID).fadeOut(500, function() {
				document.getElementById(spanID).innerHTML = "<img src='/pages/36/icon_check.gif'><span class='iconMsg iconGreen'>Added to your list</span><a class='view_list' href='?page_id=35'>View my list &raquo;</a>";
				$("#"+spanID).addClass('simplicio_success');
				$("#"+spanID).fadeIn(500);
			});
		}
	}
}

function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function mktime() {
	// http://kevin.vanzonneveld.net
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: baris ozdil
	// +      input by: gabriel paderni
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: FGFEmperor
	// +      input by: Yannoo
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +      input by: jakes
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: Marc Palau
	// +   improved by: Brett Zamir (http://brettz9.blogspot.com)

	var no=0, i = 0, ma=0, mb=0, d = new Date(), dn = new Date(), argv = arguments, argc = argv.length;

	var dateManip = {
		0: function(tt){ return d.setHours(tt); },
		1: function(tt){ return d.setMinutes(tt); },
		2: function(tt){ var set = d.setSeconds(tt); mb = d.getDate() - dn.getDate(); return set;},
		3: function(tt){ var set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - dn.getFullYear(); return set;},
		4: function(tt){ return d.setDate(tt+mb);},
		5: function(tt){
			if (tt >= 0 && tt <= 69) tt += 2000;
			else if (tt >= 70 && tt <= 100) tt += 1900;
			return d.setFullYear(tt+ma);
		}
		// 7th argument (for DST) is deprecated
	};

	for( i = 0; i < argc; i++ ){
		no = parseInt(argv[i]*1);
		if (isNaN(no)) return false;
        else {
			// arg is number, let's manipulate date object
			if(!dateManip[i](no)){
				// failed
				return false;
			}
		}
	}
	for (i = argc; i < 6; i++) {
		switch(i) {
			case 0:
				no = dn.getHours();
				break;
			case 1:
				no = dn.getMinutes();
				break;
			case 2:
				no = dn.getSeconds();
				break;
			case 3:
				no = dn.getMonth()+1;
				break;
			case 4:
				no = dn.getDate();
				break;
			case 5:
				no = dn.getFullYear();
				break;
		}
		dateManip[i](no);
	}
	
	return Math.floor(d.getTime()/1000);
}

function htmlspecialchars_decode(string, quote_style) {
	// Convert special HTML entities back to characters  
	// 
	// version: 906.401
	// discuss at: http://phpjs.org/functions/htmlspecialchars_decode
	// +   original by: Mirek Slugen
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: Mateusz "loonquawl" Zalega
	// +      input by: ReverseSyntax
	// +      input by: Slawomir Kaniecki
	// +      input by: Scott Cariss
	// +      input by: Francois
	// +   bugfixed by: Onno Marsman
	// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +    bugfixed by: Brett Zamir (http://brett-zamir.me)
	// -    depends on: get_html_translation_table
	// *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
	// *     returns 1: '<p>this -> &quot;</p>'
	var histogram = {}, symbol = '', tmp_str = '', entity = '';
	tmp_str = string.toString();
	
	if (false === (histogram = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) return false;

	for (symbol in histogram) {
		entity = histogram[symbol];
		tmp_str = tmp_str.split(entity).join(symbol);
	}
	tmp_str = tmp_str.split('&#039;').join("'");

	return tmp_str;
}


function get_html_translation_table(table, quote_style) {
	// Returns the internal translation table used by htmlspecialchars and htmlentities  
	// 
	// version: 906.401
	// discuss at: http://phpjs.org/functions/get_html_translation_table
	// +   original by: Philip Peterson
	// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: noname
	// +   bugfixed by: Alex
	// +   bugfixed by: Marco
	// +   bugfixed by: madipta
	// +   improved by: KELAN
	// +   improved by: Brett Zamir (http://brett-zamir.me)
	// +    bugfixed by: Brett Zamir (http://brett-zamir.me)
	// %          note: It has been decided that we're not going to add global
	// %          note: dependencies to php.js. Meaning the constants are not
	// %          note: real constants, but strings instead. integers are also supported if someone
	// %          note: chooses to create the constants themselves.
	// *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
	// *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}

	var entities = {}, histogram = {}, decimal = 0, symbol = '';
	var constMappingTable = {}, constMappingQuoteStyle = {};
	var useTable = {}, useQuoteStyle = {};

	// Translate arguments
	constMappingTable[0]      = 'HTML_SPECIALCHARS';
	constMappingTable[1]      = 'HTML_ENTITIES';
	constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
	constMappingQuoteStyle[2] = 'ENT_COMPAT';
	constMappingQuoteStyle[3] = 'ENT_QUOTES';

	useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
	useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

	if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
		throw new Error("Table: "+useTable+' not supported');
		// return false;
	}

	if (useTable === 'HTML_ENTITIES') {
		entities['160'] = '&nbsp;';
		entities['161'] = '&iexcl;';
		entities['162'] = '&cent;';
		entities['163'] = '&pound;';
		entities['164'] = '&curren;';
		entities['165'] = '&yen;';
		entities['166'] = '&brvbar;';
		entities['167'] = '&sect;';
		entities['168'] = '&uml;';
		entities['169'] = '&copy;';
		entities['170'] = '&ordf;';
		entities['171'] = '&laquo;';
		entities['172'] = '&not;';
		entities['173'] = '&shy;';
		entities['174'] = '&reg;';
		entities['175'] = '&macr;';
		entities['176'] = '&deg;';
		entities['177'] = '&plusmn;';
		entities['178'] = '&sup2;';
		entities['179'] = '&sup3;';
		entities['180'] = '&acute;';
		entities['181'] = '&micro;';
		entities['182'] = '&para;';
		entities['183'] = '&middot;';
		entities['184'] = '&cedil;';
		entities['185'] = '&sup1;';
		entities['186'] = '&ordm;';
		entities['187'] = '&raquo;';
		entities['188'] = '&frac14;';
		entities['189'] = '&frac12;';
		entities['190'] = '&frac34;';
		entities['191'] = '&iquest;';
		entities['192'] = '&Agrave;';
		entities['193'] = '&Aacute;';
		entities['194'] = '&Acirc;';
		entities['195'] = '&Atilde;';
		entities['196'] = '&Auml;';
		entities['197'] = '&Aring;';
		entities['198'] = '&AElig;';
		entities['199'] = '&Ccedil;';
		entities['200'] = '&Egrave;';
		entities['201'] = '&Eacute;';
		entities['202'] = '&Ecirc;';
		entities['203'] = '&Euml;';
		entities['204'] = '&Igrave;';
		entities['205'] = '&Iacute;';
		entities['206'] = '&Icirc;';
		entities['207'] = '&Iuml;';
		entities['208'] = '&ETH;';
		entities['209'] = '&Ntilde;';
		entities['210'] = '&Ograve;';
		entities['211'] = '&Oacute;';
		entities['212'] = '&Ocirc;';
		entities['213'] = '&Otilde;';
		entities['214'] = '&Ouml;';
		entities['215'] = '&times;';
		entities['216'] = '&Oslash;';
		entities['217'] = '&Ugrave;';
		entities['218'] = '&Uacute;';
		entities['219'] = '&Ucirc;';
		entities['220'] = '&Uuml;';
		entities['221'] = '&Yacute;';
		entities['222'] = '&THORN;';
		entities['223'] = '&szlig;';
		entities['224'] = '&agrave;';
		entities['225'] = '&aacute;';
		entities['226'] = '&acirc;';
		entities['227'] = '&atilde;';
		entities['228'] = '&auml;';
		entities['229'] = '&aring;';
		entities['230'] = '&aelig;';
		entities['231'] = '&ccedil;';
		entities['232'] = '&egrave;';
		entities['233'] = '&eacute;';
		entities['234'] = '&ecirc;';
		entities['235'] = '&euml;';
		entities['236'] = '&igrave;';
		entities['237'] = '&iacute;';
		entities['238'] = '&icirc;';
		entities['239'] = '&iuml;';
		entities['240'] = '&eth;';
		entities['241'] = '&ntilde;';
		entities['242'] = '&ograve;';
		entities['243'] = '&oacute;';
		entities['244'] = '&ocirc;';
		entities['245'] = '&otilde;';
		entities['246'] = '&ouml;';
		entities['247'] = '&divide;';
		entities['248'] = '&oslash;';
		entities['249'] = '&ugrave;';
		entities['250'] = '&uacute;';
		entities['251'] = '&ucirc;';
		entities['252'] = '&uuml;';
		entities['253'] = '&yacute;';
		entities['254'] = '&thorn;';
		entities['255'] = '&yuml;';
	}

	if (useQuoteStyle !== 'ENT_NOQUOTES') entities['34'] = '&quot;';
	if (useQuoteStyle === 'ENT_QUOTES') entities['39'] = '&#39;';
	entities['60'] = '&lt;';
	entities['62'] = '&gt;';

	// ascii decimals for better compatibility
	entities['38'] = '&amp;';

	// ascii decimals to real symbols
	for (decimal in entities) {
		symbol = String.fromCharCode(decimal);
		histogram[symbol] = entities[decimal];
	}
    
	return histogram;
}

(function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b})(navigator.userAgent||navigator.vendor||window.opera,'http://www.visitquadcities.com/mobile');
