var PopWin;
function ChkBlank(_1,_2){
var _3=eval("String(document."+_1+".value)");
var i;
for(i=0;i<_3.length;i++){
if(_3.charAt(i)!=" "){
break;
}
}
if(i==_3.length){
alert(_2);
eval("String(document."+_1+".focus())");
return false;
}else{
return true;
}
}
function ChkSpChars(_5,_6){
spchar=new Array("`","~","#","$","%","^","&","*","(",")","-","+","=","|","/",",","<",">","'",":",";","\\","\"","@","!","_","{","}","[","]",".","?");
var _7=eval("String(document."+_5+".value)");
for(var i=0;i<spchar.length;i++){
if(_7.indexOf(spchar[i])!=-1){
alert(_6);
return false;
}
}
}
function ChkBlankSpace(_9,_a){
spchar=new Array(" ");
var _b=eval("String(document."+_9+".value)");
for(var i=0;i<spchar.length;i++){
if(_b.indexOf(spchar[i])!=-1){
alert(_a);
return false;
}
}
}
function ChkEmail(_d,_e){
emailRegExp=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
if(emailRegExp.test(eval("String(document."+_d+".value)"))){
return true;
}else{
alert(_e);
eval("String(document."+_d+".focus())");
return false;
}
}
function ChkNumber(_f,_10){
var _11=eval("String(document."+_f+".value)");
for(i=0;i<_11.length;i++){
if(i==0&&_11.charAt(i)=="-"){
continue;
}
if((_11.charAt(i)<"0"||_11.charAt(i)>"9")&&_11.charAt(i)!="."){
break;
}
}
if(i<_11.length){
alert(_10);
eval("String(document."+_f+".focus())");
return false;
}else{
return true;
}
}
function ChkStartWithNumber(_12,_13,_14){
var _15=eval("String(document."+_12+".value)");
var _16=_15.substring(0,1);
if(_16==_14 || _16==8 || _16==7){
return true;
}else{
alert(_13);
eval("String(document."+_12+".focus())");
return false;
}
}
function ChkFloat(_17,_18){
var _19=eval("String(document."+_17+".value)");
var i;
if(_19.indexOf(".")!=_19.lastIndexOf(".")){
alert(_18);
eval("String(document."+_17+".focus())");
return false;
}
for(i=0;i<_19.length;i++){
if((_19.charAt(i)<"0"||_19.charAt(i)>"9")&&_19.charAt(i)!="."){
break;
}
}
if(i<_19.length){
alert(_18);
eval("String(document."+_17+".focus())");
return false;
}else{
return true;
}
}
function ChkCombo(_1b,_1c){
var _1d=eval("String(document."+_1b+".selectedIndex)");
var _1e=eval("String(document."+_1b+".options["+_1d+"].value)");
if(_1e=="0"){
alert(_1c);
eval("String(document."+_1b+".focus())");
return false;
}else{
return true;
}
}
function ChkDOB(_1f,_20,_21){
var day=eval("document."+_1f+"[document."+_1f+".selectedIndex].value");
var _23=eval("document."+_20+"[document."+_20+".selectedIndex].value");
var _24=eval("document."+_21+"[document."+_21+".selectedIndex].value");
if(_23=="JAN"){
_23=1;
}else{
if(_23=="FEB"){
_23=2;
}else{
if(_23=="MAR"){
_23=3;
}else{
if(_23=="APR"){
_23=4;
}else{
if(_23=="MAY"){
_23=5;
}else{
if(_23=="JUN"){
_23=6;
}else{
if(_23=="JUL"){
_23=7;
}else{
if(_23=="AUG"){
_23=8;
}else{
if(_23=="SEP"){
_23=9;
}else{
if(_23=="OCT"){
_23=10;
}else{
if(_23=="NOV"){
_23=11;
}else{
if(_23=="DEC"){
_23=12;
}
}
}
}
}
}
}
}
}
}
}
}
if(day<1||day>31){
alert("Day must be between 1 and 31.");
eval("document."+_1f+".focus()");
return false;
}
if(_23<1||_23>12){
alert("Month must be between 1 and 12."+eval("document."+_20+".selected.value"));
eval("document."+_20+".focus()");
return false;
}
if((_23==4||_23==6||_23==9||_23==11)&&day==31){
alert("This month does not have 31 days.");
eval("document."+_20+".focus()");
return false;
}
if(_23==2){
var _25=(_24%4==0&&(_24%100!=0||_24%400==0));
if(day>29||(day==29&&!_25)){
alert("February "+_24+"  does not have "+day+" days.");
eval("document."+_20+".focus()");
return false;
}
}
return true;
}
function ChkDate(_26,_27,_28){
var day=eval("document."+_26+"[document."+_26+".selectedIndex].value");
var _2a=eval("document."+_27+"[document."+_27+".selectedIndex].value");
var _2b=eval("document."+_28+"[document."+_28+".selectedIndex].value");
if(day<1||day>31){
alert("Day must be between 1 and 31.");
eval("document."+_26+".focus()");
return false;
}
if(_2a<1||_2a>12){
alert("Month must be between 1 and 12."+eval("document."+_27+".selected.value"));
eval("document."+_27+".focus()");
return false;
}
if((_2a==4||_2a==6||_2a==9||_2a==11)&&day==31){
alert("This month does not have 31 days.");
eval("document."+_27+".focus()");
return false;
}
if(_2a==2){
var _2c=(_2b%4==0&&(_2b%100!=0||_2b%400==0));
if(day>29||(day==29&&!_2c)){
alert("February "+_2b+"  does not have "+day+" days.");
eval("document."+_27+".focus()");
return false;
}
}
return true;
}
function OpenWindow(url,_2e,wid,hig){
win=open(url,_2e,"width="+wid+",height="+hig+", toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,left=2,top=0");
}
function OpenWindowFullScreen(url,_32){
win=open(url,_32,"fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0");
}
function OpenFixWindow(url,_34,wid,hig){
win=open(url,_34,"width="+wid+",height="+hig+", toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,left=2,top=0");
}
function openPopup(_37,_38){
if(!PopWin||PopWin.closed){
PopWin=window.open(_37,_38,"width=640,height=400,status=yes,scrollbars=yes");
}else{
PopWin.focus();
}
}
function SetZero(_39){
var _3a=eval("String(document."+_39+".value)");
var i;
for(i=0;i<_3a.length;i++){
if(_3a.charAt(i)!=" "){
break;
}
}
if(i==_3a.length){
eval("String(document."+_39+".value=0)");
}else{
return true;
}
}
function validateDates(_3c,_3d){
var _3e=eval("String(document."+_3c+".value)");
if(_3e.indexOf("-")!=-1){
seperator="-";
}else{
seperator="/";
}
if(_3e.length!=0){
var _3f=new String(_3e);
var _40=_3f.indexOf(seperator);
var _41=_3f.substring(0,_40);
_3f=_3f.substring(_40+1);
_40=_3f.indexOf(seperator);
var _42=_3f.substring(0,_40);
_3f=_3f.substring(_40+1);
var _43=_3f;
if(!(_41>0&&_41<32)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if(!(_42>0&&_42<13)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if((!(_43>1900))||(_43.length<4)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if(!(checkDay(_41,_42,_43))){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
}
if(_3e.length!=0){
var _44=new String(_3e);
var _45=_44.indexOf(seperator);
var _46=_44.substring(0,_45);
_44=_44.substring(_45+1);
_45=_44.indexOf(seperator);
var _47=_44.substring(0,_45);
_44=_44.substring(_45+1);
var _48=_44;
if(!(_46>0&&_46<32)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if(!(_47>0&&_47<13)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if((!(_48>1900))||(_48.length<4)){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
if(!(checkDay(_46,_47,_48))){
alert(_3d);
eval("document."+_3c+".focus()");
return false;
}
}
return true;
}
function checkDay(_49,_4a,_4b){
var _4c=[1,2,3,4,5,6,7,8,9,10,11,12];
var _4d="";
if(_4b%4==0){
_4d=[31,29,31,30,31,30,31,31,30,31,30,31];
}else{
_4d=[31,28,31,30,31,30,31,31,30,31,30,31];
}
var _4e=_4d[_4a-1];
if(_49>_4e){
return false;
}
return true;
}
function dateRange(_4f,_50,_51,_52){
var _53=eval("String(document."+_52+".value)");
var _54=_53.replace("/","-");
_54=_54.replace("/","-");
x2=_54.lastIndexOf("-");
x1=_54.indexOf("-");
var _55=_54.substring(x1+1,x2)-1;
var _56=new Date(_54.substring(x2+1,_54.length),_55,_54.substring(0,x1));
if(_56>_4f){
alert("Please give valid bill date. Bill Date can not exceed today's date.");
eval("document."+_52+".focus()");
return false;
}
if(_56<_50||_56>_51){
alert("Please enter the bill only for this financial year.");
eval("document."+_52+".focus()");
return false;
}
return true;
}
function simpleDateRange(_57,_58,_59){
var _5a=_57.replace("/","-");
_5a=_5a.replace("/","-");
var _5b=_58.replace("/","-");
_5b=_5b.replace("/","-");
x2=_5a.lastIndexOf("-");
x1=_5a.indexOf("-");
var _5c=_5a.substring(x1+1,x2)-1;
var _5d=new Date(_5a.substring(x2+1,_5a.length),_5c,_5a.substring(0,x1));
x2=_5b.lastIndexOf("-");
x1=_5b.indexOf("-");
var _5e=_5b.substring(x1+1,x2)-1;
var _5f=new Date(_5b.substring(x2+1,_5b.length),_5e,_5b.substring(0,x1));
if(_5d>_5f){
alert(_59);
return false;
}
return true;
}
function advanceDateRange(_60,_61,_62,_63){
var _64=eval("String(document."+_63+".value)");
var _65=_64.replace("/","-");
_65=_65.replace("/","-");
x2=_65.lastIndexOf("-");
x1=_65.indexOf("-");
var _66=_65.substring(x1+1,x2)-1;
var _67=new Date(_65.substring(x2+1,_65.length),_66,_65.substring(0,x1));
if(_67>_60){
alert("Please give valid payment date. Payment Date can not exceed today's date.");
eval("document."+_63+".focus()");
return false;
}
if(_67<_61||_67>_62){
alert("Please enter the payment only for this financial year.");
eval("document."+_63+".focus()");
return false;
}
return true;
function nothing(){
}
}
function ChkLength(_68,_69,len){
var _6b=eval("String(document."+_68+".value)");
if(_6b.length>len){
alert(_69);
eval("document."+_68+".focus()");
return false;
}
}
function ChkExactLength(_6c,_6d,len){
var _6f=eval("String(document."+_6c+".value)");
if(_6f.length!=len){
alert(_6d);
eval("document."+_6c+".focus()");
return false;
}
}
function ChkMinLength(_70,_71,len){
var _73=eval("String(document."+_70+".value)");
if(_73.length < len && _73.length > 0 ){
alert(_71);
eval("document."+_70+".focus()");
return false;
}
}
function ChkDotInMobile(_74,_75,len){
var j=0;
for(var i=0;i<len;i++){
var _79=eval("String(document."+_74+".value)");
var _7a=_79.substring(j,++j);
if(_7a=="."){
alert(_75);
eval("document."+_74+".focus()");
return false;
}
}
}
function strTrim(_7b){
var j=(_7b.value.length);
var sum=0;
var p;
for(p=0;p<=j;p++){
if(_7b.value.charAt(p)==" "){
sum++;
}else{
break;
}
}
var st=_7b.value.substring(sum,j);
var x=(st.length)-1;
var y=x+1;
var len=0;
var i;
for(i=x;i>=0;i--){
if(st.charAt(i)==" "){
len++;
}else{
break;
}
}
y=y-len;
var str=st.substring(0,y);
_7b.value=str;
}
function callAlert(){
return confirm("If you choose this operation. You will loose the data of the form.\nAre your Sure ?.");
}

function ChkDgChars(_85,_86){
dgchar=new Array("0","1","2","3","4","5","6","7","8","9");
var _87=0;
var _88=eval("String(document."+_85+".value)");
for(var i=0;i<dgchar.length;i++){
if(_88.indexOf(dgchar[i])!=-1){
alert(_86);
return false;
}
}
}

// 2/1/2008 add by KD for check the date validation of from date value is less than the to date value
function ChkCompareDate(_8,_9,_a)
{
	var stDate="";
	var endDate="";
	var check=true;
	var _b=eval("String(document."+_8+".value)");
	var _c=eval("String(document."+_9+".value)");
	var _d=eval("String(document."+_9+".focus())");

	if(_b.indexOf("/") > 0)
		stDate=_b.split("/");
	else
		stDate=_b.split("-");

	if(_c.indexOf("/") > 0)
		endDate=_c.split("/");
	else
		endDate=_c.split("-");

	if(parseInt(stDate[2]) > parseInt(endDate[2])) // stDate[2] & endDate[2] is YYYY,  chk for st year > end year
		check=false;
	else if(parseInt(stDate[2]) == parseInt(endDate[2]))
	{
		if(stDate[1].charAt(0)=="0")
				stDate[1]=stDate[1].substring(1,stDate[1].length);   // for eliminating '0' from '0X' month
		 
			if(endDate[1].charAt(0)=="0")
				endDate[1]=endDate[1].substring(1,endDate[1].length);
		 
		if(parseInt(stDate[1]) > parseInt(endDate[1])) // stDate[1] & endDate[1] is MM , chk for st month > end month
				check=false;
		
		else if(parseInt(stDate[1]) == parseInt(endDate[1]))
		{
			if(stDate[0].charAt(0)=="0")
				stDate[0]=stDate[0].substring(1,stDate[0].length);   // for eliminating '0' from '0X' date
			if(endDate[0].charAt(0)=="0")
				endDate[0]=endDate[0].substring(1,endDate[0].length); 

			if(parseInt(stDate[0]) > parseInt(endDate[0])) // stDate[0] & endDate[0] is DD , chk for st date > end date
				check=false;
		}
	}

	if(check==false)
	{
		alert(_a);
		_d
		return false;
	}	 
}
// 2/1/2008 add by KD for check the date validation of from date value is less than the to date value


//  Added by Abhishek Rastogi for compare two dates & return true OR false on 5/1/2008
function CompareDate(_8a,_9a)
{
	var stDate="";
	var endDate="";
	var check=true;
	var _b=eval("String(document."+_8a+".value)");
	var _c=eval("String(document."+_9a+".value)");
	var _d=eval("String(document."+_9a+".focus())");

	if(_b.indexOf("/") > 0)
		stDate=_b.split("/");
	else
		stDate=_b.split("-");

	if(_c.indexOf("/") > 0)
		endDate=_c.split("/");
	else
		endDate=_c.split("-");

	if(parseInt(stDate[2]) > parseInt(endDate[2])) // stDate[2] & endDate[2] is YYYY,  chk for st year > end year
		check=false;
	else if(parseInt(stDate[2]) == parseInt(endDate[2]))
	{
		if(stDate[1].charAt(0)=="0")
				stDate[1]=stDate[1].substring(1,stDate[1].length);   // for eliminating '0' from '0X' month
			if(endDate[1].charAt(0)=="0")
				endDate[1]=endDate[1].substring(1,endDate[1].length);

		if(parseInt(stDate[1]) > parseInt(endDate[1])) // stDate[1] & endDate[1] is MM , chk for st month > end month
			check=false;
		else if(parseInt(stDate[1]) == parseInt(endDate[1]))
		{
			if(stDate[0].charAt(0)=="0")
				stDate[0]=stDate[0].substring(1,stDate[0].length);   // for eliminating '0' from '0X' date
			if(endDate[0].charAt(0)=="0")
				endDate[0]=endDate[0].substring(1,endDate[0].length);

			if(parseInt(stDate[0]) > parseInt(endDate[0])) // stDate[0] & endDate[0] is DD , chk for st date > end date
				check=false;
			if(parseInt(stDate[0]) == parseInt(endDate[0]))
					check=true;
		}
	}

	if(check==false)
	{		
		return false;
	}
	else 
		return check; 
}
//  Added by Abhishek Rastogi for compare two dates & return true OR false on 5/1/2008

// use this function to blink the text in IE & FIREFOX browser added by Abhishek R on 1/22/2010 

spe=500;
na=document.getElementsByTagName("blink");
swi=1;
bringBackBlinky();

function bringBackBlinky() {

if (swi == 1) {
sho="visible";
swi=0;
}
else {
sho="hidden";
swi=1;
}

if(na.length > 0)
{
	for(i=0;i<na.length;i++) {
	na[i].style.visibility=sho;
	}
}
setTimeout("bringBackBlinky()", spe);
}


//added bay gaurav 4 oct 10
//this function checks the format of the string eg. SR12345
function checkFormat(el,chars,nums,msg)
{
	var val=eval("String(document."+el+".value)");
	var validChars='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var validNums='1234567890';
	var count=0;
	if(val.length != (chars+nums))
	{
		alert('Invalid length');
		eval("String(document."+el+".focus())");
		return false;
	}
	for(count=0;count<chars;count++)
	{
		if(validChars.indexOf(val.substring(count,count+1).toUpperCase())==-1)
		{
			alert(msg);
			eval("String(document."+el+".focus())");
			return false;
		}
	}
	for(count=0;count<nums;count++)
	{
		if(validNums.indexOf(val.substring((chars+count),(chars+count)+1))==-1)
		{
			alert(msg);
			eval("String(document."+el+".focus())");
			return false;
		}
	}
	return true;

}

// Added by Abhishek R to check the format of year and year must be current or greater on 11/17/2011 
function chkDateYear(v1, v2, v3)
{
	var instDate = eval("String(document."+v1+".value)");
	var rdate = "";
	var currYear = parseInt(v3);
	
	if(instDate.indexOf("/") > 0)
		rdate = instDate.split("/")
	else
		rdate = instDate.split("-")
	
	//alert('YAER: '+ parseInt(rdate[2]) +'\n curr year: '+ parseInt(currYear))

	if(rdate[2].length !=4)
	{
		alert(v2);
		eval("document."+v1+".focus()");
		return false;
	}

	if(parseInt(rdate[2]) < parseInt(currYear))
	{
		alert(v2);
		eval("document."+v1+".focus()");
		return false;
	}
}

function limitTextArea(elementName, elementLimit, msg)
{
	var text=eval("String(document."+elementName+".value)");
	if(text.length>elementLimit)
	{
		eval("document."+elementName+".value = document."+elementName+".value.substring(0,("+elementLimit+"-10))");
		eval("document."+elementName+".blur()");
		alert(msg);
		eval("document."+elementName+".focus()");
		return false;
	}
	return true;
}
