dateFuture = new Date(2012,1,25,22,0,0);
ads=1;
var userlat=0;
var userlong=0;
var userlat=0;
var userlong=0;
function resizebk()
{
	$("#bkimg").height($(window).height());
	$("#bkimg").width($(window).width());
}

function geolocate(timezone, cityPrecision, objectVar) {
 
  var api = (cityPrecision) ? "ip_query.php" : "ip_query_country.php";
  var domain = 'ipinfodb.com';
  var url = "http://" + domain + "/" + api + "?key=0fb1e8dcbd8c494ab5b5cc3737ed6a37dd9fc10f4415bfbea93c8b1e38f62b43&output=json" + ((timezone) ? "&timezone=true" : "&timezone=false" ) + "&callback=" + objectVar + ".setGeoCookie";
  var geodata;
  var callbackFunc;
  var JSON = JSON || {};
 
  // implement JSON.stringify serialization
  JSON.stringify = JSON.stringify || function (obj) {
    var t = typeof (obj);
    if (t != "object" || obj === null) {
      // simple data type
      if (t == "string") obj = '"'+obj+'"';
        return String(obj);
    } else {
    // recurse array or object
      var n, v, json = [], arr = (obj && obj.constructor == Array);
      for (n in obj) {
        v = obj[n]; t = typeof(v);
        if (t == "string") v = '"'+v+'"';
        else if (t == "object" && v !== null) v = JSON.stringify(v);
        json.push((arr ? "" : '"' + n + '":') + String(v));
      }
      return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
    }
  };
 
  // implement JSON.parse de-serialization
  JSON.parse = JSON.parse || function (str) {
    if (str === "") str = '""';
      eval("var p=" + str + ";");
      return p;
  };
 
  //Check if cookie already exist. If not, query IPInfoDB
  this.checkcookie = function(callback) {
    geolocationCookie = getCookie('geolocation');
    callbackFunc = callback;
    if (!geolocationCookie) {
      getGeolocation();
    } else {
      geodata = JSON.parse(geolocationCookie);
      callbackFunc();
    }
  }
 
  //API callback function that sets the cookie with the serialized JSON answer
  this.setGeoCookie = function(answer) {
    if (answer['Status'] == 'OK') {
      JSONString = JSON.stringify(answer);
      setCookie('geolocation', JSONString, 365);
      geodata = answer;
      callbackFunc();
    }
  }
 
  //Return a geolocation field
  this.getField = function(field) {
    try {
      return geodata[field];
    } catch(err) {}
  }
 
  //Request to IPInfoDB
  function getGeolocation() {
    try {
      script = document.createElement('script');
      script.src = url;
      document.body.appendChild(script);
    } catch(err) {}
  }
 
  //Set the cookie
  function setCookie(c_name, value, expire) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expire);
    document.cookie = c_name+ "=" +escape(value) + ((expire==null) ? "" : ";expires="+exdate.toGMTString());
  }
 
  //Get the cookie content
  function getCookie(c_name) {
    if (document.cookie.length > 0 ) {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start != -1){
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end == -1) {
          c_end=document.cookie.length;
        }
        return unescape(document.cookie.substring(c_start,c_end));
      }
    }
    return '';
  }
}

    var map;
    var geocoder;
	var specialhtml=["", "", "", "", "", ""];
	var first=0;
    function load() {
      if (GBrowserIsCompatible()) {
        geocoder = new GClientGeocoder();
        map = new GMap2(document.getElementById('map'));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(40, -100), 4);
      }
      searchLocations();
    }

   function searchLocations() {
   	first =0;
   	var sidebar = document.getElementById('bottombar');
   	//featured.innerHTML = "<CENTER><img src='images/ajax-loader.gif'></CENTER>";
   	sidebar.innerHTML = "<CENTER><img src='images/ajax-loader.gif'></CENTER>";
   	 var address = userlat + "," + userlong ;
   	 //alert (address);
     geocoder.getLatLng(address, function(latlng) {
       if (!latlng) {
         alert('Please check your input.');
       } else {
       //searchFeaturedLocations(latlng);
       searchLocationsNear(latlng);
       
       }
     });
     
   }
   
   
   function searchLocationsNear(center) {
     var searchUrl = 'ufcsearch.php?lat=' + center.lat() + '&lng=' + center.lng() + '&featured=1' + '&radius=40';
     GDownloadUrl(searchUrl, function(data) {
       var xml = GXml.parse(data);
       var markers = xml.documentElement.getElementsByTagName('marker');
       map.clearOverlays();
	   var html = "<table><tr>";
       var sidebar = document.getElementById('bottombar');
       sidebar.innerHTML = '';
       if (markers.length == 0) {
         sidebar.innerHTML = 'No results found.';
         //map.setCenter(new GLatLng(40, -100), 4);
         return;
       }

       var bounds = new GLatLngBounds();
       var fcounter = 0;
       var counter = 0;
       
       var ctr =0;
       for (var i = 0; i < markers.length; i++) {
       	html = html  + "<td valign='top' style='white-space: nowrap;'><table cellpadding=0 cellspacing=0 width='300px' ><tr>";
       	 ctr++;
         var name = markers[i].getAttribute('name');
         var address = markers[i].getAttribute('address');
         var phone = markers[i].getAttribute('phone');
         var priority = markers[i].getAttribute('priority');
		 var imageurl = markers[i].getAttribute('imageurl');
		 var url = markers[i].getAttribute('url');
		 var fl = markers[i].getAttribute('featured');
		 var city = markers[i].getAttribute('city');
		 var state = markers[i].getAttribute('state');
		 var id = markers[i].getAttribute('id');
		 var distance = parseFloat(markers[i].getAttribute('distance'));
		 var logo = "";
         if (imageurl>"")
         	{logo = "<br>" + "<a href ='" + url + "'><img src='" + imageurl + "'></a>";}
       	 
		html = html + "<td valign=top style='color: #000000;'><b>" + (i+1) + ". " + name + " </b><font size=-3>" + distance.toFixed(2) + " mi <br></font>" + address + "<br>" + phone + logo + "</td>";
		html = html + "</tr></table></td>";
       }
		//jhpspecial = "<tr><td> Get on the front page!</td></tr>";
       sidebar.innerHTML = html ;
       //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
     });
}
	
	function ajaxFunction(mydata)
	{
		$.ajax({
		   type: "GET",
		   url: "locationsbeta.asp",
		   data: mydata,
		   contentType: "application/x-www-form-urlencoded; charset=utf-8",
		   success: function(msg){   
		   }
		 });

	}
	function displaySpecial(html)
	{	
			$("div[name=special]").css({'visibility':'visible'});
		$(document).bind('mousemove',function(e)
		{
	
			$("div[name=special]").css({'top': e.pageY+15});
			$("div[name=special]").css({'left': e.pageX+15});
			$("div[name=special]").html(html);
		});
	}
	function hideSpecial()
	{
		$("div[name=special]").css({'visibility':'hidden'});
		$(document).unbind('mousemove');
	}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function changeads(url)
{
	$("div[id=ads]").load(url);
}
//######################################################################################
// Author: ricocheting.com
// For: public release (freeware)
// Date: 4/24/2003 (update: 6/26/2009)
// Description: displays the amount of time until the "dateFuture" entered below.


// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm



// TESTING: comment out the line below to print out the "dateFuture" for testing purposes
//document.write(dateFuture +"<br />");


//###################################
//nothing beyond this point
function GetCount(){
	
	dateNow = new Date();									//grab current date
	amount = dateFuture.getTime() - dateNow.getTime();		//calc milliseconds between dates
	delete dateNow;

	// time is already past
	if(amount <= 0){
		document.getElementById('countbox').innerHTML="Now!";
	}
	// date is still good
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);//days
		amount=amount%86400;

		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;

		mins=Math.floor(amount/60);//minutes
		amount=amount%60;
		
		secs=Math.floor(amount);//seconds
		if ((secs % 31) == 0)
		{
			ads++;
			if (ads == 1) 
				$("div[id=ads]").load("topads.html");
			if (ads == 2)
				$("div[id=ads]").load("middleads.html");
			if (ads == 3)
			{$("div[id=ads]").load("bottomads.html");
				ads=0;
			}
			
		}
		var dayshtml = "<font color='yellow'; size=+2><b> 0 </b></font>";
		var hourshtml = dayshtml; 
		var minshtml = dayshtml;
		var secshtml = dayshtml;
		
		if(days != 0)
		{dayshtml = "<font color='yellow'; size=+2><b>"+days+"</b></font>";}
		if(days != 0 || hours != 0)
		{hourshtml= "<font color='yellow'; size=+2><b> " + hours + "</b></font>";}
		if(days != 0 || hours != 0 || mins != 0)
		{minshtml= "<font color='yellow'; size=+2><b> " + mins + "</b></font>";}
			
		secshtml= "<font color='yellow'; size=+2><b> " + secs + "</b></font>";
		
		//document.getElementById('numdays').innerHTML=dayshtml;
		//document.getElementById('numhrs').innerHTML=hourshtml;
		//document.getElementById('nummins').innerHTML=minshtml;
		//document.getElementById('numsecs').innerHTML=secshtml;
		var tophtml = "<center><table class='tablecounter' cellpadding='0' cellspacing='0' ><tr><td valign='bottom' bgcolor='#330000' width='45px'><center>" + dayshtml + "</td><td width='45px' style='vertical-align: middle' bgcolor='#330000'><center>" + hourshtml + "</td><td valign='bottom' bgcolor='#330000' width='45px'><center>" + minshtml + "</td><td valign='bottom' bgcolor='#330000' width='45px'><center>" + secshtml + "</tr>";
		tophtml += "<tr><td class='counter' style='text-align: center; color:black'>days</td><td class='counter' style='text-align: center; color:black'>hrs</td><td class='counter' style='text-align: center; color:black'>mins</td><td class='counter' style='text-align: center; color:black'>secs</td></tr></table></center>";
		document.getElementById('countdown').innerHTML=tophtml;
		setTimeout("GetCount()", 989);
	}
	
}

function changeMovie ()
{
		var HTML = "";
		HTML = HTML + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='590' height='310' id='FLVPlayer'>"
		HTML = HTML + "	  <param name='movie' value='FLVPlayer_Progressive.swf' />"
		HTML = HTML + "	  <param name='quality' value='high'>"
		HTML = HTML + "	  <param name='wmode' value='transparent'>"
		HTML = HTML + "	  <param name='scale' value='noscale'>"
		HTML = HTML + "	  <param name='salign' value='lt'>"
		HTML = HTML + "	  <param name='FlashVars' value='&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_1&amp;streamName=" + movieloc + "&amp;autoPlay=true&amp;autoRewind=false' />"
		HTML = HTML + "	  <param name='swfversion' value='8,0,0,0'>"
		HTML = HTML + "	  <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don&#8217;t want users to see the prompt. -->"
		HTML = HTML + "	  <param name='expressinstall' value='Scripts/expressInstall.swf'>"
		HTML = HTML + "	  <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->"
		HTML = HTML + "	  <!--[if !IE]>-->"
		HTML = HTML + "	  </object>"
		HTML = HTML + "	<br>"
		HTML = HTML + "	  <object type='application/x-shockwave-flash' data='FLVPlayer_Progressive.swf' width='690' height='310'>"
		HTML = HTML + "	    <!--<![endif]-->"
		HTML = HTML + "	    <param name='quality' value='high'>"
		HTML = HTML + "	    <param name='wmode' value='transparent'>"
		HTML = HTML + "	    <param name='scale' value='noscale'>"
		HTML = HTML + "	    <param name='salign' value='lt'>"
		HTML = HTML + "	    <param name='FlashVars' value='&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_1&amp;streamName=" + movieloc + "&amp;autoPlay=true&amp;autoRewind=false' />"
		HTML = HTML + "	    <param name='swfversion' value='8,0,0,0'>"
		HTML = HTML + "	    <param name='expressinstall' value='Scripts/expressInstall.swf'>"
		HTML = HTML + "	    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->"
		HTML = HTML + "	    <div>"
		HTML = HTML + "	      <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>"
		HTML = HTML + "	      <p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a></p>"
		HTML = HTML + "        </div>"
		HTML = HTML + "	    <!--[if !IE]>-->"
		HTML = HTML + "      </object>"
		HTML = HTML + "	  <!--<![endif]-->"
		HTML = HTML + "    </object>"
		document.getElementById("play3er").innerHTML = HTML;
}


