
/* button 
preload("_off", "/i/nav/_off.gif");
preload("_on", "/i/nav/_on.gif");*/

preload("getquote_off", "/i/layout/button_get_quote.gif");
preload("getquote_on", "/i/layout/button_get_quote_on.gif");

preload("potty_off", "/i/layout/button_potty_calc.gif");
preload("potty_on", "/i/layout/button_potty_calc_on.gif");


function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function changeImages() {
  if (document.images) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
	  document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
    }
  }
}

function showPicture(url, otherContainer, canZoom, zoomSrc) {
	var container = otherContainer == null ? 'photoblockSub' : 'photoblockHome';
	var td = document.getElementById(container);
	var img = document.getElementById(container).getElementsByTagName('IMG');
	if ( img.length > 0 && img[0] != null )
	{
		img[0].src = url;
	}

	if ( document.getElementById('z') != null )
	{
		document.getElementById('z').style.display = (canZoom!= null && canZoom == true) ? 'block' : 'none';

		if ( document.getElementById('z').style.display == 'block' )
		{
			document.getElementById('zoomSrc').href = zoomSrc;
			document.getElementById('zoomSrc').target = '_blank';
		}
	}

	return false;
}

document.addEvent = function(object, eventType,fn, useCapture) {
	if (object.addEventListener) {
		object.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (object.attachEvent) {
			var r = object.attachEvent("on"+eventType, fn);
			return r;
		}
	}
};

function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
	  inputList[i].attachEvent("onpropertychange",restoreStyles);
	  inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
	  selectList[i].attachEvent("onpropertychange",restoreStyles);
	  selectList[i].style.backgroundColor = "";
	}
}

function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "")
		event.srcElement.style.backgroundColor = "";
}

document.addEvent(window,"load",setListeners,false);

/*******************************************************
popup function
*******************************************************/
function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt) {
	var scroll = '';
	var winHeight = imageHeight;
	var winWidth = imageWidth;
	if ( winHeight > 700 ) {
		scroll = ",scrollbars=yes";
		winWidth += 20;
		winHeight = 700;
	}
   	var left = Math.floor( (screen.width - winWidth) / 2);
    var top = Math.floor( (screen.height - winHeight) / 2);
	newWindow = window.open("","newWindow","resizable=1,width="+winWidth+",height="+winHeight+",left="+left+",top="+top+scroll);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt="'+alt+'">'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function pottyCalc() {
	var winHeight = 550;
	var winWidth = 650;
   	var left = Math.floor( (screen.width - winWidth) / 2);
    var top = Math.floor( (screen.height - winHeight) / 2);
	newWindow = window.open("/products/mobile_restrooms/potty_chart.php","PottyWindow","scrollbars=yes,resizable=1,width="+winWidth+",height="+winHeight+",left="+left+",top="+top);
	newWindow.focus();
	return false;
}