	function isNumeric(Input){
		var numbers="0123456789+ -";
		var CharacterCheck;
		var counter = 0; 
	
		for (var i=0; i < Input.length; i++){
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1){
				counter ++;
			}
		}
		if (counter != Input.length){
			return true;
		}
		return false;
	} 	
	
		
	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)
		{
			msg+="\n- Invalid Email Id";
		   return false
		}
	
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			msg+="- Invalid Email Id\n";
		   return false
		}
	
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			msg+="- Invalid Email Id\n";
			return false
		}
	
		 if (str.indexOf(at,(lat+1))!=-1){
			msg+="- Invalid Email Id\n";
			return false
		 }
	
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			msg+="- Invalid Email Id\n";
			return false
		 }
	
		 if (str.indexOf(dot,(lat+2))==-1){
			msg+="- Invalid Email Id\n";
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
			msg+="- Invalid Email Id\n";
			return false
		 }
	
		 return true;					
	}
	
	function isemail(Input) 
	{
		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@.-";
		var CharacterCheck;
		var counter = 0; 
	
		for (var i=0; i < Input.length; i++){
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1){
				counter ++;
			}
		}
		if (counter != Input.length){
			return true;
		}
		return false;
	} 
	
	function blockNonNumbers(obj, e, allowDecimal, allowNegative)
	{
		var key;
		var isCtrl = false;
		var keychar;
		var reg;
			
		if(window.event) {
			key = e.keyCode;
			isCtrl = window.event.ctrlKey
		}
		else if(e.which) {
			key = e.which;
			isCtrl = e.ctrlKey;
		}
		
		if (isNaN(key)) return true;
		
		keychar = String.fromCharCode(key);
		
		// check for backspace or delete, or if Ctrl was pressed
		if (key == 8 || isCtrl)
		{
			return true;
		}
	
		reg = /\d/;
		var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
		var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
		
		return isFirstN || isFirstD || reg.test(keychar);
		
	}
	
	
	function nullcheck(fname,fldname,disname)
	{
		ctrl_val=eval('document.'+fname+'.'+fldname+'.value');
		ctrl_name=eval('document.'+fname+'.'+fldname+'.name');
		disname = '"'+disname+'"';
		if(Trim(ctrl_val)=='')
		{	
			msg+="\n- "+disname+" field should not be blank";
			return false;
		}
			return true;
	}
	
	function select_nullcheck(fname,fldname,disname)
	{
		ctrl_val=eval('document.'+fname+'.'+fldname+'.value');
		ctrl_name=eval('document.'+fname+'.'+fldname+'.name');
		disname = '"'+disname+'"';
		if(ctrl_val=='')
		{
	
			msg+="\n- Please Select "+disname;
			return false;
		}
			return true;
	}
	
	function calldelete(fname,bname,cname)
	{
		ctrl=eval('document.' + fname+'.'+cname+'.checked');
		if(ctrl){
			var answer=confirm("Are you want to delete?");
			if(answer){
				eval('document.'+fname+'.'+bname+'.value="Delete"');
				return true;
			}else{
				eval('document.'+fname+'.'+bname+'.value ="Update"');
				eval('document.'+fname+'.'+cname+'.checked=false');
				return false;
			}
		}
		else{
				eval('document.'+fname+'.'+bname+'.value ="Update"');
			return false;
		}
	}


function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}

function Trim(str)
{
  return RTrim(LTrim(str));
}

//added by prabhakaran
function trim(inputString) {
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { 
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { 
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { 
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
	   }
	   return retValue; 
	}
	
function validateRetypePassword(passwd1,passwd2){
	if(passwd1 != passwd2 ){
		strErrMsg = strErrMsg + "Confirmation Password is not matching with the Password." +"\n" ;
	}
}

function validateMinLength(formField,len, pstrMsg){
	var fieldLen = formField.length
	if(fieldLen < len){
		strErrMsg = strErrMsg + pstrMsg + " should be atleast "+ len +" characters." + "\n";
	}
	
}

function validateMaxLength(formField,len, pstrMsg){
	var fieldLen = formField.length;
	if(fieldLen > len){
		strErrMsg = strErrMsg + pstrMsg + " cannot be more than "+ len +" characters." + "\n";
	}
	
}
function isAlphabets(Input,field) 
	{
		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. ";
		var CharacterCheck;
		var counter = 0; 
	
		for (var i=0; i < Input.length; i++){
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1){
				counter ++;
			}
		}
		if (counter != Input.length){
	msg+="\n- Invalid Field value"+field;
			return true;
		}
			
		return false;
	}
	
	function isNumeric(Input,field)
	{
		var numbers="0123456789+ -";
		var CharacterCheck;
		var counter = 0; 
	
		for (var i=0; i < Input.length; i++){
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1){
				counter ++;
			}
		}
		if (counter != Input.length){
			return true;
		}
				msg+="\n- Invalid "+field;
		return false;
	} 
	
		function validateUserInfo() {
	
		msg="";
		nullcheck("frmRegistration","txtFirstName","FirstName");
			var FirstName=document.frmRegistration.txtFirstName.value;
		if(FirstName!='')	{
			isNumeric(FirstName,"First Name");
		}
		nullcheck("frmRegistration","txtLastName","LastName");
		var LastName=document.frmRegistration.txtLastName.value;
		if(LastName!='')	{
			isNumeric(LastName,"Last Name");
		}
		nullcheck("frmRegistration","txtLoginName","Login Name");
		nullcheck("frmRegistration","txtPassword","Password");
		nullcheck("frmRegistration","txtEmail","Email");
		nullcheck("frmRegistration","txtAddress1","Address1");
		nullcheck("frmRegistration","txtAddress2","Address2");
			
			var Email=document.frmRegistration.txtEmail.value;
		if(Email!='')	{
			echeck(Email);
		}
		nullcheck('frmRegistration','txtCity','City');
		nullcheck('frmRegistration','txtState ','State');
		nullcheck('frmRegistration','txtZip ','Zip');
		/*var Zip=document.frmRegistration.txtZip.value;
			if(Zip!='')	{
				isNumeric(Zip,"Zip");
			}*/
		select_nullcheck('frmRegistration','cboCountry','Country');


//		nullcheck('frmRegistration','txtDOB','Date Of Birth');
		nullcheck("frmRegistration","txtTuring","Image Verification")
		
		if(msg!=""){
			msg="Please fill the following field(s)\n________________________________________\n"+
			msg +"\n________________________________________";
			alert(msg);	
			return false;
		}
		return true;
		


			
	}
function select_blognullcheck(fname,fldname,disname)
	{
		ctrl_val=eval('document.'+fname+'.'+fldname+'.value');
		ctrl_name=eval('document.'+fname+'.'+fldname+'.name');
	
		if(ctrl_val=='-1')
		{
	
			msg+="\n- Please Select "+disname;
			return false;
		}
			return true;
	}

function conPassword(argPwd,argConPwd)
{
	if(argPwd!=argConPwd)
	{
		msg+="\n- New Password and Confirm Password must be same";
		return false
	}
	return true

}

/*function fnDateAdd(argValue,argFormat){
	myDate = new Date();
	var m_names = new Array("Jan", "Feb", "Mar","Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

	k = new Date(myDate.setDate(myDate.getDate() + argValue));

	var curr_date = k.getDate();
	var curr_month = k.getMonth();
	var curr_year = k.getFullYear();

	if(argFormat==1){
		document.write(curr_date + " " + m_names[curr_month] + ", " + curr_year);
	}else{
		curr_month=curr_month+1;
		document.write(curr_year + "/" + curr_month++ + "/" + curr_date);
	}
}*/

function fnDateAdd(argValue,argFormat){
	myDate = new Date();
	var m_names = new Array("Jan", "Feb", "Mar","Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

	k = new Date(myDate.setDate(myDate.getDate() + argValue));

	var curr_date = k.getDate();
	var curr_month = k.getMonth();
	var curr_year = k.getFullYear();

	if(argFormat==1){
	return (curr_date<10) ? "0"+curr_date +" "+ m_names[curr_month] + ", " + curr_year : curr_date + " " + m_names[curr_month] + ", " + curr_year;
	}else{
		curr_month=curr_month+1;
		if(curr_date<10){
			curr_date="0"+curr_date;
		}else{
			curr_date=curr_date;		
		}
//		curr_month++;
		if(curr_month<10){
			curr_month="0"+curr_month;
		}else{
			curr_month=curr_month;		
		}
	return curr_year + "/" + curr_month + "/" + curr_date;
	}
}
function addOption(selectbox,text,value,argSelect){
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	if(argSelect=='yes'){
		//alert("Formatted Date: " + text + "\n" + "Date Value: " + value);
		optn.selected = true;	
	}
	selectbox.options.add(optn);
}
// EOF

