var i=1;
var j=1;
var height4='599px';
var theURL='home2.html';
var intHide=null;
var intShow=null;
var intHide2;
var intShow2;
var speed=4;
function showmenu()
{
document.getElementById('menu').style.display='block';
//var x=document.getElementById('menu');
clearInterval(intHide);
intShow=setInterval("show()",10);

}
function hidemenu()
{

clearInterval(intShow);
intHide=setInterval("hide()",10);

}
function showmenu2(name)
{
document.getElementById(name).style.visibility='visible';
document.getElementById('menu').style.overflow='visible';
//var x=document.getElementById('child_menu2');
//clearInterval(intHide2);
//intShow2=setInterval("show2('child_menu2','5')",10);

}
function hidemenu2(name)
{
document.getElementById(name).style.visibility='hidden';
document.getElementById('menu').style.overflow='hidden';
//clearInterval(intShow2);
//intHide2=setInterval("hide2('child_menu2')",10);

}
function show()
{
if (i<65)
	{
	i=i+speed;
	document.getElementById('menu').style.height=i;
	}
}
function hide()
{
if (i>1)
	{
	i=i-speed;
	document.getElementById('menu').style.height=i;
	}
	if(i<2)
	{document.getElementById('menu').style.display='none';}
		
}
function show2(name,size)
{
if (j<size)
	{
	j=j+speed;
	document.getElementById(name).style.height=i;
	}
}
function hide2(name)
{
if (j>1)
	{
	j=j-speed;
	document.getElementById(name).style.height=i;
	}
	if(j<2)
	{document.getElementById(name).style.display='none';}
		
}
var pri='menu0';
function change(cur)
{	
	
	if(pri!='null'){
	document.getElementById(pri+'_l').className='top_nav_l';
	document.getElementById(pri+'_c').className='top_nav_c';
	document.getElementById(pri+'_r').className='top_nav_r';
	}
	document.getElementById(cur+'_l').className='top_nav_l_sel';
	document.getElementById(cur+'_c').className='top_nav_c_sel';
	document.getElementById(cur+'_r').className='top_nav_r_sel';
	
	pri=cur;
	if(screen.availHeight<=1000)
{
	document.getElementById('staticbuttons').style.display="block";
}
else
{
	document.getElementById('staticbuttons').style.display="none";
}
}

function check()
{

			if(document.body.scrollTop>50)
		{
			document.getElementById('staticbuttons').style.display="block";
		}
		else
		{
			document.getElementById('staticbuttons').style.display="none";
		}
		setTimeout('check()', 200);
}
function change2(cur)
{	
	document.getElementById(cur+'_l').className='top_nav_l_sel';
	document.getElementById(cur+'_c').className='top_nav_c_sel';
	document.getElementById(cur+'_r').className='top_nav_r_sel';
}
function change3(cur)
{
/*{	if(cur==pri){
	document.getElementById(cur+'_l').className='top_nav_l_sel';
	document.getElementById(cur+'_c').className='top_nav_c_sel';
	document.getElementById(cur+'_r').className='top_nav_r_sel';
	}
	else{*/
	document.getElementById(cur+'_l').className='top_nav_l';
	document.getElementById(cur+'_c').className='top_nav_c';
	document.getElementById(cur+'_r').className='top_nav_r';
//	}
}

function open_window(theURL,location,height2) { 
  document.getElementById(location).src=theURL;
  document.getElementById('main_table').style.height=height2;
  height4=height2;
  checkCookie();
}



function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function checkCookie()
{
tab=getCookie('tab');

if (tab!=null && tab!="")
  {
  document.getElementById('main_table').style.height=height4;
  }
else 
  {
  //username=prompt('Please enter your name:',"");
  tab=height4;
  if (tab!=null && tab!="")
    {
    setCookie('tab',height4,1);
	document.getElementById('main_table').style.height=height4;
	document.getElementById(location).src=theURL;
    }
  }
}


function  submitForm()
			{
			var message
			message=""
			
			if (document.frmContactus.name.value == "")
				{
				message=message + "Please enter  name \n"
				}	
				
				
				
			Email=document.frmContactus.EMail.value
			
			
			
			if(Email=="")
				{
					message=message + "Please enter Email\n";
				}
				else
				{
					
					VarEmail=validateEmail(Email)
					
					if (VarEmail==false)
						{
							alert("Please enter a valid email.");
							return false;
						}
				}
				
				if (message != "")
			{
				alert(message)
				
				return false;
			}
			else
			{
				
				return true;
			}
				 
			}


/* function to validate numeric phone number  */

function chkNumeric(mytext)
{
		
	if (isNaN(mytext.value))
	{
		alert('Please enter numeric value');
		mytext.value = "";
		mytext.focus()
		
	}
	
}

/* To validate Email function*/



function validateEmail(emailstr)
{
	var message
	message = ""

	if(emailstr != "")
	{
		var emailid
		var posat
		var posat2
		var posdot
		var posspace
		var poshyphen
			
		var list = "0123456789abcdefghijklmnopqrstuvwxyz._ABCDEFGHIJKLMNOPQRSTUVWXYZ@-" ;
		var listalpha = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
		var listbeta = "@_." ;
		var nameCheck = true;
				
		emailid =document.frmContactus.email.value;
			
		for (var i = 0; i < emailid.length; i++)
		{
			
			if (list.indexOf(emailid.charAt(i)) == -1 || listalpha.indexOf(emailid.charAt(0)) == -1 )
		    {
		       	nameCheck = false;	
		       	document.frmContactus.email.value="";
				document.frmContactus.email.focus();											
				return false;       
		    }
			       	
		}  	// end of for loop	
			
		if (nameCheck != false)
		{
			posat = emailid.indexOf("@")
			posdot = emailid.indexOf(".")
			posunder = emailid.indexOf("_")
			posat2 = emailid.indexOf("@",posat+1)
			poshyphen=emailid.indexOf("-")
			posspace = emailid.indexOf(" ")
			poshyphen1=emailid
			poshyphen2=poshyphen1.indexOf("-")
			
			// joy added validation for hyphen
			while (poshyphen2!=-1)
			{
			posat1=poshyphen1.indexOf("@")
			posdot1=poshyphen1.indexOf(".")
			posunder1=poshyphen1.indexOf("_")
			if (poshyphen2==0 || posat1==0 || posdot1==0 || posunder1==0 || poshyphen2+1==posat1 || poshyphen2+1==posdot1 || poshyphen2+1==posunder1 || posat1+1==poshyphen2 || posdot1+1==poshyphen2 || posunder1+1==poshyphen1)
			{
				document.frmContactus.email.value="";
				document.frmContactus.email.focus();		
				return false;
				break;
			}
			poshyphen1=poshyphen1.substr(poshyphen2+1)
			poshyphen2=poshyphen1.indexOf("-")
			if (poshyphen2==-1)
				break;
			}
			
			// seperate validation for hyphen ends here
			// other validations for hyphen included by joy in the existing codes.			
			if ((posat <= 0) || (posdot <= 0) || (posat+1==posdot) ||(posat+1==poshyphen) || (posdot+1==poshyphen) || (poshyphen+1==posat) || (poshyphen+1==posdot) || (posat+1==posunder) || (posat2!=-1 ) || (posdot==emailid.length-1) || (poshyphen==emailid.length-1) || (posspace > 0))
			{
			   document.frmContactus.email.value="";
			   document.frmContactus.email.focus();		
			   return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return false;
		}					
						  			 			    		    
	}

}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
