// JavaScript Document
//created by purab kharat(www.eparinay.com)

function echeck(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
		}

		 //Commented to accept multiple emails.
		 //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 chkRegisterForm()
{
	//if(doValidate())
	//{
		//alert("Please select atleast one user type!");
		//return false;
	//}
	
	if(document.reg.name.value == "" )
	{
		alert("Please enter your name!");
		document.reg.name.focus();
		return false;
	}
	if(document.reg.surname.value == "" )
	{
		alert("Please enter your Surname!");
		document.reg.surname.focus();
		return false;
	}
	if(document.reg.father_name.value == "" )
	{
		alert("Please enter your Father Name!");
		document.reg.father_name.focus();
		return false;
	}
	if(document.reg.father_info.value.length < 30)
	{
		alert("Father information should be atleast 30 characters!");
		document.reg.father_info.focus();
		return false;
	}
	if(document.reg.address.value.length < 20)
	{
		alert("Address should be atleast 20 characters!");
		document.reg.address.focus();
		return false;
	}
	if(document.reg.Date_of_Birth.value == "" )
	{
		alert("Please enter your birth date!");
		document.reg.Date_of_Birth.focus();
		return false;
	}
	if(document.reg.email.value == "" )
	{
		alert("Please enter your email address!");
		document.reg.email.focus();
		return false;
	}
	if(!echeck(document.reg.email.value))
	{
		document.reg.email.focus();
		return false;
	}
	if(document.reg.password1.value == "" )
	{
		alert("Please enter your password!");
		document.reg.password1.focus();
		return false;
	}
	if(document.reg.password1.value.length < 6)
	{
		alert("Password length should be atleast 6 characters!");
		document.reg.password1.focus();
		return false;
	}
	if(document.reg.tel.value == "" )
	{
		alert("Please enter your Telephone!");
		document.reg.tel.focus();
		return false;
	}
	if(document.reg.income.value == "" )
	{
		alert("Please enter your Income!");
		document.reg.income.focus();
		return false;
	}
	if(document.reg.marital_status.value == "" )
	{
		alert("Please Select your Marital Status!");
		document.reg.marital_status.focus();
		return false;
	}
	if(document.reg.aboutfamily.value.length < 50)
	{
		alert("About Family should be atleast 50 characters!");
		document.reg.aboutfamily.focus();
		return false;
	}
	if(document.reg.expectation.value.length < 50)
	{
		alert("Expectation length should be atleast 50 characters!");
		document.reg.expectation.focus();
		return false;
	}
	
	
	//if(document.reg.Address.value.length < 6 )
	//{
		//alert("Address length should be minimum 6 characters!");
		//document.reg.Address.focus();
		//return false;
	//}
	
	
	
		//if(document.reg.friend_email.value == "" )
		//{
		//	alert("Please enter your friend's email address!");
		//	document.reg.friend_email.focus();
		//	return false;
		//}
		//if(!echeck(document.reg.friend_email.value))
		//{
		//	document.reg.friend_email.focus();
		//	return false;
		//}

	return true;
}

<!--
// Validation for non empty fields and correct input values
function chklogin()
{
	if(document.login.username.value == "" )
	{
		alert("Please enter your email address!");
		document.login.username.focus();
		return false;
	}
	if(!echeck(document.login.username.value))
	{
		document.login.username.focus();
		return false;
	}

	if(document.login.password.value=="")
	{
		alert("Please enter your password!");
		document.login.password.focus();
		return false;
	}

	if(document.login.password.value.length < 6)
	{
		alert("Password length should be minimum 6 characters!");
		document.login.password.focus();
		return false;
	}

return true;
}
//-->
function modiPass()
{

if(document.ckpass.password.value=="")
	{
		alert("Please enter your Old password!");
		document.ckpass.password.focus();
		return false;
	}

	if(document.ckpass.password.value.length < 6)
	{
		alert("Password length should be minimum 6 characters!");
		document.ckpass.password.focus();
		return false;
	}
if(document.ckpass.new_pass.value=="")
	{
		alert("Please enter your New password!");
		document.ckpass.new_pass.focus();
		return false;
	}

	if(document.ckpass.new_pass.value.length < 6)
	{
		alert("New Password length should be minimum 6 characters!");
		document.ckpass.new_pass.focus();
		return false;
	}	
if(document.ckpass.new_pass1.value=="")
	{
		alert("Please enter your new password!");
		document.ckpass.new_pass1.focus();
		return false;
	}

	if(document.ckpass.new_pass1.value.length < 6)
	{
		alert("New Password length should be minimum 6 characters!");
		document.ckpass.new_pass1.focus();
		return false;
	}	
return true;	
	
}
function validateRequest()
{
	with(document.frmRequest)
	{
		if(name.value.length < 1){
		alert("Please enter your name!");
		name.focus();
		return false;
		}
		if(email.value == "" )
		{
		alert("Please enter your email address!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		//if(company_name.value.length < 1){
		//alert("Please enter your company name!");
		//company_name.focus();
		//return false;
		//}
		if(city.value.length < 1){
		alert("Please enter your city!");
		city.focus();
		return false;
		}
		//if(telephone_number.value.length < 1){
		//alert("Please enter your telephone number!");
		//telephone_number.focus();
		//return false;
		//}
		if(feedback.value.length < 1){
		alert("Please enter your feedback!");
		feedback.focus();
		return false;
		}
	}
	return true;
}

function chkqck()
{
	if(document.quickreg.name.value == "" )
	{
		alert("Please enter your name!");
		document.quickreg.name.focus();
		return false;
	}
	if(document.quickreg.tel.value == "" )
	{
		alert("Please enter Telephone No.");
		document.quickreg.tel.focus();
		return false;
	}
	if(document.quickreg.address.value == "" )
	{
		alert("Please enter your Address!");
		document.quickreg.address.focus();
		return false;
	}
	if(document.quickreg.email.value == "" )
	{
		alert("Please enter your email Address!");
		document.quickreg.email.focus();
		return false;
	}
	if(!echeck(document.quickreg.email.value))
	{
		document.quickreg.email.focus();
		return false;
	}
	if(document.quickreg.password1.value == "" )
	{
		alert("Please enter your Password");
		document.password1.email.focus();
		return false;
	}
	if(document.quickreg.Date_of_Birth.value == "" )
	{
		alert("Please Select your Date of Birth");
		document.quickreg.Date_of_Birth.focus();
		return false;
	}
	if(document.quickreg.aboutfamily.value == "" )
	{
		alert("Please enter your email Address!");
		document.quickreg.aboutfamily.focus();
		return false;
	}
	if(document.quickreg.expectation.value == "" )
	{
		alert("Please enter your Partner Expectation");
		document.quickreg.expectation.focus();
		return false;
	}
	
	

return true;
}
	
function popup(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}

/* Menu javascript starts here */

var mastertabvar=new Object()
mastertabvar.baseopacity=0
mastertabvar.browserdetect=""

function showsubmenu(masterid, id){
if (typeof highlighting!="undefined")
clearInterval(highlighting)
submenuobject=document.getElementById(id)
mastertabvar.browserdetect=submenuobject.filters? "ie" : typeof submenuobject.style.MozOpacity=="string"? "mozilla" : ""
hidesubmenus(mastertabvar[masterid])
submenuobject.style.display="block"
instantset(mastertabvar.baseopacity)
highlighting=setInterval("gradualfade(submenuobject)",50)
}

function hidesubmenus(submenuarray){
for (var i=0; i<submenuarray.length; i++)
document.getElementById(submenuarray[i]).style.display="none"
}

function instantset(degree){
if (mastertabvar.browserdetect=="mozilla")
submenuobject.style.MozOpacity=degree/100
else if (mastertabvar.browserdetect=="ie")
submenuobject.filters.alpha.opacity=degree
}


function gradualfade(cur2){
if (mastertabvar.browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (mastertabvar.browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (typeof highlighting!="undefined") //fading animation over
clearInterval(highlighting)
}

function initalizetab(tabid){
mastertabvar[tabid]=new Array()
var menuitems=document.getElementById(tabid).getElementsByTagName("div")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
menuitems[i].setAttribute("rev", tabid) //associate this submenu with main tab
mastertabvar[tabid][mastertabvar[tabid].length]=menuitems[i].getAttribute("rel") //store ids of submenus of tab menu
if (menuitems[i].className=="selected")
showsubmenu(tabid, menuitems[i].getAttribute("rel"))
menuitems[i].getElementsByTagName("a")[0].onmouseover=function(){
showsubmenu(this.parentNode.getAttribute("rev"), this.parentNode.getAttribute("rel"))
}
}
}
}
/* menu javascript ends here */

/* password check
function thesame(value1, value2)

{

  if (((value1 != null) || (value1 != ""))

       && value2 != "" && value1 != value2)

  {

       alert("The passwords must be identical.");
		document.ckpass.new_pass1.focus();
       return (false);

  }

  return (true);
  */
