<!--
// browser detection
// browser detection:
var ua = navigator.userAgent;
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns4 = (document.layers)?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;
var moz = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)?1:0;

if (ns) document.write('<LINK rel=stylesheet type="text/css" href="optimal_ns.css">');
else document.write('<LINK rel=stylesheet type="text/css" href="optimal.css">');
if (moz) document.write('<LINK rel=stylesheet type="text/css" href="optimal.css">');
if (ns6) document.write('<LINK rel=stylesheet type="text/css" href="optimal.css">');

var allLImagesOn = new Array(
"images/btn00_on.gif",
"images/btn01_on.gif",
"images/btn02_on.gif",
"images/btn03_on.gif",
"images/btn04_on.gif",
"images/btn05_on.gif",
"images/btn07_on.gif",
"images/btn06_on.gif",
"images/btn08_on.gif",
"images/btn09_on.gif",
"images/btn10_on.gif",
"images/btn11_on.gif",
"images/btn12_on.gif",
"images/btn13_on.gif",
"images/btn14_on.gif",
"images/btn15_on.gif",
"images/btn16_on.gif",
"images/btn17_on.gif",
"images/btn18_on.gif",
"images/btn19_on.gif",
"images/btn20_on.gif",
"images/btn21_on.gif",
"images/btn22_on.gif",
"images/btn24_on.gif",
"images/btn23_on.gif"

);

var allLImagesOff = new Array(
"images/btn00.gif",
"images/btn01.gif",
"images/btn02.gif",
"images/btn03.gif",
"images/btn04.gif",
"images/btn05.gif",
"images/btn07.gif",
"images/btn06.gif",
"images/btn08.gif",
"images/btn09.gif",
"images/btn10.gif",
"images/btn11.gif",
"images/btn12.gif",
"images/btn13.gif",
"images/btn14.gif",
"images/btn15.gif",
"images/btn16.gif",
"images/btn17.gif",
"images/btn18.gif",
"images/btn19.gif",
"images/btn20.gif",
"images/btn21.gif",
"images/btn22.gif",
"images/btn24.gif",
"images/btn23.gif"
);

var allLinks = new Array(
"home.shtml",
"capability.shtml",
"about.shtml",
"control_systems.shtml",
"software.shtml",
"analysis.shtml",
"pat.shtml",
"synTQ.shtml",
"cfr.shtml",
"nir.shtml",
"vision_systems.shtml",
"plc_software.shtml",
"scada.shtml",
"integration.shtml",
"build.shtml",
"validation.shtml",
"documentation.shtml",
"support.shtml",
"quality_control.shtml",
"gamp.shtml",
"mes.shtml",
"monitoring.shtml",
"mailto:enquiries@optimal-ltd.co.uk",
"updates.shtml",
"training.shtml"
);

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 strMenus = new String("");
var strMenus_ = new String("");

for (var i=0;i<allLImagesOn.length;i++){
	if (i==7)strMenus += "<IMG src='images/spacer.gif' width=1 height=21 border=0><BR>"
	else
	{
		if (pageNo==i) strMenus += '<IMG src="'+ObjLImg_on[i].src+'" border=0><BR>';
		else strMenus += '<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><BR>';
	}
}

//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 + ">");
}



//-->