
function validateRewardsSearchForm(){
			//check searchindex
			var searchIndex=document.getElementById("searchIndex");
			if(isRequired(searchIndex.value,"Search Index")==false){
				searchIndex.value="";
				searchIndex.focus();
				return false;
			}
			return true;
		}
//This function will verify that given email is in correct format or not
function emailCheck(str) {


		var Re = new RegExp("^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" + 
                "0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\\.([a-z]" + 
                "[a-z|0-9]*(\\.[a-z][a-z|0-9]*)?)$");

		if(!str.match(Re)){
			alert("Invalid E-mail ID")
		    return false
		}
		return true					
	}
	
//Same as emailCheck but this one does not alerts the user
function emailCheckNoAlert(str) {


		var Re = new RegExp("^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" + 
                "0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\\.([a-z]" + 
                "[a-z|0-9]*(\\.[a-z][a-z|0-9]*)?)$");

		if(!str.match(Re)){
		    return false
		}
		return true					
	}
		
	
//This function will remove leading anf trailing sapces
function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	} 
	
	//This function will check that given string should not be blank
function isRequired(string,fieldName){
	if(trim(string) == ''){
		alert(fieldName+" is required");
		return false;
	}
	return true;
} 
//This function will check the length of a variable should not excceds the given length
function checkLength(string,length,fieldName){

	var originalLength=(trim(string)).length;
	if(originalLength>length){
		alert(fieldName+" is exceeding the given length i.e."+length);
		return false;
	}
	return true;
}


function lengthCheck(element, length, message, focus) {
  if(element == null || element.value.length > length) {
  	if(message != null) {
  		alert(message);
  	}
  	if(focus == true) {
  		element.focus();
  	}
  	return false;
   }
  return true;
}


function isEmpty(element, message, focus) {
  if(element == null || trim(element.value).length == 0) {
  	if(message != null) {
  		alert(message);
  	}
  	if(focus == true) {
  		element.focus();
  	}
  	return true;
  }
  return false;
}

function equalLength(string,length,fieldName){
	var originalLength=(trim(string)).length;
	if(originalLength!=length){
		alert(fieldName+" should of length="+length);
		return false;
	}
	return true;
		
}
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
  
   return blnResult;
   }
   //This method check that given string has valid chars or not
   // Note that comma is allowed here
   function checkSpecialChar(strString){
  	var strValidChars = "!@#$%^&*()+=-[]\\\';./{}|\":<>?";
  	var strChar;
    var blnResult = false;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == false; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) != -1)
         {
         blnResult = true;
         }
      }
  
   return blnResult;
   }
   
   //This function selects all checkboxes.
   //@param the checkbox control/s that need to be checked.
   
	function selectAllCheckBoxes(chkBox) {
		if(chkBox != null) {
			if(chkBox.length == undefined) {
				chkBox.checked = true;
			} else {
				for(var ii = 0; ii < chkBox.length; ii++) {
					chkBox[ii].checked = true;
				}
			}
		}
	}
	
	//This function returns true if any checkbox is selected.
	 //@param the checkbox control/s that need to be checked.
	 
	function isAnyCheckboxChecked(chkBox) {
		var checked = false;
		if(chkBox.length == undefined) {
			return chkBox.checked
		} else {
			for(var ii = 0; ii < chkBox.length; ii++) {
				if(chkBox[ii].checked == true) {
					return true;
				}
			}
		}
	}
	
function IsValidDollar(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.,";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
    if(strString.indexOf('.') != strString.lastIndexOf('.')){
    	return false;
    }
  
   return blnResult;
   }
   


// Copyright (c) 1998 Sudhakar Chandrasekharan (thaths@netscape.com)
// All rights reserved
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 dated June, 1991.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.

// Thanks to Martin Honnen (Martin.Honnen@sector27.de) for some coding
// tips.

// Funtion to return the type of credit card
function typeOfCard(number) {
	/* 
	//	Card Prefixes
	//
	//	Mastercard	51-55
	//	Visa		4
	//	AmEx		34,37
	//	Discover	6011
	*/

	var firstNumber = number.substring(0,1);
	var firstThreeNumbers = number.substring(0,3);

	if (firstNumber == 4) {
		return "Visa";
	} 

	var firstTwoNumbers = number.substring(0,2);
	if (firstTwoNumbers > 50 && firstTwoNumbers < 56) {
		return "MasterCard";
	}

	if (firstTwoNumbers == 34 || firstTwoNumbers == 37) {
		return "Amex";
	}

	var firstFourNumbers = number.substring(0,4);
	if (firstFourNumbers == 6011) {
		return "Discover";
	}
}

// Function that determines whether a credit card number is valid
// Please note that a valid credit card number is not essentially a
// credit card in good standing.
function isValidCreditCard(number) {
	var total = 0;
	var flag = 0;
	for (var i=(number.length - 1);i>=0; i--) {
		if (flag == 1) {
			var digits = number.charAt(i) * 2;
			if (digits > 9) digits -= 9;
			total += digits;
//			var reminder = digits % 10;
//			var quotient = (digits - reminder) / 10;
//			total = total + parseInt(reminder);
//			total = total + parseInt(quotient);
			flag = 0;
		} else {
			total = total + parseInt(number.charAt(i));
			flag = 1;
		}
	}
	if ((total%10) == 0) {
		return true;
	} else {
		return false;
	}
}

function validateURL(strString){
   var Re = new RegExp("^(ftp|http|file|https)://");
		if(Re.test(strString)){
		    return true;
		}
		return false;			
}

function greaterThanTodaysDate(checkDate, yearIn2Digits) {
  	
  	var startDateArr = checkDate.split("/");
  	var currentMonth = startDateArr[0] - 1;
  	var currentDate = startDateArr[1];
  	var currentYear = startDateArr[2];

  	if(yearIn2Digits == true) {
  		currentYear = "20" + currentYear;
  	}  	

  	var dateNow = new Date();
  	
  	var startDate = dateNow.setFullYear(currentYear, currentMonth, currentDate);
  	
  	if(startDate > new Date().getTime()) {
  	  	return true;
  	} 
  	return false;
}

function a(p) {
alert(p);
}
   
   