// JavaScript Document

/******************** validation **********************/

function validate_contactus(frm){

	if(frm.name.value==0){  
			alert('Please enter name'); 
			frm.name.focus();
			return false;
	}
	if(frm.company.value==0){  
			alert('Please enter company'); 
			frm.company.focus();
			return false;
	}
	if(frm.address.value==0){  
			alert('Please enter address'); 
			frm.address.focus();
			return false;
	}
	
	if(frm.email.value==0){  
		alert('Please enter email'); 
		frm.email.focus();
		return false;
	}else{
		if(!emailCheck(frm.email.value)){
			frm.email.focus()
			alert("Please enter a valid email");
			return false; 
		}
	}
	if(frm.name.subject==0){  
			alert('Please enter subject'); 
			frm.subject.focus();
			return false;
	}
	if(frm.msg.value==0){  
			alert('Please enter message'); 
			frm.msg.focus();
			return false;
	}
}
function emailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function menu(id, name, sel){
	if(sel==1){
		id.src='images/menu_'+name+'_norm.gif'
		//alert("images/menu_"+name+"_norm.gif")
	}else{
		id.src='images/menu_'+name+'_sel.gif'
	}
}

function show_div(id, hover){
	if (hover=='1'){
		document.getElementById(id).style.display="inline";
	}else{
		document.getElementById(id).style.display="none";
	}
}
function tab_sel(id, other, position){
	if(position=='left'){
		document.getElementById(id).className='select';
		document.getElementById(other).className='normal';
		document.left.src='images/tab_left_sel.gif';
		document.mid.src='images/tab_mid_normal.gif';
		document.right.src='images/tab_right_normal.gif';
	}else{
		document.getElementById(id).className='select';
		document.getElementById(other).className='normal';
		document.left.src='images/tab_left_normal.gif';
		document.mid.src='images/tab_mid_sel.gif';
		document.right.src='images/tab_right_sel.gif';
	}
	
}

function OpenWindow(url) {
		var x = window.open(url, "address", "width=410, height=500, menubar=no, scrollbars=1, resizable=0, toolbar=0");
	}

