<!--
// 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="gall_ns.css">');
else document.write('<LINK rel=stylesheet type="text/css" href="gall.css">');

var arrHeaders = new Array(
"images/hdr2_01.gif",
"images/hdr2_02.gif",
"images/hdr2_03.gif",
"images/hdr2_04.gif",
"images/hdr2_05.gif",
"images/hdr2_06.gif",
"images/hdr2_07.gif",
"images/hdr2_08.gif",
"images/hdr2_09.gif",
"images/hdr2_10.gif"
)

var allLImagesOn = new Array(
"images/mnu_01_on.gif",
"images/mnu_02_on.gif",
"images/mnu_03_on.gif",
"images/mnu_04_on.gif",
"images/mnu_05_on.gif",
"images/mnu_06_on.gif",
"images/mnu_07_on.gif",
"images/mnu_08_on.gif",
"images/mnu_09_on.gif"
);

var allLImagesOff = new Array(
"images/mnu_01_off.gif",
"images/mnu_02_off.gif",
"images/mnu_03_off.gif",
"images/mnu_04_off.gif",
"images/mnu_05_off.gif",
"images/mnu_06_off.gif",
"images/mnu_07_off.gif",
"images/mnu_08_off.gif",
"images/mnu_09_off.gif"
);

var allLinks = new Array(
"home.asp",
"contact.asp",
"company.asp",
"products.asp",
"suppliers.asp",
"engineering.asp",
"quality.asp",
"services.asp",
"resources.asp"
);

var ObjLImg_on = new Array();
var ObjLImg_off = new Array();

PreloadImages();

// Preloading all the roll-over images in the document:
function PreloadImages() {
	for (var i=0; i<allLImagesOn.length ; i++){
		ObjLImg_on[i] = new Image();
		ObjLImg_on[i].src = allLImagesOn[i];
		ObjLImg_off[i] = new Image();
		ObjLImg_off[i].src = allLImagesOff[i];
	}
}

function swap(name,index,state) {
		eval("document.images['" + name + "'].src = ObjLImg_" + state + "["+index+"].src");
}

var strMenus1 = new String("");
var strMenus2 = new String("");

for (var i=0;i<=1;i++){
	if (pageNo==i) strMenus1 += '<IMG src="'+ObjLImg_on[i].src+'" border=0>';
	else strMenus1 += '<A href="'+allLinks[i]+'" onmouseover="swap(\'mnu_'+i+'\','+i+',\'on\')" onmouseout="swap(\'mnu_'+i+'\','+i+',\'off\')"><IMG src="'+ObjLImg_off[i].src+'" border=0 name="mnu_'+i+'"></A>';
	if (i<1) strMenus1 += '<IMG src="images/mnu_bar01-02.gif" border=0 width=2 height=9 align=absmiddle hspace=5>'
}

for (var i=2;i<=8;i++){
	if (pageNo==i){
		if (pageNo==3) strMenus2 += '<A href="'+allLinks[i]+'"><IMG src="'+ObjLImg_on[i].src+'" border=0 name="mnu_'+i+'" align=absmiddle></A>';
		else strMenus2 += '<IMG src="'+ObjLImg_on[i].src+'" border=0 align=absmiddle>';
	} else strMenus2 += '<A href="'+allLinks[i]+'" onmouseover="swap(\'mnu_'+i+'\','+i+',\'on\')" onmouseout="swap(\'mnu_'+i+'\','+i+',\'off\')"><IMG src="'+ObjLImg_off[i].src+'" border=0 name="mnu_'+i+'" align=absmiddle></A>';
	if (i<8) strMenus2 += '<IMG src="images/mnu_bar.gif" border=0 width=1 height=13 align=absmiddle hspace=2>'
}

var h;
switch (pageNo) {
	case 0: h=0;break;
	case 1: h=0;break;
	case 2: h=1;break;
	case 3: h=2;break;
	case 4: h=3;break;
	case 5: h=4;break;
	case 9: h=8;break;
	case 10: h=9;break;
	default : h=0;
}

var strHdr2Img = new String('<IMG src="'+arrHeaders[h]+'" border=0 width=372 height=56>');


//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;
}

/*
Validates the e-mail address from an input.
The parameter is the input object, in format: document.formName.inputName.
*/
function ValidateEmailAddress(objEmail) {
	var strEmail = Trim(objEmail.value);
	if (strEmail == ""){
		alert("Please fill in the E-mail field.");
		objEmail.focus();
		return false;
	} else {
		// checking "@" character:
		if (strEmail.indexOf("@")==-1) {
			alert("Error:\nE-mail field must contain @ character for an e-mail address.");
			objEmail.focus();
			return false;

		} else {
			// "@" cannot be the first character:
			if (strEmail.indexOf("@")==0) {
				alert("Error:\n@ cannot be the first character for an e-mail address.");
				objEmail.focus();
				return false;
			} else {
				// Caracterul "@" sa nu fie ultimul:
				if (strEmail.lastIndexOf("@") == strEmail.length-1) {
					alert("Error:\n@ cannot be the last character for an e-mail address.");
					objEmail.focus();
					return false;
				}
			}
			
			// "@" can appear only once:
			var emailSplited=strEmail.split("@");
			if (emailSplited.length>2) {
				alert("Error:\n@ can be appear only once for an e-mail address.");
				objEmail.focus();
				return false;
			}
			
			// "." must be present:
			if (strEmail.indexOf(".")==-1) {
				alert("Error:\nCharacter . must appear at least once for an e-mail address.");
				objEmail.focus();
				return false;
			} else {
				// "." cannot be the first character:
				if (strEmail.indexOf(".")==0) {
					alert("Error:\nCharacter . cannot be the first for an e-mail address.");
					objEmail.focus();
					return false;
				} else {
					// "." cannot be the last character:
					if (strEmail.lastIndexOf(".")==strEmail.length-1) {
						alert("Error:\nCharacter . cannot be the last for an e-mail address.");
						objEmail.focus();
						return false;
					}
				}
				
				// "." cannot appear one after another.
				if (strEmail.indexOf("..")>-1) {
					alert("Error:\nInvalid e-mail address.");
					objEmail.focus();
					return false;
				}
				
				// "@." or ".@" cannot appear:
				if ((strEmail.indexOf("@.")>-1) || (strEmail.indexOf(".@")>-1)) {
					alert("Error:\nInvalid e-mail address.");
					objEmail.focus();
					return false;
				}
				
				// Sa nu contina alte caractere decat litere (mari si mici), cifre, @ , . , - si _
				var carValide=new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_");
				var carEmail=new String("");
				for (var i=0; i<strEmail.length; i++) {
					carEmail = "" + strEmail.substring(i, i+1);
					if (carValide.indexOf(carEmail) == "-1") {
						alert("Error:\nInvalid e-mail address.\nPlease use only digits, letters,  _   .  -");
						objEmail.focus();
						return false;
					}
				}
			}
		}
	}
	return true;
}

var headerHeight = 168;
var footerHeight = 60;
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 - 312;
	} else if (ns){
		contHeight = window.innerHeight - headerHeight - footerHeight - 93 - nsFix;
	} else {
		contHeight = document.body.clientHeight - headerHeight - footerHeight;
	}
	document.write("<TABLE width=650 cellspacing=0 cellpadding=0 border=0 height=" + contHeight + ">");
}


function validateCheckOut(theForm){
// START: Credit Card checkings
	if (Trim(theForm.txtAdditional.value).length > 500) {
		alert("Additional Shipping Instructions field cannot have more than 500 characters");
		theForm.txtAdditional.focus();
		return false
	}
	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;
}

//-->