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];}
}

var subMnus="";
									
function showmenu(idx,li){
	var subleftoffset=((document.body.offsetWidth-846)/2)-6;
	if(document.body.offsetWidth<895)
		subleftoffset=14;
	var sublefts=new Array(8);
	sublefts[0]=subleftoffset;
	sublefts[1]=sublefts[0]+134;
	sublefts[2]=sublefts[1]+128;
	sublefts[3]=sublefts[2]+162;
	sublefts[4]=sublefts[3]+95;
	sublefts[5]=sublefts[4]+83;
	sublefts[6]=sublefts[5]+68;
	sublefts[7]=sublefts[6]+79-50;
	try{
		hideAllMenu();
		var dv=document.getElementById("sub"+idx);
		dv.style.left=sublefts[li];
		dv.style.top=129;
		dv.style.visibility="visible";
	}
	catch(e){}
}

function hideAllMenu(){
	try{
		var ar=subMnus.split(',');
		for(i=0;i<ar.length;i++){
			var dv=document.getElementById("sub"+ar[i]);
			dv.style.visibility="hidden";
		}
	}
	catch(e){}
}

// This function is used to validate email entries
function isValidEmail(thisEmail){
	var emailexp = /.*\@.*\..*/;
	if (!emailexp.test(thisEmail)) {
		return false;
	} 
	return true;
}

// This function checks to see if a selection was made in a checkbox or radio group
function cbxSelectionMade(cbx){
	var isGood=false;
	if(cbx.checked){
		isGood=true;
	}
	for(i=0;i<cbx.length && !isGood;i++){
		if(cbx[i].checked){
			isGood=true;
		}
	}
	return isGood;
}

// This function checks to see if a selection was made in a dropdown box
function cboSelectionMade(cbo){
	var isGood=false;
	
	if(cbo.selectedIndex>0&&cbo.options[cbo.selectedIndex].value!="")
		isGood=true;
		
	return isGood;
}

// This function is used to validate financing app submissions
function validateFinApp(thisForm){
  if(thisForm.legalname.value==""){
    alert("Please provide your LEGAL NAME!");
    thisForm.legalname.focus();
    return false;
  }
  if(thisForm.address.value==""){
    alert("Please provide your ADDRESS!");
    thisForm.address.focus();
    return false;
  }
  if(thisForm.yearsat.value==""){
    alert("Please provide your YEARS AT THIS ADDRESS!");
    thisForm.yearsat.focus();
    return false;
  }
  if(thisForm.city.value==""){
    alert("Please provide your CITY!");
    thisForm.city.focus();
    return false;
  }
  if(thisForm.prov.value==""){
    alert("Please provide your PROV!");
    thisForm.prov.focus();
    return false;
  }
  if(thisForm.postal.value==""){
    alert("Please provide your POSTAL!");
    thisForm.postal.focus();
    return false;
  }
  if(thisForm.phone.value==""){
    alert("Please provide your PHONE!");
    thisForm.phone.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.dobmonth)){
    alert("Please provide your DOB MONTH!");
    thisForm.dobmonth.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.dobday)){
    alert("Please provide your DOB DAY!");
    thisForm.dobday.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.dobyear)){
    alert("Please provide your DOB YEAR!");
    thisForm.dobyear.focus();
    return false;
  }
  if(thisForm.email.value==""||!isValidEmail(thisForm.email.value)){
    alert("Please provide a valid EMAIL ADDRESS!");
    thisForm.email.focus();
    return false;
  }
  if(thisForm.SIN.value==""){
    alert("Please provide your SIN!");
    thisForm.SIN.focus();
    return false;
  }
  if(thisForm.employer.value==""){
    alert("Please provide your EMPLOYER!");
    thisForm.employer.focus();
    return false;
  }
  if(thisForm.employerphone.value==""){
    alert("Please provide your EMPLOYER PHONE NUMBER!");
    thisForm.employerphone.focus();
    return false;
  }
  if(thisForm.position.value==""){
    alert("Please provide your POSITION!");
    thisForm.position.focus();
    return false;
  }
  if(thisForm.yearsemployed.value==""&&thisForm.monthsemployed.value==""){
    alert("Please provide your YEARS AND MONTHS EMPLOYED!");
    thisForm.yearsemployed.focus();
    return false;
  }
  if(thisForm.annualgross.value==""){
    alert("Please provide your ANNUAL GROSS INCOME!");
    thisForm.annualgross.focus();
    return false;
  }
  if(thisForm.mortgage.value==""){
    alert("Please provide your MONTHLY MORTGAGE/RENT PAYMENT!");
    thisForm.mortgage.focus();
    return false;
  }
  if(thisForm.institute.value==""){
    alert("Please provide your FINANCIAL INSTITUTE's NAME!");
    thisForm.institute.focus();
    return false;
  }
  if(thisForm.inslocation.value==""){
    alert("Please provide your FINANCIAL INSTITUTE's LOCATION!");
    thisForm.inslocation.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.financetype)){
    alert("Please provide your FINANCE TYPE!");
    thisForm.financetype.focus();
    return false;
  }
  if(thisForm.financefor.value==""){
    alert("Please provide the ITEM YOU WANT TO PURCHASE!");
    thisForm.financefor.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.financeperiod)){
    alert("Please provide your FINANCE PERIOD!");
    thisForm.financeperiod.focus();
    return false;
  }
  if(!cboSelectionMade(thisForm.financepayment)){
    alert("Please provide your FINANCE PAYMENT!");
    thisForm.financepayment.focus();
    return false;
  }
  
  return true; 
}

function validateInquiry(thisForm){
  if(thisForm.name.value==""){
    alert("Please provide your Name!");
    thisForm.name.focus();
    return false;
  }
  if(thisForm.phone.value==""){
    alert("Please provide your Phone number!");
    thisForm.phone.focus();
    return false;
  }
  if(thisForm.email.value==""||!isValidEmail(thisForm.email.value)){
    alert("Please provide a valid email address!");
    thisForm.email.focus();
    return false;
  }
  
  return true; 
}

function validatePRequest(thisForm){
  if(thisForm.comments.value==""){
    alert("Please tell us what parts your looking for!");
    return false;
  }
  if(thisForm.name.value==""){
    alert("Please provide your Name!");
    thisForm.name.focus();
    return false;
  }
  if(thisForm.phone.value==""){
    alert("Please provide your Phone number!");
    thisForm.phone.focus();
    return false;
  }
  if(thisForm.email.value==""||!isValidEmail(thisForm.email.value)){
    alert("Please provide a valid email address!");
    thisForm.email.focus();
    return false;
  }
  
  return true; 
}

function writeBannerSWF(divName){
	var dv=document.getElementById(divName);
	var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="592" height="132">';
	str+='<param name="movie" value="mainBanner.swf">';
	str+='<param name="quality" value="high">';
	str+='<param name="wmode" value="opaque">';
	str+='<param name="menu" value="false">';
	str+='<embed src="mainBanner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="592" height="132" wmode="opaque" menu="false"></embed>';
	str+='</object>';
	dv.innerHTML=str;
}

function writeLeftnavSWF(divName){
	var dv=document.getElementById(divName);
	var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="84">';
	str+='<param name="movie" value="sideSpecials.swf">';
	str+='<param name="quality" value="high">';
	str+='<param name="wmode" value="opaque">';
	str+='<param name="menu" value="false">';
	str+='<embed src="sideSpecials.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="84" wmode="opaque" menu="false"></embed>';
	str+='</object>';
	dv.innerHTML=str;
}