<!--- hiding
function Trim(strText)
{
	while(strText.length != 0 && strText.charAt(0) == " ")
	{
		strText=strText.substring(1,strText.length);
	}
	while(strText.length != 0 && strText.charAt(strText.length-1) == " ")
	{
		strText=strText.substring(0,strText.length-1);
	}
	return(strText);
}

function hilitemenu(imgname,img)
{
document.images[imgname].src = img;
}
function openPopUp( strTreeDepth, strPage, strURL )
{
	var strRelativePath = "";
	for( var intI = 0; intI < strTreeDepth; intI++ )
		strRelativePath += '../';
		
	strUrl = strRelativePath + "sendtofriend/Pagetofriend.aspx?page=" + strPage + "&loc=" + strURL;
	window.open( strUrl, "", "width=520,height=430,status=no,resizable=yes,scrollbars=yes,status=no" );
}

function openPopUpRecipe( strRecipeName, strRecipeID, strVersion )
{
	strUrl = "../sendtofriend/Recipetofriend.aspx?RecipeID=" + strRecipeID + "&Version=" + strVersion + "&Title=" + strRecipeName;
	window.open( strUrl, "", "width=520,height=430,status=no,resizable=yes,scrollbars=yes,status=no" );
}

function checkForm(frmName)
{
	var friend = new UnileverConsumerFriend(frmName);
	
	friend.unMark();
	if( !friend.isFormBlank() )
	{
		alert("Fields marked in red are required. Please fill.");
		return false;
	}
	if( !friend.validateFriendFields() )
		return false;
	
	return true;
}
function validateFriendFields()
{	
	//validate the friend's name
	if( !validateAlpha( this.friendName.value ) )
	{
		alert("Enter Friend\'s Name with only alpha characters.");
	    this.mark('divfriendName');
		this.friendName.focus();
		return false;
	}
	if( !checkFriendEmail( this.friendEmail.value ) )
	{
		alert("Friend\'s email is not valid. Please correct.");
		this.mark('divfriendEmail');
		this.friendEmail.focus();
		return false
	}
	//validate the your name
	if( !validateAlpha( this.yourName.value ) )
	{
		alert("Enter your Name with only alpha characters.");
	    this.mark('divyourName');
		this.yourName.focus();
		return false;
	}
	
	if( !checkYourEmail( this.yourEmail.value ) )
	{
		alert("Your email is not valid. Please correct.");
	    this.mark('divyourEmail');
		this.yourEmail.focus();
		return false;
	}
	
	if( !CheckBadCharsAndFlag( this.greetings.value ) )
	{
		alert("The following characters are not allowed for Message. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.mark('divgreetings');
		this.greetings.focus();
		return false;
	}
	
	return true;
}

function UnileverConsumerFriend(frmName)
{
	this.defaultFontWeight = 'normal'; 
	this.defaultColor = '#43821A';
	this.errorFontWeight = 'bold';
	this.errorColor = '#FF0000';
	this.friendName = eval('document.' + frmName + '.friendName');
	this.friendEmail = eval('document.' + frmName + '.friendEmail');
	this.yourName = eval('document.' + frmName + '.yourName');
	this.yourEmail = eval('document.' + frmName + '.yourEmail');
	this.greetings = eval('document.' + frmName + '.greetings');
	this.blnFormBlank = false;
	this.isFormBlank = isFormBlank;
	this.validateFriendFields = validateFriendFields;
	this.checkFriendEmail = checkFriendEmail;
	this.checkYourEmail = checkYourEmail;
	this.unMark = unMark;
	this.mark = mark;
}

function isFormBlank()
{
	var oRegExp = new RegExp(/\S/);
	if( !oRegExp.test(this.friendName.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divfriendName');
	}
	if( !oRegExp.test(this.friendEmail.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divfriendEmail');
	}
	if( !oRegExp.test(this.yourName.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divyourName');
	}
	if( !oRegExp.test(this.yourEmail.value) )
	{	
		this.blnFormBlank = true;	
		this.mark('divyourEmail');
	}
	if( !oRegExp.test(this.greetings.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divgreetings');
	}
	return !this.blnFormBlank;
}

function mark(elementName)
{
	document.getElementById(elementName).style.fontWeight = this.errorFontWeight;
	document.getElementById(elementName).style.color = this.errorColor;
}

function unMark()
{
	document.getElementById('divfriendName').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divfriendName').style.color = this.defaultColor;
	document.getElementById('divfriendEmail').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divfriendEmail').style.color = this.defaultColor;
	document.getElementById('divyourName').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divyourName').style.color = this.defaultColor;
	document.getElementById('divyourEmail').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divyourEmail').style.color = this.defaultColor;
	document.getElementById('divgreetings').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divgreetings').style.color = this.defaultColor;
}

function checkFriendEmail( _friendEmail )
{
	var oRegExp = new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
	if ( !oRegExp.test( _friendEmail ) )
	{	
		this.mark('divfriendEmail');
		return false;
	}
	return true;
}

function checkYourEmail( _yourEmail )
{
	var oRegExp =  new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
	if ( !oRegExp.test( _yourEmail ) )
	{
		this.mark('divyourEmail');
		return false;
	}
	return true;
}



//function checkYourEmail1(emailAddr)
//{
//	var oRegExp =  new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
//	if (oRegExp.test(emailAddr))
//	 	return true;
//	else
//	 	return false;
//}

function setHidden(iMode)
{	
	var strSearchedFor = new String() ;

	if (iMode == 1)
	{
		if (document.adminSearch.selBrandID.value == "#")
		{
			alert("Please select a variety.");
			return false;
		}
		strSearchedFor = document.adminSearch.selBrandID.options[document.adminSearch.selBrandID.selectedIndex].text;
	}
		
	if (iMode==2)
	{
		// Prevent XSS Issues - START
		document.adminSearch.key1.value = RemoveBadChars( Trim( document.adminSearch.key1.value ) );
		document.adminSearch.key2.value = RemoveBadChars( Trim( document.adminSearch.key2.value ) );
		document.adminSearch.key3.value = RemoveBadChars( Trim( document.adminSearch.key3.value ) );
		// Prevent XSS Issues - END
		
		if ((document.adminSearch.key2.value!="") && (document.adminSearch.key3.value!="") && (document.adminSearch.key1.value==""))
		{
			document.adminSearch.key1.value=document.adminSearch.key2.value;
			document.adminSearch.key2.value=document.adminSearch.key3.value;
			document.adminSearch.key3.value="";
		}
	    	
		if ((document.adminSearch.key2.value=="") && (document.adminSearch.key3.value!="") && (document.adminSearch.key1.value==""))
		{
			document.adminSearch.key1.value=document.adminSearch.key3.value;
			document.adminSearch.key3.value="";
		}    

		if ((document.adminSearch.key2.value!="") && (document.adminSearch.key3.value=="") && (document.adminSearch.key1.value==""))
		{
			document.adminSearch.key1.value=document.adminSearch.key2.value;
			document.adminSearch.key2.value="";
			document.adminSearch.key3.value="";
		}        
	    
		if ((document.adminSearch.key2.value=="") && (document.adminSearch.key3.value!="") && (document.adminSearch.key1.value!=""))
		{
			document.adminSearch.key2.value=document.adminSearch.key3.value;
			document.adminSearch.key3.value="";
		}    
  		if ((document.adminSearch.key1.value==""))
		{
			alert ("Enter at least one keyword");
			document.adminSearch.key1.focus();
			return false;
		}        
	}	
		
	if (iMode == 3)
		{
			var a, b, objInput, strOldCategory, strNewCategory,strSearchedFor;
			
			a = 0;
			b = 0;
			strOldCategory = "";	
			strNewCategory = "";
			strSearchedFor = "";
					
			for(i=0;i<document.adminCategorySearch.elements.length;i++)
			{	
				if(document.adminCategorySearch.elements[i].type == "checkbox")
				{	
					strNewCategory = document.adminCategorySearch.elements[i].name;
					
					if(document.adminCategorySearch.elements[i].checked)
					{
						b=1;
						if ( strOldCategory == "" )
						{	
							//[i-3] is the number of DIV tags on the page
							strSearchedFor = strSearchedFor + ( document.adminCategorySearch.getElementsByTagName('span')[i - 3].childNodes[0].nodeValue + " OR " );
						}
						else
						{
							//[i-3] is the number of DIV tags on the page
							if( strOldCategory == strNewCategory )
								strSearchedFor = strSearchedFor + ( " OR " + document.adminCategorySearch.getElementsByTagName('span')[i - 3].childNodes[0].nodeValue + " OR " );
							else
								strSearchedFor = strSearchedFor + ( " AND " + document.adminCategorySearch.getElementsByTagName('span')[i - 3].childNodes[0].nodeValue + " AND " );
						}
						strOldCategory = strNewCategory;
					}
				}			
			}
			var myRegEx = new RegExp ('OR  AND', "g");
			strSearchedFor = strSearchedFor.replace(myRegEx, 'and');
			var myRegEx1 = new RegExp ('OR  OR', "g");
			strSearchedFor = strSearchedFor.replace(myRegEx1, 'or');
			var myRegEx2 = new RegExp ('AND  OR', "g");
			strSearchedFor = strSearchedFor.replace(myRegEx2, 'or');
			var myRegEx3 = new RegExp ('AND  AND', "g");
			strSearchedFor = strSearchedFor.replace(myRegEx3, 'and');
			
			strSearchedFor = strSearchedFor.substring( 0, ( strSearchedFor.length - 4 ) );

			if(b==0)
			{
				alert("Please select your choices to search for recipes");
				return false;
			}
		}
		document.adminSearch.hiddenSearchedFor.value=strSearchedFor;
		document.adminCategorySearch.hiddenSearchedFor.value=strSearchedFor;
		document.adminSearch.hiddenSearch.value=iMode;
		document.adminCategorySearch.hiddenSearch.value=iMode;
		
	if (iMode == 3)
	{	
		document.adminCategorySearch.submit();
	}
	else
	{	
		document.adminSearch.submit();
	}
}

function Next()
{
	document.form1.key1.value = document.form1.key1.value;
	document.form1.hdnPageNumber.value++;
	document.form1.submit();
}
function Previous()
{
	document.form1.key1.value = document.form1.key1.value;
	document.form1.hdnPageNumber.value--;
	document.form1.submit();
}
function setKeyword()
{
	document.form1.key1.value = document.form1.key1.value;	
	document.form1.submit();
}
function clearall()
{
if (document.adminSearch.hiddenClear.value == 0)
  {
	document.adminSearch.hiddenClear.value = 1;
	document.adminSearch.key1.value="";
	document.adminSearch.key2.value="";
	document.adminSearch.key3.value="";
  }
}

function RecipeDisplay(RecipeID, Version)
{
	window.location.href  = "recipeDetails.asp?RecipeID=" + RecipeID + "&Version=" + Version;
}
	
function searchRecipes()
{
	if(document.myForm.key1.value == "")
	{
		alert("Enter search criteria");
		document.myForm.key1.focus();
		return false;
	}
	else
	{
		document.myForm.submit();
	}
}



var strErrorMsg
function validateForm( TheForm ) 
{
	var blnRetVal = true;		
	
	//check that the required fields are filled in
	blnRetVal = checkRequiredFields( TheForm );
	
	
	//check the values of the fields
	if (blnRetVal == true)
		blnRetVal = validateFields( TheForm );
	
	return blnRetVal;		     
}

function checkRequiredFields( TheForm ) 
{

	if ( eval( 'document.' + TheForm + '.email.value' ) == "" ) 
	{
		alert("The Email field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.email.focus()');
		eval( 'document.' + TheForm + '.email.select()');
		return false;
	}
	
	if ( eval( 'document.' + TheForm + '.firstname.value' ) == "" ) 
	{
		alert("The First Name field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.firstname.focus()');
		eval( 'document.' + TheForm + '.firstname.select()');
		return false;
	}
	
	if ( eval( 'document.' + TheForm + '.lastname.value' ) == "" ) 
	{
		alert("The Last Name field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.lastname.focus()');
		eval( 'document.' + TheForm + '.lastname.select()');
		return false;
	}    
	
	if ( eval( 'document.' + TheForm + '.address1.value' ) == "" ) 
	{
		alert("The Address field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.address1.focus()');
		eval( 'document.' + TheForm + '.address1.select()');
		return false;
	}
	
	if ( eval( 'document.' + TheForm + '.city.value' ) == "" ) 
	{
		alert("The City field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.city.focus()');
		return false;
	}
	
	if ( eval( 'document.' + TheForm + '.state.selectedIndex' ) == 0 ) 
	{
		alert("The State field is required. Please choose your state.");
	    eval( 'document.' + TheForm + '.state.focus()');
		return false;
	}	
	
	if ( eval( 'document.' + TheForm + '.zip.value' ) == "" ) 
	{
		alert("The Zip field is required. Please fill it in.");
	    eval( 'document.' + TheForm + '.zip.focus()');
		return false;
	}
	if ( eval( 'document.' + TheForm + '.day.selectedIndex' ) == 0 
	|| eval( 'document.' + TheForm + '.month.selectedIndex' ) == 0
	|| eval( 'document.' + TheForm + '.year.selectedIndex' ) == 0) 
	{
		alert("The Date of birth field is required. Please choose your Date of birth.");
	    eval( 'document.' + TheForm + '.day.focus()');
		return false;
	}
	if ( eval( 'document.' + TheForm + '.newsletterSubscription.checked' ) == false ) 
	{
		alert("Subscribe to Lipton's Tea & Health Club e-mail newsletter is required. Please subscribe.");
	    eval( 'document.' + TheForm + '.newsletterSubscription.focus()');
		return false;
	}
	
	return true;
}

function validateContact( TheForm ) 
{
	var blnRetVal = true;
	
	var consumerContact = new UnileverConsumerContact(TheForm);
	consumerContact.unMarkContact();
	
	if( !consumerContact.isContactFormBlank() )
	{
		alert("Fields marked in red are required. Please fill.");
		return !blnRetVal;
	}
	if( !consumerContact.validateContactFields() )
	{
		return !blnRetVal;
	}
	return blnRetVal;    
}

function UnileverConsumerContact(frmName)
{	
	this.defaultFontWeight = 'normal'; 
	this.defaultColor = '#000000';
	this.errorFontWeight = 'bold';
	this.errorColor = '#FF0000';
	this.email = eval('document.' + frmName + '.email');
	this.firstname = eval('document.' + frmName + '.firstname');
	this.lastname = eval('document.' + frmName + '.lastname');
	this.address1 = eval('document.' + frmName + '.address1');
	this.address2 = eval('document.' + frmName + '.address2');
	this.city = eval('document.' + frmName + '.city');
	this.state = eval('document.' + frmName + '.state');
	this.zip = eval('document.' + frmName + '.zip');
	this.month = eval('document.' + frmName + '.month');
	this.day = eval('document.' + frmName + '.day');
	this.year = eval('document.' + frmName + '.year');
	this.crm_upc_code = eval('document.' + frmName + '.crm_upc_code');
	this.crm_mfg_code = eval('document.' + frmName + '.crm_mfg_code');
	this.crm_inquiry = eval('document.' + frmName + '.crm_inquiry');
	this.blnFormBlank = false;
	this.isContactFormBlank = isContactFormBlank;
	this.validateContactFields = validateContactFields;
	this.checkField = checkField;
	//this.checkFriendEmail = checkFriendEmail;
	//this.checkYourEmail = checkYourEmail;
	this.unMarkContact = unMarkContact;
	this.mark = mark;
}

function unMarkContact()
{
	document.getElementById('divemail').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divemail').style.color = this.defaultColor;
	document.getElementById('divfirstname').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divfirstname').style.color = this.defaultColor;
	document.getElementById('divlastname').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divlastname').style.color = this.defaultColor;
	document.getElementById('divaddress').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divaddress').style.color = this.defaultColor;
	document.getElementById('divcity').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divcity').style.color = this.defaultColor;
	document.getElementById('divstate').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divstate').style.color = this.defaultColor;
	document.getElementById('divzip').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divzip').style.color = this.defaultColor;
	document.getElementById('divdob').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divdob').style.color = this.defaultColor;
	document.getElementById('divcomments').style.fontWeight = this.defaultFontWeight;
	document.getElementById('divcomments').style.color = this.defaultColor;
}

function isContactFormBlank()
{
	var oRegExp = new RegExp(/\S/);
	if( !oRegExp.test(this.email.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divemail');
	}
	if( !oRegExp.test(this.firstname.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divfirstname');
	}
	if( !oRegExp.test(this.lastname.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divlastname');
	}
	if( !oRegExp.test(this.address1.value) )
	{	
		this.blnFormBlank = true;	
		this.mark('divaddress');
	}
	if( !oRegExp.test(this.city.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divcity');
	}
	if( this.state.selectedIndex == 0 )
	{	
		this.blnFormBlank = true;
		this.mark('divstate');
	}
	if( !oRegExp.test(this.zip.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divzip');
	}
	
	if( (this.day.selectedIndex == 0 ) 
	|| (this.month.selectedIndex == 0 )  
	|| (this.year.selectedIndex == 0 ) )
	{	
		this.blnFormBlank = true;
		this.mark('divdob');
	}
	if( !oRegExp.test(this.crm_inquiry.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divcomments');
	}
	return !this.blnFormBlank;
}

function validateContactFields()
{	
	//validate the email address
	if( !validateEmail( this.email.value ) )
		return this.checkField('divemail', 'Enter a valid Email Address', 'email');
	
	//validate the firstname
	if( !validateAlpha( this.firstname.value ) )
		return this.checkField('divfirstname', 'Enter First Name with only alpha characters', 'firstname');
	
	//validate the lastname
	if( !validateAlpha( this.lastname.value ) )
		return this.checkField('divlastname', 'Enter Last Name with only alpha characters', 'lastname');
		
	//validate the address1
	if( !CheckBadCharsAndFlag( this.address1.value ) )
	{
		alert("The following characters are not allowed for address1. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.address1.focus();
		return false;
	}
	
	//validate the address2
	if( !CheckBadCharsAndFlag( this.address2.value ) )
	{
		alert("The following characters are not allowed for address2. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.address2.focus();
		return false;
	}
	
	if( !validateAlpha( this.city.value ) )
		return this.checkField('divcity', 'Enter City with only alpha characters', 'city');
	
	//validate the zip code
	if( !validateZip( this.zip.value ) )
		return this.checkField('divzip', 'Enter a valid 5 digit or 5 digit-4 digit US zip code.\nValid formats are either: xxxxx or xxxxx-xxxx', 'zip');

	//validate the UPCCode
	if( !CheckBadCharsAndFlag( this.crm_upc_code.value ) )
	{
		alert("The following characters are not allowed for UPC code. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.crm_upc_code.focus();
		return false;
	}
	
	//validate the Manufacturing  code
	if( !CheckBadCharsAndFlag( this.crm_mfg_code.value ) )
	{
		alert("The following characters are not allowed for Manufacturing  code. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.crm_mfg_code.focus();
		return false;
	}
	
	//validate the Question
	if( !CheckBadCharsAndFlag( this.crm_inquiry.value ) )
	{
		alert("The following characters are not allowed for question/comments. Please remove.\n\n< > \" ' % ; ) ( & +");
		this.crm_inquiry.focus();
		return false;
	}
			
	return true;
} 

function checkField(sMarkField, sAlert, sField)
{
	this.mark( sMarkField );
	alert( sAlert );
	eval('this.' + sField + '.focus()');
	eval('this.' + sField + '.select()');
	return false;
}

function validateFields( TheForm )
{	
	//validate the email address
	if( validateEmail( eval( 'document.' + TheForm + '.email.value' ) ) == false ) 
	{
		alert("Enter a valid Email Address");
		eval( 'document.' + TheForm + '.email.focus()' );
		eval( 'document.' + TheForm + '.email.select()' );
		return false;
	}
	
	//validate the firstname
	if( validateAlpha( eval( 'document.' + TheForm + '.firstname.value' ) ) == false ) 
	{
		alert("Enter First Name with only alpha characters");
		eval( 'document.' + TheForm + '.firstname.focus()' );
		eval( 'document.' + TheForm + '.firstname.select()' );
		return false;      
	}
	
	//validate the lastname
	if( validateAlpha( eval( 'document.' + TheForm + '.lastname.value' ) ) == false ) 
	{
		alert("Enter Last Name with only alpha characters");
		eval( 'document.' + TheForm + '.lastname.focus()' );
		eval( 'document.' + TheForm + '.lastname.select()' );
		return false;   
	}
	
	//validate the Address1 for XSS Atacks
	if( !CheckBadCharsAndFlag( eval( 'document.' + TheForm + '.address1.value' ) ) )
	{
		alert("The following characters are not allowed for Address. Please remove.\n\n< > \" ' % ; ) ( & +");
		eval( 'document.' + TheForm + '.address1.focus()' );
		eval( 'document.' + TheForm + '.address1.select()');
		return false;
	}
	
	//validate the Address2 for XSS Atacks
	if( !CheckBadCharsAndFlag( eval( 'document.' + TheForm + '.address2.value' ) ) )
	{
		alert("The following characters are not allowed for Address. Please remove.\n\n< > \" ' % ; ) ( & +");
		eval( 'document.' + TheForm + '.address2.focus()' );
		eval( 'document.' + TheForm + '.address2.select()');
		return false;
	}
	
	if( validateAlpha( eval( 'document.' + TheForm + '.city.value' ) ) == false ) 
	{
		alert("Enter City with only alpha characters");
		eval( 'document.' + TheForm + '.city.focus()' );
		eval( 'document.' + TheForm + '.city.select()' );
		return false;
	}
	
	//validate the zip code
	if( validateZip( eval( 'document.' + TheForm + '.zip.value' ) ) == false ) 
	{
		alert("Enter a valid 5 digit or 5 digit-4 digit US zip code.\nValid formats are either: xxxxx or xxxxx-xxxx");
		eval( 'document.' + TheForm + '.zip.focus()' );
		eval( 'document.' + TheForm + '.zip.select()' );
		return false;   
	}
	/*Suzanne Brand Manager of Lipton Tea wanted phone NOT to be Mandatory
	if ( isNaN( eval( 'document.' + TheForm + '.phoneday.value' ) ) )
	{
		alert("Enter Phone with only numerics.");
	    eval( 'document.' + TheForm + '.areacode.focus()');
		return false
	}*/
	
	return true;
} 

function validateAlpha(strValue) 
{
	var blnRetVal = true;
	var strTest = new String(strValue);
	var pattern = new RegExp(/[^a-zA-Z^\-^`^ ^'^_]/);
	var result = strTest.match(pattern);
	if (result)
		blnRetVal = false;
						
	return blnRetVal;
						
}

function validateZip(strValue) 
{
	var blnRetVal = true;
				
	var strTest = new String(strValue);
	var pattern = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	var result = strTest.match(pattern);
	if (!result) 
		blnRetVal = false;
					
	return blnRetVal;					
}



function validateEmail(strValue)
{
    var blnEmail = false;
  	var oRegExp = new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
	if (oRegExp.test(strValue))
	 var blnEmail = true;
	
	return blnEmail;
}


//function validateEmail(strValue)
//{
//	var oRegExp = new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
//	if (oRegExp.test(strValue))
//	{	//proper email address
//	 	return true;
//	}
//	else
//	{	//improper email address
//	 	return false;
//	}
//}
			
function isValid(strValue) 
{
	var blnRetVal = true;
	var strTest = new String(strValue);
	var pattern = new RegExp(/[^a-zA-Z0-9^\-^^ ^.^_]/);
	var result = strTest.match(pattern);
	if (result)
		var blnRetVal = false;

	return blnRetVal;
}

function validateAgebyRules(imonth, iday, iyear, iage)
{
	var isValid = true;
	var currentDate = new Date();
	var currentYear = currentDate.getFullYear();
	var currentMonth = currentDate.getMonth();
	var currentDay = currentDate.getDate();
	
	if( parseInt( currentYear - iyear ) < parseInt( iage ) )
		isValid = false;
	if( parseInt( currentYear - iyear ) > parseInt( iage ) )
		isValid = true;
	if( parseInt( currentYear - iyear ) == parseInt( iage ) )
	{	
		if( parseInt( currentMonth  + 1 ) < parseInt( imonth ) )
			isValid = false;
		if( parseInt( currentMonth  + 1 ) > parseInt( imonth ) )
			isValid = true;
		if( parseInt( currentMonth  + 1 ) == parseInt( imonth ) )
		{
			if( parseInt( currentDay  ) < parseInt( iday ) )
				isValid = false;
			if( parseInt( currentDay  ) >= parseInt( iday ) )
				isValid = true;
		}
	}
	return isValid;
}


function validateDateOfBirth(imonth, iday, iyear)
{
	var isValid = true;
	var objDate = new Date();
	var newMonth = objDate.setMonth(imonth - 1);
	var newDate = objDate.setDate(iday);
	var newYear = objDate.setFullYear(iyear);
	var enteredDate = new Date(objDate);
  
	if (enteredDate.getDate() != iday)
	{
	  isValid = false;
	}
	return isValid;
}

function isInteger(s)
{
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function stripCharsInBag(s, bag)
{
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}

function validate_ShareWithAFriend()
{
	if (document.frmSendtoFriend.friend_name.value == "") 
	{
		alert("The Friend's Name field is required. Please fill it in.");
		document.frmSendtoFriend.friend_name.focus();
		return false;
	}
	//validate the mailee name
	if(validateAlpha(document.frmSendtoFriend.friend_name.value)==false) 
	{
		alert("Enter Friend's Name with only alpha characters");
		document.frmSendtoFriend.friend_name.focus();
		document.frmSendtoFriend.friend_name.select();
		return false;
	}
	if (document.frmSendtoFriend.friend_email.value == "") 
	{
		alert("The Friend's Email field is required. Please fill it in.");
		document.frmSendtoFriend.friend_email.focus();
		return false;
	}
	if( !validateEmail( document.frmSendtoFriend.friend_email.value ) )
	{
		alert("Friend's Email is invalid. Please enater a valid email address.");
		document.frmSendtoFriend.friend_email.focus();
		return false;
	}
	if (document.frmSendtoFriend.your_name.value == "") 
	{
		alert("Your Name is required. Please fill it in.");
		document.frmSendtoFriend.your_name.focus();
		return false;
	}
	//validate the mailer name
	if(validateAlpha(document.frmSendtoFriend.your_name.value)==false) 
	{
		alert("Enter Your Name with only alpha characters");
		document.frmSendtoFriend.your_name.focus();
		document.frmSendtoFriend.your_name.select();
		return false;
	}
	if (document.frmSendtoFriend.your_email.value == "") 
	{
		alert("Your Email is required. Please fill it in.");
		document.frmSendtoFriend.your_email.focus();
		return false;
	}
	if( !validateEmail( document.frmSendtoFriend.your_email.value ) )
	{
		alert("Your Email is invalid. Please enater a valid email address.");
		document.frmSendtoFriend.your_email.focus();
		return false;
	}
	if (document.frmSendtoFriend.greetings.value == "") 
	{
		alert("Message is required. Please fill it in.");
		document.frmSendtoFriend.greetings.focus();
		return false;
	}
	return true;
}

	// Prevent XSS Attack - START
	function RemoveBadChars(strTemp) 
	{ 
	    strTemp = strTemp.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-/g,""); 
	    return strTemp;
	} 
	
	function CheckBadCharsAndFlag(strValue) 
	{ 
		var blnRetVal = true;
		var strTest = new String(strValue);
		var pattern = new RegExp(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+/g);
		var result = strTest.match(pattern);
		if (result)
			var blnRetVal = false;

		return blnRetVal;
	}

	// Prevent XSS Attack - END
	
	
// end hiding --->
