<!-- Hide From the old browsers
function TextValidate(txtCtrl,val) {
	var ctrName = val;
	Remove_Spaces(txtCtrl);
	if (txtCtrl.value == "") {
		alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	
		return false;		
	}
	if(txtCtrl.value.indexOf("'") > -1)
	{
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}

function ImageValidate(txtCtrl,val) {
	var ctrName = val;
	Remove_Spaces(txtCtrl);
	if (txtCtrl.value == "") {
		alert("Please browse " + ctrName + ".");
		txtCtrl.focus();	
		return false;		
	}
	if(txtCtrl.value.indexOf("'") > -1)
	{
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}

//Text Area
function TextAreaValidate(txtCtrl,val) {
	var ctrName = val;
	if (txtCtrl.value == "") {
		alert("Please enter " + ctrName + ".");
		txtCtrl.focus();	
		return false;		
	}
	if(txtCtrl.value.indexOf("'") > -1)
	{
		alert("Please Don't enter ' in " + ctrName + ".");		
		txtCtrl.focus();   	
		return false;		
	}			
}

// Function for Compare Two passwords
function ComparePassword(txtCtrl1, txtCtrl2) {
	//Find length
	if(txtCtrl1.value.length < 4){
		alert("The password should be atleast 4 characters !");
		txtCtrl1.focus();	
		return false;
	}
	// Find length
	if(txtCtrl2.value.length < 4){
		alert("The Confirm password should be atleast 4 characters !");
		txtCtrl2.focus();	
		return false;
	}		
	if (txtCtrl1.value != txtCtrl2.value) {
		alert("The password and Confirm password does not match!");
		txtCtrl1.focus();	   	
		return false;
	}
}

// Req
function SelValidate(selCtrl,val) {
	if(!val) val = "list";
	if (selCtrl.value == "" || selCtrl.value == "0" || selCtrl.value== "Please select") {
		alert("Please select an option in the "+val);
		selCtrl.focus();	   	
		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 Comparedate(fdate,tdate)
{
	
	var strarr = fdate.value.split("-");
	strarr = fdate.value.split("-");	
	var y = strarr[2];
	var m = strarr[1];
	var d = strarr[0];
	var strarr = tdate.value.split("-");

	var y1 = strarr[2];
	var m1 = strarr[1];
	var d1 = strarr[0];
	if( y == y1)
	{
		if(m == m1)
		{
			if(d > d1)
			{
				alert("Start date exceeds End date date!");		
				tdate.focus();
				tdate.select();
				return false;
			}
		}
		else if (m > m1)
		{
			alert("Start date exceeds End date mon!");			
			tdate.focus();
			tdate.select();
			return false;
		}
	}	
	if(y > y1)				
	{
		alert("Start date exceeds End date yea!");		
		tdate.focus();
		tdate.select();
		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 == "JPG" || 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 if (file_type =="both" && (type == "pdf" || type == "doc" || type == "jpg" || type == "JPG" || type == "peg" || type == "PEG")) {	
			fileCtrl.src="file:///" + fileCtrl.value;
			return true;
		} else if (file_type =="doc" && (type == "pdf" || type == "doc" || type == "xls" || type == "zip" || type == "rar"|| type == "ppt")) {	
			fileCtrl.src="file:///" + fileCtrl.value;
			return true;
		} else {
			fileCtrl.value = '';
			alert("Please upload valid file");
			return false;				
		} 
	} 
}

function openWindow(url, argwidth, argheight){
	features = "width=" + argwidth + ",height=" + argheight + ",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=yes";
	open(url,'', features);
}

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 = '';
   }
 
 }
// End -->
