var seen =0;
//////////////////////////////////////
function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

/////////////////////////////////////////////
////////////////Contact Us///////////////////
function contactUsCheck()
{
	var root=document.contact;
	var name = root.name;
	var email = root.email;
	var address = root.address;
	var comment = root.comment;
	if(name.value == '')
	{
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value == '')
	{
		alert('Please enter your email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2)
	{
		alert("Please enter a valid email address.");
		email.select();
		return false;
	}
	if(address.value == '')
	{
		alert('Please enter your address.');
		address.focus();
		return false;
	}
	if(comment.value == '')
	{
		alert('Please enter your comment.');
		comment.focus();
		return false;
	}
	if(vcode.value == '')
	{
		alert('Please enter the visual code.');
		vcode.focus();
		return false;
	}
	return true;
}
function clearContactUsForm()
{
	var root=document.contact;
	if(confirm('Are you sure you want to clear all the form ?')){
		root.name.value='';
		root.email.value='';
		root.address.value='';
		root.comment.value='';
		root.vcode.value='';
		return false;
	}return false;
}

///////////////////NewsLetter////////
function validateNewsletter(){
	var root= document.newsletter_form;
	if(root.name.value==''){
		root.name.focus();
		alert('Please enter your full name');
		return false;
	}
	if(root.email.value==''){
		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;
}
//////////////////////////////////////

///popImage///
function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 100;
	defaultHeight = 100;
	//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();
		}
}

///////////////////// Events ///////////////////
function validateAlertMe(root){
	var combo = root.name.split("_");
	var check = "alertme"+combo[1];
	var email = "email"+combo[1];
	var c = document.getElementById(check);
	var e = document.getElementById(email);
	
	if(c.checked == false){
		alert("Please check the box below the item you want");
		c.focus();
		return false;
	}
	if(e.value==''){
		alert("Please enter your email address");
		e.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=e.value.match(pattern);
	if(!flag){
		alert('please insert a valid email address');
		e.focus();
		return false;
	}

	//return false;
	return true;
}
////////////////////////////////////////////////
/////////////SERGE ////////////////////////////
/////////////////////////////////////
//////////// TELL A FRIEND //////////
//////////////////////////////////////
function validateTellAFriend(e){
	var root = document.tell_a_friend;
	var name = root.name.value;
	if (name==''){
		alert('Please fill up your name.');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		alert('Please fill up your email address.');
		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;
	}
	var count=0;
	for(var i=0;i<e;i++){
		var f_name= eval('root.f_name'+i+'.value');
		var f_email= eval('root.f_email'+i+'.value');
		if(f_name==''&&f_email==''){
			count++;
		}
		if(f_name==''&&f_email!=''){
			alert('Please fill up your friends name.');
			eval('root.f_name'+i+'.focus()');
			return false;
		}
		if(f_name!=''&&f_email==''){
			alert('Please fill up your friends email.');
			eval('root.f_email'+i+'.focus()');
			return false;
		}
		var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(f_name!=''){
			flag=f_email.match(pattern);
			if(!flag){
				alert('Please insert a valid email address.');
				eval('root.f_email'+i+'.select()');
				return false;
			}
		}
	}
	if(count==e){
		alert('Please provide at least one friend email.');
		root.f_name0.focus();
		return false;
	}
	var vcode = root.vcode.value;
	if (vcode==''){
		alert('Please provide the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}

function clearTellaFriend(e){
	var con=confirm('Are you sure you want to clear all the form ?');
	if(con){
		var root = document.tell_a_friend;
		root.name.value='';
		root.email.value='';
		root.message.value='';
		root.vcode.value='';
		for(var i=0;i<e;i++){
			var f_name= eval('root.f_name'+i+'');
			var f_email= eval('root.f_email'+i+'');
			f_name.value='';
			f_email.value='';
		}
	}else{
		return false;
	}
}
/////////////////////////////////////
function validateGuestbook(){
	var root = document.testimonial;
	if(root.name.value==''){
		alert("Please enter your name");
		root.name.focus();
		return false;
	}
	if(root.email.value==''){
		alert("Please enter your email");
		root.email.focus();
		return false;
	}
	if(root.country_id.value==''){
		alert("Please enter your country");
		root.country_id.focus();
		return false;
	}
	if(root.message.value==''){
		alert("Please enter your message");
		root.message.focus();
		return false;
	}
	if(root.vcode.value==''){
		alert("Please enter the visual code below");
		root.vcode.focus();
		return false;
	}
}

