// SIMPLE BROWSER CHECK
v4=(parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<=5)?1:0 
ie=(document.all && v4)?1:0 
ns=(document.layers && v4)?1:0



// DEALS WITH CURSOR OVER LAYER
document.onmousemove = getMousePos
if (ns) document.captureEvents(Event.MOUSEMOVE)

function getMousePos(e){
	if(ns){mousex=e.pageX; mousey=e.pageY}
	if(ie){mousex=event.clientX; mousey=event.clientY;}
	}
	
function checkMousePos(i){          
	if(ns){     
		x_min=eval('document.'+dropLayer[i]+'.left')
		x_max=x_min+eval('document.'+dropLayer[i]+'.clip.width')
		y_min=eval('document.'+dropLayer[i]+'.top')
		y_max=y_min+eval('document.'+dropLayer[i]+'.clip.height')
		}    
	if(ie){     
		x_min=eval(dropLayer[i]+'.style.pixelLeft')
		x_max=x_min+eval(dropLayer[i]+'.style.pixelWidth')
		y_min=eval(dropLayer[i]+'.style.pixelTop')
		y_max=y_min+eval(dropLayer[i]+'.style.pixelHeight')
		}
	if (mousex>=x_min && mousex<=x_max && mousey>=y_min && mousey<=y_max){
		hideIt=0; setTimeout('hideAll()',500)
		}
	else { hideIt=1 }
	return hideIt
	}

	

// CODE FOR POPUP WINDOWS BELOW 
var popupWin;
	function openWindow(url,parameters) {
		if (popupWin == null || popupWin.closed) {
			popupWin=window.open(url,"popupWin",parameters);
		}
		else {
			popupWin.location.href = url;
			popupWin.focus();
		}
	};
	function closeWindow() {
		if (popupWin != null && !popupWin.closed) {
			popupWin.close();
		}
	};
	
	
	
// CODE FOR VALIDATING THE ORDER FORM 
function validateForm() {
	
	if (document.orderForm.monthDue.selectedIndex == 0) {
    	alert("Please select the Month the report is due.");
		document.orderForm.monthDue.focus();
		return false;
	}
	if (document.orderForm.dayDue.selectedIndex == 0) {
    	alert("Please select the Day the report is due.");
		document.orderForm.dayDue.focus();
		return false;
	}
	if (document.orderForm.yearDue.selectedIndex == 0) {
    	alert("Please select the Year the report is due.");
		document.orderForm.yearDue.focus();
		return false;
	}
	if (!document.orderForm.appraisalType[0].checked && 
     	!document.orderForm.appraisalType[1].checked &&
		!document.orderForm.appraisalType[2].checked &&
		!document.orderForm.appraisalType[3].checked &&
		!document.orderForm.appraisalType[4].checked &&
		!document.orderForm.appraisalType[5].checked &&
		!document.orderForm.appraisalType[6].checked &&
		!document.orderForm.appraisalType[7].checked &&
		!document.orderForm.appraisalType[8].checked &&
		!document.orderForm.appraisalType[9].checked &&
		!document.orderForm.appraisalType[10].checked &&
		!document.orderForm.appraisalType[11].checked &&
		!document.orderForm.appraisalType[12].checked &&
		!document.orderForm.appraisalType[13].checked &&
		!document.orderForm.appraisalType[14].checked &&
		!document.orderForm.appraisalType[15].checked &&
     	!document.orderForm.appraisalType[16].checked) {
 		alert("Please select the Type of Appraisal.");
		document.orderForm.appraisalType[0].focus();
		return false;
	}
	if (document.orderForm.email.value == "" || document.orderForm.email.value.indexOf("@") == -1 || document.orderForm.email.value.indexOf(".") == -1) {
        alert("Please enter a proper email address (e.g. somebody@isp.com).");
     	document.orderForm.email.focus();
        return false;
	}
	if((document.orderForm.borrowersAddress.value == "") || (document.orderForm.borrowersAddress.value == null)) {
		alert('Please enter the Property Address.');
		document.orderForm.borrowersAddress.focus();
		return false;
	}
	if((document.orderForm.borrowersCity.value == "") || (document.orderForm.borrowersCity.value == null)) {
		alert('Please enter the Property City.');
		document.orderForm.borrowersCity.focus();
		return false;
	}
	if (document.orderForm.borrowersState.selectedIndex == 0) {
    	alert("Please enter the Property State.");
		document.orderForm.borrowersState.focus();
		return false;
	}
	if((document.orderForm.borrowersZip.value == "") || (document.orderForm.borrowersZip.value == null)) {
		alert('Please enter the Property Zip Code.');
		document.orderForm.borrowersZip.focus();
		return false;
	}
	if (document.orderForm.access.selectedIndex == 0) {
    	alert("Please enter the method of Access.");
		document.orderForm.access.focus();
		return false;
	}
	if((document.orderForm.companyName.value == "") || (document.orderForm.companyName.value == null)) {
		alert('Please enter your Company Name.');
		document.orderForm.companyName.focus();
		return false;
	}
	if((document.orderForm.companyContact.value == "") || (document.orderForm.companyContact.value == null)) {
		alert('Please enter your Company Contact Person.');
		document.orderForm.companyContact.focus();
		return false;
	}
	if((document.orderForm.companyAddress.value == "") || (document.orderForm.companyAddress.value == null)) {
		alert('Please enter the Company Address.');
		document.orderForm.companyAddress.focus();
		return false;
	}
	if((document.orderForm.companyCity.value == "") || (document.orderForm.companyCity.value == null)) {
		alert('Please enter the Company City.');
		document.orderForm.companyCity.focus();
		return false;
	}
	if (document.orderForm.companyState.selectedIndex == 0) {
    	alert("Please enter the Company State.");
		document.orderForm.companyState.focus();
		return false;
	}
	if((document.orderForm.companyZip.value == "") || (document.orderForm.companyZip.value == null)) {
		alert('Please enter the Company Zip Code.');
		document.orderForm.companyZip.focus();
		return false;
	}
	if((document.orderForm.companyPhone.value == "") || (document.orderForm.companyPhone.value == null)) {
		alert('Please enter your Company Phone Number.');
		document.orderForm.companyPhone.focus();
		return false;
	}
	if((document.orderForm.companyFax.value == "") || (document.orderForm.companyFax.value == null)) {
		alert('Please enter your Company Fax Number.');
		document.orderForm.companyFax.focus();
		return false;
	}
	return true;
}



// CODE FOR IMAGE SWAP

	// precache all 'off' images
	var offImgArray =  new Array()
	offImgArray["about"] = new Image(92,10)
	// off image array -- set 'off' image path for each image
	offImgArray["about"].src = "images/about_white.gif"
	
	offImgArray["service"] = new Image(124,10)
	offImgArray["service"].src = "images/service_white.gif"
	
	offImgArray["fee"] = new Image(123,10)
	offImgArray["fee"].src = "images/fee_white.gif"
	
	offImgArray["order"] = new Image(169,10)
	offImgArray["order"].src = "images/order_white.gif"
	
	offImgArray["contact"] = new Image(110,10)
	offImgArray["contact"].src = "images/contact_white.gif"
	
	offImgArray["downloads"] = new Image(112,10)
	offImgArray["downloads"].src = "images/downloads_white.gif"
	
	
	// precache all 'on' images
	var onImgArray =  new Array()
	onImgArray["about"] = new Image(92,10)
	// on image array -- set 'on' image path for each image
	onImgArray["about"].src = "images/about_blue.gif"
	
	onImgArray["service"] = new Image(124,10)
	onImgArray["service"].src = "images/service_blue.gif"
	
	onImgArray["fee"] = new Image(123,10)
	onImgArray["fee"].src = "images/fee_blue.gif"
	
	onImgArray["order"] = new Image(169,10)
	onImgArray["order"].src = "images/order_blue.gif"
	
	onImgArray["contact"] = new Image(110,10)
	onImgArray["contact"].src = "images/contact_blue.gif"
	
	onImgArray["downloads"] = new Image(112,10)
	onImgArray["downloads"].src = "images/downloads_blue.gif"
	
	
	
	// functions that swap images & status bar
	function imageOff(imgName) {
		if (document.images) {
			document.images[imgName].src = offImgArray[imgName].src
		}
	}
	
	function imageOn(imgName) {
		if (document.images) {
			document.images[imgName].src = onImgArray[imgName].src
		}
	}
