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

function validateAlert(formName){
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = eval("document."+formName+".email.value;");
	flag=email.match(pattern);
	if(!flag){
		alert('please insert a valid email address');
		eval("document."+formName+".email.focus();");
		return false;
	}
}


function alertMe(text,formName){
	if(eval("document."+formName+".email.value == '"+text+"';")){
		eval("document."+formName+".email.value = '';");
	}
}

function validatemailinglist(NAME,EMAIL){
	var root= document.newsletter;
	if(root.name.value==NAME){
		root.name.focus();
		alert('Please enter your full name');
		return false;
	}
	if(root.email.value==EMAIL){
		root.email.focus();
		alert('Please enter your email address');
		return false;
	}
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email.value;
	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address');
		root.email.select();
		return false;
	}
	return true;
}

function validateWebmail(){
	var root = document.implogin;
	var imapuser = root.imapuser.value;
	var pass = root.pass.value;
	if (imapuser == ''){
		alert('Please give your username.');
		root.imapuser.focus();
		return false;
	}
	if (pass == ''){
		alert('Please give your password.');
		root.pass.focus();
		return false;
	}
	return true;
}

function validateLogin(){
	var root = document.members;
	
	var username = root.username.value;
	var password = root.password.value;
	if (username == '' || username == 'username'){
		alert('Please give your username.');
		root.username.focus();
		return false;
	}
	if (password == '' || password== 'password'){
		alert('Please give your password.');
		root.password.focus();
		return false;
	}
	password = hex_md5(password);
	root.password.value = password;
	root.hashed.value = 'yes';
	return true;
}

function submitNewsletter(){
	var root = document.newsletter;
	
	var name = root.name.value;
	var email = root.email.value;
	
	if (name == ''){
		alert('Please give your name');
		root.name.focus();
		return false;
	}
	if (email == ''){
		alert('Please give your email');
		root.email.focus();
		return false;
	}
	return true;
}

function changeVisibility(){
	var vis = document.getElementById('logform').style.visibility;
	if(vis=='hidden'){
		document.getElementById('logform').style.visibility='visible';
	}else{
		document.getElementById('logform').style.visibility='hidden';
	}
}

function validateContact(lang){
	var root = document.contactus;
	
	var name = root.name.value;
	if(name == ''){
		alert("Please insert your name");
		root.name.focus();
		return false;
	}
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var email = root.email.value;
	flag=email.match(pattern);
	if(!flag){
		alert('please insert a valid email address');
		root.email.focus();
		return false;
	}
	var subject = root.subject.value;
	if(subject == ''){
		alert("Please insert your subject");
		root.subject.focus();
		return false;
	}
	var message = root.message.value;
	if(message == ''){
		alert("Please insert your message");
		root.message.focus();
		return false;
	}
		var visualCode = root.vcode.value;
	if(visualCode == ''){
		alert("Please Insert visual code from the green picture");
		root.vcode.focus();
		return false;
	}
}

function hoverOn(imName) {
	eval("document." + imName + ".src = " + imName + "OnImage.src");
}

function hoverOff(imName) {
	eval("document." + imName + ".src = " + imName + "OffImage.src");
}

var urlArray = new Array; //for URL's, increase size as necessary
var banArray = new Array; //for banners, increase size as necessary
var typeArray = new Array; //for banners types, internal or external
var counter = 0;
var count = 0;


//document.getElementById('bannerTd').style.

function changeBanner() //banner changer function
{
	//alert(counter);
  if(counter >= count){
   counter = 0;
  }
  temp = new Image();
  temp.src = banArray[counter].src;
  document.getElementById('bannerTd').style.background = 'url('+temp.src+')'; //sets a new banner
  if(urlArray[counter]!=''){
  	document.getElementById('bannerHref').href = 'http://'+urlArray[counter]; //sets a new link
  	document.getElementById('bannerHref').target = '_blank'; //sets a new link
  }else{
  	document.getElementById('bannerHref').href = 'javascript:return false;'; //sets a new link
  	document.getElementById('bannerHref').target = '_self'; //sets a new link
  }
  counter++; //increase the counter for the next banner
}

function reheader(url){
	var counter1 = counter;
	counter1--;
	window.open(urlArray[counter1]);
	//location.href = urlArray[counter1];
}

//calls the changeBanner() function every 10 seconds
//change the timer as necessary (minutes * 60000) or (seconds * 1000)
var timer = window.setInterval("changeBanner()", 10000);

function submitNewsletter(){
	var root = document.newsletter;
	
	var name = root.name.value;
	var email = root.email.value;
	
	if (name == ''){
		alert('Please give your name');
		root.name.focus();
		return false;
	}
	if (email == ''){
		alert('Please give your email');
		root.email.focus();
		return false;
	}
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}	
	return true;
}


function sh(cat_id){
		document.getElementById(cat_id).style.visibility='hidden';
}


function shv(cat_id){
	document.getElementById(cat_id).style.visibility='visible';
}


function emptyForm(name){
	var con =confirm('Are you sure you want to clear this form ?');
	if(con){ 
	var formElements = eval('document.'+name+'.elements');
	for(i=0;i<formElements.length;i++){
		formElements[i].value="";
	}
	return true;
	}
}

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

	var name=root.name;
	var email=root.email;
	var country=root.country;
	var subject=root.subject;
	var message=root.message;
	var vcode=root.vcode;

	if(name.value==""){
		blinkBlink('name');
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==""){
		blinkBlink('email');
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		blinkBlink('email');
		email.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;
	}
		if(vcode.value==""){
		blinkBlink('vcode');
		alert('Please enter the visual code.');
		vcode.focus();
		return false;
	}
}


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

function blinkBlink (target){
	color1 = "#4ABA4A"; // 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 popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 500;
	defaultHeight = 500;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	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=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//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 validateLogin(){
	var root = document.members;
	
	var username = root.username.value;
	var password = root.password.value;
	if (username == ''){
		alert('Please give your username.');
		root.username.focus();
		return false;
	}
	if (password == ''){
		alert('Please give your password.');
		root.password.focus();
		return false;
	}
	password = hex_md5(password);
	root.password.value = password;
	root.hashed.value = 'yes';
	return true;
}

function passValidation(){
	var root = document.change_password;
	var oldp = root.old.value;
	var newp = root.newp.value;
	var confnew = root.confnew.value;
	
	if (oldp == '' || newp == '' || confnew == ''){
		alert('Please fill up all the fields');
		root.old.focus();
		return false;
	}
	if (!isNaN(newp)){
		alert('Please insert a password that contains characters.');
		root.newp.focus();
		return false;
	}
	
	if (newp != confnew){
		alert('The password and it\'s confirmation do not match');
		root.confnew.focus();
		return false;
	}
	
	oldp = hex_md5(oldp);
	newp = hex_md5(newp);
	confnew = hex_md5(confnew);
	
	root.old.value = oldp;
	root.newp.value = newp;
	root.confnew.value = confnew;
	root.enc.value = '1';
	
	return true;
}