// JavaScript Document

function validate(){
var usrid=document.form1.fname.value; //txtUserid-->ID of textbox
var alphanum=/^[a-zA-Z]+$/; //This contains A to Z , 0 to 9 and A to B
if(usrid.match(alphanum)){
return true;
}else{

return false;
}
}

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
		}

		 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 registration()
{
if(document.form1.citation.value=='')
{
alert("Please Enter Citation");
return false;
}
if(document.form1.fname.value=='')
{
alert("Please enter your first name.");
return false;
}
if(validate()==false)
{
alert('Enter Valid Name');
document.form1.fname.value="";
document.form1.fname.focus();
return false;
}
if(document.form1.lname.value=='')
{
alert("Please enter your last name");
return false;
}
if(document.form1.user_id.value=='')
{
alert("Please enter your Email");
return false;
}
if (echeck(document.form1.user_id.value)==false){
		document.form1.user_id.value=""
		document.form1.user_id.focus()
		return false
	}
if(document.form1.password.value=='')
{
alert("Please enter your password");
return false;
}
if(document.form1.compass.value=='')
{
alert("please enter confirm password");
return false;
}
if(document.form1.password.value!=document.form1.compass.value)
{
alert("Password and confirm password not same");
return false;
}
if((document.form1.dobdate.value=='') || (document.form1.dobmonth.value=='') || (document.form1.dobyear.value==''))
{
alert("Please enter date of Birth");
return false;
}

if(document.form1.country.value=='')
{
alert("please select country");
return false;
}
if(document.form1.varicode.value=="")
{
alert("Please Enter Varification Code");
return false;
}

if(document.form1.varicode.value!=document.getElementById("captch").innerHTML)
{
alert("Varification code not valid");
return false;
}
return true;
}

function wirte_biography()
{



if(document.frm.title.value=='')
{
alert("Please enter title of biography");
document.frm.title.focus();
return false;
}
if(document.frm.level.checked==false)
{
alert("Please select level");
return false;
}

if(document.getElementsById('sdesc').value=="")
{
alert("Please Enter description");
return false;
}

return true;

}

function checkpass()
{
if(document.getElementById('oldpass').value=="")
{
alert("Please enter old password");
return false;

}
if(document.getElementById('newpass').value=="")
{
alert("Please enter new password");
return false;

}
if(document.getElementById('confirmpass').value=="")
{
alert("Please enter confirm password");
return false;

}
if(document.getElementById('oldpass').value!=document.getElementById('old').value)
{
alert("Old password is wrong");
return false;
}
if(document.getElementById('newpass').value!=document.getElementById('confirmpass').value)
{
alert("New password and Confirm pasword doesn't Match");
return false;
}
return true;
}


function chkcheked(){	
	var count,c,c1;
	var frm=document.form1;
	count=frm.elements.length;
	c=0;
	c2=0;

	for (i=0; i < count ; i++){
		if(frm.elements[i].name == 'chk[]'){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(document.getElementById('selectbio').value=="")
	{
	alert("Please select one biography");
	return false;
	}
	if(c==0)
	{
	alert("select at least one friend");
	return false;
	
	}
return true;
}
function keyworkchk()
{
if(document.getElementById('keyword').value=="")
{
alert("Please enter keyword");
return false;
}
return true;
}
function commchk()
{
if(document.getElementById('comment').value=="")
{
alert("Please enter comments");
return false;
}
if(document.getElementById('radio').value=="")
{
alert("Please choose suggetion or comment");
return false;
}
return true;
}
function search_frnd()
{
if(document.getElementById('keyword').value=="")
{
alert("Please enter name");
return false;
}
return true;
}

function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}
function forgot()
{
if(document.main.uname.value=='')
{
alert("Enter user name");
document.main.uname.focus();
return false;
}

if(document.main.mailid.value=='')
{
alert("Enter mailid id");
document.main.mailid.focus();
return false;
}
if(document.main.confirmid.value=='')
{
alert("Enter confrim mail id");
document.main.confirmid.focus();
return false;
}
if((document.main.confirmid.value)!=(document.main.mailid.value))
{
alert("mailid and confirm mail doesn't match");
return false;
}
if((document.main.dobdate.value=='') || (document.main.dobmonth.value=='') || (document.main.dobyear.value==''))
{
alert("Enter date properly");
return false;
}
}
function loginvalidate()
{
if(document.main.username.value=='')
{
alert("Enter username");
document.main.username.focus();
return false;
}
if(document.main.password.value=='')
{
alert("Enter password");
document.main.password.focus();
return false;
}
return true;
}
function setpass()
{
var pwd;

pwd=document.main.cookpassword.value;

document.main.password.value=pwd;
}
