var link0 = new Image();
var link1 = new Image();
var link2 = new Image();
var link3 = new Image();
var link4 = new Image();
var link5 = new Image();
var link6 = new Image();
var link7 = new Image();
var link8 = new Image();
var link9 = new Image();
var link10 = new Image();
var link11 = new Image();
var link12 = new Image();
var link13 = new Image();

link0.src = "/images/menu/home.gif";
link1.src = "/images/menu/home_vis.gif";
link2.src = "/images/menu/products.gif";
link3.src = "/images/menu/products_vis.gif";
link4.src = "/images/menu/case_study.gif";
link5.src = "/images/menu/case_study_vis.gif";
link6.src = "/images/menu/faq.gif";
link7.src = "/images/menu/faq_vis.gif";
link8.src = "/images/menu/r_news.gif";
link9.src = "/images/menu/r_news_vis.gif";
link10.src = "/images/menu/downloads.gif";
link11.src = "/images/menu/downloads_vis.gif";
link12.src = "/images/menu/contact_us.gif";
link13.src = "/images/menu/contact_us_vis.gif";

function validateSearch(){
	root = document.search;
	if(root.keyword.value==''){
		alert('Please enter a search word.');
		root.keyword.focus();
		return false;
	}
	if(root.keyword.value.length<3){
		alert('Please enter a search word greater than 3 characters.');
		root.keyword.focus();
		return false;
	}
	return true;
}


function checkContactform(){
	var root=document.contactForm;

	var name=root.name;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(name.value==""){
		blinkBlink('name');
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		blinkBlink('country');
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		blinkBlink('phone');
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		blinkBlink('phone');
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}

	if(email.value==""){
		blinkBlink('email');
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if(department.value==""){
		blinkBlink('department');
		alert('Please select the department you wish to contact.');
		department.focus();
		return false;
	}
	if(subject.value==""){
		blinkBlink('subject');
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		blinkBlink('message');
		alert('Please enter your message.');
		message.focus();
		return false;
	}
	var vcode=root.vcode;
	if(vcode.value==""){
		blinkBlink('vcode');
		alert('Please enter the visual code.');
		vcode.focus();
		return false;
	}
}

function clearContactForm(){
	var root=document.contactForm;

	var name=root.name;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;
	var vcode=root.vcode;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		street.value="";
		city.value="";
		state.value="";
		country.value="";
		phone.value="";
		email.value="";
		department.value="";
		subject.value="";
		message.value="";
		vcode.value="";

		return false;
	}

	return false;
}

function blinkExecute(target,color){
	document.getElementById(target).style.backgroundColor = color;
}

function blinkBlink (target){
	color1 = "#7BB0F6"; // blinking color
	color2 = ""; // background color

	setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);
	document.getElementById(target).focus();
}


function toggle(obj) {
	// Moz. or IE
	var sibling=(obj.nextSibling.nodeType==3)? obj.nextSibling.nextSibling : obj.nextSibling;
	// hide or show
	if(sibling.style.display=='' || sibling.style.display=='block') {
		sibling.style.display='none';
		obj.firstChild.firstChild.data='+';
	}
	else {
		sibling.style.display='block';
		obj.firstChild.firstChild.data='-';
	}
}
//
function initCollapse() {

	var oDT=document.getElementById('version').getElementsByTagName('dt');
	for (var i=0; i < oDT.length; i++) {
		oDT[i].onclick=function() {toggle(this)};
		var oSpan=document.createElement('span');
		var sign=document.createTextNode('->');
		oSpan.appendChild(sign);
		oDT[i].insertBefore(oSpan, oDT[i].firstChild);
		oSpan.style.fontFamily='tahoma';
		oSpan.style.paddingRight='10px';
		oDT[i].style.cursor='pointer';
		toggle(oDT[i]);
	}
	oDT=null;
}

function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 200;
	defaultHeight = 200;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=0,top=0';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=0,top=0';
		var optIE='scrollbars=yes,width=150,height=100,left=0,top=0';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"></body></html>');
			close();
		}
}

function validateFaq(){
	var root=document.submit_faq;
	question1 = root.question.value;
	if(question1==''){
		alert('Please provide a question.');
		root.question.focus();
		return false;
	}
	return true;
}

function displaySnapshot(img){
	var we = window.open('', 'view_image', 'width=610,height=450,status=0,toolbar=0,scrollbars=1,resizable=0,history=0,left=50,top=50');
	we.document.write('<html><head><TITLE>'+img+'</TITLE></HEAD><BODY onblur="self.close()"><img src="/products/snapshots/'+img+'"></BODY></html>');
	return false;
}

function displaySnapshot1(img){
	var we = window.open('', 'view_image', 'width=1000,height=600,status=0,toolbar=0,scrollbars=1,resizable=1,history=0,left=50,top=50');
	we.document.write('<html><head><TITLE>'+img+'</TITLE></HEAD><BODY onblur="self.close()"><img src="'+img+'"></BODY></html>');
	return false;
}