
function checkChangePwd(){
	if(document.login.username.value==""){
		alert("Please enter your user name");
		document.login.username.focus();
		return false;
	}
	else{
		var data=document.login.username.value;
		var valid=checkData(data);

		if (valid==0)
		{
			alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
			document.login.username.focus();
			return false;
		}
	}

	if(document.login.oldpassword.value==""){
		alert("Please enter your old password");
		document.login.oldpassword.focus();
		return false;
	}

	if(document.login.newpassword.value==""){
		alert("Please enter your new password");
		document.login.newpassword.focus();
		return false;
	}
	
	if(document.login.newpassword.value!=""){
		var numaric =document.login.newpassword.value;
		var al=0;
		var nu=0;
		var ln=numaric.length;
		if(ln >=7){
			for(var j=0; j<numaric.length; j++)
			{
				var alphaa = numaric.charAt(j);
				var hh = alphaa.charCodeAt(0);
				if((hh > 64 && hh<91) || (hh > 96 && hh<123))
				{
					//OK
				}
				else{
					al=al+1;
				}
			}
			
			for(var j=0; j<numaric.length; j++)
			{
				var alphaa = numaric.charAt(j);
				var hh = alphaa.charCodeAt(0);
				if((hh > 47 && hh<59))
				{
					//OK
				}
				else{
					nu=nu+1;
				}
			}
			
			if(al == ln){
				alert('Password should be alphanumeric');
				document.login.newpassword.focus();
				return false;
			}

			if(nu == ln){
				alert('Password should be alphanumeric');
				document.login.newpassword.focus();
				return false;
			}
		}
		else{
			alert('Password should be greater than 7');
			document.login.newpassword.focus();
			return false;
		}
	}
	
	var encstring = document.login.oldpassword.value;
	encstring=hex_md5(encstring);

	document.login.oldpassword.value = encstring;


	var encstring = document.login.newpassword.value;
	encstring=hex_md5(encstring);

	document.login.newpassword.value = encstring;
}


function check_form11(){
	if (document.qcat.Subject.value=="")
	{
		alert("Please enter subject");
		document.qcat.Subject.focus();
		return false;
	}
	else{
		var data=document.qcat.Subject.value;
		var valid=checkData(data);

		if (valid==0)
		{
			alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
			document.qcat.Subject.focus();
			return false;
		}
	}

	if (document.qcat.Enquiry_For_Cell_Module_Type1.value=="")
	{
		alert("Please select one option");
		document.qcat.Enquiry_For_Cell_Module_Type1.focus();
		return false;
	}

	if (document.qcat.Peak_Power_output_cell_in_watts1.value=="")
	{
		alert("Please select one option");
		document.qcat.Peak_Power_output_cell_in_watts1.focus();
		return false;
	}

	if (document.qcat.Quantity1.value=="")
	{
		alert("Please enter one quantity");
		document.qcat.Quantity1.focus();
		return false;
	}
	else{
		if (isNaN(document.qcat.Quantity1.value))
		{
			alert("Please enter valid quantity");
			document.qcat.Quantity1.focus();
			return false;
		}
	}

	if (document.qcat.Quantity2.value!="")
	{
		if (isNaN(document.qcat.Quantity2.value))
		{
			alert("Please enter valid quantity");
			document.qcat.Quantity2.focus();
			return false;
		}
	}

	if (document.qcat.Quantity3.value!="")
	{
		if (isNaN(document.qcat.Quantity3.value))
		{
			alert("Please enter valid quantity");
			document.qcat.Quantity3.focus();
			return false;
		}
	}

	if (document.qcat.Quantity4.value!="")
	{
		if (isNaN(document.qcat.Quantity4.value))
		{
			alert("Please enter valid quantity");
			document.qcat.Quantity4.focus();
			return false;
		}
	}

	if (document.qcat.Quantity5.value!="")
	{
		if (isNaN(document.qcat.Quantity5.value))
		{
			alert("Please enter valid quantity");
			document.qcat.Quantity5.focus();
			return false;
		}
	}

	go();
}

function check_form12(){

}

/**************************************************************************************************/

function checkData(data){
	var validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	var checkStr=data;
	var status=1;
	
	for (var i=0;i<checkStr.length ; i++)
	{
		var ch=checkStr.charAt(i);
		for (var j=0;j<validChars.length ;j++ )
		{
			if (ch==validChars.charAt(j))
			{
				break;
			}
		}

		if (j==validChars.length)
		{
			status=0;
		}
	}
	
	return status;
}

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					
}