/*******************************
 *   Master Page
 *******************************/
function bodyOnLoad(){
  preloadImages('Images/nav_home_h.gif','Images/nav_reserve_h.gif','Images/nav_unit_h.gif','Images/nav_faqs_h.gif','Images/nav_about_h.gif','Images/nav_careers_h.gif','Images/nav_contact_h.gif','Images/nav_services_h.gif','Images/nav_city_h.gif');
}

_uacct = "UA-4634811-1";
urchinTracker();

function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function setContentClass(className) {
  var td = document.getElementById("TdContent");
  td.className=className;
}

function clearInput(txt){
  if(txt.value=='enter zip code')
  {
    txt.value = "";
    txt.className = "";
  }
}
/*******************************
 *   Locations Page
 *******************************/
var gmap;
function loadGMap(lat,lng) {
  if (GBrowserIsCompatible()) {
    gmap = new GMap2(document.getElementById("googlemap"));
    gmap.setCenter(new GLatLng(lat,lng),14);
    var point = new GLatLng(lat,lng);
    var marker = new GMarker(point);
    gmap.addOverlay(marker);
    gmap.addControl(new GSmallMapControl());
  }
}

function addPt(lat,lng) {
	var point = new GLatLng(lat,lng);
	var marker = new GMarker(point);
	gmap.addOverlay(marker);
}

/*******************************
 *   Main Menu RollOver
 *******************************/
function 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=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 changeImg(id, number){
	var idName;
	var td;
	var img;
	
	img = document.getElementById('ctl00_ContentPlaceHolder1_Image1');
	img.src = "./Images/" + id + number + ".jpg"
	
	for(var x = 1; x < 5; x++)
	{
		idName = 'space' + x;
		td = document.getElementById(idName);
	 
		if(x == number)
		{
			td.className = "bullet";
		}
		else
		{
			td.className = "";
		}
	}
}


function restoreImg() { //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 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImg() { //v3.0
  var i,j=0,x,a=swapImg.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*******************************
 *   Unit Page
 *******************************/
 var selectedImage;

function unitSizeClick(img){
  img.onload = null;
  unhilight(selectedImage);
  selectedImage = img;
  hilight(img);
  
  var TableUnitSize = document.getElementById("TableUnitSize");

  var TdImageUnitSize = document.getElementById("TdImageUnitSize");
  var TdVisualize = document.getElementById("TdVisualize");
  var TdDescription = document.getElementById("TdDescription");

	var txts = TdImageUnitSize.getElementsByTagName("img");
	var lsts = TdVisualize.getElementsByTagName("span");
	var dess = TdDescription.getElementsByTagName("span");
	
	for(var i = 0; i < txts.length; i++)
	{
	  var txt = img.id.replace("btn_", "txt_");
	  
	  if (txts[i].id == txt)
	  {
	    txts[i].height = 46;
	    lsts[i].style.display = "";
	    dess[i].style.display = "";
	  }
	  else
	  {
      txts[i].height = 0;
	    lsts[i].style.display = "none";
	    dess[i].style.display = "none";
	  }
	}

  TableUnitSize.style.visibility = "";
  
	return false;
}

function unitSizeMouseOut(img){
  swapHilight(img);
}

function unitSizeMouseOver(img){
  swapHilight(img);
}

function swapHilight(img){
  if (img == null)
  {
    return;
  }

  // if hilighted, remove hilight
  if (img.src.indexOf("_h.gif", 0) == -1)
  {
    hilight(img);
  }
  else
  {
    unhilight(img);
  }
}

function hilight(img){
  if (img == null)
  {
    return;
  }

  img.src = img.src.replace(".gif", "_h.gif");
}

function unhilight(img){
  if (img == null)
  {
    return;
  }

   img.src = img.src.replace("_h.gif", ".gif");
}

function checkEnter(e){ 
  var characterCode 

  if(e && e.which){ 
    e = e;
    characterCode = e.which ;
  }
  else{
    e = event;
    characterCode = e.keyCode;
  }

  if(characterCode == 13){
  
    var btn = document.getElementById('ctl00_ContentPlaceHolder1_ProcessLocations1_btnZip');
    
    btn.click();
    
    return false;
  }
  else{
    return true;
  }
}
