// Place your application-specific JavaScript functions and classes here

// This file is automatically included by javascript_include_tag :defaults







////////////Hide Show2////////////////

function askTaxID(type) {

	document.getElementById("00N80000003HJF8").value = type;

	if (type =="Sole Proprietor"){

		    document.getElementById("div_taxid").style.display = "none";

			document.getElementById("00N80000003HJxk").value = ""; //blank out Tax ID field

			

		 	var first = document.getElementById("first_name").value;

		 	var last = document.getElementById("last_name").value;

		 	var full_name = first +" "+last;	

		document.getElementById("00N80000003HJR4").value =  full_name ; //Auto populate BLN as owner's full name 

	}

	if (type == "Corporation" || type == "LLC") {

		document.getElementById("div_taxid").style.display = "block";

		document.getElementById("00N80000003HJR4").value = "";}

	if (type == "Partnership" || type == "Other") {

		document.getElementById("div_taxid").style.display = "none";

		document.getElementById("00N80000003HJR4").value = "";

		document.getElementById("00N80000003HJxk").value = ""; //blank out Tax ID field

	}	

}

function hideDiv(arg) {
       document.getElementById(arg).style.display = "none";
}
function showDiv(arg) {
       document.getElementById(arg).style.display = "block";
}



////////////Hide Show2////////////////div_taxid

function TaxLogic(){

	var b_type = document.getElementById("00N80000003HJF8").value;

	if (b_type == "Sole Proprietor" || b_type =="Partnership" || b_type =="Other") { 

	document.getElementById("div_taxid").style.display = "none"; }

	if (b_type == "Corporation" || b_type =="LLC") { 

	   document.getElementById("div_taxid").style.display = "block"; }

	if (b_type == "") { document.getElementById("div_taxid").style.display = "none"; }

}



function clearForms()

	{

 	 var i;

 	 for (i = 0; (i < document.forms.length); i++) {

    document.forms[i].reset();

 	 }

	}



function highlight(divID)

	{

		document.getElementById(divID).style.backgroundColor = "#FFC";

	}

function unhighlight(id)

	{

		document.getElementById(id).style.backgroundColor= "";

	}

////Contact Window//

var contactWindow = null;

function windowContactOpen(){

	if (contactWindow && !contactWindow.closed){

		return true; }

		return false;

}

function closeContactBrowser() { 

  contactWindow.document.close();

}



function openContactWindow(theURL,winName,features) { 

  if(windowContactOpen()){

  contactWindow.close();}

  contactWindow = window.open(theURL,winName,features);

}

	////Contact Window//

	







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 formReset(formname)

{

document.getElementById(formname).reset()

}



///Price Assurance//

var newWindow = null;

function windowOpen(){

	if (newWindow && !newWindow.closed){

		return true; }

		return false;

}

function openNewBrowser(URL,winName,style) { 

  if(windowOpen()){

  newWindow.close();}

  newWindow = window.open(URL,winName,style);

}

function priceAssuranceWin() {

	window.open("home","VIP Price Assurance Guarantee", "height=625,width=850");

	

}

//Calculator Tips
function numbersonly(e, decimal) {
var key;
var keychar;

if (window.event) {
   key = window.event.keyCode;
}
else if (e) {
   key = e.which;
}
else {
   return true;
}
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
   return true;
}
else if ((("0123456789").indexOf(keychar) > -1)) {
   return true;
}
else if (decimal && (keychar == ".")) { 
  return true;
}
else
   return false;
}
