/*
Copyright 2011, JMSZone LLC - All Rights Reserved
*/

/*
if(navigator.geolocation){wpid=navigator.geolocation.watchPosition(locationFound, locationNotFound, {enableHighAccuracy:true, maximumAge:30000, timeout:27000})};

function locationFound(position){
	var latitude = position.coords.latitude;
	var longitude = position.coords.longitude;
	var accuracy = position.coords.accuracy;
	if(isNaN(position.coords.speed)){var speed=0}else{var speed=position.coords.speed};
	if(isNaN(position.coords.altitude)){var altitude=0}else{var altitude = position.coords.altitude};
	if(isNaN(position.coords.altitudeAccuracy)){var altitudeAccuracy=0}else{var altitudeAccuracy = position.coords.altitudeAccuracy};

	var curtime = new Date();
	var curhour = curtime.getHours();
	var curmin = curtime.getMinutes();
	var cursec = curtime.getSeconds();
	var curmon = curtime.getMonth()+1;
	var curday = curtime.getDate();
	var curyear = curtime.getFullYear();
	var cur_date_time=curyear;
	if(curmon.length==1){cur_date_time+="-0"+curmon}else{cur_date_time+="-"+curmon};
	if(curday.length==1){cur_date_time+="-0"+curday}else{cur_date_time+="-"+curday};
	if(curhour.length==1){cur_date_time+=" 0"+curhour}else{cur_date_time+=" "+curhour};
	if(curmin.length==1){cur_date_time+=":0"+curmin}else{cur_date_time+=":"+curmin};
	if(cursec.length==1){cur_date_time+=":0"+cursec}else{cur_date_time+=":"+cursec};
	var signlat=1;
	if(latitude < 0)  { signlat = -1; }
	var latAbs = Math.abs( Math.round(latitude * 1000000.));
	var signlon=1;
	if(longitude < 0)  { signlon = -1; }
	var lonAbs = Math.abs(Math.round(longitude * 1000000.));

	var latsecs=( Math.floor(((((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60) - Math.floor(((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)) * 100000) *60/100000 );
	var lonsecs=( Math.floor(((((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60) - Math.floor(((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60)) * 100000) *60/100000 );
	var deglat = ((Math.floor(latAbs / 1000000) * signlat) + '&deg;' + Math.floor(  ((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)  + '\' ' +  latsecs.toFixed(0) + '&quot;'  );
	var deglon = ((Math.floor(lonAbs / 1000000) * signlon) + '&deg;' + Math.floor(  ((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60)  + '\' ' +  lonsecs.toFixed(0) + '&quot;'  );
	var c_deglat = ((Math.floor(latAbs / 1000000) * signlat) + '&deg;' + Math.floor(  ((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)  + '\' ' +  latsecs.toFixed(2) + '&quot;'  );
	var c_deglon = ((Math.floor(lonAbs / 1000000) * signlon) + '&deg;' + Math.floor(  ((lonAbs/1000000) - Math.floor(lonAbs/1000000)) * 60)  + '\' ' +  lonsecs.toFixed(2) + '&quot;'  );

	if(document.getElementById('display_lat_lng')){
		var r_display_lat_lng = document.getElementById('display_lat_lng');
		r_display_lat_lng.innerHTML=deglat+','+deglon;
	};

	document.cookie = "c_capture_time=" + cur_date_time + "; path=/";
	document.cookie = "c_" + "latitude=" + latitude + "; path=/";
	document.cookie = "c_" + "longitude=" + longitude + "; path=/";
	document.cookie = "c_" + "deglat=" + escape(c_deglat) + "; path=/";
	document.cookie = "c_" + "deglon=" + escape(c_deglon) + "; path=/";
	document.cookie = "c_" + "accuracy=" + accuracy + "; path=/";
	document.cookie = "c_" + "speed=" + speed + "; path=/";
	document.cookie = "c_" + "altitude=" + altitude + "; path=/";
	document.cookie = "c_" + "altitudeAccuracy=" + altitudeAccuracy + "; path=/";
};
function locationNotFound() {
//		alert('Could not find location');
};
*/


function loadPromoRestaurants(where, returnCount) {
    $("#promoContentLoader")
    .ajaxStart(function() {
        $(this).show();
    })
    .ajaxStop(function() {
        $(this).hide();
    });

    $("#promoRestaurants").hide();
    $.ajax({
        url: "/ajax-requests/promoRestaurants.ashx",
        data: "where=" + where + "&returnCount=" + returnCount,
        success: function(data) {
            $("#promoRestaurants").html(data);
            $("#promoRestaurants").show();
        }
    });
}

function loadPromoReviews(what, city, state, returnCount) {
    $("#promoContentLoader")
    .ajaxStart(function() {
        $(this).show();
    })
    .ajaxStop(function() {
        $(this).hide();
    });

    $("#promoReviews").hide();
    $.ajax({
        url: "/ajax-requests/promoReviews.ashx",
        data: "what=" + what + "&city=" + city + "&state=" + state + "&returnCount=" + returnCount,
        success: function(data) {
            $("#promoReviews").html(data);
            $("#promoReviews").show();
        }
    });
}

function loadCityFavorites(where) {
    $('#cityFavoritesLoader')
    .ajaxStart(function() {
        $(this).show();
    })
    .ajaxStop(function() {
        $(this).hide();
    });

    //$("#cityFavoritesContent").hide();
    $.ajax({
        url: "/ajax-requests/cityFavorites.ashx",
        data: "where=" + where,
        success: function(data) {
            $("#cityFavoritesContent").html(data);
            loadCityFavoritesCallback();
            //$("#cityFavoritesContent").show();
        }
    });
}
function loadCityFavoritesCallback() {
    $('#cityFavoritesLoader').hide();
    $("#flowpanes").scrollable({ circular: true, mousewheel: true }).navigator({
        // select #flowtabs to be used as navigator
        navi: "#flowtabs",
        // select A tags inside the navigator to work as items (not direct children)
        naviItem: 'li',
        // assign "current" class name for the active A tag inside navigator
        activeClass: 'current',
        // make browser's back button work
        history: false

    }).autoscroll({ autoplay: true, interval: 8000 });
}

function showChangeLocation() {
    $("#change-location").animate({ top: "0px" }, 500);
}
function hideChangeLocation() {
    $("#change-location").animate({ top: "-300px" }, 500);
}
$(function() {
    $("#cityRemoteNewCity").focus(function() { if (this.value == this.defaultValue) this.value = ""; }).bind("blur", function() { if (this.value == "") this.value = this.defaultValue; });
});


function showSearchResultsPhone(spanid, type) {
	$("#viewphone_" + type + "_" + spanid).hide();
	$("#phonenumber_" + type + "_" + spanid).show();
}


