function valid_register()
{
	var invalid = " "; // Invalid character is a space
	var minLength = 5; // Password Minimum length

	var name = document.getElementById("txtName").value;
	var email = document.getElementById("txtEmail").value;
	var pass = document.getElementById("txtPass").value;
	var error = "";

	if(name=="")	error+="Please enter your name.\n"; 
	if(email==""){
		error+="Please enter your email.\n"; 	
	}else{
		if(emailCheck(email) != "Valid")
			error+="Please enter valid email.\n"; 	
	}
	if(pass==""){
		error+="Please enter password.\n"; 
	}else{
		if(pass.length < minLength)
			error+="Your password must be at least " + minLength + " characters long.\n";
		if(pass.indexOf(invalid) > -1)
			error+="Sorry, spaces are not allowed.\n";
	}

	if(error!="")
	{
		alert(error);
		return false;
	}
}

function valid_login()
{
	var email = document.getElementById("txtEmail").value;
	var pass = document.getElementById("txtPass").value;
	var error = "";

	if(email==""){
		error+="Please enter your email.\n"; 	
	}else{
		if(emailCheck(email) != "Valid")
			error+="Please enter valid email.\n"; 	
	}
	if(pass==""){
		error+="Please enter password.\n"; 
	}
	if(error!="")
	{
		alert(error);
		return false;
	}
}

function valid_forgot()
{
	var email = document.getElementById("txtEmail").value;
	var error = "";

	if(email==""){
		error+="Please enter your email.\n"; 	
	}else{
		if(emailCheck(email) != "Valid")
			error+="Please enter valid email.\n"; 	
	}
	if(error!="")
	{
		alert(error);
		return false;
	}
}


function emailCheck (emailStr) 
{ 
        var checkTLD=1;
        var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
        var emailPat=/^(.+)@(.+)$/;
        var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
        var validChars="\[^\\s" + specialChars + "\]";
        var quotedUser="(\"[^\"]*\")";
        var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
        var atom=validChars + '+';
        var word="(" + atom + "|" + quotedUser + ")";
        var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
        var matchArray=emailStr.match(emailPat);
        if (matchArray==null) {
                return "Email address is invalid";
                //return ;
        }
        var user=matchArray[1];
        var domain=matchArray[2];
        for (i=0; i<user.length; i++) {
                if (user.charCodeAt(i)>127) {
                        return "Ths username contains invalid characters.";
                        //return ;
                   }
        }
        for (i=0; i<domain.length; i++) {
                if (domain.charCodeAt(i)>127) {
                        return "Ths domain name contains invalid characters.";
                        //return ;
                  }
        }
        if (user.match(userPat)==null) {
                return "The username doesn't seem to be valid.";
                //return ;
        }
        var IPArray=domain.match(ipDomainPat);
        if (IPArray!=null) {
                for (var i=1;i<=4;i++) {
                        if (IPArray[i]>255) {
                                return "Destination IP address is invalid!";
                                //return ;
                         }
                }
                return "Valid";
        }
        var atomPat=new RegExp("^" + atom + "$");
        var domArr=domain.split(".");
        var len=domArr.length;
        for (i=0;i<len;i++) {
                if (domArr[i].search(atomPat)==-1) {
                        return "The domain name does not seem to be valid.";
                        //return ;
                 }
        }

        if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
                return "The address must end in a well-known domain or two letter " + "country.";
                //return ;
        }

        if (len<2) {
                return "This address is missing a hostname!";
                //return ;
        }
        return "Valid";
}

function valid_poll(txtid)
{
	/*
	var text_id=txtid.split('-');
	var cond_if = new Array();
	for(i=0;i<text_id.length;i++)
	{
		pos = text_id[i].indexOf("_");
		txtlen= text_id[i].length;
		ctlen = txtlen-pos;
		total_field = text_id[i].substr(pos+1,ctlen);
		cat_shortname = text_id[i].substr(0,pos);
		
		for(j=1;j<=total_field;j++)
		{
			cond_if[m+1]="document.getElementById("+cat_shortname+"_"+j+").value==''";
		}
		
	}
	*/

	c1_1 = document.getElementById("bnam_1").value;
	c1_2 = document.getElementById("bnam_2").value;
	c1_3 = document.getElementById("bnam_3").value;
	
	c2_1 = document.getElementById("bnaf_1").value;
	c2_2 = document.getElementById("bnaf_2").value;
	c2_3 = document.getElementById("bnaf_3").value;
	
	c3_1 = document.getElementById("bnanrm_1").value;
	c3_2 = document.getElementById("bnanrm_2").value;
	c3_3 = document.getElementById("bnanrm_3").value;
	
	c4_1 = document.getElementById("bnanrf_1").value;
	c4_2 = document.getElementById("bnanrf_2").value;
	c4_3 = document.getElementById("bnanrf_3").value;

	c5_1 = document.getElementById("bnsam_1").value;
	c5_2 = document.getElementById("bnsam_2").value;
	c5_3 = document.getElementById("bnsam_3").value;
	
	c6_1 = document.getElementById("bnsaf_1").value;
	c6_2 = document.getElementById("bnsaf_2").value;
	c6_3 = document.getElementById("bnsaf_3").value;

	
	c7_1 = document.getElementById("bncam_1").value;
	c7_2 = document.getElementById("bncam_2").value;
	c7_3 = document.getElementById("bncam_3").value;
	
	c8_1 = document.getElementById("bncaf_1").value;
	c8_2 = document.getElementById("bncaf_2").value;
	c8_3 = document.getElementById("bncaf_3").value;

	c9_1 = document.getElementById("bnnfts_1").value;
	c9_2 = document.getElementById("bnnfts_2").value;
		
	c10_1 = document.getElementById("bnfts_1").value;
	c10_2 = document.getElementById("bnfts_2").value;

	c11_1 = document.getElementById("bnoc_1").value;
	c11_2 = document.getElementById("bnoc_2").value;
	c11_3 = document.getElementById("bnoc_3").value;
	
	c12_1 = document.getElementById("bntpm_1").value;

	c13_1 = document.getElementById("bntpf_1").value;
		
	c14_1 = document.getElementById("mpttm_1").value;
	c14_2 = document.getElementById("mpttm_2").value;
	c14_3 = document.getElementById("mpttm_3").value;
	
	c15_1 = document.getElementById("mpttf_1").value;
	c15_2 = document.getElementById("mpttf_2").value;
	c15_3 = document.getElementById("mpttf_3").value;

	c16_1 = document.getElementById("bnca_1").value;
	c16_2 = document.getElementById("bnca_2").value;
	c16_3 = document.getElementById("bnca_3").value;

	c17_1 = document.getElementById("bnacm_1").value;
	c17_2 = document.getElementById("bnacm_2").value;
	c17_3 = document.getElementById("bnacm_3").value;
	
	c18_1 = document.getElementById("bnacf_1").value;
	c18_2 = document.getElementById("bnacf_2").value;
	c18_3 = document.getElementById("bnacf_3").value;

	if(c1_1=="" && c1_2=="" && c1_3=="" && c2_1=="" && c2_2=="" && c2_3=="" && c3_1=="" && c3_2=="" && c3_3=="" && c4_1=="" && c4_2=="" && c4_3=="" && c5_1=="" && c5_2=="" && c5_3=="" && c6_1=="" && c6_2=="" && c6_3=="" && c7_1=="" && c7_2=="" && c7_3=="" && c8_1=="" && c8_2=="" && c8_3=="" && c9_1=="" && c9_2=="" && c10_1=="" && c10_2=="" && c11_1=="" && c11_2=="" && c11_3=="" && c12_1=="" && c13_1=="" && c14_1=="" && c14_2=="" && c14_3=="" && c15_1=="" && c15_2=="" && c15_3=="" && c16_1=="" && c16_2=="" && c16_3=="")
	{
		alert("Please fill the nomination form");	
		return false;
	}

}
