<!--

//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;
	}

//Fix 100% Height maintaining standards compliance

function fix_height() {
			var isNav, isIE;
			if (parseInt(navigator.appVersion) >= 4) {
				isNav = (navigator.appName == "Netscape");
				isIE = (navigator.appName.indexOf("Microsoft") != -1);
				isSafari = (navigator.appVersion.indexOf("Safari") != -1);
			}
			if (isIE) {
		 	int_available = document.body.clientHeight
			} else {
				if (isSafari) {
		 	 	int_available = window.innerHeight
				} else {
		 	 	int_available = window.innerHeight
				}
			}
		 
		 if (document.getElementById("header")) {
		 int_header = document.getElementById("header").offsetHeight
		 } else {
		 int_header = 0
		 }
		 //int_nav = document.getElementById("nav").offsetHeight
		 //int_subnav = document.getElementById("subnav").offsetHeight
		 if (document.getElementById("footer")) {
		 int_footer = document.getElementById("footer").offsetHeight
		 } else {
		 int_footer = 0
		 }
		 if (document.getElementById("banner")) {
		 int_banner = document.getElementById("banner").offsetHeight
		 } else {
		 int_banner = 0
		 }
		 int_fix = int_header+int_banner+int_footer
		 int_remaining = int_available-(int_fix)
		 //alert("Available - " + int_available + "\nHeader - " + int_header + "\nNav - " + int_nav + "\nFooter - " + int_footer + "\nFix - " + int_fix + "\nRemaining - " + int_remaining)
			var myElement = document.getElementById("content");
			myElement.style.height = int_remaining + "px";

}

//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;
  }
