
	/*	obj is the Object on which check is required. 
		objName is the Name of the Object to be displayed.
		The function checks the Blank value & prompts the user	*/
	function checkBlankMessage(obj,objName)
	{
		if ( obj.value == "" )
		{
			alert("Please enter "+objName);
			obj.focus();
			return false;
		}//end if()
		else
			return true;
	}//end isBlank()

	function checkDropDown(obj,objName)
	{
		if ( obj.value == "" )
		{
			alert("Please select "+objName);
			obj.focus();
			return false;
		}//end if()
		else
			return true;
	}//end isBlank()
	function checkExpDate(){
		var d = new Date();
		var year = getFullYear();
		var month = gettMonth();
		
		if(document.getElementById('ccexpiry_y').value < year){
			alert('Please check expire date of your credit card');
			return false;
		}else{
			if(document.getElementById('ccexpiry_y').value < month && document.getElementById('ccexpiry_y').value < year){
				alert('Please check expire date of your credit card');
				return false;
			}else{
				return true;
			}
		}
	}
	/*	obj is the Object on which $$check is required. 
		The function only checks the Blank value without prompting the user	*/
	function checkBlank(obj)
	{
		if (obj.value == "")
			return true;
		else
			return false;
	}//end checkBlank()
	
	function doBlank(obj)
	{
		obj.value="";
	}//end checkBlank()
	
	
	/*	obj is the Object on which check is required. 
		dateChar is the Character to split Day, Month & Year.
		objName is the Name of the Object to be displayed.
		firstElement is the First portion of the Date.
		secondElement is the Second portion of the Date.
		thirdElement is the Third portion of the Date.	*/
	function checkDate(obj,dateChar,objName,firstElement,secondElement,thirdElement)
	{
		if ( ! checkBlank(obj) )
		{
			var tot=0 , first=0	, second=0;
			/*	tot is to count the characters that split Day, Month & Year.
				first is to point the position of the first occurence of the splitting char.
				second is to point the position of the second occurence of the splitting char.	*/
			for(i=0;i<obj.value.length;i++)
			// to count the splitting chars & position the occurences of the char.
			{
				if(obj.value.charAt(i) == dateChar)
				{
					if (first == 0)
						first=i;
					else
					{
						if (second == 0)
							second=i;
					}//end else
					tot=tot+1;
				}//end if()
			}//end for()

			if (tot==2)
			{
				if (firstElement == "Month" )
					enteredMon=obj.value.substring(0,first);
				else if (firstElement == "Day" )
					enteredDay=obj.value.substring(0,first);
				else if (firstElement == "Year" )
					enteredYear=obj.value.substring(0,first);
					
				if (secondElement == "Month")
					enteredMon=obj.value.substring(first+1,second);
				else if (secondElement == "Day")
					enteredDay=obj.value.substring(first+1,second);
				else if (secondElement == "Year")
					enteredYear=obj.value.substring(first+1,second);
					
				if (thirdElement == "Month")
					enteredMon=obj.value.substring(second+1,obj.value.length);
				else if (thirdElement == "Day")
					enteredDay=obj.value.substring(second+1,obj.value.length);
				else if (thirdElement == "Year")
					enteredYear=obj.value.substring(second+1,obj.value.length);

				if (enteredMon!="" && enteredDay!="" && enteredYear!="")
				{
					if (enteredMon>12 || enteredDay>31 || enteredYear.length!=4)
					{
						alert(objName+" should be in proper format");
						obj.focus();
						return false;
					}//end if()
					else
					{
						dt=new Date();
						currentDay=dt.getDate();
						currentMon=dt.getMonth();
						currentYear=dt.getYear();
						currentMon=currentMon+1;

						if(enteredYear>currentYear)
						{
							alert(objName+" must be less than today's date !");
							obj.focus();
							return false;
						}
						else
						{
							if(enteredYear==currentYear && enteredMon>currentMon)
							{
								alert(statement+" must be less than today's date !");
								obj.focus();
								return false;
							}
							else
							{
								if(enteredMon==currentMon && enteredDay>currentDay)
								{
									alert(objName+" must be less than today's date !");
									obj.focus();
									return false;
								}

							}//end else
						}//end else

					}//end else
				}//end if()
			}//end if()
			else
			{
				alert(objName+" should be in proper format");
				obj.focus();
				return false;
			}//end else
		}//end if()
		return true;
	}//end checkDate()
	
	/*	obj is the Object on which check is required.
		len is the length of the Object that is required. 
		objName is the Name of the Object to be displayed.
		The function checks the specified length of the Object	*/
	function checkLengthGreater(obj,len,objName)
	{
		if ( (obj.value.length > len) && ( !checkBlank(obj) ) )
		{
	    		alert(objName+" length must not exceed from "+len);
			obj.focus();
			return false;
		}//end if()
		return true;
	}//end checkLengthGreater()
	
	
	function checkLengthLesser(obj,len,objName)
	{
	
		if ( (obj.value.length < len) && ( !checkBlank(obj) ) )
		{	
			alert("Invalid "+objName+". Length must not be less than "+len);
			obj.focus();
			return false;
		}//end if()
		return true;
	}//end checkLengthLesser()
	
	
	
	
	/*	obj is the Object on which check is required.
		objName is the Name of the Object to be displayed.
		The function checks that only Integer values exists in the value of the Object.	*/
	function checkIntegerOnly(obj,objName)
	{
		if ( !checkBlank(obj) )
		{
			for (i=0;i<obj.value.length;i++)
			{
				if( !(obj.value.charAt(i) >='0' && obj.value.charAt(i) <= '9') )
				{
					alert("Only Integer values are allowed in "+objName);
					obj.focus();
					return false;
				}//end if()
			}//end for()
		}//end if()
		return true;
	}//end checkIntegerOnly()
	
	function checkValidEmail(obj)
	{
		invalidChar = new String("/:,;");
		email = new String(obj.value);
		for(i=0; i<invalidChar.length; i++) //check for Invalid  Characters
		{
			if (email.indexOf(invalidChar.charAt(i), 0) >= 0)
			{
				alert("Invalid email format. Please enter the correct email address");
				obj.focus();
				return false;
 			}//end if()
		}//end for()
		atPos = email.indexOf("@" ,1);			//check for @
		if(atPos == -1)
		{
			alert("Bad Email Address format. Please provide your correct email address");
			obj.focus();
			return false;
		}//end if()
		if (email.indexOf("@" , atPos +1) != -1)
		{ 	//check for only one @
			alert("Bad Email Address format. Please provide your correct email address");
			obj.focus();
			return false;
		}//end if()
		periodPos = email.indexOf("." , atPos);		// atleast one . after @
        	if (periodPos == -1)
		{
			alert("Bad Email Address format. Please provide your correct email address");
			obj.focus();
			return false
		}//end if()
		if(periodPos + 2 > email.length)
		{
			alert("Bad Email Address format. Please provide your correct email address");
			obj.focus();
			return false
		}//end if()
		return true
	}//end checkValidEmail()
	
	function checkTextOnly(obj,objName)
	{
		if ( !checkBlank(obj) )
		{
			for (i=0;i<obj.value.length;i++)
			{
				if( !( (obj.value.charAt(i) ==' ')||(obj.value.charAt(i) >='a' && obj.value.charAt(i) <= 'z')
						 ||(obj.value.charAt(i) >='A' && obj.value.charAt(i) <= 'Z') ) )
				{
					alert("Invalid Characters in "+objName);
					obj.focus();
					return false;
				}//end if()
					
			}//end for()
		}//end if()
		return true;
	}//end checkTextOnly()
	
	/*
	Password and RePassword Is Matched or Not
	*/
	function checkPassMatch(obj1,obj2,objName)
	{
	var pwd=obj1.value
	var repwd=obj2.value
	if (pwd!=repwd)
	{
		alert(objName+" does not match");
		obj1.focus();
		obj1.select();
		return false;
    }
    	return true;
}

	function checkCheckBoxMessage(obj,objName)
	{
		if( ! obj.checked )
		{
			alert("You must accept the "+objName);
			obj.focus();
			return false;
		}//end if()
		else
			return true;
	}//end checkCheckBox()
	
	function checkCheckBox(obj)
	{
		if ( !obj.checked )
		{
			alert("True");
			return true;
		}
		else
		{
			alert("False");
			return false;
		}
	}//end checkCheckBox()
	
	function checkRadioButton(obj,objName)
	{
		if (obj.length > 0)
		{
			for(i=0;i< obj.length;i++)
			{
				if(  obj(i).checked )
					return true;
			}
			alert("Please Select the "+objName);
		}//end if()
		else
		{
			if (  obj.checked )
				return true;
			else
				alert("Please Select the "+objName);
		}//end else()

		return false;
	}//end checkRadioButton()
	
	function copyValue(sourceObj,destinationObj)
	{
		destinationObj.value=sourceObj.value;
	}//end copyValue()
	
	function disableObj(obj,opt)
	{
		obj.disabled=opt;
	}//end enableDisable()
	
function checkPhone(obj,objName) {
	 if(!isValidPhone(obj.value)) {
		alert("Bad Characters in "+objName+" Only digits 0-9, hyphen - and small brackets() are allowed");
		obj.focus();
		obj.select();
		return false;
		}
	else return true;
}
function isValidPhone(n)
{
	return true;
	
	var m =0;
	j = n.length;
	for (i=0;i<j;i++)
	{
		if((n.charAt(i) >='0' && n.charAt(i) <= '9') || n.charAt(i) == '-' || n.charAt(i) == '(' || n.charAt(i) == ')' || n.charAt(i) == ' ')
			m=0 ;

		else

			m=1;

		if (m==1)
		    return false;
	}
	return true;
}

function checkIP(obj,objName) {
			 if(!isValidPhone(obj.value)) {
				alert("Only Integers and '.' is allowed in "+objName);
				obj.focus();
				obj.select();
				return false;
		}
	else return true;
}





	function goToPage(pag)
	{
		location.href=pag;
	}//end cancelFunction()
	
	function firstObj(obj)
	{
		obj.focus();
	}//end firstObj()
	

