<!--
//path variables
var inkpath = "http://66.115.16.70/";
var inksslpath = "http://66.115.16.70/";

// browser detection
// browser detection:
var ua = navigator.userAgent;
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns6 = (document.getElementById && ns)?1:0;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1)?1:0;
var macie4 = (mac && !ns && parseInt(ua.substr(ua.indexOf("MSIE")+4,2)) <= 4)?1:0;

if (ns || ns6) document.write('<LINK rel=stylesheet type="text/css" href="ink_ns.css">');
else document.write('<LINK rel=stylesheet type="text/css" href="ink.css">');

//trims the leading and trailing blanks from a given string 
function Trim(strToTrim){
	while(strToTrim.charAt(0)==' '){	
		strToTrim = strToTrim.substring(1,strToTrim.length);
	}
	while(strToTrim.charAt(strToTrim.length-1)==' '){	
		strToTrim = strToTrim.substring(0,strToTrim.length-1);
	}
	return strToTrim;
}


var headerHeight = 135;
var footerHeight = 42;
var nsFix = 0;

function GetTDHeight(){
	if (ns6){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8;
	} else if (ns){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8 - nsFix;
	} else {
		contHeight = document.body.clientHeight - headerHeight - footerHeight - 8;
	}
	document.write("<TD height=" + contHeight + " valign=top>");
}

function GetTableHeight(){
	if (ns6){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8;
	} else if (ns){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8 - nsFix;
	} else {
		contHeight = document.body.clientHeight - headerHeight - footerHeight - 8;
	}
	document.write("<TABLE cellspacing=0 cellpadding=0 border=0 height=" + contHeight + ">");
}


function validateCheckOut(theForm){
// START: Credit Card checkings
	if (theForm.lstCreditCardType.selectedIndex == 0) {
		alert("Please enter the Credit Card type.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (Trim(theForm.txtCardNumber.value) == "") {
		alert("Please fill in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (isNaN(parseInt(new Number(theForm.txtCardNumber.value)))) {
		alert("The Credit Card Number field may not contain spaces, non-numeric characters, or dashes.");
		theForm.txtCardNumber.focus();
		return false;
	}
	var checkOK = "0123456789";
	var checkStr = theForm.txtCardNumber.value;
	var allValid = true;
	var validGroups = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch == ".") {
			allNum += ".";
			decPoints++;
		} else if (ch == "," && decPoints != 0)	{
			validGroups = false;
			break;
		} else if (ch != ",")
			allNum += ch;
	}
	if (!allValid) {
		alert("Please enter only digit characters in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (decPoints > 1 || !validGroups || !check(checkStr)) {
		alert("Please enter a valid number in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (theForm.lstCreditCardType.selectedIndex != 0 && check(checkStr)=="wrongtype") {
		alert("This looks like a "+cardType+" card number, not a "+ theForm.lstCreditCardType.options[theForm.lstCreditCardType.selectedIndex].value +" card number.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (theForm.lstCreditCardType.selectedIndex != 0 && check(checkStr)=="unknowntype") {
		alert("This is not a "+ theForm.lstCreditCardType.options[theForm.lstCreditCardType.selectedIndex].value +" card number.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (theForm.lstMonthExpires.selectedIndex == 0) {
		alert("Please select the Credit Card Expiration month.");
		theForm.lstMonthExpires.focus();
		return false;
	}else if (theForm.lstYearExpires.selectedIndex == 0) {
		alert("Please select the Credit Card Expiration year.");
		theForm.lstYearExpires.focus();
		return false;
	}else{
		var today = new Date();
		var month = parseInt(new Number(theForm.lstMonthExpires.options[theForm.lstMonthExpires.selectedIndex].value));
		var year = parseInt(new Number("20"+new String(theForm.lstYearExpires.options[theForm.lstYearExpires.selectedIndex].value)));
		var expiry = new Date(year,month);
		if (today.getTime() > expiry.getTime()){
			alert("The credit card is expired.");
			theForm.lstMonthExpires.focus();
			return false;
		}
	}
	
	theForm.action = "checkout.asp";
	return true;
	// END: Credit Card checkings
}

//value that holds the creditcard type
var cardType = new String("");

//Validates the credit card number
/*************************************************************************
boolean check([String CardNumber])
returns true if card Number passes the luhn check else returns false.
*************************************************************************/
function check(Number) {
	cardType = "";
	var digArr = new Array();
	var givenCardType = new String(document.frmChk_2.lstCreditCardType.options[document.frmChk_2.lstCreditCardType.selectedIndex].value);
	var CardNumber = new String(Number);
	var no_digit = CardNumber.length;
	var oddoeven = no_digit & 1;
	var sum = 0;
	for (var count = 0; count < no_digit; count++) {
		var digit = parseInt(CardNumber.charAt(count));
		digArr[count] = digit;
		if (!((count & 1) ^ oddoeven)) {
		digit *= 2;
		if (digit > 9)
			digit -= 9;
		}
		sum += digit;
	}
	if (sum % 10 == 0){
		if (no_digit==13){
			if (digArr[0]==4) cardType = "VISA";
		}
		if (no_digit==16){
			if (digArr[0]==4) cardType = "VISA";
			if (digArr[0]==5&&(digArr[1]==1||digArr[1]==2||digArr[1]==3||digArr[1]==4||digArr[1]==5)) cardType = "MasterCard";
			if (digArr[0]==6&&digArr[1]==0&&digArr[2]==1&&digArr[3]==1) cardType = "Discover";
		}
		if (no_digit==15){
			if (digArr[0]==3&&(digArr[1]==4||digArr[1]==7)) cardType = "American Express";
		}
		if(cardType ==""){
			return "unknowntype";
		}else if(cardType != givenCardType && cardType!=""){
			return "wrongtype";
		}else return true;
	}else
		return false;
}

//-->
