<!--

//window.onload = function(){
//	fix_height();
//}
//window.onresize = function(){
//	fix_height();
//}

function submit_form(str_form_name) {
	eval("document.forms." + str_form_name + ".submit();")
}
function clear_form(str_form_name) {
	eval("document.forms." + str_form_name + ".reset();")
}

function confirm_action(msg) {
  document.return_value = confirm(msg);
}


function check_minimum_quantity(int_mq,int_q,frm_name) {
 if(int_q>=int_mq) {
 submit_form(frm_name)
 } else {
 alert("You must order a minimum of " + int_mq + " units!")
 document.forms.product_form.int_quantity.value = int_mq
 }
}

function verify_email(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){return false}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {return false}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {return false}
	if (str.indexOf(at,(lat+1))!=-1) {return false}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {return false}
	if (str.indexOf(dot,(lat+2))==-1) {return false}
	if (str.indexOf(" ")!=-1) {return false}
	return true					
	}

function ensureNumeric(strString,mini,maxi)
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   if (strString.length < mini | strString.length > maxi) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function check_form(str_form,str_args) { // v0 copyright Andrew Watson Paligap 2004 (CALL) onClick="check_form('frm_subscribe','str_name|t|1|You have not entered your name.,str_email|e|1|You have entered an invalid e-mail address.');return document.check_form_return;"
	var arr_args = str_args.split(",")
	str_error_message = ""
	for(i=0;i<arr_args.length;i++) {
		var arr_this_element = arr_args[i].split("|")
		str_field = arr_this_element[0]
		str_type = arr_this_element[1]
		bln_required = arr_this_element[2]
		str_message = arr_this_element[3]
		this_value = eval("document." + str_form + "." + str_field + ".value")
		this_value = this_value.replace(" ","")
			if (str_type == "t") { //Check String
				if (bln_required==1) {
					if (this_value=='') {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "e") { //Check Email
				if (bln_required==1) {
					if (this_value==''||!verify_email(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&!verify_email(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "n") { //Check Numeric
				if (bln_required==1) {
					if (this_value==''||isNaN(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&isNaN(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			} else if (str_type == "d") { //Check Date
				if (bln_required==1) {
					if (this_value==''||!verify_date(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				} else {
					if (this_value!=''&&!verify_date(this_value)) {str_error_message = str_error_message + str_message + "\n\n"}
				}
			}
		}
		if (str_error_message!="") {
			str_error_message = "Incomplete Form Information!                              \n________________________\n\n" + str_error_message
			alert(str_error_message)
			document.check_form_return = false
		} else {
			document.check_form_return = true
			//eval("document.forms." + str_form + ".submit();")
		}
	}


function do_color_swap(str_color) {
	ele_header = document.getElementById("container");
	ele_header.style.backgroundColor = str_color;
	}


//POP UP WINDOW
function popupwin(str_url,h,w,scrolling) {
	vars = "height="+h+",width="+w+",left="+(screen.width/2-(w/2))+",top="+(screen.height/2-(h/2))+",scrollbars="+ scrolling +",toolbar=no,status=no,resizable=no"
	focus_win = window.open(str_url,'newwin',vars)
	focus_win.window.focus()
	}
var submitcount = 0
function checkPayForm() {
	str_errors = "Please correct the following entries...\n\n"
		if (document.frmPayment.fldCardholder.value=="" | document.frmPayment.fldCardholder.value==null )  {str_errors = str_errors + "Invalid Card Holder Name Entered\n"}
		myString = new String(document.frmPayment.Pan.value)
		rExp = / /gi;
		newString = new String ("")
		results = myString.replace(rExp, newString)
		int_pan = parseInt(results)
		if (int_pan=="" | int_pan==null | !ensureNumeric(int_pan,13,19))  {str_errors = str_errors + "Invalid Card Number Entered\n"}
		if (document.frmPayment.CV2.value!="") {
			if (!ensureNumeric(document.frmPayment.CV2.value,3,3)) {str_errors = str_errors + "Invalid 3-Digit Security Code Entered\n"}
			}
		if (document.frmPayment.IssNo.value!="") {
			if (!ensureNumeric(document.frmPayment.IssNo.value,1,2)) {str_errors = str_errors + "Invalid Issue Number Entered\n"}
			}
		if (str_errors!="Please correct the following entries...\n\n") {
		document.return_value = false
		alert(str_errors)
		} else {
		 	if (submitcount == 0) {
			submitcount++
			document.return_value = true
			} else {
			alert("Your order is being processed...")
			}
		}
	}

function clearForm() {
	document.frmPayment.fldCardholder.value=""
	document.frmPayment.Pan.value=""
	document.frmPayment.CV2.value=""
	document.frmPayment.IssNo.value=""
	
	}


function insert_smilie(myValue) {
myField = document.frm_post.str_body
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == 0) {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}

function runCalc(code,amount,rid,deposit)
  {
  	var screenX=screen.width;
  	var screenY=screen.height;
  	var winWidth=440;
  	var winHeight=320;
  	
  	var topX=(screenX/2) - (winWidth / 2);
  	var topY=(screenY/2) - (winHeight / 2);
  	
  	newWin = window.open("","Wait","width="+winWidth+",height="+winHeight+", left="+topX+",top="+topY);
  	
  	
  	newWin.location="http://www.creditenabler.com/able2buy/webjsp/autocalc.jsp?cgid="+code+"&price="+amount+"&id="+rid+"&deposit="+deposit;
  }
  
  function check_reg() {
if(document.forms.frm_register.str_password.value!=document.forms.frm_register.str_password_confirm.value) {
alert("Passwords do not match..!");
document.check_return = false;
} else if (document.forms.frm_register.str_password.value.length < 6) {
alert("Password must be at least 6 characters long.!");
document.check_return = false;
} else if (document.forms.frm_register.str_username.value.indexOf(" ") > -1) {
alert("Username cannot contain spaces");
document.check_return = false;
} else {
check_form('frm_register','str_firstname|t|1|You have not entered your first name.,str_lastname|t|1|You have not entered your last name.,str_email|e|1|You have entered an invalid e-mail address.,str_username|t|1|You have not entered a username.,str_password|t|1|You have not entered a password.')
return document.check_form_return;
}
}

function showModel(str)
{
if (str=="")
  {
  document.getElementById("str_model").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("str_model").innerHTML=xmlhttp.responseText;
    }
  }
  //alert("getcar.asp?q="+str)
xmlhttp.open("POST","/getcar.asp?q="+str,true);
xmlhttp.send();
}

function showModel1(str)
{
if (str=="")
  {
  document.getElementById("str_model1").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("str_model1").innerHTML=xmlhttp.responseText;
    }
  }
  //alert("getcar.asp?q="+str)
xmlhttp.open("POST","/getcar1.asp?q="+str,true);
xmlhttp.send();
}


function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickback(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
