<!-- Hide From the old browsers
//				Copy right Bosco Infotech 2002 :: Author : Loganathan N , logudotcom@yahoo.com  
// 						 All rights are reserved . 

function TextValidate(txtCtrl,val) {
	var ctrName = val;		
	Remove_Spaces(txtCtrl);		
	if (txtCtrl.value == "") {		
		alert("Please enter your " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}
	if(txtCtrl.value.indexOf("'") > -1){		
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}

// to check pdf or doc file formats
function chkExtension(fileCtrl, file_type, imgName) {

	if(fileCtrl.value != ""){		
		var len = fileCtrl.value.length;
		var type = fileCtrl.value.substr(len-3,3);

		if (file_type="img" && (type == "jpg" || type == "gif" || type == "bmp" || type == "BMP" || type == "png" || type == "JPG" || type == "GIF" || type == "peg" || type == "PEG")) {	
			fileCtrl.src="file:///" + fileCtrl.value;
			if(imgName != "") {
				imgName.src		= "file:///" + fileCtrl.value;
				imgName.height 	= 90;
				imgName.width 	= 100;
			}
			return true;
		} else {
			fileCtrl.value = '';
			alert("Please upload valid file");
			return false;				
		} 
	} 
}		


// required fileds
function chkFileExtension(fileCtrl) {
	if(fileCtrl.value != ""){		
		var len = fileCtrl.value.length;
		var type = fileCtrl.value.substr(len-3,3);

		if (type == "pdf" || type == "doc") {	
			fileCtrl.src="file:///" + fileCtrl.value;
			return true;
		} else {
			fileCtrl.value = '';
			alert("Please select valid file(.pdf .doc) to upload!");
			return false;				
		} 
	} 
}


function DateValidate(txtCtrl,val) {	
	var ctrName = val;
//	alert (ctrName);		
	Remove_Spaces(txtCtrl);
	if(txtCtrl.value != "")
	{		
		var strarr = txtCtrl.value.split("/");
		var d = strarr[0];
		var m = strarr[1];
		var y = strarr[2];
		var len = strarr.length;
		date =new Date();
		if(len > 3 || isNaN(d) || isNaN(m) || isNaN(y) || d<1 || m<1 || m>12 || y<date.getFullYear()-40 || y > date.getFullYear())
		{
			alert("Please enter valid " + ctrName + ".");			
			txtCtrl.focus();
			txtCtrl.select();
			return false;
		}
		if( y == date.getFullYear())
		{
			if(m == date.getMonth()+1)
			{
				if(d > date.getDate())
				{
					alert("Please enter valid" + ctrName + ".");		
					txtCtrl.focus();
					txtCtrl.select();
					return false;
				}
			}
			else if (m > date.getMonth()+1)
			{
				alert("Please enter valid " + ctrName + ".");		
				txtCtrl.focus();
				txtCtrl.select();
				return false;
			}
		}					
		if (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
		{
			if(d>31 || d<=0)
			{
				alert("Please enter valid " + ctrName + ".");		
				txtCtrl.focus();
				txtCtrl.select();
				return false;
			}	
		}
		else if(m==2)
		{	
			if(y%4 ==0)
			{
				if(d >29 || d<1)
				{
					alert("Please enter valid " + ctrName + ".");		
					txtCtrl.focus();
					txtCtrl.select();
					return false;
				}
			}
			else
			{
				if(d >28 || d<1)
				{
					alert("Please enter valid " + ctrName + ".");		
					txtCtrl.focus();
					txtCtrl.select();
					return false;
				}
			}
		}
		else
		{	
			if(d >30 || d<=0)
			{
				alert("Please enter valid " + ctrName + ".");		
				txtCtrl.focus();
				txtCtrl.select();
				return false;
			}
		}	
	}
}

function TextAreaValidate(txtCtrl, val) {	
	var ctrName	= val;
	//Remove_Spaces(txtCtrl);	
	var str = txtCtrl.value;
	if(str.length<0){
		alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	   	
		return false;
	}		
}
//-----------------------------------------------------------
function NumberValidate(txtCtrl, val) {
	var ctrName = val;
	Remove_Spaces(txtCtrl);
	if (txtCtrl.value == "" || isNaN(txtCtrl.value)) {
		alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	   	
		return false;
	}		
}

function NumberValidateCheck(txtCtrl) {
	Remove_Spaces(txtCtrl);
	var fLength = txtCtrl.value.length;
	if (fLength == 0) {
 		return false;
	}		
	// Required but check Empty
	if (txtCtrl.value == "" || isNaN(txtCtrl.value)){ 	
			alert("The value " + txtCtrl.value + " is not a vaild data.\n\r" +  
				"Enter numeric values !");		
			txtCtrl.focus();
			txtCtrl.select();
			return false;	
	}		
}

//-----------------------------------------
// Req field
function EmailValidate(txtCtrl, val) {
	var ctrName = val;
	Remove_Spaces(txtCtrl);
	txtCtrl.value=txtCtrl.value.replace(/ \*/g,"");

	if (txtCtrl.value.indexOf("@") < 2 ||txtCtrl.value.indexOf(".") < 0) {
		alert("Please enter valid email Id");
		txtCtrl.focus();	   	
		txtCtrl.select();
		return false;
	}		
	if(txtCtrl.value.indexOf("'") > -1){		
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			

}
// Not req, but check format - use onblur
function EmailValidateCheck(txtCtrl) {
	var xlogus = txtCtrl.value.length;
	Remove_Spaces(txtCtrl);
	txtCtrl.value=txtCtrl.value.replace(/ \*/g,"");

	if (xlogus == 0) {
 		return false;
	}
	if (txtCtrl.value.indexOf("@") < 2 ||txtCtrl.value.indexOf(".") < 0) {
		alert("Please enter a valid email id.\n me@you.com");		
		txtCtrl.focus();	   	
		txtCtrl.select();
		return false;
	}		
	if(txtCtrl.value.indexOf("'") > -1){		
		alert("Please Don't enter ' ." );		
		txtCtrl.focus();   	
		return false;		
	}			
}

//-----------------------------------------
// Req
function PhoneValidate(txtCtrl,val) {	

	var fLength = txtCtrl.value.length; // Length of supplied field in characters.
	
	// If field is empty do nothing
	// Not Required but need valid
	if ( fLength == 0) {
 		return true;
	}	
	var ctrName = val;
	// Not Required but check format
		if (txtCtrl.value.indexOf("-") < 2 ) {		
		//alert("The value " + txtCtrl.value + " is not a vaild data.\n\r" +  
		//"Enter a valid phone number !");			
		alert(" Please enter " + ctrName + ".");
		txtCtrl.focus();
		txtCtrl.select();
		return false;	
		}
//	var ctrName = val;
	//if (txtCtrl.value.indexOf("-")<0) {	
		//alert(" Please enter " + ctrName + ".");
//		txtCtrl.focus();	   	
//		return false;
//	}		
	if(txtCtrl.value.indexOf("'") > -1){		
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}


// Not req, but check format - use onblur
function PhoneValidateCheck(txtCtrl) {
	var xlogus = txtCtrl.value.length;
	if (xlogus == 0) {
 		return false;
	}
	var strarr = txtCtrl.value.split("-");
	var first = strarr[0];
	var last = strarr[1];
	if (txtCtrl.value.indexOf("-") < 3 || isNaN(first) || isNaN(last)|| txtCtrl.value.indexOf(".") != -1 || first.length < 3 || last.length < 4 ) {
		alert("Please enter a valid phone number.");
		txtCtrl.focus();	   	
		txtCtrl.focus();
		return false;
	}		
	if(txtCtrl.value.indexOf("'") > -1){		
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}


//-------------------------
//Req
/*function DateValidate(txtCtrl,val) {
	var	ctrName = val;
	if (txtCtrl.value == "") {
		//alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	   	
		return false;
	}		
}*/
// Req
function SelValidate(selCtrl) {
	if (selCtrl.value == "" || selCtrl.value == "0" || selCtrl.value== "Please select") {
		alert("Please select an option in the list.");
		selCtrl.focus();	   	
		return false;
	}		
}

function OptValidate(optCtrl) {
	  var el = document.forms[0].elements;
	for(var i = 0 ; i < el.length ; ++i){
			if(el[i].type == "radio"){
		var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		var itemchecked = false;
		for(var j = 0 ; j < radiogroup.length ; ++j) {
		if(radiogroup[j].checked){
          itemchecked = true;
          break;
         }
    }
    if(!itemchecked) {
     alert("Please choose an option for "+el[i].name+".");
     if(el[i].focus)
      el[i].focus();
         return false;
		}
   }
  }
} // Function End

function CloseWindow() {
		window.close();
		window.opener.focus();
	} 

function Remove_Spaces(txtCtrl){
  txtCtrl.value = txtCtrl.value.replace(/\r/g, " ");

  txtCtrl.value = txtCtrl.value.replace(/[^ A-Za-z0-9`~!@#\$%\^&\*\(\)-_=\+\\\|\]\[\}\{'";:\?\/\.>,<]/g, "");

  txtCtrl.value = txtCtrl.value.replace(/'/g, "");

  txtCtrl.value = txtCtrl.value.replace(/ +/g, " ");

  txtCtrl.value = txtCtrl.value.replace(/^\s/g, "");

  txtCtrl.value = txtCtrl.value.replace(/\s$/g, "");
  
  if (txtCtrl.value == ' '){	
	 txtCtrl.value = '';
   }
 
 }
//-->

function LeastPass(txtCtrl){
	
//	if (txtCtrl1.value.length <5)

}
// Function for Compare Two passwords
function Comparetextboxes(txtCtrl1, txtCtrl2) {
	//Find length
	if(txtCtrl1.value.length <5){
		alert("The password should be atleast 5 characters !");
		txtCtrl1.focus();	
		return false;
	}
	if(txtCtrl1.value.indexOf("'") > -1){		
		alert("Please Don't enter '.");		
		txtCtrl1.focus();   	
		return false;		
	}			
	// Find length
	if(txtCtrl2.value.length <5){
		alert("The retype password should be atleast 5 characters !");
		txtCtrl2.focus();	
		return false;
	}		
	if(txtCtrl2.value.indexOf("'") > -1){		
		alert("Please Don't enter '.");		
		txtCtrl2.focus();   	
		return false;		
	}			
	if (txtCtrl1.value != txtCtrl2.value) {
		alert("The password and retype password does not match !");
		txtCtrl1.focus();	   	
		return false;
	}
}

function chkFile(frmName)	{
	if(frmName.file.value != "")	{		
						var strarr = frmName.file.value.split(".");
						var len = strarr.length;
						if(len != 2){
							alert("Please check your file name !");
							frmName.file.focus();
							frmName.file.select();
							return false;
						}
						var type = strarr[1];						
						if (type < 3) {							
							alert("Please check your file format !");
							frmName.file.select();
							return 1;
						}						
					}		
		}
// ----------------------Logu inserted on Feb 06, 2003, 11:21 GMT HRS 				
<!-- Begin
function checkLength(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
// End -->