
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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function P7_ShowPic(a,b) { //v2.0 by PVII
 var g,gg,d,dd,ic,im;if((g=MM_findObj(b))!=null){
 if(!document.P7ShowPic){document.P7ShowPic=true;}else{
 if((d=MM_findObj(document.P7SPlay))!=null){
  dd=(document.layers)?d:d.style;dd.visibility="hidden";}}
 document.P7SPlay=b;gg=(document.layers)?g:g.style;im=b+"im";
 if((ic=MM_findObj(im))!=null){ic.src=a;gg.visibility="visible";}}
}

function addBookmark(title,url) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}

var newWindow = null;
 
function closeWin(){
        if (newWindow != null){
               if(!newWindow.closed)
                       newWindow.close();
        }
}

//------------------- OPEN NEW WINDOW -------------------//
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){	
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,menubar=no,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function popUpSWF(url, type, Width, Height, arg1, arg2, arg3){
	closeWin();
	tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+Width+",height="+Height+",left=0,top=0";
	if(type == "mcl"){
		newWindow = window.open(url+"?bandwidth="+arg1+"&video="+arg2+"&lan="+arg3, 'newWin', tools);
	}
	if(type == "bna"){
		newWindow = window.open(url+"?proceedure="+arg1+"&case="+arg2, 'newWin', tools);
	}
	if(type == "casinovideo"){
    	newWindow = window.open(url+"?bandwidth="+arg1+"&video="+arg2, 'newWin', tools);
    } 
	newWindow.focus();
}


//------------------- for clearing and replacing text in form input fields and textareas -------------------//
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}


// Form Validation Start
function ValidateSmallForm(){
	var bitErr = false;
	var bitErrEmail = false;
	var reqField = "";
 
	if (document.contact_quick.first_name.value == ""){ bitErr = true; reqField += "- First Name\n";}
	if (document.contact_quick.last_name.value == "") { bitErr = true; reqField += "- Last Name\n"; }
	if (document.contact_quick.first_name.value == "First Name"){ bitErr = true; reqField += "- First Name\n";}
	if (document.contact_quick.last_name.value == "Last Name") { bitErr = true; reqField += "- Last Name\n"; }
	if (document.contact_quick.email.value == "") { bitErr = true; bitErrEmail = true; }
	if (document.contact_quick.email.value == "Email") { bitErr = true; bitErrEmail = true; }
	if (document.contact_quick.email.value.indexOf("@") == -1) { bitErr = true; bitErrEmail = true; }
	if (document.contact_quick.email.value.indexOf(".") == -1) { bitErr = true; bitErrEmail = true; }
	if (document.contact_quick.home_phone.value == "") { bitErr = true; reqField += "- Home Phone\n"; }
	if (document.contact_quick.home_phone.value == "Home Phone") { bitErr = true; reqField += "- Home Phone\n"; }

	if (bitErrEmail){
		reqField += "- Email (Use a valid email address.)\n";
	}
	if (bitErr){
		alert("Please fill out the following required information:\n"+reqField);
		return false;
	}
	
	document.contact_quick.submit();
}
// Form Validation End


function ValidateLeadForm(){
	var bitErr = false;
	var bitErrEmail = false;
	var reqField = "";
 
	if (document.contact_main.first_name.value == ""){ bitErr = true; reqField += "- First Name\n";}
	if (document.contact_main.last_name.value == "") { bitErr = true; reqField += "- Last Name\n"; }
	if (document.contact_main.home_phone.value == "") { bitErr = true; reqField += "- Home Phone\n"; }
	if (document.contact_main.email.value == "") { bitErr = true; bitErrEmail = true; }
	if (document.contact_main.email.value.indexOf("@") == -1) { bitErr = true; bitErrEmail = true; }
	if (document.contact_main.email.value.indexOf(".") == -1) { bitErr = true; bitErrEmail = true; }
	//alert(document.contact_main.desired_location.value)
	if ((document.contact_main.desired_location.value == "City, State" && document.contact_main.type_of_loan.value =="Purchase")  ) { bitErr = true; reqField += "- Desired Property Location\n"; }
	if (document.contact_main.type_of_loan.value == "") { bitErr = true; reqField += "- Type of Loan\n"; } 

	if (bitErrEmail){
		reqField += "- Email (Use a valid email address.)\n";
	}
	if (bitErr){
		alert("Please fill out the following required information:\n"+reqField);
		return false;
	}
	
	//document.contact_main.submit();
}


						
function showinput(id){

	if (document.contact_main.type_of_loan.value == 'Purchase'){
		var el = document.getElementById(id);
		el.style.display =  'block';
	} else {
		var el = document.getElementById(id);
		el.style.display = 'none';
	}
	
}

function printFlash(source, width, height, id, bg_color, flashVars) {
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
document.write('width="'+width+'" height="'+height+'" id="'+id+'" align="middle" />');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name=flashVars value="'+flashVars+'" />');
document.write('<param name="movie" value="'+source+'" />');
document.write('<param name="menu" value="false" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="'+bg_color+'" />');
document.write('<embed src="'+source+'" flashVars="'+flashVars+'" menu="false" quality="high" bgcolor="'+bg_color+'" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" ');
document.write('allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}
