msghidediv="";
msghidediv+='<div id="tophidediv" style="position:absolute; top:0; left:0; visibility:visible; z-index:2"><table width="779" border="0"><tr><td height="300">&nbsp;</td></tr></table></div>';
document.write(msghidediv);

// in yyyymmdd format
function datechkfin(x,y)
{
	var datv = x.value;
	datvlen = x.value.length
	if(datvlen<8)
		{
				alert("Please enter " + y +" in valid yyyymmdd format");
				x.focus();
				x.select();
				return false
		}

	regdt = /^\d{8}$/;
	if(datv.match(regdt)!=datv) {
		alert("Please enter " + y +" in valid yyyymmdd format");
		x.focus();
		x.select();
		return false;
	}
		yyyy = datv.substr(0,4)
		mm = datv.substr(4,2)
		dd = datv.substr(6,2)
	if(datechk(dd,mm,yyyy)) {
	return true
	}
	else {
		alert("Please enter " + y +" in valid yyyymmdd format");
		x.focus();
		return false;
	}
}

// in ddmmyyyy format
function datechkfin1(x)
{
	var datv = x;
	datvlen = x.length

	regdt = /^\d{8}$/;
	if(datv.match(regdt)!=datv)
	{
		alert("Please enter valid date format eg. ddmmyyyy");
		x.focus();
		x.select();
		return false;
	}
		dd = datv.substr(0,2)
		mm = datv.substr(2,2)
		yyyy = datv.substr(4,4)
	if(datechk(dd,mm,yyyy))
	{
		return true
	}
	else
	{
		alert("Please enter valid date format eg. ddmmyyyy");
		x.focus();
		return false;
	}
}

// in dd-mmm-yyyy format
function datechkfrdatepicker(x)
{
	var datv = x;
	datvlen = x.length
	regdt = /^\d{2}-[a-zA-Z]{3}-\d{4}$/;
	if(datv.match(regdt)!=datv)
	{
		alert("Please enter valid date format eg. dd-mmm-yyyy");
		x.focus();
		x.select();
		return false;
	}
		dd = datv.substr(0,2)
		mmm = datv.substr(3,3)
		yyyy = datv.substr(7,4)
		var mm=0;
		switch (mmm)//Converting month string value to integer value
		{
			case "JAN": case "Jan": case "jan":
				mm=01;
				break;
	        case "FEB": case "Feb": case "feb":
				mm=02;
				break;
			case "MAR": case "Mar": case "mar":
				mm=03;
				break;
			case "APR": case "Apr": case "apr":
				mm=04;
				break;
			case "MAY": case "May": case "may":
				mm=05;
				break;
			case "JUN": case "Jun": case "jun":
				mm=06;
				break;
			case "JUL": case "Jul": case "jul":
				mm=07;
				break;
			case "AUG": case "Aug": case "aug":
				mm=08;
				break;
			case "SEP": case "Sep": case "sep":
				mm=09;
				break;
			case "OCT": case "Oct": case "oct":
				mm=10;
				break;
			case "NOV": case "Nov": case "nov":
				mm=11;
				break;
			case "DEC": case "Dec": case "dec":
				mm=12;
				break;
		}

	if(datechk(dd,mm,yyyy))
	{
		return true;
	}
	else
	{
		alert("Please enter valid date format eg. ddmmyyyy");
		x.focus();
		return false;
	}
}

function datechk(dd,mm,yyyy){
	switch(chkdate(dd,mm,yyyy)){
		case 1:
			alert("Invalid Day format");
			return false;
			break;
		case 2:
			alert("Invalid Month format");
			return false;
			break;
		case 3:
			alert("Invalid Year format");
			return false;
			break;
		case 4:
			alert("This month has only 30 days");
			return false;
			break;
		case 5:
			alert("This is a leap year. Feb has only 29 days");
			return false;
			break;
		case 6:
			alert("This is not a leap year. Feb has only 28 days");
			return false;
			break;
		case 7:
			alert("This year is a leap year. Feb has only 29 days");
			return false;
			break;
		case 8:
			alert("The \"date\" cannot be greater than today\'s date");
			return false;
			break;
	}
	return true;
}

function chkdate(dd,mm,yyyy){
	var dt = new Date();
	invdate=mm+"/"+dd+"/"+yyyy;
	var invdate=new Date(invdate);
	sysdate = dt.getUTCMonth()+1 + '/' + dt.getUTCDate() + '/' + dt.getUTCFullYear();
	var sysdate=new Date(sysdate);
	if(dd==0 || dd>31) return 1;
	if(mm==0 || mm>12) return 2;
	if(yyyy==0) return 3;
	if ((mm==4||mm==6||mm==9||mm==11) && (dd>30)) return 4;
	if(mm==2 && dd>29 && yyyy %400==0) return 5;
	if(mm==2 && dd>28 && yyyy % 4!=0) return 6;
	if(mm==2 && dd>29 && yyyy % 4==0 && yyyy %400!=0) return 7;
	//if (sysdate < invdate) return 8;
}

function datechkparind(dd,mm,yyyy,dd1,mm1,yyyy1){
	switch(chkdateparind(dd,mm,yyyy,dd1,mm1,yyyy1)){
		case 1:
			alert("Invalid Day format");
			return false;
			break;
		case 2:
			alert("Invalid Month format");
			return false;
			break;
		case 3:
			alert("Invalid Year format");
			return false;
			break;
		case 4:
			alert("This month has only 30 days");
			return false;
			break;
		case 5:
			alert("This is a leap year. Feb has only 29 days");
			return false;
			break;
		case 6:
			alert("This is not a leap year. Feb has only 28 days");
			return false;
			break;
		case 7:
			alert("This year is a leap year. Feb has only 29 days");
			return false;
			break;
		case 8:
//			alert("The \"date\" cannot be greater than today\'s date");
			return false;
			break;
	}
	return true;
}

function chkdateparind(dd,mm,yyyy,dd1,mm1,yyyy1){
	var dt = new Date();
	invdate=mm+"/"+dd+"/"+yyyy;
	var invdate=new Date(invdate);

	invdate1=mm1+"/"+dd1+"/"+yyyy1;
	var invdate1=new Date(invdate1);
//	alert(invdate)
//	alert(invdate1)
//	alert(invdate1<invdate)
/*	if(dd==0 || dd>31) return 1;
	if(mm==0 || mm>12) return 2;
	if(yyyy==0) return 3;
	if ((mm==4||mm==6||mm==9||mm==11) && (dd>30)) return 4;
	if(mm==2 && dd>29 && yyyy %400==0) return 5;
	if(mm==2 && dd>28 && yyyy % 4!=0) return 6;
	if(mm==2 && dd>29 && yyyy % 4==0 && yyyy %400!=0) return 7;*/
	if (invdate < invdate1) return 8;
}

function validdate(dd,mm,yy)
{
	 if  (((yy % 4 == 0) && (yy % 100 != 0)) || (yy % 400 == 0))
	 {
		  if(mm == 2)
	  		{
				if(dd > 29)
				{
					alert("It is a Leap Year, Select a date upto 29th");
					return false;
				}
			}
	 }
	 else
	 {
	 		if(mm == 2)
	 		{
	 			if(dd > 28)
	 			{
	 				alert("Select a date upto 28th for February");
	 				return false;
	 			}
	 		}
	  }
		if(mm == 4 || mm == 6 || mm == 9 || mm == 11)
		{
			if(dd > 30)
			{
				alert("Select date upto 30th")
				return false;
			}
		}
		else{
			if(dd > 31)
			{
				alert("Select date upto 31st")
				return false;
			}
		}

		return true;
}

function timechk(x)
{
timeval = x
hrs = timeval.substr(0,2)
min = timeval.substr(2,2)
sec = timeval.substr(4,2)
	if(hrs < 0 || hrs >23)
	{
		alert("Hour must be between 0 and 23")
		return false
	}
	if (min<0 || min > 59)
	{
		alert ("Minute must be between 0 and 59.");
		return false;
	}

	if(sec < 0 || sec > 59)
	{
		alert ("Second must be between 0 and 59.");
		return false;
	}
	return true
}

function chkinitial(x,y)
{
	if(x.value==y)
		x.value="";
	return true;
}
function percentagechk(x,y)
	{
		var num=/[0-9]+\.[0-9][0-9]\%/;
		var num1=/[0-9]+\.[0-9]\%/;
		var num2=/[0-9]+\%/;
		numflag=x.value.match(num);
		numflag1=x.value.match(num1);
		numflag2=x.value.match(num2);
		if(numflag != x.value && numflag1 != x.value && numflag2 != x.value)
		{
				alert("Please enter a valid "+y);
				x.focus();
				x.select();
				return false;
		}
		return true;
	}
function decimalchk(x,y)
	{
		var num=/[0-9]+\.[0-9][0-9]/;
		var num1=/[0-9]+\.[0-9]/;
		var num2=/[0-9]+/;
		numflag=x.value.match(num);
		numflag1=x.value.match(num1);
		numflag2=x.value.match(num2);
		if(numflag != x.value && numflag1 != x.value && numflag2 != x.value)
		{
				alert("Please enter a valid number");
				x.focus();
				x.select();
				return false;
		}
		return true;
	}
	function decimalchk_withcomma(x,y)
	{
		var num=/[0-9\,]+\.[0-9][0-9]/;
		var num1=/[0-9\,]+\.[0-9]/;
		var num2=/[0-9\,]+/;
		numflag=x.value.match(num);
		numflag1=x.value.match(num1);
		numflag2=x.value.match(num2);
		if(numflag != x.value && numflag1 != x.value && numflag2 != x.value)
		{
				alert("Please enter a valid number");
				x.focus();
				x.select();
				return false;
		}
		if(x.value.substring(0,1)==","){
		alert("A number can't starts with comma please enter valid number");
		x.focus();
		x.select();
		return false
		}
		return true;
	}
function blankchk(x,y)
	{
		if(x.value=="")
		{
			alert("Field " + y +" cannot be left blank. Please enter valid data.");
			x.focus();
			return false
		}
		return true;
	}

function alphanum(x)
{
//alert()
	var num=/[0-9A-Za-z\s]+/;
	uidflag=x.value.match(num);
	if(uidflag != x.value)
		return false;
	else
		return true;
}
function spalphanum(x)
{
//alert()
	var num=/[0-9A-Za-z\s]+/;
	uidflag=x.value.match(num);
	if(uidflag != x.value)
		return false;
	else
		return true;
}

function onlynumchk(x)
{
	var cnt=0;
	var num=/[0-9]/;
	str=x.value.split("");
	for(i=0;i<str.length;i++)
	{
		userflag=str[i].match(num);
		if(userflag!=str[i])
		{
			flag=1;
			break;
		}
		else cnt++;
	}
	if(cnt==str.length)
		return false;
	return true;
}
function onlycharchk(x)
{
	var cnt=0;
	str=x.value.split("");
	var num=/[a-zA-Z]/;
	for(i=0;i<str.length;i++)
	{
		userflag=str[i].match(num);
		if(userflag!=str[i])
		{
			flag=1;
			break;
		}
		else cnt++;
	}
	if(cnt==str.length)
		return false;
	return true;
}

function validatelogin(loginid,pswd){
var flag=0;
var cnt=0;
if(loginid.value=="Username"){
		alert("Please enter Username.")
		loginid.focus();
	 	loginid.select();
		return false;
	}
	else if(loginid.value.length<6)
	{
		alert("Username cannot be less than 6 characters")
		loginid.focus();
	 	loginid.select();
		return false;
	}
	/*else
	{
		if(!onlynumchk(loginid))
		{
			alert("please enter a valid username");
			loginid.focus();
	 		loginid.select();
			return false;
		}
	}*/
	var usr=/[a-zA-Z0-9\_]+/;
	uidflag=loginid.value.match(usr);
	if(uidflag != loginid.value)
	{
		alert("Please enter valid Username.")
		loginid.focus();
 		loginid.select();
		return false;
	}
	if(pswd.value==""){
		alert("Please enter Password.")
		pswd.focus();
	 	pswd.select();
		return false;
	}
	if(pswd.value.length<6)
	{
		alert("Password cannot be less than 6 characters")
		pswd.focus();
	 	pswd.select();
		return false;
	}
	/*if(!onlynumchk(pswd))
	{
		alert("please enter a valid password");
		pswd.focus();
 		pswd.select();
		return false;
	}*/
	if(!onlycharchk(pswd))
	{
		alert("please enter a valid password");
		pswd.focus();
 		pswd.select();
		return false;
	}
	return true;
}

function pgdropdnchk(x,y)
{

	if(eval(x)==-1)
	{
		alert("Please select a valid option from  " + y );
		return false;
	}
	return true;

}

function pgdropdnchk1(x,y)
{

	if(eval(x)==-1)
	{
		alert("Please select a valid option");
		return false;
	}

	y.submit();
	return true;

}



function chkkeyword(x)
{
	var searchname=/[a-zA-Z0-9\s\"\-]+/;
	if(parseInt(x.value.length)<=1 || x.value.match(searchname)!= x.value)
	{
		alert("Invalid Search");
		x.focus();
		x.select();
		return false;
	}
	dbase=new Array ("&","about","1","after","all","2","also","3","an","4","and","5","6","another","any","7","are","8","as","9","at","0","be","$","because","been","before","being","between","both","but","by","came","can","come","could","did","do","does","each","else","for","from","get","got","has","had","he","have","her","here","him","himself","his","how","if","in","into","is","it","its","just","like","make","many","me","might","more","most","much","must","my","never","now","of","on","only","or","other","our","out","over","re","said","same","see","should","since","so","some","still","such","take","than","that","the","their","them","then","there","these","they","this","those","through","to","too","under","up","use","very","want","was","way","we","well","were","what","when","where","which","while","who","will","with","would","you","your","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
	var myString=x.value.toLowerCase();
	splitString = myString.split(" ");
	var count=0;
	var i,j;
	for(i=0;i<splitString.length;i++)
	{
		var temp=splitString[i];
		if(splitString[i]=="")
		{
			count=count+1;
			continue;
		}
		for(j=0;j<dbase.length;j++)
		{
			if(temp==dbase[j])
				count=count+1;
		}
	}
	if(count==splitString.length)
	{
		alert("Invalid Search");
		x.focus();
		x.select();
		return false;
	}
	return true;
}

function valsitesrch()
	{
		var searchname=/[a-zA-Z0-9\s\*\"\-]+/;
		trimit(document.frmsitesrch.keyword);
		if(document.frmsitesrch.keyword.value=="" || document.frmsitesrch.keyword.value=="Enter keyword")
		{
			alert("please enter a valid keyword");
			document.frmsitesrch.keyword.focus();
			return false;
		}
		if(!chkkeyword(document.frmsitesrch.keyword))
			return false;
		return true;
	}


function valdpsrch()
	{
			if(document.frmdpsrch.dpsrch[1].checked)
			{
				trimit(document.frmdpsrch.dpname);				
				if((document.frmdpsrch.dpname.value=="" || document.frmdpsrch.dpname.value=="Enter DP Name"))
				{
					alert("please enter the DP name");
					document.frmdpsrch.dpname.focus();
					document.frmdpsrch.dpname.select();
					return false;
				}
				if(!alphanum(document.frmdpsrch.dpname))
				{
					alert("please enter a valid DP name");
					document.frmdpsrch.dpname.focus();
					document.frmdpsrch.dpname.select();
					return false;
				}			
			}	
			return true;	
	}


function valdpCsrch()
{
     if(document.frmdpCsrch.dpCsrch[1].checked)
     {
    		trimit(document.frmdpCsrch.dpCname);
    		if((document.frmdpCsrch.dpCname.value=="" || document.frmdpCsrch.dpCname.value=="Enter DP service center name"))
    		{
    			//alert("please enter the DP service center name");
    			//document.frmdpCsrch.dpCname.focus();
    			//return false;
    			return true;
    		}
    		if(!alphanum(document.frmdpCsrch.dpCname))
    		{
    			alert("please enter a valid DP service center name");
    			document.frmdpCsrch.dpCname.focus();
    			return false;
    		}
      }

}

	function trimit(x)
		{
			splitstr=x.value.split("");

			var i=0;
			if(splitstr[i]==" ")
			{
				x.value=""
				while(splitstr[i]==" ")
					i++;
				for(j=i;j<splitstr.length;j++,i++)
					x.value=x.value+splitstr[i];
			}
			splitstr=x.value.split("");

			i=splitstr.length-1
			if(splitstr[i]==" ")
			{
				x.value="";
				while(splitstr[i]==" ")
					i--;
				for(j=0;j<=i;j++)
					x.value=x.value+splitstr[j];
			}

	}

	function valcompsrch()
	{
		if(document.frmcompsrch.cmpsrch[0].checked)
			{
				trimit(document.frmcompsrch.compname);
				if(document.frmcompsrch.compname.value=="" || document.frmcompsrch.compname.value=="Issuer/Company Name")
				{
					alert("please enter Company name");
					document.frmcompsrch.compname.focus();
					return false;
				}
				/*if(document.frmcompsrch.compname.value.length<3)
				{
					alert("Company name cannot be less than 3 characters. Please reenter");
					document.frmcompsrch.compname.focus();
					document.frmcompsrch.compname.select();
					return false;
				}*/
				if(!alphanum(document.frmcompsrch.compname))
				{
					alert("please enter a valid Company name");
					document.frmcompsrch.compname.focus();
					return false;
				}
			}
			if(document.frmcompsrch.cmpsrch[1].checked)
			{
				trimit(document.frmcompsrch.isinnum);
				if(document.frmcompsrch.isinnum.value=="")
				{
					alert("please enter the ISIN Number");
					document.frmcompsrch.isinnum.focus();
					return false;
				}
				var num=/[A-Za-z0-9]+/
				numflag=document.frmcompsrch.isinnum.value.match(num);
				if(numflag != document.frmcompsrch.isinnum.value)
				{
					alert("please enter a valid ISIN Number");
					document.frmcompsrch.isinnum.focus();
					return false;
				}
			}
		return true;
	}
	function valrtasrch()
		{

			//if(ie){
			trimit(document.frmrtasrch.rtaname);
			if(document.frmrtasrch.rtasrch[0].checked)
			{
			trimit(document.frmrtasrch.rtaname);
			if(document.frmrtasrch.rtaname.value=="" || document.frmrtasrch.rtaname.value=="RTA Name")
				{
					alert("please enter either a valid RTA name");
					document.frmrtasrch.rtaname.focus();
					return false;
				}
				if(!alphanum(document.frmrtasrch.rtaname))
				{
					alert("please enter a valid RTA name");
					document.frmrtasrch.rtaname.focus();
					return false;
				}
			}
			if(document.frmrtasrch.rtasrch[1].checked)
			{
				trimit(document.frmrtasrch.rtaname1);
				if(document.frmrtasrch.rtaname1.value=="" || document.frmrtasrch.rtaname1.value=="Company Name")
				{
					alert("please enter a valid Company name");
					document.frmrtasrch.rtaname1.focus();
					return false;
				}
				if(!alphanum(document.frmrtasrch.rtaname1))
				{
					alert("please enter a valid Company name");
					document.frmrtasrch.rtaname1.focus();
					return false;
				}
				//document.frmrtasrch.rtaname[0].value = document.frmrtasrch.rtaname[1].value;

			}
			return true;
			/*}
			if(ns){
			//alert(document.rtasrch)
			if(document.rtasrch.document.frmrtasrch.rtasrch[0].checked)
			{
				trimit(document.rtasrch.document.frmrtasrch.rtaname);
				if(document.rtasrch.document.frmrtasrch.rtaname.value=="" || document.rtasrch.document.frmrtasrch.rtaname.value=="RTA Name")
				{
					alert("please enter either a valid RTA name");
					document.rtasrch.document.frmrtasrch.rtaname.focus();
					return false;
				}
			}
			if(document.rtasrch.document.frmrtasrch.rtasrch1.checked)
			{
				trimit(document.rtasrch.document.frmrtasrch.rtaname1);
				if(document.rtasrch.document.frmrtasrch.rtaname1.value=="" || document.rtasrch.document.frmrtasrch.rtaname1.value=="Company Name")
				{
					alert("please enter a valid Company name");
					document.rtasrch.document.frmrtasrch.rtaname1.focus();
					return false;
				}
				//document.rtasrch.document.frmrtasrch.rtaname[0].value = document.rtasrch.document.frmrtasrch.rtaname[1].value;

			}
			return true;
			}*/
	}
	function trimit(x)
			{
				splitstr=x.value.split("");

				var i=0;
				if(splitstr[i]==" ")
				{
					x.value=""
					while(splitstr[i]==" ")
						i++;
					for(j=i;j<splitstr.length;j++,i++)
						x.value=x.value+splitstr[i];
				}
				splitstr=x.value.split("");

				i=splitstr.length-1
				if(splitstr[i]==" ")
				{
					x.value="";
					while(splitstr[i]==" ")
						i--;
					for(j=0;j<=i;j++)
						x.value=x.value+splitstr[j];
				}

	}

	function power(x)
	{
		var ctr=parseInt(x);
		var i,mult=1;
		for(i=1;i<=ctr;i++)
			mult=2*mult;
		return mult;
	}
function validboID(x,y)
{
	if(x.value=="")
		{
			alert("Field cannot be blank.Please enter a valid BOID.");
			x.focus();
			return false;
		}
		if(y.value=="")
		{
			alert("Field cannot be blank.Please enter a valid BOID.");
			y.focus();
			return false;
		}

		var str=x.value + y.value;
		if(str.length!=16)
		{
			alert("Please enter a valid BOID.")
			x.focus();
			x.select();
	 		return false;
		}

		var flag=/[0-9]+/;
		fieldflag=str.match(flag);
		if(fieldflag != str)
		{
			alert("Please enter numbers only.")
			x.focus();
			return false;
		}
		var len=parseInt(str.length);
		var sum=0,i;
		for(i=0;i<len-1;i++)
		{
			var a=power(i);
			var digit=parseInt(str.charAt(i));
			sum+=a*digit;
		}
		var lastdigit=parseInt(str.charAt(len-1));
		var mod=sum%11;
		if(mod==10)
			mod=1;
		if(lastdigit!=mod)
		{
			alert("Please enter a valid BOID.")
			x.focus();
			x.select();
	 		return false;
		}
		return true;
}

function winopen(){
		if(document.boregfrm.agree.checked==true)
		{
			var w=window.open("agreement.htm","agreement","height=400,width=470,scrollbars=yes")
			w.focus();
		}
	}

//Only alphabets are allowed
function alphachk(x,y){
	var alpha=/[a-zA-Z]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphabets only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}
// Only alpha numeric allowed
function alphanumchk(x,y){
	var alpha=/[-a-zA-Z0-9_\.]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric character only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}
//Alpha Numeric Ch. & Space are allowed
function alphanumchksp(x,y){
	var alpha=/[-a-zA-Z0-9_\.]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric character only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

function alphanumchkspnb(x,y){
	var alpha=/[-a-zA-Z0-9_\.]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

function prevref(z,x,y)
	{
		if(z==0)
		{
			x.disabled;
			return true;
		}
		else
		{
			if(alphanumchkspchnb1(x,y))
				return true;
			else
				return false;
		}
	}
//Contract Note ref.No.
function alphanumchkspchnb(x,y){
	var alpha=/^[AB][a-zA-Z0-9 .:,-]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric & valid special characters only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

function alphanumchkspchnb1(x,y){
	var alpha=/[- a-zA-Z0-9.:,]+/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric & valid special characters only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

function alphanumchkspchnb2(x,y){
	var alpha=/[a-zA-Z0-9 .:,-]{4,}/
	alphaflag=x.value.match(alpha);
	if(alphaflag != x.value){
		alert("Please enter alphanumeric & valid special characters only in " + y +" field.")
		x.focus();
 		x.select();
		return false;
	}
	return true;
}
function minlength(x,y)
{
	var num=/[a-zA-Z0-9- .:,]{7,}/
	numflag=x.value.match(num);
	if(numflag != x.value)
	{
		alert("Please enter a number with 7 to 13 characters in " + y +" field.");
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

//Only alphabets are allowed Condition: when field is not blank
function alphachknb(x,y){
	if(x.value!="")
	{
		var alpha=/[a-zA-Z]+/
		alphaflag=x.value.match(alpha);
		if(alphaflag != x.value){
			alert("Please enter alphabets only in " + y +" field.")
			x.focus();
 			x.select();
			return false;
		}
	}
	return true;
}

	function alphaspchk(x,y)
	{
	var sp=/[a-zA-Z\s]+/;
	alpflag=x.value.match(sp);
	if(alpflag != x.value)
	{
		alert("Please enter alphabets only in " + y +" field.")
			x.focus();
 			x.select();
			return false;
	}
	return true;
	}

	function alphaspchknb(x,y)
	{
	if(x.value!="")
	{
		var sp=/[a-zA-Z\s]+/;
		alpflag=x.value.match(sp);
		if(alpflag != x.value)
		{
			alert("Please enter alphabets only in " + y +" field.")
			x.focus();
 			x.select();
			return false;
		}
	}
	return true;
	}


function emailchk(x)
	{
		var email =/[-a-zA-Z0-9_\.]+@[-a-zA-Z0-9]+\.[-a-zA-Z0-9\.]+/;
		var eflag = x.value.match(email);
		if(eflag!=x.value){
			alert("Please enter valid Email-Id.")
			x.focus();
			x.select();
			return false;
		}
		return true;
	}

function phonechk(x){
	//alert()
	if(x.value.length<4)
		return false;
	var num=/[0-9\-\s]+/
	numflag=x.value.match(num);
	if(numflag != x.value)
		return false;
	return true;
}
function addrchk(x){
	//alert()

	var num=/[a-zA-Z0-9\-\s\,]+/
	alpflag=x.value.match(num);
	if(alpflag != x.value)
		return false;
	return true;
}


function numchk(x,y){
	var num=/[0-9]+/
	numflag=x.value.match(num);
	if(numflag != x.value){
		alert("Please enter numbers in " + y +" field.");
		x.focus();
 		x.select();
		return false;
	}
	return true;
}
function numwithcommachk(x,y){
	var num=/[0-9\,]+/
	numflag=x.value.match(num);
	if(numflag != x.value){
		alert("Please enter numbers in " + y +" field.");
		x.focus();
 		x.select();
		return false;
	}if(x.value.substring(0,1)==","){
		alert("A number can't starts with comma please enter valid number");
		x.focus();
		x.select();
		return false
		}
	return true;
}

function numdecichk(x,y){
	var num=/[0-9\.]+/
	numflag=x.value.match(num);
	if(numflag != x.value){
		alert("Please enter numbers in " + y +" field.");
		x.focus();
 		x.select();
		return false;
	}
	return true;
}

// checks for Blank, Numbers and Decimal Numbers(DN)
//DN not more than 10 digits before dot(.)and not more than 5 digits after dot(.)
function decimalspchk(x,y)
	{
		if(x.value=="")
		{
				alert("Field " + y +" cannot be blank")
				x.focus();
				x.select();
				return false;
		}

		var num1=/[0-9]+\.[0-9]+/;
		var num2=/[0-9]+/

		numflag1=x.value.match(num1);
		numflag2=x.value.match(num2);
		if((numflag1 != x.value) && (numflag2!= x.value))
		{
				alert("Please enter a valid number in  " + y +" field");
				x.focus();
				x.select();
				return false;
		}
		if(x.value.indexOf(".")!=-1)
		{
				xval = x.value
				xvalsp = xval.split(".")
				if(xvalsp[0].length>10)
				{
				alert("The values before decimal cannot be more than 10 characters")
				x.focus()
				return false
				}
				if(xvalsp[1].length>5)
				{
				alert("The values after decimal cannot be more than 5 characters")
				x.focus()
				return false
				}
		}
		else
		{
				if(x.value.length>10)
				{
				alert("The values  cannot be more than 10 characters")
				x.focus();
	 			x.select();
				return false;
				}
		}
		return true;
	}

function decimalspchk1(x,y)
	{
		var num1=/[0-9]+.[0-9]+/;
		var num2=/[0-9]+/

		numflag1=x.value.match(num1);
		numflag2=x.value.match(num2);
		if((numflag1 != x.value) && (numflag2!= x.value))
		{
				alert("Please enter a valid number in  " + y +" field");
				x.focus();
				x.select();
				return false;
		}
		if(x.value.indexOf(".")!=-1)
		{
				xval = x.value
				xvalsp = xval.split(".")
				if(xvalsp[0].length>10)
				{
				alert("The values before decimal cannot be more than 10 characters")
				x.focus()
				return false
				}
				if(xvalsp[1].length>5)
				{
				alert("The values after decimal cannot be more than 5 characters")
				x.focus()
				return false
				}
		}
		else
		{
				if(x.value.length>10)
				{
				alert("The values  cannot be more than 10 characters")
				x.focus();
	 			x.select();
				return false;
				}
		}
		return true;
	}

function menuinit()
{
if(ie){
divbot.onmouseover = hideall;
divtop.onmouseover = hideall;
tophidediv.style.visibility="hidden";
}
if (ns){
document.divbot.captureEvents(Event.MOUSEDOWN);
document.divbot.onmouseover = hideall;

document.divtop.captureEvents(Event.MOUSEDOWN);
document.divtop.onmouseover = hideall;

document.tophidediv.visibility="hide";
}

}
function hideall()
{
if(ie){
divbot.style.visibility="hidden";
divtop.style.visibility="hidden";
about.style.visibility="hidden";
associates.style.visibility="hidden";
investor.style.visibility="hidden";
publication.style.visibility="hidden";
whatsnew.style.visibility="hidden";
electronic.style.visibility="hidden";
}
if(ns){
document.divbot.visibility="hide";
document.divtop.visibility="hide";
document.about.visibility="hidden";
document.associates.visibility="hidden"
document.investor.visibility="hidden";
document.publication.visibility="hidden";
document.whatsnew.visibility="hidden";
document.electronic.visibility="hidden";
}
}


function showlink(x)
{
hideall();
if(ie){
if(x=="electronic")
	electronic.style.visibility="visible";
else{
	var ctie=eval(x +".style");
	ctie.top=60;
	if(x=="about")
	ctie.left=112;
	if(x=="associates")
	ctie.left=250;
	if(x=="investor")
	ctie.left=400;
	if(x=="publication")
	ctie.left=175;
	if(x=="whatsnew")
	ctie.left=460;
	if(mywidth>800)
	ctie.left=parseFloat(ctie.left)+100;
	ctie.visibility="visible";
	divtop.style.visibility="visible";
	divbot.style.visibility="visible";
	}
}
if(ns){
if(x=="electronic")
	document.electronic.visibility="visible";
else{
	var ct=eval("document."+x);
	ct.top=60;
	if(x=="about")
	ct.left=112;
	if(x=="associates")
	ct.left=245;
	if(x=="investor")
	ct.left=400;
	if(x=="publication")
	ct.left=175;
	if(x=="whatsnew")
	ct.left=540;
	if(mywidth>800)
	ct.left=parseFloat(ct.left)+100;
	ct.visibility="visible";
	document.divbot.visibility="visible";
	document.divtop.visibility="visible";
	}
}
}
if(document.images) {
	abt1 = new Image();
	abt1.src="/images/mo_abtcdsl.gif"
	abt2 = new Image();
	abt2.src="/images/abt_cdsl.gif"
	assoc1 = new Image();
	assoc1.src="/images/mo_cdsl_assoct.gif"
	assoc2 = new Image();
	assoc2.src="/images/cdsl_assoct.gif"
	invest1 = new Image();
	invest1.src="/images/mo_investor.gif"
	invest2 = new Image();
	invest2.src="/images/investor.gif"
	publtn1 = new Image();
	publtn1.src="/images/mo_publtn.gif"
	publtn2 = new Image();
	publtn2.src="/images/publtn.gif"
	watnew1 = new Image();
	watnew1.src="/images/mo_watsnew.gif"
	watnew2 = new Image();
	watnew2.src="/images/watsnew.gif"
}

function changeimg(x)
{
if(x=="about")
document.abt.src=abt1.src;
if(x=="associates")
document.assoc.src=assoc1.src;
if(x=="investor")
document.invest.src=invest1.src;
if(x=="publication")
document.publtn.src=publtn1.src;
if(x=="whatsnew")
document.watnew.src=watnew1.src;

}
function changeback(x)
{
if(x=="about")
document.abt.src=abt2.src;
if(x=="associates")
document.assoc.src=assoc2.src;
if(x=="investor")
document.invest.src=invest2.src;
if(x=="publication")
document.publtn.src=publtn2.src;
if(x=="whatsnew")
document.watnew.src=watnew2.src;
}
/*function changeimg(x)
{
if(x=="about")
document.abt.src="/images/mo_abtcdsl.gif"
if(x=="associates")
document.assoc.src="/images/mo_cdsl_assoct.gif"
if(x=="investor")
document.invest.src="/images/mo_investor.gif"
if(x=="publication")
document.publtn.src="/images/mo_publtn.gif"
if(x=="whatsnew")
document.watnew.src="/images/mo_watsnew.gif"

}
function changeback(x)
{
if(x=="about")
document.abt.src="/images/abt_cdsl.gif"
if(x=="associates")
document.assoc.src="/images/cdsl_assoct.gif"
if(x=="investor")
document.invest.src="/images/investor.gif"
if(x=="publication")
document.publtn.src="/images/publtn.gif"
if(x=="whatsnew")
document.watnew.src="/images/watsnew.gif"
}*/

function validatedp()
	{
		x=document.boregfrm;
		var flag=0;
		var cnt=0;
		if(x.login.value=="")
		{
			alert("Please enter Username.");
			x.login.focus();
			x.login.select();
			return false;
		}else{
			if(x.login.value.length<6){
				alert("Username cannot be less than 6 characters.");
				x.login.focus();
				x.login.select();
				return false;
			}
			/*else{
				str=x.login.value.split("");
				var num=/[0-9]/;
				for(i=0;i<str.length;i++)
				{
					userflag=str[i].match(num);
					if(userflag!=str[i])
					{
						flag=1;
						break;
					}
					else cnt++;
				}
				if(cnt==str.length)
				{
					alert("please enter a valid username");
					x.login.focus();
			 		x.login.select();
					return false;
				}
			}
			if(flag==1)
			{*/
				var usr=/[a-zA-Z0-9\_]+/;
				uidflag=x.login.value.match(usr);
				if(uidflag != x.login.value){
					alert("Please enter valid Username.")
					x.login.focus();
			 		x.login.select();
					return false;
				}
			//}
		}

		if(!emailchk(x.email))
			return false;
		if((x.telno.value=="" || x.telno.value=="Phone no.") && x.mobile.value=="")
		{
			alert("Please enter either the Phone No. or Mobile no.")
			x.telno.focus();
			x.telno.select();
			return false;
		}else{
			regphone=/[0-9]+/;
			if(x.telno.value!="" && x.telno.value!="Phone no."){
				phoneflag=x.telno.value.match(regphone);
				if(phoneflag!=x.telno.value /*|| x.telno.value.length<4*/){
					alert("Please enter valid Phone No.")
					x.telno.focus();
					x.telno.select();
			      	return false;
				}
				if(x.std.value=="STD Code"){
					alert("Plese enter STD Code.");
					x.std.focus();
					x.std.select();
					return false;
				}
				else{
					phoneflag=x.std.value.match(regphone);
					if(phoneflag!=x.std.value){
						alert("Please enter valid STD Code.")
						x.std.focus();
						x.std.select();
			      		return false;
					}
				}
				/*if(x.std.value.charAt(0)!="0"){
					alert("Please enter valid STD Code.")
					x.std.focus();
					x.std.select();
		      		return false;
				}*/
			}
			if(x.mobile.value!=""){
				phoneflag=x.mobile.value.match(regphone);
				if(phoneflag!=x.mobile.value/* || x.mobile.value.length<10*/){
					alert("Please enter valid Mobile No.")
					x.mobile.focus();
					x.mobile.select();
			      	return false;
				}
			}
		}
		trimit(x.ans)
		if(x.ans.value=="")
		{
			alert("Please enter your answer");
			x.ans.focus();
			x.ans.select();
			return false;
		}
		trimit(x.confirmans)
		if(x.confirmans.value=="")
		{
			alert("Please confirm your answer");
			x.confirmans.focus();
			x.confirmans.select();
			return false;
		}
		if(x.confirmans.value!=x.ans.value)
		{
			alert("Confirmed answer is not same as answer");
			x.confirmans.focus();
			x.confirmans.select();
			return false;
		}
		if(x.agree.checked==false)
		{
			alert("Please agree to our Terms and Conditions");
			return false;
		}
		if(x.chkcheck.value==0)
		{
			alert("Please agree to our Terms and Conditions");
			return false;
		}
	}
	function validate()
	{
		x=document.boregfrm;
		var flag=0;
		var cnt=0;
		if(x.login.value=="")
		{
			alert("Please enter Username.");
			x.login.focus();
			x.login.select();
			return false;
		}else{
			if(x.login.value.length<6){
				alert("Username cannot be less than 6 characters.");
				x.login.focus();
				x.login.select();
				return false;
			}
			else{
				str=x.login.value.split("");
				var num=/[0-9]/;
				for(i=0;i<str.length;i++)
				{
					userflag=str[i].match(num);
					if(userflag!=str[i])
					{
						flag=1;
						break;
					}
					else cnt++;
				}
				if(cnt==str.length)
				{
					alert("please enter a valid username");
					x.login.focus();
			 		x.login.select();
					return false;
				}
			}
			if(flag==1)
			{
				var usr=/[a-zA-Z0-9\_]+/;
				uidflag=x.login.value.match(usr);
				if(uidflag != x.login.value){
					alert("Please enter valid Username.")
					x.login.focus();
			 		x.login.select();
					return false;
				}
			}
		}

		if(!emailchk(x.email))
			return false;
		if((x.telno.value=="" || x.telno.value=="Phone no.") && x.mobile.value=="")
		{
			alert("Please enter either the Phone No. or Mobile no.")
			x.telno.focus();
			x.telno.select();
			return false;
		}else{
			regphone=/[0-9]+/;
			if(x.telno.value!="" && x.telno.value!="Phone no."){
				phoneflag=x.telno.value.match(regphone);
				if(phoneflag!=x.telno.value /*|| x.telno.value.length<4*/){
					alert("Please enter valid Phone No.")
					x.telno.focus();
					x.telno.select();
			      	return false;
				}
				if(x.std.value=="STD Code"){
					alert("Plese enter STD Code.");
					x.std.focus();
					x.std.select();
					return false;
				}
				else{
					phoneflag=x.std.value.match(regphone);
					if(phoneflag!=x.std.value){
						alert("Please enter valid STD Code.")
						x.std.focus();
						x.std.select();
			      		return false;
					}
				}
				/*if(x.std.value.charAt(0)!="0"){
					alert("Please enter valid STD Code.")
					x.std.focus();
					x.std.select();
		      		return false;
				}*/
			}
			if(x.mobile.value!=""){
				phoneflag=x.mobile.value.match(regphone);
				if(phoneflag!=x.mobile.value/* || x.mobile.value.length<10*/){
					alert("Please enter valid Mobile No.")
					x.mobile.focus();
					x.mobile.select();
			      	return false;
				}
			}
		}
		trimit(x.ans)
		if(x.ans.value=="")
		{
			alert("Please enter your answer");
			x.ans.focus();
			x.ans.select();
			return false;
		}

		trimit(x.confirmans)
		if(x.confirmans.value=="")
		{
			alert("Please confirm your answer");
			x.confirmans.focus();
			x.confirmans.select();
			return false;
		}
		if(x.confirmans.value.toLowerCase()!=x.ans.value.toLowerCase())
		{
			alert("Confirmed answer is not same as answer");
			x.confirmans.focus();
			x.confirmans.select();
			return false;
		}

		if(x.agree.checked==false)
		{
			alert("Please agree to our Terms and Conditions");
			return false;
		}
		if(x.chkcheck.value==0)
		{
			alert("Please agree to our Terms and Conditions");
			return false;
		}
	}
	function clearall(frmname)
	{

			for(i=0; i<frmname.length; i++){
				if(frmname.elements[i].type=="text")
				{
					frmname.elements[i].value="";
				}
				if(frmname.elements[i].type=="select-one")
				{
					frmname.elements[i].selectedIndex=0;
				}
				if(frmname.elements[i].type=="textarea")
				{
					frmname.elements[i].value="";
				}
				if(frmname.elements[i].type=="checkbox")
				{
					frmname.elements[i].checked=false;
				}
				/*if(frmname.elements[i].type=="file")
				{
					frmname.elements[i].value="";
				}*/
				if(frmname.elements[i].type=="password")
				{
					frmname.elements[i].value="";
				}
			}
	}
function validatepass(oldpass,newpass,confpass,loginid){
	if(oldpass.value==""){
		alert("Please enter your Old Password.");
		oldpass.focus();
		oldpass.select();
		return false;
	}
	if(newpass.value==""){
		alert("Please enter your New Password.");
		newpass.focus();
		newpass.select();
		return false;
	}
	if(newpass.value.length < 8){
		alert("New Password cannot be less than 8 characters.");
		newpass.focus();
		newpass.select();
		return false;
	}	
	if(confpass.value==""){
		alert("Please enter Confirm Password.");
		confpass.focus();
		confpass.select();
		return false;
	}
	if(confpass.value!=newpass.value){
			alert("Confirm Password should be same as New Password.");
			confpass.focus();
			confpass.select();
			return false;
	}
	
	/*if(!onlynumchk(newpass) || !onlycharchk(newpass))
	{
		alert("Please enter a valid Alpha Numeric password.");
		newpass.focus();
		newpass.select();
		return false;
	}*/
	if(newpass.value==oldpass.value){
		alert("New Password and old password cannot be same.");
		newpass.focus();
		newpass.select();
		return false;
	}
	if(newpass.value==loginid.value)
	{
		alert("Password cannot be same as the Username");
		newpass.focus();
		newpass.select();
		return false;
	}
	if(passchk(newpass)){
		alert("Please enter a valid Alpha Numeric password.");
		newpass.focus();
		newpass.select();
		return false;
	}
return true;	
}
//for validate boid if 16 didgit boid is in  single textbox
function validatePOABOID(x)
	{			
		if(x.value=="")
		{
			alert("Field cannot be blank.Please enter a valid BOID.");
			x.focus();
			x.select();
			return false;
		}
		var str=x.value;
		if(str.length!=16)
		{
			alert("Please enter a valid BOID.")
			x.focus();
			x.select();
	 		return false;
		}

		var flag=/[0-9]+/
		fieldflag=str.match(flag);
		if(fieldflag != str)
		{
			alert("Please enter numbers only.")
			x.focus();
			return false;
		}
		var len=parseInt(str.length);
		var sum=0,i;
		for(i=0;i<len-1;i++)
		{
			var a=power(i);
			var digit=parseInt(str.charAt(i));
			sum+=a*digit;
		}
		var lastdigit=parseInt(str.charAt(len-1));
		var mod=sum%11;
		if(mod==10)
			mod=1;
		if(lastdigit!=mod)
		{
			alert("Please enter a valid BOID.")
			x.focus();
			x.select();
	 		return false;
		}
		return true;
	}
function validatePOAID(x)
	{
		var flag=/[0-9]+/
		var str=x.value;
		fieldflag=str.match(flag);
		if(x.value=="")
		{
			alert("Field cannot be blank.Please enter a valid POAID.");
			x.focus();
			x.select();
			return false;
		}
		if(fieldflag != str)
		{
			alert("POAID should be numbers only.")
			x.focus();
			x.select();
			return false;
		}
		if(str.length!=16)
		{
			alert("Please enter 16 digit valid POAID.")
			x.focus();
			x.select();
	 		return false;
		}
	return true;
}
function validateMobile(x){
		var regphone=/[0-9]+/;
		if(x.value!=""){
				phoneflag=x.value.match(regphone);
				if(phoneflag!=x.value || x.value.length < 10){
					alert("Please enter valid Mobile No.")
					x.focus();
					x.select();
			      	return false;
				}
		}
		return true;
}
function alphanumWithdash_underscore(x)
{
	var num=/[0-9A-Za-z\s\-\_\.]+/;
	uidflag=x.match(num);
	if(uidflag != x)
		return false;
	else
		return true;
}
function passchk(x){
	var alphacnt=0;
	var numcnt=0;
	var num=/[0-9]/;
	var alpha=/[a-zA-Z]/;
	str=x.value.split("");
	for(i=0;i<str.length;i++)
	{
		userflagnum=str[i].match(num);
		if(userflagnum==str[i]){
		numcnt++;
		}
		userflagalpha=str[i].match(alpha);
		if(userflagalpha==str[i]){
		alphacnt++
		}
	}
	if(numcnt > 0 && numcnt < str.length && alphacnt > 0 && alphacnt < str.length){
		return false;
	}
return true;
}
function validateloginName(loginid){
	if(loginid.value==""){
		alert("Please enter Login Name.")
		loginid.focus();
	 	loginid.select();
		return false;
	}
	else if(loginid.value.length<6)
	{
		alert("Login Name cannot be less than 6 characters")
		loginid.focus();
	 	loginid.select();
		return false;
	}
	var usr=/[a-zA-Z0-9\_]+/;
	uidflag=loginid.value.match(usr);
	if(uidflag != loginid.value)
	{
		alert("Please enter valid Login Name.")
		loginid.focus();
 		loginid.select();
		return false;
	}
return true;
}
function isnumericonly(x){
	var usr=/[0-9]+/;
	uidflag=x.value.match(usr);
	if(uidflag != x.value)
	{
		x.focus();
 		x.select();
		return false;
	}
	return true;
}