function validateradio(cnt){
	var FstCode=document.all(cnt);
	var flag=false;
	for(i=0;i<FstCode.length;i++){
		if(FstCode[i].checked==true)
			flag=true;
	}
	if(flag==false){
		alert('Please Select ' +cnt );
		return false;
	}
	return true;
}
function validateEqual(Email,ConfirmEmail){
	var e=document.all('Email');
	var c=document.all('ConfirmEmail');
	if(e.value!=c.value){
			alert(Email +' and '+ConfirmEmail + 'should be Same'); 	
			return false;
	}
	return true;
	
}
function isExist(cstr,tocheck)
{
			var regex1
			regex1=new RegExp(tocheck,"gi")
			if(regex1.test(cstr))
				return true
			else
				return false

}
function validatecombo(str){
		var cnt
		cnt=document.all(str)
		if(cnt.selectedIndex==0){
				alert("Please Select ");
				cnt.focus();
				return false;
		}
		else{
				return true;
		}
}

function  isEmpty(cntname)
{
	cnt=document.all(cntname)
	if(cnt.value=="")
		return true
	else
		return false
	
}

function getFocus(cstr)
{
	cnt=document.all(cstr)
	cnt.focus()
}


function replaceit(str,replacechar,replacewith)
{
	var regstr=new RegExp(replacechar,"gi")
	str=str.replace(regstr,replacewith)
	return str
}
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
//   while (ch == " ") { // Check for spaces at the beginning of the string
  //    retValue = retValue.substring(1, retValue.length);
    //  ch = retValue.substring(0, 1);
   //}
   ch = retValue.substring(retValue.length-1, retValue.length);

   while (ch == " " || (ch.charCodeAt(0)==10) || (ch.charCodeAt(0)==9) || (ch.charCodeAt(0)==13)) { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
//   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
  //    retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
//   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function



function validateto(cnt)
{
	var Name
	Name=document.all(cnt)
	if(isEmpty(cnt))
		{
			
			alert(cnt+" Can't left blank")
			getFocus(cnt)
			return 0
		}
	
	return 1
}

function validateEmail()
{
	var Email
	Email=document.all("Email")
	if(isEmpty("Email"))
		{
			alert("Email  can't left blank")
			getFocus("Email")
			return 0
		}
		if(checkspecial(Email.value,"[^a-zA-Z0-9\x2d\x5F\x40\.]"))
			{
					alert("\n Not a valid E-mail Address")
					getFocus("Email")
					return 0
			}
		else
			{
				if(!isExist(Email.value,"@"))
					{
					alert("\n Not a valid E-mail Address")
					Email.focus()
					return 0
					}
		
			}
	
	return 1
}

function validate_email(str)
{
	var Email
	Email=document.all(str)
	if(isEmpty(str))
		{
			alert("Email  can't left blank")
			getFocus(str)
			return 0
		}
		if(checkspecial(Email.value,"[^a-zA-Z0-9\x2d\x5F\x40\.]"))
			{
					alert("\n Not a valid E-mail Address")
					getFocus(str)
					return 0
			}
		else
			{
				if(!isExist(Email.value,"@"))
					{
					alert("\n Not a valid E-mail Address")
					Email.focus()
					return 0
					}
		
			}
	
	return 1
}


function validatecuseremail()
{
	var cuseremail
	cuseremail=document.all("cuseremail")
	if(isEmpty("cuseremail"))
		{
			alert("Confirm Email  can't left blank")
			getFocus("cuseremail")
			return 0
		}
	if(cuseremail.value!=document.all("useremail").value)
		{
			alert("Confirm Email  is not Same !!")
			getFocus("cuseremail")
			return 0
		}
	return 1
}

function validateconfirmpassword()
{

	var cuserpassword
	cuserpassword=document.all("cpassword")
	if(isEmpty("cpassword"))
		{
			alert("Confirm Password can't left blank")
			getFocus("cpassword")

			return 0
		}
	if(cuserpassword.value!=document.all("password").value)
		{

		alert("Confirm Password is not same !!")
			
		getFocus("cpassword")
	  	return 0
		}

	return 1
}

function validateuserpassword()

{

	var userpassword
	userpassword=document.all("password")
	if(isEmpty("password"))
		{

			alert("userpassword can't left blank")
			getFocus("password")
			return 0
		}
		var passlength
		passlength=userpassword.value

	if(passlength.length <6)  
		{

		alert("Password should be between 6 and 12 characters")
		getFocus("password")
		return 0
		}
	if(passlength.length > 12) 
		{
						set_class("cpassword",wrong)
		alert("Password should be between 6 and 12 characters")
		getFocus("password")
		return 0
		}
					
	return 1
}
function validatewordlimit()
{
	wordlimit=document.all("wordlimit")
	if(isEmpty("wordlimit"))
		{
		alert("Can't left blank")
		getFocus("wordlimit")
		return 0
		}
	cstr=wordlimit.value
	if(checkspecial(cstr,"[^0-9]"))
		{
		alert("should be integer numberic")
		getFocus("wordlimit")
	  	return 0
		}
	if(parseInt(cstr)>1000)
		{
		alert("should be less then 1000 ")
		getFocus("wordlimit")
	  	return 0
		}
		
		
	return 1
}
function validatefloat(cnt)
{
	wordlimit=document.all(cnt)
	if(isEmpty(cnt))
		{
		alert(cnt+ " Can't left blank")
		getFocus(cnt)
		return 0
		}
	cstr=wordlimit.value
	if(checkspecial(cstr,"[^0-9\.]"))
		{
		alert(cnt +" should be  numberic")
		getFocus(cnt)
	  	return 0
		}
	
		
		
	return 1
}
function validateint(cnt)
{
	wordlimit=document.all(cnt)
	if(isEmpty(cnt))
		{
		alert("Can't left blank")
		getFocus(cnt)
		return 0
		}
	cstr=wordlimit.value
	if(checkspecial(cstr,"[^0-9]"))
		{
		alert("should be  Integer  numberic")
		getFocus(cnt)
	  	return 0
		}
	
		
		
	return 1
}

function checkspecial(cstr,tocheck)
{
			var regex1
			regex1=new RegExp(tocheck,"gi")
			if(regex1.exec(cstr)==null)
				return false
			else
				return true
			
}



