/* Disable Right Click */
//document.oncontextmenu = new Function("return false;");

setCookie("ABSCOOKIE","DEFAULT","/");

/*function checkCookie(){
if(document.cookie == ''){
   document.location.href ="/eCommerceWeb/jsp/eCommerce/common/errorPage/cookieDisableError.jsp";
   }
}*/

var swapImages = new swapImages();

function swapImages(){
	window.onload= function(){
		loadSwapImage();
	}
} 

function weeklycatgeory(){
	var catid = document.getElementById('weekcatg').value;
	if(catid!=0){
		var catgids = catid.split(':');
		var url= 'http://albertsons.shoplocal.com/albertsons/Default.aspx?action=browsecategoryl2&storeid=2407397&cattreeid='+catgids[1]+
			'&featuredcategorydropdown='+catgids[0]+'%3A'+catgids[1];
		 
	
		window.open(url);
	}
}

function weeklybrand(){
	var brand = document.getElementById('brandid').value;
	if(brand!=0){
		var url= 'http://albertsons.shoplocal.com/albertsons/Default.aspx?action=browsebrand&storeid=2407397&brandid='+brand;
		window.open(url);
	}

}

function test(){
window.opener.parent.location.href='/eCommerceWeb/ContactUsAction.do?action=beginContactUs';
}


function checkForEnter(e,fnName) 
{ var key = e.keyCode;
   if(key=="13" && navigator.userAgent=="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1"){
   eval(fnName);
   } if(key=="13" && navigator.userAgent=="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20001108 Netscape6/6.0"){     
      eval(fnName); 
    }
 }
 
function recipeSearch(){
var status = checkCookie();
if(status){
if(isBlank(document.forms[0].remoteQuery.value)){
alert("Please enter the word or phrase you would like to search for");
document.forms[0].remoteQuery.focus();
}else if(!isAlphaNumSrchKeyword(document.forms[0].remoteQuery.value)){
                alert(KeywordInval);
               document.forms[0].remoteQuery.focus();
    }
else{
document.forms[0].submit();
}
}
}
 
 
 
 function checkForEnterKey(e,fnName) 
{
    var key = "";
    if(window.event) {
        key = e.keyCode;
    } else if(e.which) {
        key = e.which; 
    }     
    if(key == "13"){
        eval(fnName);
    }    
}

function checkStatus()
  {
  if(document.forms[0].promotionalOffers.checked == true)
  document.forms[0].promotionalOffers.value ="Y";
  if(document.forms[0].personalizedOffers.checked == true)
  document.forms[0].personalizedOffers.value ="Y";
  if(document.forms[0].specialOffers.checked == true)
  document.forms[0].specialOffers.value ="Y";
  if(document.forms[0].seasonalArticles.checked == true)
  document.forms[0].seasonalArticles.value ="Y";
  if(document.forms[0].customerSurveys.checked == true)
  document.forms[0].customerSurveys.value ="Y";
  if(document.forms[0].infoPartners.checked == true)
  document.forms[0].infoPartners.value ="Y";
  document.forms[0].submit;
  return false;
  }
  
  
 function checkForEnterParam1(e,fnName,param1,param2) {
 var key = e.which; 
 var methodName = fnName+ "(" +"'"  +param1+ "'"  + "'"  +param2+ "'"+")";
   if(key=="13" && navigator.userAgent=="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1"){
           eval(methodName);
   }
   if(key=="0" && navigator.userAgent=="Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20001108 Netscape6/6.0"){     
           eval(methodName);
    }
 }
 
function checkForEnterSearch(e,fnName) 
{
    var key = "";
    if(window.event) {
        key = e.keyCode;
    } else if(e.which) {
        key = e.which; 
    }     
    if(key == "13" || key == "0"){
        eval(fnName);
    } 
     
}

    //CVV maximum entries field
    var visaMaxLen=3
    var masterMaxLen=3
    var amExMaxLen=4
    var discoverMaxLen=3



     //JS error messages 
    //Credit card
     var cardDescriptionNull="Please enter your credit card description.";
     var cardDescriptionAlpha="Your card description can contain only alpha-numeric characters. Please re-enter.";
     var cardDescriptionBlankSpace="Your card description cannot contain blank spaces. Please re-enter.";
     var cardHolderName="Please enter your card holder name exactly as it appears on the credit card.";
     var cardHolderNameAlpha="Your card holder name can contain only alpha characters. Please re-enter.";
     var cardTypeNull="Please select your credit card type.";
     var cardNumNull="Please enter credit card number.";
     var cardNumInvalid="Please enter a valid credit card number.";
     var visacardLength="Your visacard can be either 13 or 16 digits.";
     var mastercardLength = "Your mastercard should be 16 digits.";
     var discovercardLength = "Your discovercard should be 16 digits.";
     var amexcardLength="Your AmericanExpress card should be 15 digits.";
     
     var cardNumLength="Your credit card can contain 16 numeric digits. Please re-enter.";
     var cardNumNumeric="Your credit card can contain only numeric digits. Please re-enter.";
     var cardMisMatch="Please enter a valid credit card number.";
     var cardVerificationNumNull="Please enter the card verification code as it appears on your credit card.";
     var cardVerificationNumNumeric="Your verification number can contain only numeric digits. Please re-enter.";
     var cardVerificationInvalid="Your verification number can contain 3 or 4 numeric digits. Please re-enter.";
     var cardExpiryMonthNull="Please select the month that your credit card expires.";
     var cardExpiryYearNull="Please select the year that your credit card expires.";
     var cardExpiryMonthYearInvalid="Your credit card has expired. Please check the expiration date and try again.";
     var cardVerificationVisaInvalid="Your verification number for VisaCard can contain only "+visaMaxLen+" digits. Please re-enter.";
     var cardVerificationMasterInvalid="Your verification number for MasterCard can contain only "+masterMaxLen+" digits. Please re-enter.";
     var cardVerificationAmExInvalid="Your verification number for AmExCard can contain only "+amExMaxLen+" digits. Please re-enter.";
     var cardVerificationDiscoverInvalid="Your verification number for DiscoverCard can contain only "+discoverMaxLen+" digits. Please re-enter.";
     
    
    //Address
	 var descriptionNull="Please enter a short description to help you identify this address.";
	 var descriptionAlpha="You entered special characters that cannot be read by our system. Please re-enter your description.";
	 var streetNull="Please enter your street address.";
     var streetNumeric="Your street address cannot contain only numeric characters. Please re-enter";
	 var streetInvalid="Your street address can contain only letters and numbers and special characters like , . -. Please re-enter";
     var unitInval="Your unit can contain only alpha-numeric characters and some special characters like  # , - . & ; (). Please re-enter.";
	 var cityNull="Please enter your city of residence.";
	 var cityAlpha="Your city can contain only alphabets and some special characters like . , -. Please re-enter."; 
	 var countryAlpha="Your country can contain only alphabets. Please re-enter.";
	 var phoneNull="Please enter your phone number.";
	 var phoneInvalid="Please enter a valid phone number."; 
	 var stateNull="Please select your state of residence.";
	 var zipNull="Please enter your zip code.";
	 var zipLength="Your zip code must be five digits long. Please re-enter your zip code.";
	 var zipInvalid="Please enter a valid zip code.";
	 var zipLastInvalid="Please enter a valid zip code 2 add-on.";
	 var zipLastLength="Your zip code 2 add-on must be four digits long. Please re-enter your zip code add-on.";
     var zipLastOnlyNumber="Your zip code 2 add-on must be numeric. Please enter only numbers."

     var splDelvInstructionLength="Special Delivery Instructions must be 300 characters or less. Please re-enter";
     var maxLength1="Word length cannot exceed 50 characters: Please re-enter ";
     var maxLength2="Word length cannot exceed 25 characters: Please re-enter ";
     var compNameInvalid ="Company Name can contain only alpha-numeric characters and some special characters like - . , & @ |(). Please re-enter."; 
     var AptSuiteInval = "Apt/Suite can contain only alpha-numeric characters and some special characters like   # , . - & ; (). Please re-enter."; 
     var messageToFriend = "Message to freind can contain only alpha-numeric characters and some special characters like  !-,@*\"()'$&%: . Please re-enter."; 
     var SplDelvInstructInval = "Special instructions can contain only alpha-numeric characters and some special characters like  ?$\"\\,()&<>@|';+ . Please re-enter."; 
     
//Account Details
     var firstNameNull="Please enter your first name.";
     var middleNameAlphaNumeric = "You entered special characters that cannot be read by our system. Please re-enter your middle name.";
     var firstNameAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter your first name.";
     var lastNameNull="Please enter your last name.";
     var lastNameAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter your last name.";
     var firstNameOnlyNumber="First Name should not contain only numbers.";
     var middleNameOnlyNumber="Middle Name should not contain any number.";
     var lastNameOnlyNumber="Last Name should not contain only numbers.";
     var userNameNull="Please enter your user name.";
     var userNameNPwdNull="Please enter your user name and password.";
     var userNameAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter your user name.";
     var userNameLength="The user name should be between 6 and 20 characters. Please re-enter.";
     var usernameOnlyNumber="User Name should not contain only numbers.";
     var oldPasswordNull="Please enter your old password.";
     var oldPasswordAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter a valid password.";
     var passwordNull="Please enter your password.";
     var passwordAlphaNumeric="You entered special characters/blank spaces that cannot be read by our system. Please re-enter a valid password.";
     var passwordInvalid="Your password should contain at least one character and one digit. Please re-enter.";
     var passwordLength="Your password should be between 6 to 20 characters. Please re-enter";
     var passwordMatch="The username and password cannot be similar. Please re-enter.";
     var rePasswordNull="Please enter your password once again.";
     var passwordMisMatch="The passwords entered do not match. Please re-enter.";
     var emailNull="Please enter your e-mail address.";
     var emailInvalid="Please enter a valid email address.";
     var ccEmailInvalid="Please enter a valid CC email address.";
     var reEmailNull="Please re-enter your email address.";
     var reEmailInvalid="Please enter a valid email address";
     var emailMisMatch="The emails should match. Please re-enter.";
     var currentPasswordNull="Please enter your current password";
     var passwordNull="Please enter your password";
     var passwordWithoutSpace="Your password should not contain blank spaces. Please re-enter.";
     
     var hintQuestionCodeNull="Please select a password hint question.";
     var hintAnswerNull="Please enter an answer to your password hint question.";
     var hintAnswerAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter the answer to your password hint question.";
     var pscNumberNull="Please enter your PSC number.";
     var pscNumberLength="Please enter 11 digits for PSC number.";
     var pscPhoneNumberNull="Please enter your PSC phone number.";
     var pscPhoneNumberLength="Please enter 10 digits for PSC phone number.";
     var referralsInvalid="Please enter a valid email address.";
     var termsCheckedNull="Please read our terms & conditions before continuing.";
     var alternateIdNumeric="Alternate Id should be a numeric value. Please re-enter."
     var alternateIdLength="Alternate Id should contain 10 digits. Please re-enter."
     var alternateIdInvalid="Alternate Id should not start with 0, 1, 800, 866, 877, 888, 900 or 976 and the prefix should not be 555. Please re-enter."
     var replaceCardInvalid="Replace Card number should start with 4. Please re-enter."
     var substitutionpolicy="Please read & select our substitution policy";
     var replaceCardNull = "Please enter the Replace Card number.";
     var replaceCardLength ="Please enter 11 digits for Replace Card number.";
 //Community Form
    var companyNameNull="Please select the company name.";
    var companyNameAlphaNumeric="You entered special characters that cannot be read by our system. Please re-enter your company name.";
    var communityCardNull="Please enter your card number.";
    var communityCardLength="Your card number contain 11 digits. Please re-enter.";
      
//contact us
    var firstNameNull = "Please enter first name.";
	var lastNameNull = "Please enter last name.";
    var nameNull="Please enter the name.";
    var nameInvalid="Please enter valid name.";
    var incidentDateInvalid="Please enter in date format.";
    var commentsNull="Please enter your comments.";
    var streeNull="Please enter your street address.";
    var incidentDateInvalid="Please enter a valid Incident Date.";
    var commentsNull="Please enter the comments.";
    var unitInvalid="You entered special characters that cannot be read by our system.";
    var zipLastInvalid="Please enter a valid zip code 2 add-on.";
    var timeOfContactInvalid="Best Time to contact can contain only alphabets and time information. Please re-enter.";
    var TextLongInvalid="The text in the Comments field cannot exceed 2000 characters.";
    var invalidDescription="The text in the Description field cannot exceed 254 characters.";
    var InvalidDate="Incident date should not be after current date.";
    var InvalidTime="Incident time should not be after current time.";    
    var phoneEmpty="Please enter your phone number.";
    var pscNumberInvalid = "Please enter valid PSC number.";
    var InvalidTimeValidDate = "Please enter valid time.";
    var InvalidDateValidTime = "Please enter valid date.";
	var CommentsInval = "Comments can contain only alpha-numeric characters and some special characters like (-!,@*\"()'$&%:). Please re-enter.";  
    var DescInval = "Description of the problem can contain only alpha-numeric characters and some special characters like (-!,@*\"()'$&%:). Please re-enter.";
    var NoteInsructInval = "Notes & Instructions of the problem can contain only alpha-numeric characters and some special characters like ?$\"\\,()&<>@|';+ . Please re-enter.";    
    var storeAddressAlphaNumeric="Store Address can contain only alpha-numeric characters and special characters like &. Please re-enter.";
    
    
//ShoppingListCart
    var CartLiteLoading = "Cart is loading, please wait";   
    
//Search Messages
    var searchTermNull="Please enter the word or phrase you would like to search for";
    var KeywordInval="You entered certain special characters that cannot be read by our system. Please re-enter.";
        
function getElementsByClassName(cls,tag,parent) {
	var d,a,e,i,c;
	d = (parent) ? parent : document;
	if(tag) {
        a = d.all && d.all.tags(tag) || d.getElementsByTagName(tag);
	} else {
		a = d.all || d.getElementsByTagName("*");
	}
	e = [];
	for(i=0,c=0; i<a.length; i++) {
	   if(a[i].className == cls) {
	       e[c] = a[i];
	   c++;
	   }
	}
	return e;
}

function loadSwapImage() {

    var e = getElementsByClassName('swap');

    for(var i=0; i<e.length; i++) {
        var imgObj = e[i].getElementsByTagName("IMG")[0];
        if(imgObj){
            e[i].synImg = imgObj;
            var tmpI = new Image();
            tmpI.src = swapImage(e[i],0,0);
            e[i].onmouseover = function(){ swapImage(this,1,1) };
            e[i].onmouseout = function(){ swapImage(this,0,1) };
        }
    }
}

function swapImage(obj,state,swap){
	var over = "_1.";
	var out = "_0.";
	var str = obj.synImg.src;
	str = (str.indexOf(over)!=-1)?str.replace(over,out):str.replace(out,over);
	
    if(swap){
	    if(state==1 || state==0 && obj.init){
	        obj.synImg.src = str;
	    }
	    obj.init = true;
	}
    return str;
}


function selectTimeSlot(Id,winInd,dateInd)
 {
     obj=document.getElementById(Id);
     document.tempCheckForm.cacheSlotId.value = Id;
     var selObjImgSrc = null;
     var slotFullIcon =  false;
     if(obj.src.indexOf("full_icon.gif")!=-1){  
     	slotFullIcon =  true;
        alert("This time slot is Full.Please select another slot.");      
     }
     else
     {
         document.forms["checkoutForm"].slotDate.value = dateSlot[dateInd];
         document.forms["checkoutForm"].slotTime.value = timeSlot[winInd];
         document.forms["checkoutForm"].windowId.value = windowIds[winInd];
         document.forms["checkoutForm"].selDatess.value = dateSlotDiffPatern[dateInd];
         document.forms["checkoutForm"].selDatess1.value = datePattern[dateInd];
        var oldId = document.forms["truckForm"].truckID.value;
          //alert(oldId);
          if(oldId != "00")
          {
              oldObj=document.getElementById(oldId);
              oldObj.src = document.forms["truckForm"].truckImage.value;
          }   
          document.forms["truckForm"].truckID.value=Id;
        
          if(obj.src.indexOf("available_icon.gif")!=-1)
          {
              selObjImgSrc = "/eCommerceWeb/images/eCommerce/myOrders/available_icon.gif"; 
              obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
              document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/available_icon.gif";
          }
          else if(obj.src.indexOf("almost_icon.gif")!=-1)
          {	
          	   selObjImgSrc = "/eCommerceWeb/images/eCommerce/myOrders/almost_icon.gif"; 	
          	   obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/almost_icon.gif";
          }
          else if(obj.src.indexOf("selected_icon.gif")!=-1)
          {
               obj.src = document.forms["truckForm"].truckImage.value;
          }
        }
        
		var slotSelText="<table border='0' class='tab-1-5' width='503' height='44'><tr><td width='146' align='right'><img src='"+selObjImgSrc+"' height='25px'  alt='Available' title='Available'/></td>"+
						"<td class='pad-left-5'>You have selected <b>"+document.forms["checkoutForm"].selDatess.value+suffixId(document.forms["checkoutForm"].selDatess1.value)+"</b><br>at <b>"+document.forms["checkoutForm"].slotTime.value+".</b></td></tr>"+
						"</table>";
					
						
		if(slotFullIcon != true){
		document.getElementById('slotSelectionDisplay').style.visibility="visible";
		document.getElementById('slotSelectionDisplay').innerHTML = slotSelText;
		document.tempCheckForm.selInfoTxt.value = slotSelText;
		}else{
			document.getElementById('slotSelectionDisplay').innerHTML = "";
		}
		return false;
	}
	
function selectTimeSlotPickup(Id,winInd,dateInd)
{
     obj=document.getElementById(Id);
     document.tempCheckForm.cacheSlotId.value = Id;
     var selObjImgSrc = null;
     var slotFullIcon =  false;
     if(obj.src.indexOf("full_icon_pickup.gif")!=-1){  
     	slotFullIcon =  true;
        alert("This time slot is Full.Please select another slot.");      
     }
     else
     {
         document.forms["checkoutForm"].slotDate.value = dateSlot[dateInd];
         document.forms["checkoutForm"].slotTime.value = timeSlot[winInd];
         document.forms["checkoutForm"].windowId.value = windowIds[winInd];
         document.forms["checkoutForm"].selDatess.value = dateSlotDiffPatern[dateInd];
         document.forms["checkoutForm"].selDatess1.value = datePattern[dateInd];
         var oldId = document.forms["truckForm"].truckID.value;
          if(oldId != "00")
          {
              oldObj=document.getElementById(oldId);
              oldObj.src = document.forms["truckForm"].truckImage.value;
          }   
          document.forms["truckForm"].truckID.value=Id;
          
          if(obj.src.indexOf("available_icon_pickup.gif")!=-1)
          {
          	  selObjImgSrc = "/eCommerceWeb/images/eCommerce/myOrders/available_icon_pickup.gif";
              obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon_pickup.gif";
              document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/available_icon_pickup.gif";
          }
          else if(obj.src.indexOf("almost_icon_pickup.gif")!=-1)
          {
          	   selObjImgSrc = "/eCommerceWeb/images/eCommerce/myOrders/almost_icon_pickup.gif"; 	
          	   obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon_pickup.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/almost_icon_pickup.gif";
          }
          else if(obj.src.indexOf("selected_icon_pickup.gif")!=-1)
          {
               obj.src = document.forms["truckForm"].truckImage.value;
          }
        }
        
		var slotSelText="<table border='0' class='tab-1-5' width='503' height='44'><tr><td width='146' align='right'><img src='"+selObjImgSrc+"' height='25px'  alt='Available' title='Available'/></td>"+
						"<td class='pad-left-5'>You have selected <b>"+document.forms["checkoutForm"].selDatess.value+suffixId(document.forms["checkoutForm"].selDatess1.value)+"</b><br>at <b>"+document.forms["checkoutForm"].slotTime.value+".</b></td></tr>"+
						"</table>";
					
						
		if(slotFullIcon != true){
		document.getElementById('slotSelectionDisplay').style.visibility="visible";
		document.getElementById('slotSelectionDisplay').innerHTML = slotSelText;
		document.tempCheckForm.selInfoTxt.value = slotSelText;
		}else{
			document.getElementById('slotSelectionDisplay').innerHTML = "";
		}
		return false;
	}
	
function suffixId(id){
 if(id%10==1 && id!=11)
 return "st";
 else if(id%10 == 2 && id!=12)
 return "nd";
 else if(id%10 == 3 && id!=13)
 return "rd"
 else
  return "th";
}

 function selectOrderTimeSlot(Id,winInd,dateInd)
 {
     obj=document.getElementById(Id);
     document.checkoutForm.cacheSlotId.value = Id;
     if(obj.src.indexOf("full_icon.gif")!=-1){   
        alert("This time slot is Full.Please select another slot.");      
     }
     else
     {
         document.forms["checkoutForm"].slotDate.value = dateSlot[dateInd];
         document.forms["checkoutForm"].slotTime.value = timeSlot[winInd];
         document.forms["checkoutForm"].windowId.value = windowIds[winInd];
        var oldId = document.forms["truckForm"].truckID.value;
          if(oldId != "00")
          {
              oldObj=document.getElementById(oldId);
              oldObj.src = document.forms["truckForm"].truckImage.value;
          }   
          document.forms["truckForm"].truckID.value=Id;
          
          if(obj.src.indexOf("available_icon.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/available_icon.gif";
          }
          else if(obj.src.indexOf("almost_icon.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/almost_icon.gif";
          }
          else if(obj.src.indexOf("selected_icon.gif")!=-1)
          {
               obj.src = document.forms["truckForm"].truckImage.value;
          }
    
     }
     return false;
 
 }
 
function selectOrderTimeSlotPickup(Id,winInd,dateInd)
 {
     obj=document.getElementById(Id);
     document.checkoutForm.cacheSlotId.value = Id;
     if(obj.src.indexOf("full_icon_pickup.gif")!=-1){   
        alert("This time slot is Full.Please select another slot.");      
     }
     else
     {
         document.forms["checkoutForm"].slotDate.value = dateSlot[dateInd];
         document.forms["checkoutForm"].slotTime.value = timeSlot[winInd];
         document.forms["checkoutForm"].windowId.value = windowIds[winInd];
        var oldId = document.forms["truckForm"].truckID.value;
          if(oldId != "00")
          {
              oldObj=document.getElementById(oldId);
              oldObj.src = document.forms["truckForm"].truckImage.value;
          }   
          document.forms["truckForm"].truckID.value=Id;
          
          if(obj.src.indexOf("available_icon_pickup.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon_pickup.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/available_icon_pickup.gif";
          }
          else if(obj.src.indexOf("almost_icon_pickup.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon_pickup.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/almost_icon_pickup.gif";
          }
          else if(obj.src.indexOf("selected_icon_pickup.gif")!=-1)
          {
               obj.src = document.forms["truckForm"].truckImage.value;
          }
    
     }
     return false;
 
 }
 
function changeImage(Id)
 {
     //alert ("hai"+Id);
     obj=document.getElementById(Id);
     //alert(parseInt(Id%10));
     //alert(obj.src);
      //alert(document.forms["checkoutForm"].slotDate.value);
     if(obj.src.indexOf("full_icon.gif")!=-1){   
        alert("This time slot is Full.Please select another slot.");      
     }
         
     else
     {
         document.forms["checkoutForm"].slotDate.value = dateSlot[Id%10];
         document.forms["checkoutForm"].slotTime.value = timeSlot[parseInt(Id/10)];
         document.forms["checkoutForm"].windowId.value = windowIds[parseInt(Id/10)];
        var oldId = document.forms["truckForm"].truckID.value;
          //alert(oldId);
          if(oldId != "00")
          {
              oldObj=document.getElementById(oldId);
              oldObj.src = document.forms["truckForm"].truckImage.value;
          }   
          document.forms["truckForm"].truckID.value=Id;
          
          if(obj.src.indexOf("available_icon.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/available_icon.gif";
          }
          else if(obj.src.indexOf("almost_icon.gif")!=-1)
          {
               obj.src = "/eCommerceWeb/images/eCommerce/myOrders/selected_icon.gif";
               document.forms["truckForm"].truckImage.value="/eCommerceWeb/images/eCommerce/myOrders/almost_icon.gif";
          }
          else if(obj.src.indexOf("selected_icon.gif")!=-1)
          {
               obj.src = document.forms["truckForm"].truckImage.value;
          }
    
     }
     return false;
 
 }

function checkValidZip(param, len)
{ 
    var param=trim(param);
    var num="0123456789";
    var tempChar;
    
        if (param.length== len ){
        if(param.charAt(0)=="0" && param.charAt(1)=="0"){
            return false;
        }
        else{
        for(ctrI=0; ctrI < param.length; ctrI++){
             if (num.indexOf(param.charAt(ctrI)) == -1){
                 return false;
             }
         }
         }
         }
          return true;
}

/*JavaSript code for ShowImages/HideImages */
function showHideImages(divId,divText,imgHeight,imgWidth)
{
    var img = document.images;
    if(divText == "Show Images"){
        for(var i=0;i<img.length;i++){
            if(img[i].className == 'HideImageClass'){
                img[i].className = 'ShowImageClass';
                img[i].width = imgWidth;
                img[i].height = imgHeight;
                img[i].style.width =imgWidth+'px' ;
            }
        }
        eval("document.getElementById('" + divId + "').innerHTML = 'Hide Images'");
    }else{
        for(var i=0;i<img.length;i++){
            if(img[i].className == 'ShowImageClass'){
                img[i].className = 'HideImageClass';
                img[i].width = '0';
                img[i].height = '0';
                img[i].style.width = '0px' ;
            } 
        }
        eval("document.getElementById('" + divId + "').innerHTML = 'Show Images'");
    }
    setShowHideImgCookie(divText);
}

function prodListShowHideImages(divId,divText,imgHeight,imgWidth)
{
    var img = document.images;
    if(divText == "SHOW IMAGES"){
        for(var i=0;i<img.length;i++){
            if(img[i].className == 'HideImageClass'){
                img[i].className = 'ShowImageClass';
                img[i].width = imgWidth;
                img[i].height = imgHeight;
             }
        }
        eval("document.getElementById('" + divId + "').innerHTML = 'HIDE IMAGES'");
    }else{
        for(var i=0;i<img.length;i++){
            if(img[i].className == 'ShowImageClass'){
                img[i].className = 'HideImageClass';
                img[i].width = '0';
                img[i].height = '0';
            } 
        }
        eval("document.getElementById('" + divId + "').innerHTML = 'SHOW IMAGES'");
    }
    setShowHideImgCookie(divText);
}

var DH = 0
var an = 0
var al = 0
var ai = 0
if (document.getElementById) {
	ai = 1
	DH = 1
}else {
alert('test1')
	if (document.all) {
		al = 1
	 	DH = 1
	} else { 
		browserVersion = parseInt(navigator.appVersion)
	 	if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
	 		an = 1
	 		DH = 1
	 	}
	 }
} 

function fd(oi, wS) {
	if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi)
	if (al) return wS ? document.all[oi].style: document.all[oi]
	if (an) return document.layers[oi]
}

function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null
}

function mouseX(evt) {
	if (evt.pageX) 
		return evt.pageX
	else if (evt.clientX)
		return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft)
	else 
	 	return null
}
function mouseY(evt) {
	if (evt.pageY) 
		return evt.pageY
	else if (evt.clientY)
		return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop)
	else 
	 	return null
}
function popUp(evt,oi) {

	if (DH) {
		var wp = pw()
		dm = fd(oi,0)
		ds = fd(oi,1)
		st = ds.visibility
		if (dm.offsetWidth) 
			ew = dm.offsetWidth
		else if (dm.clip.width) 
			ew = dm.clip.width
		if (st == "visible" || st == "show") { 
			ds.visibility = "hidden"
		 } else {
			tv = mouseY(evt) + 20
			lv = mouseX(evt) - (ew/4)
			if (lv < 2) lv = 2
				else if (lv + ew > wp) 
					lv -= ew/2
			if (!an) {
				lv += 'px'
				tv += 'px'
			}
			ds.left = lv
			ds.top = tv
			ds.visibility = "visible"
		}
	}
}

function showHideImages2(divId1,divId2, divText,imgHeight,imgWidth)//This method is for pages having '2' hide Images link

{
//alert("hai");
var img = document.images;

if(divText == "Show Images"){
    for(var i=0;i<img.length;i++){
        if(img[i].className == 'HideImageClass'){
            img[i].className = 'ShowImageClass';
            img[i].width = imgWidth;
            img[i].height = imgHeight;
        }
    }
    eval("document.getElementById('" + divId1 + "').innerHTML = 'Hide Images'");
    eval("document.getElementById('" + divId2 + "').innerHTML = 'Hide Images'"); //Modified by ranga/prem
}else{
    for(var i=0;i<img.length;i++){
        if(img[i].className == 'ShowImageClass'){
            img[i].className = 'HideImageClass';
            img[i].width = 0;
            img[i].height = 0;
        } 
    }
    eval("document.getElementById('" + divId1 + "').innerHTML = 'Show Images'");
    eval("document.getElementById('" + divId2 + "').innerHTML = 'Show Images'"); //Modified by ranga/prem 
}
setShowHideImgCookie(divText);
}


/*JavaSript code for Spinner Ctl  */
    
//'Quantity' Text field name is assumed to be qty
function incr(form,index,divId,maxQty)
  {

            var elm = eval("document."+form+".elements");
           
            var k=0;
            for(var l=0; l<elm.length;l++)
            {
                if(elm[l].name == 'qty')
                {
                    k++;
                }
            }

             var ind=parseInt(index)-1; 
    if(k>1)
    {
  
           var isCartPresent= eval("document."+form+".isCartPresent["+ind+"].value");
           var s1=eval("document."+form+".qty["+ind+"].value");
           if ( isNaN(s1) || s1=='')
            {
                s1 = 1;                                        
            }
           var s2=parseInt(s1)+1;         
           if(s2>0)
           {
                if(s2 > maxQty)
                {
                  alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                  s2=s2-1;
                } else if(eval("document."+form+".controlCode["+ind+"].value") == 4 ){
                    prodId = eval("document."+form+".productId["+ind+"].value");
                    deaLimit = eval("document."+form+".deaLimit.value");
	                var allowableQty = checkDEALimit(window.frames['cartFrame'].document.forms[0],prodId,s2,deaLimit);
                    if(allowableQty > 0) {         
	                    s2 = allowableQty;
	                }else if(allowableQty == 0){
                        s2=1;
                    }
                   
	            }
                /*else{
	                if(s2 > maxQty)
	                    {
	                      alert("You can add a maximum of "+ maxQty + " quantity");
	                      s2=s2-1;
	                    } 
                }  */  
             if(isCartPresent == 'true') 

             eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + index + ",\\'update\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_update.gif\" alt=\"Update Cart\" title=\"Update Cart\"></a>'");
         
           else
           
             eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + index + ",\\'add\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_add.gif\" alt=\"Add To Cart\" title=\"Add To Cart\"></a>'");  
         }       
          eval("document."+form+".qty[" + ind + "].value='" + s2 + "'");    
      } 
      
      
      else
        { 
            var isCartPresent= eval("document."+form+".isCartPresent.value");
            var s1=eval("document."+form+".qty.value");
            if ( isNaN(s1) || s1=='')
            {
                s1 = 1;
                
            }
            var s2=parseInt(s1)+1;                
             
               if(s2>0)
               {
               
                  if(s2 > maxQty)
                    {
                      alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                      s2=s2-1;
                    }else if(eval("document."+form+".controlCode.value") == 4 ){
                    prodId = eval("document."+form+".productId.value");
                    deaLimit = eval("document."+form+".deaLimit.value");
                    var allowableQty = checkDEALimit(window.frames['cartFrame'].document.forms[0],prodId,s2,deaLimit);
                    if(allowableQty > 0) {         
                        s2 = allowableQty;
                    }else if(allowableQty == 0){
                        s2=s2-1;
                    }
                } 
               
                     if(isCartPresent == 'true') 
        
                    eval("document.getElementById('" + divId + "').innerHTML = \"<a href=\\'#\\' onclick=javascript:addToCart('" + form + "',1,'update')><img src='/eCommerceWeb/images/eCommerce/common/cart_update.gif' alt='Update Cart' title='Update Cart'></a>\"");
                 
                   else
                   
                     eval("document.getElementById('" + divId + "').innerHTML = \"<a href=\\'#\\' onclick=javascript:addToCart('" + form + "',1,'add')><img src='/eCommerceWeb/images/eCommerce/common/cart_add.gif' alt='Add To Cart' title='Add To Cart'></a>\"");  
               }   
               
               eval("document."+form+".qty.value='" + s2 + "'");                     
        }
      
       
  }

 function decr(form,ind,divId)
  {
         var elm = eval("document."+form+".elements");
           
            var k=0;
            for(var l=0; l<elm.length;l++)
            {
                if(elm[l].name == 'qty')
                {
                    k++;
                }
            }
       
    if(k>1)
    {
       var index=parseInt(ind)-1; 
       var isCartPresent= eval("document."+form+".isCartPresent["+index+"].value");
       var s1=eval("document."+form+".qty["+index+"].value");
       if ( isNaN(s1) || s1=='')
            {   
                s1 = 1;
                
            }
       var s2=parseInt(s1)-1;
           if(s2<=0 && isCartPresent == 'true')
            {
               s2=0;
               eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + ind + ",\\'remove\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_remove.gif\" alt=\"Remove Cart\" title=\"Remove Cart\"></a>'");                        
            }
            else
            {
              if(s2<=1)
                s2=1;
            }
            eval("document."+form+".qty[" + index + "].value='" + s2 + "'");
            
     }
     
     else
     {     
            var isCartPresent= eval("document."+form+".isCartPresent.value");
            var s1=eval("document."+form+".qty.value");
            if ( isNaN(s1) || s1=='')
            {
                s1 = 1;
                
            }
            var s2=parseInt(s1)-1;
               if(s2 <=0 && isCartPresent == 'true')
                {
                   s2=0;
                   eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + ind + ",\\'remove\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_remove.gif\" alt=\"Remove Cart\" title=\"Remove Cart\"></a>'");                        
                   
                }
                 else
                    {
                      if(s2<=1)
                        s2=1;
                    }
                 eval("document."+form+".qty.value='" + s2 + "'");   
                        
      }        
      

  } 
          
//'Quantity' Text field name is assumed to be qty
  function on_Change(form,index,divId,maxQty)
     {
       var key = window.event.keyCode;
       var elm = eval("document."+form+".elements");
       var controlCode = null;
       var k=0;
       var elm = eval("document."+form+".elements");
       var controlCode = null;
       var discBogoVal = null;
        var k=0;
        for(var l=0; l<elm.length;l++)
        {
            if(elm[l].name == 'qty')
            {
                k++;
            }
        }
               
         var ind=parseInt(index)-1; 
         if(k>1)   
           {              
             var isCartPresent= eval("document."+form+".isCartPresent["+ind+"].value");
             var s3=eval("document."+form+".qty["+ind+"].value"); 
             discBogoVal= eval("document."+form+".discBogo["+ind+"].value");
             if (( isNaN(s3) || s3 == ' ' || s3 == '-' )) 
		    { 
		        alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
                eval("document."+form+".qty[" + ind + "].value=1");   
                eval("document."+form+".qty["+ind+"].focus()");
                return false;
		    } 
             
             var prodId = eval("document."+form+".productId["+ind+"].value");
             controlCode = eval("document."+form+".controlCode["+ind+"].value");     
	          if(s3 == '' && key=='13')
	            {
	             alert("quantity field must not be empty");
                 eval("document."+form+".qty[" + ind + "].value='" + 1 + "'");   
                 if(discBogoVal == '4')
                 eval("document."+form+".qty[" + ind + "].value='" + 2 + "'");     
	            }                 
           } 
         else
           {
             var isCartPresent= eval("document."+form+".isCartPresent.value");
             var s3=eval("document."+form+".qty.value");
             discBogoVal= eval("document."+form+".discBogo.value");
             if (( isNaN(s3) || s3 == ' ' || s3 == '-' )) 
            { 
                alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
                eval("document."+form+".qty.value=1"); 
                eval("document."+form+".qty.focus()");
                return false;
            } 
             var prodId = eval("document."+form+".productId.value");
             controlCode = eval("document."+form+".controlCode.value")
             if(s3 == '' && key=='13')
		        {
		         alert("quantity field must not be empty");
	 		     eval("document."+form+".qty.value='" + 1 + "'");    
                 if(discBogoVal == '4')
                 eval("document."+form+".qty.value='" + 2 + "'"); 
	            }             
           }
        
         var s4= new Number(s3);
         var temp="0123456789";
           
         for(var i=0;i<s3.length;i++)
            {
                var s5=""+s3.substring(i,i+1);
                if(temp.indexOf(s5)!="-1")
                    {
                 
                                                
                         if(s4<=0)
                             {
                             
                             if(isCartPresent == 'true')                                      
                               {                                     
                                s4=0;                                        
                                eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + index + ",\\'remove\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_remove.gif\" alt=\"Remove Cart\" title=\"Remove Cart\"></a>'");                        
                              
                                }
                              else
                                {
                                  s4 = 1;
                                  if(discBogoVal == '4')
                                  s4 = 2;
                                }    
                                
                               
                                   if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + s4 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + s4 + "'");    
                                
                                
                             }  
         
                            else
                            {
                               if(controlCode == 4 ){
				                    deaLimit = eval("document."+form+".deaLimit.value");
					                var allowableQty = checkDEALimit(window.frames['cartFrame'].document.forms[0],prodId,s4,deaLimit);
                                    if(allowableQty > 0) {         
					                    s4 = allowableQty;
					                }else if(allowableQty == 0){
					                    s4 = 1;
					                }
                                    if(s4 > maxQty && allowableQty == -1 )
                                    {
                                      alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                                      s4 = maxQty;
                                    }
					            }else {
	                                if(s4 > maxQty)
	                                {
	                                  alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
	                                  s4 = maxQty;
	                                }
                                }
                               if(isCartPresent == 'true') 
                               {
                                    
                                     eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + index + ",\\'update\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_update.gif\" alt=\"Update Cart\" title=\"Update Cart\"></a>'");
                                } 
                               else
                               {    
                                    
                                     eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + index + ",\\'add\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_add.gif\" alt=\"Add To Cart\" title=\"Add To Cart\"></a>'");  
                                }
                                  if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + s4 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + s4 + "'");    
                            }        
                    }
            
                    else
                    {
                                if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + 1 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + 1 + "'");    
                        alert("Item quantity must be a whole number. Fractions and decimals are not allowed");   
                        return;
                    }  
                           
                }    
               
      }
      
      
   /* Add To Cart Function */           
    function addToCart(formName,ind,transType,price,isCartPresent){        
     //alert(formName+","+ind+","+transType+","+price+","+isCartPresent);
    document.addToCartForm.toCart.value = transType;
    var oldIndex = ind;
	 var prodIndex = "";
	 if(document.getElementById('prodIndex'+ind) != null){
		prodIndex = document.getElementById('prodIndex'+ind).value;
	 }
	 //alert("index :"+ind);
	 //alert("prodIndex: "+prodIndex);	 
  	 //alert("formName:"+formName+".ind.:"+ind+".prodIndex.:"+prodIndex);
     var elm = eval("document."+formName+".elements");
     var productId=null;
     var productName=null;
     var sizeDescription=null; 
     var prodId=null;
     var controlCode= null; 
     var aisleId = null;
     var categoryId = null;
     var specialItem = null;
     var bogo =null;
     var k=0;
     var specialPrice=null;
     var offerPrice =null;
     var savePrice =null;
     //var otherSavings =null
     var lcspecialPrice=null;
     var popUpPosition = null;
     var nextPosition = null;
     var pos1 = null;
     var pos2 = null;
     var cartLitePresent = eval("document.addToCartForm.cartLitePresent.value");
     
    for(var l=0; l<elm.length;l++)
    {
        if(elm[l].name == 'qty')
        {
            k++;
        }
    }
    if(prodIndex != ""){
		ind = prodIndex;
    }
    var index=parseInt(ind)-1;
     if(k>1)
     {
		for(var i=1;i<=k;i++){
			if(document.getElementById('PopUpText'+i))
			{
			document.getElementById('PopUpText'+i).innerHTML = "";
			document.getElementById('PopUpText'+i).style.display = 'none';
			}
		}
	   offerPrice= eval("document."+formName+".offerPrice["+index+"].value"); 
	   savePrice= eval("document."+formName+".savePrice["+index+"].value"); 
	   //otherSavings= eval("document."+formName+".otherSavings["+index+"].value"); 
       lcspecialPrice= eval("document."+formName+".lcspecialPrice["+index+"].value");       
       specialItem = eval("document."+formName+".specialItems["+index+"].value");
       popUpPosition = "popUpDiv"+oldIndex;
       var popUp = "PopUpText"+oldIndex;
       productId=eval("document."+formName+".productId["+index+"].value");
		       
       productName=eval("document."+formName+".productName["+index+"].value");
       //alert("index and productId:::"+index+","+productId+","+productName);
       sizeDescription=eval("document."+formName+".sizeDescription["+index+"].value");
	   controlCode=	eval("document."+formName+".controlCode["+index+"].value");	
	   /* This part of code is written for browse the aisles featuredItems Implementation */
	   /* STARTS */
	   bogo =eval("document."+formName+".bogo["+index+"].value");
	   if(formName == "browseAislesFeaturedItems")
	   {
	    aisleId = eval("document."+formName+".aisleId["+index+"].value");
	    categoryId = eval("document."+formName+".categoryId["+index+"].value");
        }
		/*ENDS */                           
       qty=trim(eval("document."+formName+".qty["+index+"].value"));
        if ( isNaN(qty))
         {                 
           alert("Please enter an item quantity.");
           eval("document."+formName+".qty["+index+"].focus()");       
           return false;  
         }
         else if(qty=='')
         {
           if(transType =='remove')
           {
           alert("The quantity must be zero to remove the item from your cart.");
           eval("document."+formName+".qty[" + index + "].value='" + 0 + "'");
           }
           else 
           {
           alert("Please enter an item quantity.");
           eval("document."+formName+".qty[" + index + "].value=''");
           }
           eval("document."+formName+".qty["+index+"].focus()");
           return false;
         }
      }
     else
     {
       offerPrice=eval("document."+formName+".offerPrice.value");
       savePrice=eval("document."+formName+".savePrice.value");
       //otherSavings= eval("document."+formName+".otherSavings.value"); 
       specialPrice= eval("document."+formName+".specialPrice.value");
 	   lcspecialPrice= eval("document."+formName+".lcspecialPrice.value");
       popUpPosition = "popUpDiv1";
       var popUp = "PopUpText1";
       productId = eval("document."+formName+".productId.value");
                        
       productName = eval("document."+formName+".productName.value");
                        
       sizeDescription = eval("document."+formName+".sizeDescription.value");

       controlCode = eval("document."+formName+".controlCode.value")
        
        specialItem =eval("document."+formName+".specialItems.value");
        bogo = eval("document."+formName+".bogo.value");
       /* This Part of code is written for browse The Aisles FeaturedItems Implementation */
       /*STARTS */ 
       if(formName == "browseAislesFeaturedItems")
	   {
	    aisleId = eval("document."+formName+".aisleId.value");
	    categoryId = eval("document."+formName+".categoryId.value");
        }  
	   /*ENDS*/                  
       qty= trim(eval("document."+formName+".qty.value"));
     
       if ( isNaN(qty))
         {                 
           alert("Please enter an item quantity.");
           eval("document."+formName+".qty.focus()");      
           return false;                                   
         }
         else if(qty=='')
         {
           if(transType =='remove')
           {
           alert("The quantity must be a zero to remove the item from your cart.");
           eval("document."+formName+".qty.value='" + 0 + "'");  
           }
           else 
           {
           eval("document."+formName+".qty.value=''");  
           alert("Please enter an item quantity.");
           }
           eval("document."+formName+".qty.focus()");
           return false;
         }
      
     } 
     lcspecialPrice = parseInt(lcspecialPrice);
     qty = parseInt(qty);
     if(bogo == 'yes' && qty == '1'){
     document.getElementById(popUp).style.display = "";
        if(document.getElementById(popUp).style.left =='' && document.getElementById(popUp).style.top ==''){
	 	pos1 = findPos(document.getElementById(popUpPosition));
		    if(window.parent.document.getElementById("collapsing")!=null)   
			    {
			    document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-510+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
			    }
		    else if(window.parent.document.getElementById("expanding")!=null)
			    {
			    document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-410+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
			else if(window.parent.document.getElementById("searchPosDiv")!=null)
				{
				document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-260+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
			else
				{
				document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-320+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
		}
		
		var imgPath="/eCommerceWeb/images/eCommerce/common/cart-popupSubmit_btn.gif";     
		var OfferText = "<iframe src=\"/eCommerceWeb/html/eCommerce/dummy.html\" style='z-index=-1;'></iframe><table border='0' align='center' height='120px' width='220px'><tr><td align='left' colspan='2' style='padding-left:18px; padding-top:15px; font-family:Verdana; font-size:11px; color:#6e7839;'>This is a Buy 1 Get 1 Free item.</td></tr>"+
		"<tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'>You will save $"+price+".</td></tr>"+
	    "<tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'>Do you want the <strong>1 free</strong> item?</td></tr>"+
        "<tr><td colspan='1' align='right' style='font-family:Verdana; font-size:11px; color:#6e7839;'><input type='radio' value='yes' name='option' id='bogocheck' checked><strong>Yes</strong><br/>"+
        "</td><td colspan='1' align='left' style='font-family:Verdana; font-size:11px; color:#6e7839;'><input type='radio' value='no' name='option' id='bogocheck'/><strong>No</strong><br/>"+
  	    "</td></tr><tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'><a href='#' onClick=\"javascript:cartAction(\'"+(oldIndex-1)+"\',\'"+productId+"\',\'"+productName+"\',\'"+qty+"\',\'"+sizeDescription+"\',\'"+controlCode+"\',\'"+transType+"\',\'"+formName+"\');\">"+
  	    "<img src='"+imgPath+"' alt='Submit'/></a>"+
        "</td></tr></table>"; 
        setTimeout("void(0);",500);
	   document.getElementById(popUp).innerHTML=OfferText;
		
	 } else if(specialItem == 'yes' && qty != '0' && qty < lcspecialPrice && lcspecialPrice == '10' )
	 {	
		document.getElementById(popUp).style.display = "";
	 	if(document.getElementById(popUp).style.left =='' && document.getElementById(popUp).style.top ==''){  
	 	pos1 = findPos(document.getElementById(popUpPosition));
		    if(window.parent.document.getElementById("collapsing")!=null)   
			    {
			    document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-510+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
			    }
		    else if(window.parent.document.getElementById("expanding")!=null)
			    {
			    document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-410+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
			else if(window.parent.document.getElementById("searchPosDiv")!=null)
				{
				document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-260+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
			else
				{
				document.getElementById(popUp).style.offsetLeft;
				document.getElementById(popUp).style.top=pos1[1]-320+"px";
				document.getElementById(popUp).style.width=222+"px";
				document.getElementById(popUp).style.height=132+"px";
				}
		}
		var imgPath="/eCommerceWeb/images/eCommerce/common/cart-popupSubmit_btn.gif";
		var OfferText = "<iframe src=\"/eCommerceWeb/html/eCommerce/dummy.html\" style='z-index=-1;'></iframe><table border='0' align='center'height='120px' width='220px' ><tr><td align='left' colspan='2' style='padding-left:15px; padding-top:15px; font-family:Verdana; font-size:11px; color:#6e7839;'>This is a Buy <strong> "+lcspecialPrice+"</strong> for $"+offerPrice+" item.</td></tr>"+
		"<tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'>You will save $"+savePrice+".</td></tr>"+
	    "<tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'>Would you like to buy<strong> "+lcspecialPrice+"</strong> items?</td></tr>"+
        "<tr><td colspan='1' align='right' style='font-family:Verdana; font-size:11px; color:#6e7839;'><input type='radio' value='yes' name='option' id='specialcheck' checked><strong>Yes</strong><br/>"+
        "</td><td colspan='1' align='left' style='font-family:Verdana; font-size:11px; color:#6e7839;'><input type='radio' value='no' name='option' id='specialcheck'/><strong>No</strong><br/>"+
  	    "</td></tr><tr><td colspan='2' align='center' style='font-family:Verdana; font-size:11px; color:#6e7839;'><a href='#' onClick=\"javascript:cartAction(\'"+(oldIndex-1)+"\',\'"+productId+"\',\'"+productName+"\',\'"+qty+"\',\'"+sizeDescription+"\',\'"+controlCode+"\',\'"+transType+"\',\'"+formName+"\');\">"+ 
  	    "<img src='"+imgPath+"' alt='Submit'/></a>"+
        "</td></tr></table>";
        setTimeout("void(0);",500);
	   document.getElementById(popUp).innerHTML=OfferText;
	 } else{
       cartAction(oldIndex-1,productId,productName,qty,sizeDescription,controlCode,transType,formName);
       }
  }   
  
   

//The following increment  functionality are for modules excluding Product Catalog     
          
function incr1(form,txtName,index,maxQty)
{
         if(isFinite(eval("document."+form+"."+txtName+".length"))){
                if(index != null){
                       var ind=parseInt(index)-1;                        
                       var s1=eval("document."+form+"."+txtName+"["+ind+"].value");
                       if ( isNaN(s1) || s1=='')
                             {                        
                                s1 = 1;                                          
                             }
                       var s2=parseInt(s1)+1;
                        if(s2 > maxQty){
                          alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                          s2=s2-1;
                        } 
                       eval("document."+form+"."+txtName+"["+ind+"].value='" + s2 + "'");
                 }else{
                    var s1=eval("document."+form+"."+txtName+".value");
                    if ( isNaN(s1) || s1=='')
                             {                        
                                s1 = 1;                                          
                             }
                    var s2=parseInt(s1)+1;
                    if(s2 > maxQty){
                          alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                          s2=s2-1;
                        } 
                    eval("document."+form+"."+txtName+".value='" + s2 + "'");
                  }
    }else{
      
            var s1=eval("document."+form+"."+txtName+".value");
            if ( isNaN(s1) || s1=='')
             {                        
                s1 = 1;                                          
             }
            var s2=parseInt(s1)+1;
            if(s2 > maxQty)
            {
              alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
              s2=s2-1;
            } 
            eval("document."+form+"."+txtName+".value='" + s2 + "'");
    }   
}
  
  
//The following decrement  functionality are for modules excluding Product Catalog   
function decr1(form,txtName,ind)
{
    if(isFinite(eval("document."+form+"."+txtName+".length")))
        {
                        if(ind != null){
                           var index=parseInt(ind)-1; 
                           var s1=eval("document."+form+"."+txtName+"["+index+"].value");
                           if ( isNaN(s1) || s1=='')
                             {                        
                                s1 = 1;                                          
                             }
                           var s2=parseInt(s1)-1;
                               if(s2<=1){
                                   s2=1;
                                }
                           eval("document."+form+"."+txtName+"["+index+"].value='" + s2 + "'");
                         }else{
                            var s1=eval("document."+form+"."+txtName+".value");
                            if ( isNaN(s1) || s1=='')
                             {                        
                                s1 = 1;                                          
                             }
                            var s2=parseInt(s1)-1;
                            if(s2<=1){
                               s2=1;
                            }
                            eval("document."+form+"."+txtName+".value='" + s2 + "'");
                          }   
        
        }else{
              var s1=eval("document."+form+"."+txtName+".value");
              if ( isNaN(s1) || s1=='')
                 {                        
                    s1 = 1;                                          
                 }
              var s2=parseInt(s1)-1;
              if(s2<=1){
                   s2=1;
                }
              eval("document."+form+"."+txtName+".value='" + s2 + "'");
    }
} 

 //The following onChange   functionality are for modules excluding Product Catalog
 function on_Change2(form,txtName,index,maxQty)
{
    if(index != null){                
        if(isFinite(eval("document."+form+"."+txtName+".length"))){
            var ind=parseInt(index)-1; 
            var s3=eval("document."+form+"."+txtName+"["+ind+"].value");
        }else
            var s3=eval("document."+form+"."+txtName+".value");  
            var s4=new Number(s3);
            var temp="0123456789"
            for(var i=0; i < s3.length;i++){
                var s5=""+s3.substring(i,i+1);
                if(temp.indexOf(s5)!="-1"){
                    if(s4<=0){
                        s4=1;
                        if(isFinite(eval("document."+form+"."+txtName+".length")))         
                            eval("document."+form+"."+txtName+"["+ind+"].value='" + s4 + "'");
                        else
                            eval("document."+form+"."+txtName+".value='" + s4 + "'");
                    }else{
                        if(s4 > maxQty){
                            alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                            s4 = maxQty;
                    } 
                    if(isFinite(eval("document."+form+"."+txtName+".length")))         
                        eval("document."+form+"."+txtName+"["+ind+"].value='" + s4 + "'");
                    else
                        eval("document."+form+"."+txtName+".value='" + s4 + "'");
                }        
            }else{
                if(isFinite(eval("document."+form+"."+txtName+".length")))         
                    eval("document."+form+"."+txtName+"["+ind+"].value='" + 1 + "'");
                else
                    eval("document."+form+"."+txtName+".value='" + 1 + "'");
                alert("Item quantity must be a whole number. Fractions and decimals are not allowed");  
                return;
            }  
        }
    }else{
        var ind=parseInt(index)-1; 
        var s3=eval("document."+form+"."+txtName+".value");
        var s4=new Number(s3);
        var temp="0123456789"
        for(var i=0;i<s3.length;i++){
            var s5=""+s3.substring(i,i+1);
            if(temp.indexOf(s5)!="-1"){
                if(s4<=0){
                    s4=1;                                                  
                    eval("document."+form+"."+txtName+".value='" + s4 + "'");                                                   
            	}else{
                    eval("document."+form+"."+txtName+".value='" + s4 + "'");
                }        
            }else{
                if(s4 > maxQty){
                    alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                    s4 = maxQty;
                } 
                eval("document."+form+"."+txtName+".value='" + 1 + "'");
                alert("Item quantity must be a whole number. Fractions and decimals are not allowed");  
                return;
            }  
        }   
    }
}   
/*JavaSript code for Spinner Ctl  ends here */



/* JavaScript for productSort */

function setShowHideImgCookie(showHideImgValue)
{
   setCookie("showHideImgCookie",showHideImgValue,"/");
}


function setPPSortCookie()
{
    setCookie("ppSortBy",document.productSort.sortByAttribute.value,"/");
    document.productSort.submit();
}


function setSortCookie()
{
    setCookie("attributeCookie",document.productSort.sortByAttribute.value,"/");
    document.productSort.submit();
}

function setProductsPerPageCookie()
{
    setCookie("pageNoCookie",document.productSort.productsPerPage.value,"/");  
    document.productSort.submit();
}


function setCookie(name,value,path) {
    var today = new Date();
    var expire = new Date();
    var nDays=365*2;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = name + "=" + escape(value) +
    ((path) ? "; path=" + path : "")+
    ";expires="+expire.toGMTString();
}


function paginate(formName,paramQuery,pageNo)
{ 
    actionUrl = eval("document."+ formName + ".action");
    paramQuery = replaceAll(paramQuery,"+&+","+%26+");
    //paramQuery = replaceAll(paramQuery,"*","%27");
    paramQuery = replaceAll(paramQuery,"(","%28");
    paramQuery = replaceAll(paramQuery,")","%29");
   	paramQuery = replaceAll(paramQuery,",", "%2C");
   	
    if(actionUrl.indexOf('action=') != -1){
        if(paramQuery.indexOf('action=') != -1 && paramQuery.indexOf('&') != -1){
            paramQuery = paramQuery.substring(paramQuery.indexOf('&'),paramQuery.length);
        }else{
            paramQuery='';
        }
    }
    if(actionUrl.indexOf('action=') == -1){
        paramURL = document.forms[formName].action + "?"+  paramQuery + "&currentPage="+pageNo;
    }else{
        paramURL = document.forms[formName].action + paramQuery + "&currentPage="+pageNo;
    }
     document.forms[formName].action = paramURL;
     document.forms[formName].submit();
}

function changeAction(addToOption)
{
    var list ="list";
    var allUnchecked = "true"; 
    var qtyEntered = "true";   
    var quantity = eval(document.PastPurchaseForm.quantity);
    var submitted = "false";
    if (isFinite(document.PastPurchaseForm.quantity.length)){     
        optionList=eval(document.PastPurchaseForm.option);
        quantity = eval(document.PastPurchaseForm.quantity);       
        for (var j=0;j<optionList.length;j++){
            if (document.PastPurchaseForm.option[j].checked == true){
                allUnchecked= "false";                             
            }
        }  
        if(allUnchecked == "false"){
            for (var i=0;i<optionList.length;i++){
                if (document.PastPurchaseForm.option[i].checked == true){
                    eval("document.PastPurchaseForm.addOption[" + i + "].value = 'add'");
                    quantity[i].value = trim(quantity[i].value);
                   if( quantity[i].value == '') 
                   {
                       if (addToOption == 'addToList'){
                            alert("Please enter an item quantity.");
                        }else{
                            alert("Please enter an item quantity.");
                        }
                       quantity[i].focus();
                       quantity[i].value=1;
                       qtyEntered = "false";     
                   }
                }else{
                    eval("document.PastPurchaseForm.addOption[" + i + "].value = 'nill'");
                }   
            }
            if(qtyEntered == "true")
            {
            	
            	eval("document.PastPurchaseForm.action='/eCommerceWeb/AddPastPurchasesAction.do?action=addPastPurchasesToListnCart&addToCart=true&target="+addToOption+"'");
				if(document.getElementById("submitHidden").value != "true"){
		            document.PastPurchaseForm.submit();
    	            submitted = "true";
    	        }else{
    	        	alert("Items are being added to your cart. Thank you for your patience.");
    	        }
            }    
        }else{
             if (addToOption == 'addToList'){
                     alert("Please choose the item before adding to List.");
                   }else{
                     alert("Please choose the item before adding to Cart.");
                   }
        }
    
    }else{
        optionList=eval(document.PastPurchaseForm.option);
        if (document.PastPurchaseForm.option.checked == true){
            if (document.PastPurchaseForm.option.checked == true){
                eval("document.PastPurchaseForm.addOption.value = 'add'");  
                quantity.value = trim(quantity.value);
                         
             if( quantity.value=='') 
               {  if (addToOption == 'addToList'){
                     alert("Please enter an item quantity.");
                   }else{
                     alert("Please enter an item quantity.");
                   }
                 quantity.value=1;
                 quantity.focus();
                 qtyEntered = "false";
               } 
            }
            if(qtyEntered == "true")
            {
            	eval("document.PastPurchaseForm.action='/eCommerceWeb/AddPastPurchasesAction.do?action=addPastPurchasesToListnCart&addToCart=true&target="+addToOption+"'");
				if(document.getElementById("submitHidden").value != "true"){	            
		            document.PastPurchaseForm.submit();
	                submitted = "true";            
	            }else{
	            	alert("Items are being added to your cart. Thank you for your patience.");
	            }
            }   	            
        }else{
        
                 if (addToOption == 'addToList'){
                     alert("Please choose the item before adding to List.");
                   }else{
                     alert("Please choose the item before adding to Cart.");
                   }
            
        }
    }
    if(addToOption == "addToCart" && submitted == "true"){
        document.getElementById("submitHidden").value="true";
        document.getElementById("messagezone1").style.visibility="visible";
        document.getElementById("messagezone2").style.visibility="visible";
    }    
}


/*******************************************
Common js functions
******************************************/

function account(){
    var pscInvalidFlag=-1;
     
    if(isBlank(document.forms[0].firstName.value)){
        alert(firstNameNull);
        document.forms[0].firstName.focus();
    }else if(!isAlphaNumeric(document.forms[0].firstName.value)) {
        alert(firstNameAlphaNumeric);
        document.forms[0].firstName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].firstName.value)){
        alert(firstNameOnlyNumber);
        document.forms[0].firstName.focus();
    }else if(!isBlank(document.forms[0].middleName.value) && !isAlphaNumeric(document.forms[0].middleName.value)){
        alert(middleNameAlphaNumeric);
        document.forms[0].middleName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].middleName.value)){
        alert(middleNameOnlyNumber);
        document.forms[0].middleName.focus();
    }else if(isBlank(document.forms[0].lastName.value)){
        alert(lastNameNull);
        document.forms[0].lastName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].lastName.value)){
        alert(lastNameOnlyNumber);
        document.forms[0].lastName.focus();
    }else if(!isAlphaNumeric(document.forms[0].lastName.value)){
        alert(lastNameAlphaNumeric);
        document.forms[0].lastName.focus();
    }else if(isBlank(document.forms[0].userName.value)){
        alert(userNameNull);
        document.forms[0].userName.focus();
    }else if(!isUserAlphaNumeric(document.forms[0].userName.value)){
        alert(userNameAlphaNumeric);
        document.forms[0].userName.focus();
    }else if(document.forms[0].userName.value.length <'6' || document.forms[0].userName.value.length>'20'){
        alert(userNameLength);
        document.forms[0].userName.focus();
    }else if (isNumericOnly(document.forms[0].userName.value)){
        alert(usernameOnlyNumber);
        document.forms[0].userName.focus();
    }else if(isBlankPass(document.forms[0].password.value)){
        alert(passwordNull);
        document.forms[0].password.focus();
    }else if(document.forms[0].password.value.length<'6' ||  document.forms[0].password.value.length>'20'){    
        alert(passwordLength);
        document.forms[0].password.focus();
    }else if(!passwordIsAlphaNumeric(document.forms[0].password.value)){
        alert(passwordAlphaNumeric);
        document.forms[0].password.focus();
    }else if(!isPassword(document.forms[0].password.value)){
        alert(passwordInvalid);
        document.forms[0].password.focus();
    }else if (!isBlankSpace(document.forms[0].password)){
        alert(passwordWithoutSpace);
        document.forms[0].password.focus();
    }else if(isBlankPass(document.forms[0].rePassword.value)){
        alert(rePasswordNull);
        document.forms[0].rePassword.focus();
    }else if((document.forms[0].password.value!=document.forms[0].rePassword.value)){     
        alert(passwordMisMatch);
        document.forms[0].rePassword.focus();
    }else if(passwdEqualsLogin(document.forms[0].userName.value, document.forms[0].password.value)){
        alert(passwordMatch);
        document.forms[0].password.focus();
    }else if(isBlank(document.forms[0].email.value)){
        alert(emailNull);
        document.forms[0].email.focus();      
    }else if(checkemail(document.forms[0].email)){
        alert(emailInvalid);
        document.forms[0].email.focus(); 
    }else if(isBlank(document.forms[0].reEmail.value)){
        alert(reEmailNull);
        document.forms[0].reEmail.focus(); 
    }else if(trim(document.forms[0].email.value)!=trim(document.forms[0].reEmail.value)){
        alert(emailMisMatch);
        document.forms[0].reEmail.focus(); 
    }else if(document.forms[0].hintQuestion.options[document.forms[0].hintQuestion.selectedIndex].value==" Choose"){
        alert(hintQuestionCodeNull);
        document.forms[0].hintQuestion.focus();
    }else if(isBlank(document.forms[0].hintAnswer.value)){   
        alert(hintAnswerNull);
        document.forms[0].hintAnswer.focus();
    }else if(!isAlphaNumeric(document.forms[0].hintAnswer.value)){
        alert(hintAnswerAlphaNumeric);
        document.forms[0].hintAnswer.focus();
    }else if(document.forms[0].pscOption[1].checked){
        pscInvalidFlag=0;
        if(isBlank(document.forms[0].pscNumber.value)){
            alert(pscNumberNull);
            document.forms[0].pscNumber.focus();
            pscInvalidFlag=1;
            return false;
        }else if(document.forms[0].pscNumber.value.length < '11'){
            alert(pscNumberLength);
            document.forms[0].pscNumber.focus();
            pscInvalidFlag=1;
            return false;
        }else if(isBlank(document.forms[0].pscPhoneNumber.value)){
            alert(pscPhoneNumberNull);
            document.forms[0].pscPhoneNumber.focus();
            pscInvalidFlag=1;
            return false;
        }else if(document.forms[0].pscPhoneNumber.value.length < '10'){
            alert(pscPhoneNumberLength);
            document.forms[0].pscPhoneNumber.focus();
            pscInvalidFlag=1;
            return false;
        }if(!pscInvalidFlag==1 || !pscInvalidFlag==0){
            document.forms[0].submit();
        }
    }else{
        document.forms[0].submit();
    }
}
 
function accountContinue(store,psc){
  zipLastInvalidFlag=0;

 if(!psc=="1" || !psc=="2"){
 
    if(isBlank(document.forms[0].streetAddress.value)){
        alert(streetNull);
        document.forms[0].streetAddress.focus();
    }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
        alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
    	alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
        alert(AptSuiteInval);
        document.forms[0].unit.focus();
    }else if(isBlank(document.forms[0].city.value)){
        alert(cityNull);
        document.forms[0].city.focus();
    /*}else if(isBlank(document.forms[0].unit.value)){
        alert(unitInval);
        document.forms[0].unit.focus();*/
    }else if(!isAlphaCity(document.forms[0].city.value)){
        alert(cityAlpha);
        document.forms[0].city.focus();
    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
        alert(stateNull);
        document.forms[0].state.focus();*/
        else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
        alert(stateNull);
        document.forms[0].state.focus();
    }else if(isBlank(document.forms[0].zip.value)){
        alert(zipNull);
        document.forms[0].zip.focus();
    }else if(!checkLength(document.forms[0].zip.value, 5)){
        alert(zipLength);
        document.forms[0].zip.focus();
    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
        alert(zipInvalid);
        document.forms[0].zip.focus();
    }else if(!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
        alert(zipLastOnlyNumber);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if(!isBlank(document.forms[0].zipLast.value) && !checkLength(document.forms[0].zipLast.value, 4)){
        alert(zipLastLength);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if(isBlank(document.forms[0].phone.value)&& isBlank(document.forms[0].phoneMiddle.value) && isBlank(document.forms[0].phoneLast.value)){
        alert(phoneNull);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(!checkValidFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!checkValidMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast)){
        alert(phoneInvalid);
        document.forms[0].phoneLast.focus();
    }else if(!isBlank(document.forms[0].replacementCardNum.value && document.forms[0].registerOption.value=='N')) {
        document.forms[0].registerOption.value='R'; 
        accountContinue(); 
    }else if(document.forms[0].registerOption.value=='R' && isBlank(document.forms[0].replacementCardNum.value)) {
        alert(replaceCardNull); 
        document.forms[0].replacementCardNum.focus(); 
    }else if(document.forms[0].registerOption.value=='R' && document.forms[0].replacementCardNum.value.length < '11'){
        alert(replaceCardLength);
        document.forms[0].replacementCardNum.focus();
    }else if(document.forms[0].registerOption.value=='R' && !checkValidReplaceCard(document.forms[0].replacementCardNum)) {
        alert(replaceCardInvalid);
        document.forms[0].replacementCardNum.focus();
    }else if(!isBlank(document.forms[0].alternateId.value) && !isNumericOnly(document.forms[0].alternateId.value)) {
        alert(alternateIdNumeric);
        document.forms[0].alternateId.focus();
    }else if(!isBlank(document.forms[0].alternateId.value) && document.forms[0].alternateId.value.length<10) {
        alert(alternateIdLength);
        document.forms[0].alternateId.focus();
    }else if(!isBlank(document.forms[0].alternateId.value) && !checkValidAltIdFirst(document.forms[0].alternateId)) {
        alert(alternateIdInvalid);
        document.forms[0].alternateId.focus();
    }/*else if(!document.forms[0].substitutionCode.checked) {
       alert(substitutionpolicy);
       document.forms[0].substitutionCode.focus();
    } */else if((store!="")&&(!isBlank(document.forms[0].referrals.value))&&(checkemail(document.forms[0].referrals))){
              alert(referralsInvalid);
              document.forms[0].referrals.focus();      
     }else if(!document.forms[0].isTermsChecked.checked){
             alert(termsCheckedNull);
             document.forms[0].isTermsChecked.focus();
     }else{
      document.forms[0].submit();
      }
 }
 
 else{
    if(document.forms[0].makeDefault.checked)
    { 
          if(isBlank(document.forms[0].streetAddress.value)){
              alert(streetNull);
              document.forms[0].streetAddress.focus();
           }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
               alert(streetNumeric);
               document.forms[0].streetAddress.focus();
           /*}else if(isBlank(document.forms[0].unit.value)){
                alert(unitInval);
                document.forms[0].unit.focus();*/
           }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
		    	alert(streetInvalid);
		        document.forms[0].streetAddress.focus();
           }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
	            alert(AptSuiteInval);
	            document.forms[0].unit.focus();
		    }else if(isBlank(document.forms[0].city.value)){
               alert(cityNull);
               document.forms[0].city.focus();
           }else if(!isAlphaCity(document.forms[0].city.value)){
                alert(cityAlpha);
                document.forms[0].city.focus();
          }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
                alert(stateNull);
             document.forms[0].state.focus();*/
             else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
                alert(stateNull);
             document.forms[0].state.focus();
             
          }else if(isBlank(document.forms[0].zip.value)){
                alert(zipNull);
                document.forms[0].zip.focus();
         }else if(!checkLength(document.forms[0].zip.value, 5)){
                alert(zipLength);
                document.forms[0].zip.focus();
         }else if(!checkValidZip(document.forms[0].zip.value, 5)){
                alert(zipInvalid);
                document.forms[0].zip.focus();
         }else if(!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
                alert(zipLastOnlyNumber);
                document.forms[0].zipLast.focus();
                zipLastInvalidFlag=1;
         }else if(!isBlank(document.forms[0].zipLast.value)&& !checkLength(document.forms[0].zipLast.value, 4)){
                alert(zipLastLength);
                document.forms[0].zipLast.focus();
                zipLastInvalidFlag=1;
         }else if(isBlank(document.forms[0].phone.value)&& isBlank(document.forms[0].phoneMiddle.value) && isBlank(document.forms[0].phoneLast.value)){
                alert(phoneNull);
                document.forms[0].phone.focus();
         }else if(isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone)) {
                alert(phoneInvalid);
                document.forms[0].phone.focus();
         }else if(!checkValidFirst(document.forms[0].phone)) {
                alert(phoneInvalid);
                document.forms[0].phone.focus();
         }else if(isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle)){
                alert(phoneInvalid);
                document.forms[0].phoneMiddle.focus();
         }else if(!checkValidMiddle(document.forms[0].phoneMiddle)){
                alert(phoneInvalid);
                document.forms[0].phoneMiddle.focus();
         }else if(isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast)){
                alert(phoneInvalid);
                 document.forms[0].phoneLast.focus();
         }else if(psc=="2"){
	            if(!isBlank(document.forms[0].replacementCardNum.value && document.forms[0].registerOption.value=='N')) {
			        document.forms[0].registerOption.value='R'; 
			        accountContinue(); 
			    }else if(document.forms[0].registerOption.value=='R' && isBlank(document.forms[0].replacementCardNum.value)) {
			        alert(replaceCardNull); 
			        document.forms[0].replacementCardNum.focus(); 
			    }else if(document.forms[0].registerOption.value=='R' && document.forms[0].replacementCardNum.value.length < '11'){
			        alert(replaceCardLength);
			        document.forms[0].replacementCardNum.focus();
			    }else if(document.forms[0].registerOption.value=='R' && !checkValidReplaceCard(document.forms[0].replacementCardNum)) {
			        alert(replaceCardInvalid);
			        document.forms[0].replacementCardNum.focus();
			    }else if(!isBlank(document.forms[0].alternateId.value) && !isNumericOnly(document.forms[0].alternateId.value)) {
	                alert(alternateIdNumeric);
	                document.forms[0].alternateId.focus();
	             }else if(!isBlank(document.forms[0].alternateId.value) && document.forms[0].alternateId.value.length<10) {
	                alert(alternateIdLength);
	                document.forms[0].alternateId.focus();
	            }else if(!isBlank(document.forms[0].alternateId.value) && !checkValidAltIdFirst(document.forms[0].alternateId)) {
	                alert(alternateIdInvalid);
	                document.forms[0].alternateId.focus();
	            }/*else if(!document.forms[0].substitutionCode.checked) {
                    alert(substitutionpolicy);
                    document.forms[0].substitutionCode.focus();
                }*/else if((store!="")&&(!isBlank(document.forms[0].referrals.value))&&(checkemail(document.forms[0].referrals))){
	                alert(referralsInvalid);
	                document.forms[0].referrals.focus();      
	            }else if(!document.forms[0].isTermsChecked.checked){
	                alert(termsCheckedNull);
	                document.forms[0].isTermsChecked.focus();
	            }else{
	                document.forms[0].submit();
	            }
         }else{
                /*if(!document.forms[0].substitutionCode.checked) {
                    alert(substitutionpolicy);
                    document.forms[0].substitutionCode.focus();
                }else*/ if((store!="")&&(!isBlank(document.forms[0].referrals.value))&&(checkemail(document.forms[0].referrals))){
	                alert(referralsInvalid);
	                document.forms[0].referrals.focus();      
	            }else if(!document.forms[0].isTermsChecked.checked){
	                alert(termsCheckedNull);
	                document.forms[0].isTermsChecked.focus();
	            }else{
	                document.forms[0].submit();
	            }
         }
    }   
    else{   
    if(isNumericOnly(document.forms[0].streetAddress.value)) {
        alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    /*}else if(isBlank(document.forms[0].unit.value)){
        alert(unitInval);
        document.forms[0].unit.focus();*/
    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
    	alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
                alert(AptSuiteInval);
                document.forms[0].unit.focus();
    }else if(!isAlphaCity(document.forms[0].city.value)){
        alert(cityAlpha);
        document.forms[0].city.focus();
    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
                alert(stateNull);
             document.forms[0].state.focus();*/
      else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
         alert(stateNull);
        document.forms[0].state.focus();    
    }else if(isBlank(document.forms[0].zip.value)){
        alert(zipNull);
        document.forms[0].zip.focus();
    }else if(!checkLength(document.forms[0].zip.value, 5)){
        alert(zipLength);
        document.forms[0].zip.focus();;
    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
        alert(zipInvalid);
        document.forms[0].zip.focus();
    }else if (!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
        alert(zipLastOnlyNumber);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if(!isBlank(document.forms[0].zipLast.value)&& !checkLength(document.forms[0].zipLast.value, 4)){
        alert(zipLastLength);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if((!isBlank(document.forms[0].phoneMiddle.value)||!isBlank(document.forms[0].phoneLast.value)) && (isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone))) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if((!isBlank(document.forms[0].phoneMiddle.value)||!isBlank(document.forms[0].phoneLast.value)) && (!checkValidFirst(document.forms[0].phone))) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(!isBlank(document.forms[0].phone.value)&& (isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle))){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!isBlank(document.forms[0].phone.value)&& (!checkValidMiddle(document.forms[0].phoneMiddle))){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!isBlank(document.forms[0].phoneMiddle.value)&& (isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast))){
        alert(phoneInvalid);
        document.forms[0].phoneLast.focus();
    }else if(psc=="2"){
             if(!isBlank(document.forms[0].replacementCardNum.value && document.forms[0].registerOption.value=='N')) {
		        document.forms[0].registerOption.value='R'; 
		        accountContinue(); 
		     }else if(document.forms[0].registerOption.value=='R' && isBlank(document.forms[0].replacementCardNum.value)) {
		        alert(replaceCardNull); 
		        document.forms[0].replacementCardNum.focus(); 
		     }else if(document.forms[0].registerOption.value=='R' && document.forms[0].replacementCardNum.value.length < '11'){
		        alert(replaceCardLength);
		        document.forms[0].replacementCardNum.focus();
		     }else if(document.forms[0].registerOption.value=='R' && !checkValidReplaceCard(document.forms[0].replacementCardNum)) {
		        alert(replaceCardInvalid);
		        document.forms[0].replacementCardNum.focus();
		     }else if(!isBlank(document.forms[0].alternateId.value) && !isNumericOnly(document.forms[0].alternateId.value)) {
                alert(alternateIdNumeric);
                document.forms[0].alternateId.focus();
             }else if(!isBlank(document.forms[0].alternateId.value) && document.forms[0].alternateId.value.length<10) {
                alert(alternateIdLength);
                document.forms[0].alternateId.focus();
             }else if(!isBlank(document.forms[0].alternateId.value) && !checkValidAltIdFirst(document.forms[0].alternateId)) {
                alert(alternateIdInvalid);
                document.forms[0].alternateId.focus();
             }/*else if(!document.forms[0].substitutionCode.checked) {
                alert(substitutionpolicy);
                document.forms[0].substitutionCode.focus();
             }*/else if((store!="")&&(!isBlank(document.forms[0].referrals.value))&&(checkemail(document.forms[0].referrals))){
                alert(referralsInvalid);
                document.forms[0].referrals.focus();      
             }else if(!document.forms[0].isTermsChecked.checked){
                alert(termsCheckedNull);
                document.forms[0].isTermsChecked.focus();
             }else{
                document.forms[0].submit();
             }
    }else{
            /*if(!document.forms[0].substitutionCode.checked) {
              alert(substitutionpolicy);
              document.forms[0].substitutionCode.focus();
            }else*/ if((store!="")&&(!isBlank(document.forms[0].referrals.value))&&(checkemail(document.forms[0].referrals))){
	         alert(referralsInvalid);
	         document.forms[0].referrals.focus();      
	        }else if(!document.forms[0].isTermsChecked.checked){
	          alert(termsCheckedNull);
	          document.forms[0].isTermsChecked.focus();
	        }else{
	          document.forms[0].submit();
	        }
    }

  }
  }
} 

 function radassign(field,checkBox){
	if(eval('document.forms[0].'+checkBox+'.checked'))
	 {
	 	eval("document.forms[0]."+field+".value = 'Y'");
	 }
	 else{
	 	eval("document.forms[0]."+field+".value = 'N'"); 
	 }
 }    

function checkRememberAssign()
   {
   
	 var f = document.UserDetailsForm;
	 if(f != null){
  		if(f.enhanceSecure.checked)
		{
			f.enhancedSec.value = "";
		}
		else{
		    f.enhancedSec.value = "N";
		}
	}

}



function accountDetails(){
    var zipLastInvalidFlag=0;
    if(isBlank(document.forms[0].firstName.value)){
        alert(firstNameNull);
        document.forms[0].firstName.focus();
    }else if(!isAlphaNumeric(document.forms[0].firstName.value)){
        alert(firstNameAlphaNumeric);
        document.forms[0].firstName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].firstName.value)){
        alert(firstNameOnlyNumber);
        document.forms[0].firstName.focus();
    }else if(!isBlank(document.forms[0].middleName.value) && !isAlphaNumeric(document.forms[0].middleName.value)){
        alert(middleNameAlphaNumeric);
        document.forms[0].middleName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].middleName.value)){
        alert(middleNameOnlyNumber);
        document.forms[0].middleName.focus();
    }else if(isBlank(document.forms[0].lastName.value)){
        alert(lastNameNull);
        document.forms[0].lastName.focus();
    }else if(!isAlphaNumeric(document.forms[0].lastName.value)){
        alert(lastNameAlphaNumeric);
        document.forms[0].lastName.focus();
    }else if (isNumericOnlyWithSpace(document.forms[0].lastName.value)){
        alert(lastNameOnlyNumber);
        document.forms[0].lastName.focus();
    }else if(isBlank(document.forms[0].email.value)){
        alert(emailNull);
        document.forms[0].email.focus();      
    }else if(checkemail(document.forms[0].email)){
        alert(emailInvalid);
        document.forms[0].email.focus(); 
    }else if(isBlank(document.forms[0].reEmail.value)){
        alert(reEmailNull);
        document.forms[0].reEmail.focus(); 
    }else if(checkemail(document.forms[0].reEmail)){
        alert(reEmailInvalid);
        document.forms[0].reEmail.focus(); 
    }else if(document.forms[0].email.value!=document.forms[0].reEmail.value){
        alert(emailMisMatch);
        document.forms[0].email.focus(); 
    }/*else if(isNumericOnly(document.forms[0].streetAddress.value)) {
        alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    }else if(isBlank(document.forms[0].unit.value)){
        alert(unitInval);
        document.forms[0].unit.focus();
    }else if(!isAlphaNumeric(document.forms[0].streetAddress.value)) {
        alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }*/else if(!isBlankPass(document.forms[0].oldPassword.value) || !isBlankPass(document.forms[0].password.value) || !isBlankPass(document.forms[0].password1.value) || !isBlankPass(document.forms[0].hintAnswer.value))
    {
		if(!isBlankPass(document.forms[0].oldPassword.value)){
		        if (!isBlankSpace(document.forms[0].oldPassword)){
			        alert(passwordWithoutSpace);
			        document.forms[0].oldPassword.focus();
			    }else if(isBlankPass(document.forms[0].password.value)){
			        alert(passwordNull);
			        document.forms[0].password.focus();
			    }else if(document.forms[0].password.value.length< '6' ||  document.forms[0].password.value.length> '20'){    
		        	alert(passwordLength);
		        	document.forms[0].password.focus();
			    }else if(!passwordIsAlphaNumeric(document.forms[0].password.value)){
			        alert(passwordAlphaNumeric);
			        document.forms[0].password.focus();
			    }else if(!isPassword(document.forms[0].password.value)){
			        alert(passwordInvalid);
			        document.forms[0].password.focus();
			    }else if (!isBlankSpace(document.forms[0].password)){
			        alert(passwordWithoutSpace);
			        document.forms[0].password.focus();
			    }else if(isBlankPass(document.forms[0].password1.value)){
			        alert(rePasswordNull);
			        document.forms[0].password1.focus();
			    }else if((document.forms[0].password.value != document.forms[0].password1.value)){     
			        alert(passwordMisMatch);
			        document.forms[0].password1.focus();
			    }else if(passwdEqualsLogin(document.forms[0].loginName.value, document.forms[0].password.value)){
			        alert(passwordMatch);
			        document.forms[0].password.focus();
			    }else if(isBlank(document.forms[0].hintAnswer.value)){   
			        alert(hintAnswerNull);
			        document.forms[0].hintAnswer.focus();
			    }else if(!isAlphaNumeric(document.forms[0].hintAnswer.value)){
			        alert(hintAnswerAlphaNumeric);
			        document.forms[0].hintAnswer.focus();
			    }
			    else if(isBlank(document.forms[0].streetAddress.value)){
        		alert(streetNull);
         		document.forms[0].streetAddress.focus();
		    }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
		        alert(streetNumeric);
		        document.forms[0].streetAddress.focus();
		    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
		        alert(streetInvalid);
		        document.forms[0].streetAddress.focus();
            }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
                alert(AptSuiteInval);
               document.forms[0].unit.focus();
		    }else if(isBlank(document.forms[0].city.value)) {
		        alert(cityNull);
		        document.forms[0].city.focus();
		    }else if(!isAlphaCity(document.forms[0].city.value)) {
		        alert(cityAlpha);
		        document.forms[0].city.focus();
		    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
		        alert(stateNull);
		        document.forms[0].state.focus();*/
              else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
                alert(stateNull);
                document.forms[0].state.focus();  
		    }else if(isBlank(document.forms[0].zip.value)){
		        alert(zipNull);
		        document.forms[0].zip.focus();
		    }else if(!checkLength(document.forms[0].zip.value, 5)){
		        alert(zipLength);
		        document.forms[0].zip.focus();
		    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
		        alert(zipInvalid);
		        document.forms[0].zip.focus();
		    }else if (!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
		        alert(zipLastOnlyNumber);
		        document.forms[0].zipLast.focus();
		        zipLastInvalidFlag=1;
		    }else if(!isBlank(document.forms[0].zipLast.value) && !checkLength(document.forms[0].zipLast.value, 4)){
		        alert(zipLastLength);
		        document.forms[0].zipLast.focus();
		        zipLastInvalidFlag=1;
		    }else if(isBlank(document.forms[0].phone.value)&& isBlank(document.forms[0].phoneMiddle.value) && isBlank(document.forms[0].phoneLast.value)){
			    alert(phoneNull);
	            document.forms[0].phone.focus();
		    }else if(isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone)) {
		        alert(phoneInvalid);
		        document.forms[0].phone.focus();
		    }else if(!checkValidFirst(document.forms[0].phone)) {
		        alert(phoneInvalid);
		        document.forms[0].phone.focus();
		    }else if(isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle)){
		        alert(phoneInvalid);
		        document.forms[0].phoneMiddle.focus();
		    }else if(!checkValidMiddle(document.forms[0].phoneMiddle)){
		        alert(phoneInvalid);
		        document.forms[0].phoneMiddle.focus();
		    }else if(isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast)){
		        alert(phoneInvalid);
		        document.forms[0].phoneLast.focus();
		    } else{
		        document.forms[0].submit();
		    }
			    
			    
		    }
		    else if(!isBlankPass(document.forms[0].password.value)){
		    	if(isBlankPass(document.forms[0].oldPassword.value)){
		        	alert(currentPasswordNull);
		        	document.forms[0].oldPassword.focus();
		    	}
		    }
		    else if(!isBlankPass(document.forms[0].password1.value)){
		    	if(isBlankPass(document.forms[0].oldPassword.value)){
		        	alert(currentPasswordNull);
		        	document.forms[0].oldPassword.focus();
		    	}
		    }
		    else if(!isBlankPass(document.forms[0].hintAnswer.value)){
		    	if(isBlankPass(document.forms[0].oldPassword.value)){
		        	alert(currentPasswordNull);
		        	document.forms[0].oldPassword.focus();
		    	}
		    }
		    
	}else if(isBlank(document.forms[0].streetAddress.value)){
         alert(streetNull);
         document.forms[0].streetAddress.focus();
    }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
         alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
        alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
       alert(AptSuiteInval);
       document.forms[0].unit.focus();
    }else if(isBlank(document.forms[0].city.value)) {
        alert(cityNull);
        document.forms[0].city.focus();
    }else if(!isAlphaCity(document.forms[0].city.value)) {
        alert(cityAlpha);
        document.forms[0].city.focus();
    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
        alert(stateNull);
        document.forms[0].state.focus();*/
      else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
        alert(stateNull);
        document.forms[0].state.focus();  
    }else if(isBlank(document.forms[0].zip.value)){
        alert(zipNull);
        document.forms[0].zip.focus();
    }else if(!checkLength(document.forms[0].zip.value, 5)){
        alert(zipLength);
        document.forms[0].zip.focus();
    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
        alert(zipInvalid);
        document.forms[0].zip.focus();
    }else if (!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
        alert(zipLastOnlyNumber);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if(!isBlank(document.forms[0].zipLast.value) && !checkLength(document.forms[0].zipLast.value, 4)){
        alert(zipLastLength);
        document.forms[0].zipLast.focus();
        zipLastInvalidFlag=1;
    }else if(isBlank(document.forms[0].phone.value)&& isBlank(document.forms[0].phoneMiddle.value) && isBlank(document.forms[0].phoneLast.value)){
        alert(phoneNull);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(!checkValidFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!checkValidMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast)){
        alert(phoneInvalid);
        document.forms[0].phoneLast.focus();
    } else{
        document.forms[0].submit();
    }
}         




function checkPhoneFirst(field)
{
    var invalid = false;
    var checkOK = "0123456789";
    if ((field.value.length != 3)){
        invalid = true;
    }
    else{
        if (field.value.charAt(0)=="0"){
            invalid = true;
        }
        for(i=0; i < field.value.length; i++) {
            ch = field.value.charAt(i);
            for (j = 0;  j < checkOK.length; j++) {
                if (ch == checkOK.charAt(j)) {
                    break;
                }
                if (j == (checkOK.length-1)) {
                    invalid = true;
                    break;
                }
            }        
        }
    }
    return invalid;
}

function checkPhoneMiddle(field){
    var invalid = false;
    var checkOK = "0123456789";
    if ((field.value.length != 3) ) {
        invalid = true;
    }
    else {
        //if (field.value.charAt(0)=="0") {
       //     invalid = true;
       // }
        for(i=0; i < field.value.length; i++) {
            ch = field.value.charAt(i);
            for (j = 0;  j < checkOK.length;  j++) {
                if (ch == checkOK.charAt(j)) {
                    break;
                }
                if (j == (checkOK.length-1)) {
                    invalid = true;
                    break;
                }
            }        
        }
    }
    return invalid;
}

function checkPhoneLast(field){
    var invalid = false;
    var checkOK = "0123456789";
    if ((field.value.length != 4) ){
        invalid = true;
    }
    else {
        //if (field.value.charAt(0)=="0") {
            //invalid = true;
       // }
        for(i=0; i < field.value.length;i++) {
            ch = field.value.charAt(i);
            for (j = 0;  j < checkOK.length;j++) {
                if (ch == checkOK.charAt(j)){
                    break;
                }
                if (j == (checkOK.length-1)) {
                    invalid = true;
                    break;
                }
            }        
        }
    }
    return invalid;
}

function changePassword(){
    if(isBlankPass(document.forms[0].password.value)){
        alert(passwordNull);
        document.forms[0].password.focus();
    }else if(document.forms[0].password.value.length< '6' ||  document.forms[0].password.value.length> '20'){    
        alert(passwordLength);
        document.forms[0].password.focus();
    }else if(!passwordIsAlphaNumeric(document.forms[0].password.value)){
        alert(passwordAlphaNumeric);
        document.forms[0].password.focus();
    }else if(!isPassword(document.forms[0].password.value)){
        alert(passwordInvalid);
        document.forms[0].password.focus();
    }else if (!isBlankSpace(document.forms[0].password)){
        alert(passwordWithoutSpace);
        document.forms[0].password.focus();
    }else if(isBlankPass(document.forms[0].password1.value)){
        alert(rePasswordNull);
        document.forms[0].password1.focus();
    }else if((document.forms[0].password.value != document.forms[0].password1.value)){     
        alert(passwordMisMatch);
        document.forms[0].password1.focus();
    }else if(passwdEqualsLogin(document.forms[0].loginName.value, document.forms[0].password.value)){
        alert(passwordMatch);
        document.forms[0].password.focus();
    }else if(isBlank(document.forms[0].hintAnswer.value)){   
        alert(hintAnswerNull);
        document.forms[0].hintAnswer.focus();
    }else if(!isAlphaNumeric(document.forms[0].hintAnswer.value)){
        alert(hintAnswerAlphaNumeric);
        document.forms[0].hintAnswer.focus();
    }else{
        document.forms[0].submit();
    }
}
/*  
    While updating this method plz update validateAddress() method in checkout.js for any functionality changes.
*/
function address(){
        
    if(isBlank(document.forms[0].description.value)){
        alert(descriptionNull);
        document.forms[0].description.focus();
    }else if(!isAlphaNumeric(document.forms[0].description.value)){
       alert(descriptionAlpha);
       document.forms[0].description.focus();
    }else if(isBlank(document.forms[0].streetAddress.value)){
        alert(streetNull);
        document.forms[0].streetAddress.focus();
    }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
        alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    /*}else if(isBlank(document.forms[0].unit.value)){
        alert(unitInval);
        document.forms[0].unit.focus();*/
    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
        alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }else if(!isAlphaNumCompanyName(document.forms[0].companyName.value)){
        alert(compNameInvalid);
        document.forms[0].companyName.focus();
    }else if(!isAlphaNumeAptSuite(document.forms[0].unit.value)){
        alert(AptSuiteInval);
        document.forms[0].unit.focus(); 
        
    }else if(isBlank(document.forms[0].city.value)){
       alert(cityNull);
       document.forms[0].city.focus();
    }else if(!isAlphaCity(document.forms[0].city.value)){
        alert(cityAlpha);
        document.forms[0].city.focus();
    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
        alert(stateNull);
        document.forms[0].state.focus();*/
      else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
        alert(stateNull);
        document.forms[0].state.focus();  
    }else if(isBlank(document.forms[0].zip.value)){
        alert(zipNull);
        document.forms[0].zip.focus();
    }else if(!(checkLength(document.forms[0].zip.value, 5))){
        alert(zipLength);
        document.forms[0].zip.focus();
    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
        alert(zipInvalid);
        document.forms[0].zip.focus();
    }else if(!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
        alert(zipLastOnlyNumber);
        document.forms[0].zipLast.focus();
    }else if(!isBlank(document.forms[0].zipLast.value)&& !checkLength(document.forms[0].zipLast.value, 4)){
        alert(zipLastLength);
        document.forms[0].zipLast.focus();
    }else if(isBlank(document.forms[0].phone.value)&& isBlank(document.forms[0].phoneMiddle.value) && isBlank(document.forms[0].phoneLast.value)){
        alert(phoneNull);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phone.value)||checkPhoneFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(!checkValidFirst(document.forms[0].phone)) {
        alert(phoneInvalid);
        document.forms[0].phone.focus();
    }else if(isBlank(document.forms[0].phoneMiddle.value)||checkPhoneMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!checkValidMiddle(document.forms[0].phoneMiddle)){
        alert(phoneInvalid);
        document.forms[0].phoneMiddle.focus();
    }else if(!isAlphaNumSplDelvInstruct(document.forms[0].splDelvInstruction.value)){
                alert(SplDelvInstructInval);
               document.forms[0].splDelvInstruction.focus();
    }else if(isBlank(document.forms[0].phoneLast.value)||checkPhoneLast(document.forms[0].phoneLast)){
        alert(phoneInvalid);
        document.forms[0].phoneLast.focus();
    } 
    else{
       if(!textareaSpecified(document.forms[0].splDelvInstruction.value,1,"Instruction")) {
            document.forms[0].splDelvInstruction.focus(); 
    }else if(!textareaSpecified(document.forms[0].description.value,2,"Description")) {
            document.forms[0].description.focus(); 
    }else if(!textareaSpecified(document.forms[0].streetAddress.value,2,"Street Address")) {
            document.forms[0].streetAddress.focus(); 
    }else if(!textareaSpecified(document.forms[0].city.value,2,"City")) {
            document.forms[0].city.focus(); 
    }else{
            document.forms[0].submit();
        }
      }        
  
}
/*  
    While updating this method plz update validateCard() method in checkout.js for any functionality changes.
*/
function card(){
    
         var expiryDate= new Date();
    if(isBlank(document.forms[0].description.value)){
        alert(cardDescriptionNull);
        document.forms[0].description.focus();
    }else if(!isAlphaNumeric(document.forms[0].description.value)){
        alert(cardDescriptionAlpha);
        document.forms[0].description.focus();
    }else if(document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value=="Choose"){
        alert(cardTypeNull);
        document.forms[0].cardType.focus();
    }else if(isBlank(document.forms[0].cardHoldersName.value)){
        alert(cardHolderName);
        document.forms[0].cardHoldersName.focus();
    }else if(!isAlpha(document.forms[0].cardHoldersName.value)){
        alert(cardHolderNameAlpha);
        document.forms[0].cardHoldersName.focus();
    }else if(isBlank(document.forms[0].ccNo.value)){
        alert(cardNumNull);
        document.forms[0].ccNo.focus();
    }else if(!isNumber(document.forms[0].ccNo.value)){
        alert(cardNumNumeric);
        document.forms[0].ccNo.focus();
    }else if((document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value=="1") &&((document.forms[0].ccNo.value.length !='13') && (document.forms[0].ccNo.value.length !='16'))){
        alert(visacardLength);
        document.forms[0].ccNo.focus();
    }else if((document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value=="3")&&(document.forms[0].ccNo.value.length !='15')){
        alert(amexcardLength);
        document.forms[0].ccNo.focus();
    }else if((document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value=="2")&&(document.forms[0].ccNo.value.length !='16')){
        alert(mastercardLength);
        document.forms[0].ccNo.focus();
    }else if((document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value=="4")&&(document.forms[0].ccNo.value.length !='16')){
        alert(discovercardLength);
        document.forms[0].ccNo.focus();
    }else if(document.forms[0].expMonth.options[document.forms[0].expMonth.selectedIndex].value=="Month..."){
        alert(cardExpiryMonthNull);
        document.forms[0].expMonth.focus();
    }else if(document.forms[0].expYear.options[document.forms[0].expYear.selectedIndex].value=="Year..."){
        alert(cardExpiryYearNull);
        document.forms[0].expYear.focus();
    }else if(20+document.forms[0].expYear.options[document.forms[0].expYear.selectedIndex].value< expiryDate.getFullYear()){
       alert(cardExpiryMonthYearInvalid);
       document.forms[0].expYear.focus();
    }else if(20+document.forms[0].expYear.options[document.forms[0].expYear.selectedIndex].value== expiryDate.getFullYear() && document.forms[0].expMonth.options[document.forms[0].expMonth.selectedIndex].value < expiryDate.getMonth()+1){
       alert(cardExpiryMonthYearInvalid);
       document.forms[0].expYear.focus();       
    }else if(!isCreditcard(document.forms[0].ccNo.value)){
        document.forms[0].ccNo.focus();
    }else if(isBlank(document.forms[0].verificationNo.value)){
        alert(cardVerificationNumNull);
        document.forms[0].verificationNo.focus();
    }else if(!isNumber(document.forms[0].verificationNo.value)){
        alert(cardVerificationNumNumeric);
        document.forms[0].verificationNo.focus();
    }else if(document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value==1 && !checkLength(document.forms[0].verificationNo.value, visaMaxLen)){
        alert(cardVerificationVisaInvalid);
        document.forms[0].verificationNo.focus();    
    }else if(document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value==2 && !checkLength(document.forms[0].verificationNo.value,masterMaxLen)){
        alert(cardVerificationMasterInvalid);
        document.forms[0].verificationNo.focus();    
    }else if(document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value==3 && !checkLength(document.forms[0].verificationNo.value,amExMaxLen)){
        alert(cardVerificationAmExInvalid);
        document.forms[0].verificationNo.focus();    
    }else if(document.forms[0].cardType.options[document.forms[0].cardType.selectedIndex].value==4 && !checkLength(document.forms[0].verificationNo.value,discoverMaxLen)){
        alert(cardVerificationDiscoverInvalid);
        document.forms[0].verificationNo.focus();    
    }else if(isBlank(document.forms[0].streetAddress.value)){
        alert(streetNull);
        document.forms[0].streetAddress.focus();
    }else if(isNumericOnly(document.forms[0].streetAddress.value)) {
        alert(streetNumeric);
        document.forms[0].streetAddress.focus();
    }else if(!validateStreetAddress(document.forms[0].streetAddress.value)) {
        alert(streetInvalid);
        document.forms[0].streetAddress.focus();
    }else if(isBlank(document.forms[0].city.value)){
        alert(cityNull);
        document.forms[0].city.focus();
    }else if(!isAlphaCity(document.forms[0].city.value)){
        alert(cityAlpha);
        document.forms[0].city.focus();
    }/*else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="-- Choose One --"){
        alert(stateNull);
        document.forms[0].state.focus();*/
        else if(document.forms[0].state.options[document.forms[0].state.selectedIndex].value=="--"){
        alert(stateNull);
        document.forms[0].state.focus();
    }else if(isBlank(document.forms[0].zip.value)){
        alert(zipNull);
        document.forms[0].zip.focus();
    }else if(!(checkLength(document.forms[0].zip.value, 5))){
        alert(zipLength);
        document.forms[0].zip.focus();
    }else if(!checkValidZip(document.forms[0].zip.value, 5)){
        alert(zipInvalid);
        document.forms[0].zip.focus();
    }else if(!isBlank(document.forms[0].zipLast.value) && !isNumericOnly(document.forms[0].zipLast.value)){
        alert(zipLastOnlyNumber);
        document.forms[0].zipLast.focus();
    }else if(!isBlank(document.forms[0].zipLast.value) && !(checkLength(document.forms[0].zipLast.value, 4))){
        alert(zipLastLength);
        document.forms[0].zipLast.focus();
    }else{
            document.forms[0].submit();
    }//else 

}
/* Functions used to validate the credit card*/
var Cards = new makeArray(8);
Cards[2] = new CardType("MasterCard", "51,52,53,54,55", "16");
var MasterCard = Cards[2];
Cards[1] = new CardType("VisaCard", "4", "13,16");
var VisaCard = Cards[1];
Cards[3] = new CardType("DiscoverCard", "6011", "16");
var DiscoverCard = Cards[3];
Cards[4] = new CardType("AmExCard", "34,37", "15");
var AmExCard = Cards[4];
Cards[5] = new CardType("DinersClubCard", "30,36,38", "14");
var DinersClubCard = Cards[5];
Cards[0] = new CardType("enRouteCard", "2014,2149", "15");
var enRouteCard = Cards[0];
Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
var JCBCard = Cards[6];
var LuhnCheckSum = Cards[7] = new CardType();

/* This function is invoked to check for a valid credit card number*/  
function checkCCardNumber(form) {
    var tmpyear;
    var tmpmonth;
    var str;
    var card;
    var cardName;
    var cardname;
    tmpyear = "20" + form.expYear.options[form.expYear.selectedIndex].value;
    tmpmonth = form.expMonth.options[form.expMonth.selectedIndex].value;
    card = form.cardType.options[form.cardType.selectedIndex].value;
    if(card==1){
    cardName = "VisaCard";
    }
    if(card==2){
    cardName = "MasterCard";
    }
    if(card==3){
    cardName = "AmExCard";
    }
    if(card==4){
    cardName = "DiscoverCard";
    }
    if(form.expMonth.options[form.expMonth.selectedIndex].value!="Month...") {
       if(form.expYear.options[form.expYear.selectedIndex].value=="Year...") { 
         return 1;
        }
     }
    else return 1;
    cardname = "";
    var retval = eval(cardName + ".checkCardNumber(\"" + form.ccNo.value +"\", " + tmpyear + ", " + tmpmonth + ");");
    if (retval){
    return 2;
    }
    else {
    for (var n = 0; n < Cards.size; n++) {
     if (Cards[n].checkCardNumber(form.ccNo.value, tmpyear, tmpmonth)) {
      cardname = Cards[n].getCardType();
      break;
     }
    }
    if (cardname.length > 0) {
     return 3;
    }
    else {
     return 3;
    }
  }
  return 3;
}

/* This function is invoked to return the card type*/  
function CardType() {
    var n;
    var argv = CardType.arguments;
    var argc = CardType.arguments.length;
    this.objname = "object CardType";
    var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
    var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
    var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";
    this.setCardNumber = setCardNumber;  
    this.setCardType = setCardType;  
    this.setLen = setLen;  
    this.setRules = setRules;  
    this.setExpiryDate = setExpiryDate;  
    this.setCardType(tmpcardtype);
    this.setLen(tmplen);
    this.setRules(tmprules);
    if (argc > 4)
    this.setExpiryDate(argv[3], argv[4]);
    this.checkCardNumber = checkCardNumber;  
    this.getExpiryDate = getExpiryDate;  
    this.getCardType = getCardType;  
    this.isCardNumber = isCardNumber;  
    this.isExpiryDate = isExpiryDate;  
    this.luhnCheck = luhnCheck;
    return this;
}

/* This function is invoked to check card number*/  
function checkCardNumber() {
    var argv = checkCardNumber.arguments;
    var argc = checkCardNumber.arguments.length;
    var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
    var year = (argc > 1) ? argv[1] : this.year;
    var month = (argc > 2) ? argv[2] : this.month;
    this.setCardNumber(cardnumber);
    this.setExpiryDate(year, month);
    if (!this.isCardNumber())
    return false;
    if (!this.isExpiryDate())
    return false;
    return true;
}

/* This function is invoked to get the card type*/  
function getCardType() {
    return this.cardtype;
}

/* This function is invoked to get the expiry date*/  
function getExpiryDate() {
    return this.month + "/" + this.year;
}

/* This function is invoked to validate the card number*/  
function isCardNumber() {
    var argv = isCardNumber.arguments;
    var argc = isCardNumber.arguments.length;
    var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
    if (!this.luhnCheck())
    return false;
    for (var n = 0; n < this.len.size; n++)
    if (cardnumber.toString().length == this.len[n]) {
    for (var m = 0; m < this.rules.size; m++) {
    var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
    if (headdigit == this.rules[m])
    return true;
    }
    return false;
    }
    return false;
}

/* This function is invoked to validate the expiry date*/  
function isExpiryDate() {
    var argv = isExpiryDate.arguments;
    var argc = isExpiryDate.arguments.length;
    year = argc > 0 ? argv[0] : this.year;
    month = argc > 1 ? argv[1] : this.month;
    if (!isNum(year+""))
    return false;
    if (!isNum(month+""))
    return false;
    today = new Date();
    expiry = new Date(year, month);
    if (today.getTime() > expiry.getTime())
    return false;
    else
    return true;
}

/* This function is invoked to check the value is a number*/  
function isNum(argvalue) {
    argvalue = argvalue.toString();
    if (argvalue.length == 0)
    return false;
    for (var n = 0; n < argvalue.length; n++)
    if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
    return false;
    return true;
}

/* This function is invoked to do luhncheck*/  
function luhnCheck() {
    var argv = luhnCheck.arguments;
    var argc = luhnCheck.arguments.length;
    var CardNumber = argc > 0 ? argv[0] : this.cardnumber;
    if (! isNum(CardNumber)) {
    return false;
    }
    var no_digit = CardNumber.length;
    var oddoeven = no_digit & 1;
    var sum = 0;
    for (var count = 0; count < no_digit; count++) {
    var digit = parseInt(CardNumber.charAt(count));
    if (!((count & 1) ^ oddoeven)) {
    digit *= 2;
    if (digit > 9)
    digit -= 9;
    }
    sum += digit;
    }
    if (sum % 10 == 0)
    return true;
    else
    return false;
}

/* This function is invoked to costruct the array*/  
function makeArray(size) {
    this.size = size;
    return this;
}

/* This function is invoked to set the card number*/  
function setCardNumber(cardnumber) {
    this.cardnumber = cardnumber;
    return this;
}

/* This function is invoked to set the card type*/  
function setCardType(cardtype) {
    this.cardtype = cardtype;
    return this;
}

/* This function is invoked to set the expiry date*/  
function setExpiryDate(year, month) {
    this.year = year;
    this.month = month;
    return this;
}

/* This function is invoked to set the length*/  
function setLen(len) {
    if (len.length == 0 || len == null)
    len = "13,14,15,16,19";
    var tmplen = len;
    n = 1;
    while (tmplen.indexOf(",") != -1) {
    tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
    n++;
    }
    this.len = new makeArray(n);
    n = 0;
    while (len.indexOf(",") != -1) {
    var tmpstr = len.substring(0, len.indexOf(","));
    this.len[n] = tmpstr;
    len = len.substring(len.indexOf(",") + 1, len.length);
    n++;
    }
    this.len[n] = len;
    return this;
}

/* This function is invoked to set the rules*/  
function setRules(rules) {
    if (rules.length == 0 || rules == null)
    rules = "0,1,2,3,4,5,6,7,8,9";
    var tmprules = rules;
    n = 1;
    while (tmprules.indexOf(",") != -1) {
    tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
    n++;
    }
    this.rules = new makeArray(n);
    n = 0;
    while (rules.indexOf(",") != -1) {
    var tmpstr = rules.substring(0, rules.indexOf(","));
    this.rules[n] = tmpstr;
    rules = rules.substring(rules.indexOf(",") + 1, rules.length);
    n++;
    }
    this.rules[n] = rules;
    return this;
}
/* Functions used to validate credit card ends*/ 
 
 
 
 
 
 
 
function isBlank(str)
{
    if(str.length == 0)
        return true;
    else{
        var strblank ="";
        for(i=0; i<str.length; i++)
            strblank = strblank + " " ;

        if(str == strblank)
            return true;
        else 
            return false;
    }

}

function isBlankPass(str)
{
    if(str.length == 0)
        return true;
}

function isNumericOnly(str)
{
    
    var str = trim(str);
    var ctrI;
    var counter = 0;
    var strLength = str.length;
    var validStr = "1234567890";
    if(strLength == 0){
    return false;
    }
    for (ctrI = 0;ctrI < strLength;ctrI++){
    if (validStr.indexOf(str.charAt(ctrI)) != -1){
    counter++;}
    }if(strLength == counter){
   return true;
   }
   return false;
}

function isNumericOnlyWithSpace(str)
{
    var str = trim(str);
    var ctrI;
    var counter = 0;
    var strLength = str.length;
    var validStr = "1234567890 ";
    if(strLength == 0){
    return false;
    }
    for (ctrI = 0;ctrI < strLength;ctrI++){
    if (validStr.indexOf(str.charAt(ctrI)) != -1){
    counter++;}
    }if(strLength == counter){
   return true;
   }
   return false;
}

function isAlphaNumeric(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

function isUserAlphaNumeric(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

//This function is for validate Special Delivery Instruction field
function isAlphaNumSplDelvInstruct(str)
{
    var temp = str.split("\n");  
    var ctr;  
    for(ctr=0;ctr < temp.length;ctr++){
        var ctrI;        
        temp[ctr]=temp[ctr].replace("\r","");       
        temp[ctr]=trim(temp[ctr]);
 
        var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890?$\"\\,&()<>@|;+'/.! ";
        for (ctrI = 0; ctrI < temp[ctr].length; ctrI++) {
         temp[ctr]=temp[ctr].replace(" ","");      
        if(validStr.indexOf(temp[ctr].charAt(ctrI)) == -1){
            return false;
        }
        
        }
    }
     return true;
   
   
   
 
}
//This function is for validate Special Delivery Instruction field
/*function isAlphaNumSplDelvInstruct(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890?$\"\\,&()<>@|;+'";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}*/

function isAlphaNumSrchKeyword(str)
{
    var str=trim(str);
    str = str.replace(" ", "");
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,\*\"\'$&:()/;+ ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

function isAlphaCity(str)
{
    var str=trim(str);
    str = str.replace(" ", "");
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,-. ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

function isAlphaNumHelpSrch(str)
{
    var str=trim(str);
    str = str.replace(" ", "");
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-,\*\"\'&()/;+:$ ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}
function isShoppingListItemsName(str)
{    
    var temp = str.split("\n");
    var ctr; 
    for(ctr=0;ctr < temp.length;ctr++){
        var ctrI;
        temp[ctr]=temp[ctr].replace("\r","");          
        temp[ctr]=trim(temp[ctr]);
        var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,*\" \'$&:()/;+ ";
        for (ctrI = 0; ctrI < temp[ctr].length; ctrI++) {
        if(validStr.indexOf(temp[ctr].charAt(ctrI)) == -1){
            return false;
        }        
    }
    }
   return true;
}

//This function is for validate comments field of ContactUS
function isAlphaNumComments(str)
{
var temp = str.split("\n");
    var ctr;  
    for(ctr=0;ctr < temp.length;ctr++){
        var ctrI;
        temp[ctr]=temp[ctr].replace("\r","");          
        temp[ctr]=trim(temp[ctr]);
        var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-!,@*\"'()$&%: ";
        for (ctrI = 0; ctrI < temp[ctr].length; ctrI++) {
	        temp[ctr]=temp[ctr].replace(" ",""); 
	        if(validStr.indexOf(temp[ctr].charAt(ctrI)) == -1){
	            return false;
        }
        
    }
    }
   return true;
}
/*function isAlphaNumComments(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-!,@*\"'()$&%: ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}*/
function passwordIsAlphaNumeric(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}
function isAlphaNumericStore(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890&_- ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}
function isAlphaNumeAptSuite(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/,-.&;()# ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

//This function is for validate Company field
function isAlphaNumCompanyName(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 . - , & @ |() ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false; 
        }
    }
   return true;
}

function isAlphaNumStAd(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-, ";
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}


function checkemail(field){
    var testresults=false;
    field.value=trim(field.value);
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if((field.length==0)){
        testresults=false;
    }else{
        if (filter.test(field.value)){
            testresults=false;
        }else{
            testresults=true;
        }
     }
return testresults;
}

function checkLength(param, len)
{ 
    var param=trim(param);
    var num="0123456789";
    var tempChar;
    if (param.length != len){        
        return false;
    }else{
  return true;
  }
}


// To check if the variable contains only alphabets.  Returns true if the variable contains only alphabets
function isAlpha(str)
{
    var str=trim(str);
    var ctrI;
    var strLength = str.length;
    var validStr='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
    for (ctrI = 0; ctrI < strLength; ctrI++) {
       if (validStr.indexOf(str.charAt(ctrI)) == -1){
          return false;
        }
    }
   return true;
}

///checks if a number
function isNumber(s){
    var s=trim(s);
    var ctrI;
    var tempChar;
    for (ctrI = 0; ctrI < s.length; ctrI++){   
        // Check that current character is number.
        tempChar = s.charAt(ctrI);
        if (((tempChar < '0') || (tempChar > '9')))
           return false;
    }
    // All characters are numbers.
    return true;
}

//check if a valid password
function isPassword(str){
    var str=trim(str);
    var isDigit=0;
    var isAlpha=0;
    var alpha='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
    var digit='0123456789';
    for (ctrI = 0; ctrI < str.length; ctrI++) {
       if (alpha.indexOf(str.charAt(ctrI)) == -1){
          isAlpha=1;
       }
       if(digit.indexOf(str.charAt(ctrI)) == -1){
          isDigit=1;
       }
    }
    if((isAlpha==1) && (isDigit==1)){
        return true;
    }else{
        return false;
    }
}

function passwdEqualsLogin(userName, password)
{
    var userName=trim(userName.toLowerCase());
    var password=trim(password.toLowerCase());
    if(userName==password)
        return true;
    else
        return false;
}

/* START: Force Numeric */
function ForceNumeric(field){
    var inputStr = field.value.toString();
    var strLength = inputStr.length;
    var newStr = "";
    for (var i = 0; i < strLength; i++){
       var oneChar = inputStr.charAt(i); 
    if (!( isNaN(oneChar) || oneChar == ' ' || oneChar == '-' )) 
    { 
        newStr = String(newStr) + String(field.value.substring(i,i+1));
    }
}
    if (newStr != field.value) 
    {
        field.value = newStr;
    }
}
function NumericKeyUp(fieldToEval,fieldToEvalLength,objToJumpTo) 
{
    ForceNumeric(fieldToEval);
    if ((fieldToEval.value.length == fieldToEvalLength)&& (fieldToEval.value != prevValue) && (objToJumpTo != null))
    { 
        objToJumpTo.focus() 
    } 
        prevValue = fieldToEval.value;
}
/* END: Force Numeric */

/* START: Force Numeric */
function ForceNumericPsc(field){
    var inputStr = field.value.toString();
    var strLength = inputStr.length;
    var newStr = "";
    for (var i = 0; i < strLength; i++){
       var oneChar = inputStr.charAt(i); 
    if (!( isNaN(oneChar) || oneChar == ' ') || oneChar == '-' ) 
    { 
        newStr = String(newStr) + String(field.value.substring(i,i+1));
    }
}
    if (newStr != field.value) 
    {
        field.value = newStr;
    }
}

function NumericKeyUpPsc(fieldToEval,fieldToEvalLength,objToJumpTo) 
{
    ForceNumericPsc(fieldToEval);
    if ((fieldToEval.value.length == fieldToEvalLength)&& (fieldToEval.value != prevValue) && (objToJumpTo != null))
    { 
        objToJumpTo.focus() 
    } 
        prevValue = fieldToEval.value;
}
/* END: Force Numeric */

//Function trim starts
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; 
} 

/* OpenWindow
ACTION:
Open a new instance of browser
NOTES:
Multiple calls will re-use the same window;
Scrollable arg should be "scroll" or "no_scroll" for ease of reading(nothing cryptic)
*/
function OpenWindow(url,height,width,top,left,scrollable){
  var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,'cm_ow','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll);
  cm_ow.focus();
}

function OpenWindowPopup(url,height,width,top,left,scrollable){
  var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,'cm_ow1','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll);
  cm_ow.focus();
}

function OpenWindowFeatures(url,height,width,top,left,scrollable){
 var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,'cm_ow','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll+',status='+1+',toolbar='+1+',menubar='+1+',location='+1);
  cm_ow.focus();
}

/*
  OpenNamedWindow 
*/
function OpenNamedWindow(url,name,height,width,top,left,scrollable){
  var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,name,'height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll);
  cm_ow.focus();
}

/*Open window without toolbar*/
function OpenWindowToolBar(url,height,width,top,left,scrollable,toolbar){

var owcscroll = (scrollable=='scroll')?'yes':'no';
var owctool = (toolbar=='tool')?'no':'yes';

cm_ow = window.open(url,'cm_ow','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll+',toolbar='+owctool);

cm_ow.focus();

}
/*this function is used to print PSC card*/

function printCard(cardNumber) {
    
    document.forms[0].target="foo";
    window.open('',document.forms[0].target,'height=220,width=330,scrollbars=no,titlebar=no,resizable=no');
    document.forms[0].submit();
    }
    
/* START:COMMON SCRIPT*/
function swapImg(imgid,id) {
  o = document.getElementById(imgid);
  o.src = o.src.replace(/_\d\./,'_'+id+'.');
}

/* END:COMMON SCRIPT*/

//  This function extracts the Jsession id from url1 and inserts in url2
function formURL(url1, url2){
    var jSessionId=url1.substring(url1.indexOf(";"), url1.indexOf("?")+1);
    var tempURL=url2.split("?");
    var resultURL=tempURL[0]+jSessionId+tempURL[1];

return resultURL;
}

function textareaSpecified(str,chk,fld)
{  
   if(str.length>300)
    {
        alert(splDelvInstructionLength);    
        return false;
    }
   var temp = str.replace(/\r\n/g," ");
    word = temp.split(" ");
    totalWords = word.length;
     
    if(chk == 1)
    {
	    for(i=0;i<totalWords;i++)
	    {
	        if(word[i].length > 50)
	        {
	            alert(maxLength1+fld);
	            return false;
	            break;
	        }
	    }
    }
    else if(chk == 2)
    {
        for(i=0;i<totalWords;i++)
        {
            if(word[i].length > 25)
            {
                alert(maxLength2+fld);
                return false;
                break;
            }
        }
    }    
    return true;
    
}


function isBlankSpaceFront(str)
  {  
     flag = false;
     str = str.value; 
     strlen = str.length;
      for(i=0;i<strlen;i++){
      if(str.charAt(i)!=" ")
           {
            
            flag = true;
            break;
            }
            else
            {
            
            flag = false;
            break;
            }
      }
     
                  
      return flag;
 
}

function isBlankSpaceRear(str){
 flag = false ;
 str = str.value;
 strlen = str.length;
      for(i=strlen;i>0;i--)
      {  
        if(str.charAt(i-1)!=" ")
        {
         
         flag = true;
         break; 
         }
         else
         {
         flag = false;
         break;
         }
       }
       return flag;
   }
   
   
function isBlankSpace(str){
    flag = false ;
    if(isBlankSpaceFront(str) != false)
    {
        if(isBlankSpaceRear(str) != false){
            return true; }
        else
            return false;
    }
        return false;

}

function isCreditcard(str){
        var cardValid; 
        cardValid = checkCCardNumber(document.forms[0]); 
        if(cardValid==1){
            alert(cardNumInvalid);
            return false;
        }else if(cardValid==3){
            alert(cardMisMatch);
            return false;           
        }else if(cardValid==2){
            return true;
        }
      }
//added for Forgot password Click check
function forgotPasswordCheck()
{
    if(isBlank(document.UserDetailsForm.userName.value) || document.UserDetailsForm.userName.value == "Username")
    {
        alert(userNameNull);
        document.UserDetailsForm.userName.focus();
     }
    else
    {
    	document.UserDetailsForm.method = "post"
		document.UserDetailsForm.action = "/eCommerceWeb/ForgotPasswordAction.do?action=forgottenPassword&param=displayHintQuestion"
		document.UserDetailsForm.submit();
	}
}
      
function validateSiteSearch()    {  
   if(isBlank(document.SearchForm.searchText.value)){  
        alert(searchTermNull);    
        document.SearchForm.searchText.focus();        
    }   
    
    else if(document.SearchForm.searchText.value.length > 75){ 
        alert ("Search text cannot have a length of more than 75 characters"); 
    }else if(!isAlphaNumSrchKeyword(document.SearchForm.searchText.value)){
               alert(KeywordInval);
               document.SearchForm.searchText.focus();
    }
    
    else 
    { 
        if(document.SearchForm.searchContext.value=="productsOnline") 
        { 
           document.ProductSearchForm.searchStr.value=document.SearchForm.searchText.value;
           document.ProductSearchForm.searchContext.value=document.SearchForm.searchContext.value
          document.ProductSearchForm.submit(); 
        } 
        else
        document.SearchForm.submit(); 
    }   
}  

function validateHeaderSiteSearch(){  
 var searchStr = document.getElementById('searchBox').value;
    if(isBlank(document.getElementById('searchBox').value)){  
        alert(searchTermNull);    
        document.getElementById('searchBox').focus();        
    }else if(document.getElementById('searchBox').value == "Search our site"){  
        alert(searchTermNull);    
        document.getElementById('searchBox').focus();           
    }else if(document.getElementById('searchBox').value.length > 75) {
        alert("Search text cannot have a length of more than 75 characters"); 
         document.getElementById('searchBox').focus();  
    }else{
         searchStr = strCheck(searchStr);   
	 if(searchStr.length < 3){   
                alert("Search terms need to be at least 3 characters");
			 document.getElementById('searchBox').focus();  
               }else{
               if(searchStr=="invalidStr"){                
		         document.getElementById('searchBox').focus();  
                }else{
		         location.href = '/eCommerceWeb/SiteSearchAction.do?action=getSiteSearchResults&amp;q='+document.getElementById('searchBox').value;
		}
	 }
    }
}


        var ie4 = (document.all) ? true : false;
        var ns4 = (document.layers) ? true : false;
        var ns6 = (document.getElementById && !document.all) ? true : false;
        var scaly_list = false;
        
        function hidelayer(doc,lay) {
            var ie4 = (doc.all) ? true : false;
            var ns4 = (doc.layers) ? true : false;
            var ns6 = (doc.getElementById && !doc.all) ? true : false;
            if (ie4) {doc.all[lay].style.visibility = "hidden";}
            if (ns4) {doc.layers[lay].visibility = "hide";}
            if (ns6) {doc.getElementById([lay]).style.display = "none";
            //document.getElementById([lay]).style.visibility = "block";
            doc.getElementById([lay]).style.visibility = "hidden"; }
        }
        
        function showlayer(doc,lay) {
            var ie4 = (doc.all) ? true : false;
            var ns4 = (doc.layers) ? true : false;
            var ns6 = (doc.getElementById && !doc.all) ? true : false;
            if (ie4) {doc.all[lay].style.visibility = "visible";}
            if (ns4) {doc.layers[lay].visibility = "show";}
            if (ns6) {doc.getElementById([lay]).style.display = "block";
            doc.getElementById([lay]).style.visibility = "visible";}
            }
        
            function writetolayer(doc,lay,txt)
            {
               if (ie4) {
                
                 if (txt != "prepage")
                    {
                        hidelayer(doc,"prepage");
                    }
                    if (txt != "postpage")
                    {
                        hidelayer(doc,"postpage");
                    }
                    doc.getElementById(lay).innerHTML = doc.getElementById(txt).innerHTML;
                    }
                    if (ns4) {
                    doc[lay].document.write(txt);
                    doc[lay].document.close();
                    }
                    if (ns6) {
        
                    //show(1, txt);
                    if (txt != "prepage")
                    {
                        hidelayer(doc,"prepage");
                    }
                    if (txt != "postpage")
                    {
                        hidelayer(doc,"postpage");
                    }
                    showlayer(doc,txt);
            }
         }  
         
  /*function in FindSavings for Promotions */    
  
  function popUpThirdPartywindow(promoURL){
                  var w = 404;
                    var h= 309;
                   
                    if (document.all) {
                        w = document.body.clientWidth;
                        h = document.body.clientHeight;
                    }
                    else if (document.layers) {
                      w = window.innerWidth;
                      h = window.innerHeight;
                    }
                
                                    
                    var popW = 300, popH = 200;
                    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
                    
                    var thirdPartyWin = window.open("","","width=405,height=319,top=" + topPos + ",left=" + leftPos + ",location=0,status=0,scrollbars=true,menubar=0,resizable=0")
                    /*var nWin = window.open("","",""620"",""750"",""80"",""150"",""no_scroll"")*/
                    
                    var text = promoURL;
                    
                    var html =  "<html>\n"+
                                "<title>Albertsons :: Third Party Site Notification</title>\n" +
                                "<body style='background: url(/eCommerceWeb/images/eCommerce/common/bg-3rdparty-notice.gif)';\n" + 
                                "<table width=404 height=309 border=0>"+
                                "<tr><td align=right>"+
                                "<br><br><br><br><br><br><br><br><br><br><br><br> &nbsp; "+
                                "<a href=# onclick='javascript:window.open(\"" + text + "\");javascript:window.close();' ><img src='/eCommerceWeb/images/eCommerce/promotions/ok_button.gif' border='0'></a>&nbsp;&nbsp;&nbsp;" + 
                                "<a href=Javascript:window.close();><img src='/eCommerceWeb/images/eCommerce/promotions/cancel_button.gif'  border='0'></a>" + 
                                "</td></tr>" + 
                                "</table></body>" 
                                
                    thirdPartyWin.document.open();
                    thirdPartyWin.document.write(html);
                    thirdPartyWin.document.close();
                }
/*function to open a popup*/    
  
  function thirdPartywindowpopup(promoURL,name,height,width){
    var w = 404;
    var h= 309;
       
        if (document.all) {
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
    }
    
                    
    var popW = 300, popH = 200;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
    
    var popupwindow = window.open("","","width=400,height=316,top=" + topPos + ",left=" + leftPos + ",location=0,status=0,scrollbars=true,menubar=0,resizable=0")
    var popup = popupwindow.document;
    popup.write('<html><head><title>SUPERVALU :: Third Party Site Notification</title>');
    popup.write('</head>');
    popup.write('<body background="/eCommerceWeb/images/corporate/common/bg-3rdparty-notice.gif">');
    popup.write('<br><br><br><br><br><br>&nbsp;');
    popup.write('<table width=404 height=165 border=0>');
    popup.write('<tr><td align=right style="padding-top:81px;padding-right:45px">');
    popup.write('<input type="image" src="/eCommerceWeb/images/corporate/common/button-3rdpartyok.gif" border="0"  onclick="javascript:window.open(\''+promoURL+'\', \'' +name+'\',\'height='+height+',width='+width+',scrollbars='+1+'\');javascript:window.close()"> ');
    popup.write('&nbsp;&nbsp;&nbsp;');   
    popup.write('<input type="image" src="/eCommerceWeb/images/corporate/common/button-3rdpartycancel.gif" border="0"  onclick="javascript:window.close()">');
    popup.write('</td></tr>');
    popup.write('</table>');
    popup.write('</body></html>');
    popup.close();
 }

                
/*This function is used in Help and FAQ search pages*/

function validate() {
      
    if(isBlank(document.searchForm.searchStr.value)){  
        alert(searchTermNull);    
        document.searchForm.searchStr.focus();        
    } 
    
     else if(document.searchForm.searchStr.value.length > 75){
        alert ("Search text cannot have a length of more than 75 characters");  
    }else if(!isAlphaNumHelpSrch(document.searchForm.searchStr.value)){
                alert(KeywordInval);
               document.searchForm.searchStr.focus();
    } 
    else {
        document.searchForm.submit();
    }   
}
/*This function is used to search in product listing pages*/
function searchVal(){
    var searchStr = document.SearchForm.searchStr.value;                               
    if(isBlank(searchStr)){  
        alert(searchTermNull);    
        document.SearchForm.searchStr.focus();        
    } 
    else{
       if(searchStr.length > 75){
          alert ("Search text cannot have a length of more than 75 characters"); 
         }else{             
            searchStr = strCheck(searchStr);         
            if(searchStr.length < 3){   
                alert("Search terms need to be at least 3 characters");
                document.SearchForm.searchStr.focus();
               }else{
               if(searchStr=="invalidStr"){
                document.SearchForm.searchStr.focus();
                }
                else
                    document.SearchForm.submit();
                }
             }   
          }
 }

/* For Item Search */
function itemSearchVal(){
    /*searchStr = document.ItemSearchForm.searchStr.value;                               
    if(isBlank(searchStr) || searchStr=="Search for item(s)"){  
        alert(searchTermNull);    
        document.ItemSearchForm.searchStr.focus();        
    } 
    else{
       if(searchStr.length > 75){
          alert ("Search text cannot have a length of more than 75 characters"); 
         }else{             
            searchStr = strCheck(searchStr);         
            if(searchStr.length < 3){   
                alert("Search keyword is too short to initiate search");
                document.ItemSearchForm.searchStr.focus();
               }else{
               if(searchStr=="invalidStr" )
                document.ItemSearchForm.searchStr.focus();
                else
                    document.ItemSearchForm.submit();
                }
             }   
          }*/
          
          if(isBlank(document.getElementById('itemSearchDiv').value)){  
        alert(searchTermNull);    
        document.getElementById('itemSearchDiv').focus();        
    }else if(document.getElementById('itemSearchDiv').value == "Search for item(s)"){  
        alert(searchTermNull);    
         document.getElementById('itemSearchDiv').focus();           
    }else if(document.getElementById('itemSearchDiv').value.length > 75) {
        alert("Search text cannot have a length of more than 75 characters"); 
         document.getElementById('itemSearchDiv').focus();  
    }else{
         //location.href = '/eCommerceWeb/SiteSearchAction.do?action=getSiteSearchResults&amp;q='+document.getElementById('searchBox').value;
         location.href = '/eCommerceWeb/ItemSearchAction.do?action=getProductSearchResults&page=shop&btnClick=true&searchStr='+document.getElementById('itemSearchDiv').value;
    }
          
 }
  /*function for sending email offline*/
function emailFormSubmit(email)
        { 
           if(email.value == '')
            {
             alert("Please enter a valid email address.");
             email.focus();
            }         
              else
               if (!checkemail(email))
              {
                   //  document.emailForm.action = "/eCommerceWeb/ShopOnlineAction.do?action=insertEmailId";
                       document.emailForm.submit();                               
              }
              else
              {
               alert("Please enter a valid email address.");
               //Commented for bug#5774
               //email.value="";
               email.focus();
              }
        }
        
 /* function to implement more options in Product search*/
  function moreOptions(isPastPurchasePresent)
        {          
          var searchText = document.SearchForm.searchText.value;
          var ingredients = document.SearchForm.ingredients.value;
          var desc = document.SearchForm.description.value;
          
          var descript = null;
          if(trim(searchText) == '') 
          {
           alert("Please Enter the Product Name ");
           document.SearchForm.searchText.focus();
          }
          else if(searchText.length > 75 ){
            alert ("Product Name cannot have a length of more than 75 characters");
            document.SearchForm.searchText.focus();
          }  
          else if(ingredients.length > 50){
            alert ("Ingredients cannot have a length of more than 50 characters");
            document.SearchForm.ingredients.focus();
          }  
          else if(desc.length > 50){
            alert ("Description cannot have a length of more than 50 characters"); 
            document.SearchForm.description.focus(); 
          }   
          else
          {
                  if(searchText.length>0){
                    searchText = strCheck(searchText);
                    document.SearchForm.searchText.focus();
                    }
                  if(searchText != 'invalidStr' && searchText.length>0 && ingredients.length>0){
                     ingredients = strCheck(ingredients);
                     document.SearchForm.ingredients.focus();
                     }
                  if(searchText != 'invalidStr' && searchText.length>0 && ingredients != 'invalidStr' && desc.length>0){
                       descript = strCheck(desc); 
                       document.SearchForm.description.focus(); 
                      }                                      
                  if((searchText!= 'invalidStr') && (ingredients!= 'invalidStr') && (descript != 'invalidStr'))
                  {
                          if((searchText.length > 0 && searchText.length < 3)) 
		                  {            
		                     alert("Product Name is too short to initiate search");
                             document.SearchForm.searchText.focus();
		                  }
                          else if(ingredients.length > 0 && ingredients.length < 3)      
                          {
                             alert("Ingredients text is too short to initiate search");
                             document.SearchForm.ingredients.focus();
                          }
                          else if(descript != null && descript.length > 0 && descript.length < 3)
                          {
                              alert("Description text is too short to initiate search");
                              document.SearchForm.description.focus(); 
                          }
		                  else
		                  {
		                    if(document.SearchForm.limitToSales.checked == true)
		                      {
		                        document.SearchForm.limitToSales.value = "true" ;
		                      }
		                      if(isPastPurchasePresent == true && document.SearchForm.limitToPastPurchase.checked == true)
		                      {
		                        document.SearchForm.limitToPastPurchase.value = "true" ;
                                document.SearchForm.action.value = "getPastPurchasesForProdSearch";
		                      }
		                      document.SearchForm.submit();
		                  }  
                  }
           }    
                      
  } 
  /*function to evaluate the search string in product search*/
  function strCheck(searchStr){       
          var flag="false";         
          strLength=searchStr.length;    
          var tempStr = "invalidStr";   
          var count = 0;  
          var validStr='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,*\'$&:()/;+-" ';
                for (ctrI = 0; ctrI < strLength; ctrI++) {
                   if (validStr.indexOf(searchStr.charAt(ctrI)) == -1){                        
                      flag="true";                        
                    }
                }
          if(flag == "true"){
            alert(KeywordInval);
            return tempStr;
            }
          else
          {  
           if(searchStr.length > 0){
            if(searchStr.indexOf('"')!=-1) 
               {
                          if(searchStr.indexOf('"') == 0 ){
                            searchStr=searchStr.substring(1,searchStr.length)                            
                          }  
                          if(searchStr.indexOf('"')== searchStr.length-1){                            
                            searchStr=searchStr.substring(0,searchStr.length-1)                            
                          }
                          if(searchStr.indexOf('&') != -1 || searchStr.indexOf('%') != -1){                          
                            searchStr = searchStr.replace('&','*');
                            searchStr = searchStr.replace('%','*'); 
                          }                     
                }
                else if(searchStr.indexOf('*') != -1 || searchStr.indexOf('?') != -1 || searchStr.indexOf('.') != -1)
                {                    
                    /*for(i=0; i<searchStr.length;i++){                        
                        searchStr = searchStr.replace('&','*');
                        searchStr = searchStr.replace('%', '*');
                        searchStr = searchStr.replace('.','*');  
                    }*/
                    
                }                
                count = searchStr.indexOf('*');  
                     if(count != -1)
                      {
                        subStr = searchStr.substring(0,count+1);   
		                strLen = searchStr.length;                
		                for(i=count+1; i<strLen;i++){                     
		                    if(i!=0){
		                        if(searchStr.charAt(i)== '*'){ 
		                            if(!(searchStr.charAt(i-1) == '*')){                                
		                                subStr = subStr + searchStr.charAt(i); 
		                            }
		                        }else{                            
		                            subStr = subStr + searchStr.charAt(i); 
		                        }                        
		                    }
		                }  
                          searchStr = subStr; 
                     }              
         }         
         return searchStr;
         }
  }
  
 function checkValidAltIdFirst(field)
{
    var valid = true;
    if (field.value.substr(0,1) == 1 || field.value.substr(0,1) == 0
        || field.value.substr(0,3) ==  800 || field.value.substr(0,3) ==  866
        || field.value.substr(0,3) ==  888  || field.value.substr(0,3) ==  900
        || field.value.substr(0,3) ==  976 || field.value.substr(0,3) ==  877
        || field.value.substr(3,3) == 555)
    {
        valid = false;
    }
    else
    {
        if (field.value.charAt(0)=="0")
        {
            valid = false;
        }
       
    }
     return valid;
}
  
 
  /* function in shoppinglist update and search*/ 
  function validateUpdateAndSearch()
  {
    if(isBlank(document.updateListForm.itemName.value)){
        alert("Please enter item to update");
        document.updateListForm.itemName.focus();        
        }
    else if(document.updateListForm.itemName.value.length > 250){
        alert ("Item cannot have a length of more than 250 characters");    
     }else if(!isShoppingListName(document.updateListForm.itemName.value)){
    	 alert("You entered special characters that cannot be part of the shopping list items. Please re-enter");
         document.updateListForm.itemName.focus();
    }else{
        document.updateListForm.submit();
     }
 } 
   
   function validateUpdate()
  {
    if(isBlank(document.updateForm.itemName.value))
        {
	        alert("Please enter item to update");
	        document.updateForm.itemName.focus();   
        }
        
    else if(document.updateForm.itemName.value.length > 250){
        alert ("Item cannot have a length of more than 250 characters");    
        }
    else if(!isShoppingListName(document.updateForm.itemName.value)){
	   	 alert("You entered special characters that cannot be part of the shopping list items. Please re-enter");
         document.updateForm.itemName.focus();
    }     
    else{
        document.updateForm.submit();
        }
   } 
   
   /*function to check for mandatory fields in Step II of registration*/
    function checkCheckBox(checkPSC){
    if(checkPSC != ""){
    if(document.forms[0].makeDefault.checked == true){
    sa.innerHTML = "Street Address *";
    cty.innerHTML = "City *";
    tel.innerHTML = "Telephone *"
    }
    else{
    sa.innerHTML = "Street Address ";
    cty.innerHTML ="City ";
    tel.innerHTML = "Telephone "
    }
    }
    return false;
    } 
    
    
    /*function to check the mandatory password fields for Account Details on focus*/
    function manPassFieldsON(){
currpassw = document.getElementById("currpass");
newpassw = document.getElementById("newpass");
secquest = document.getElementById("secques");
currpassw.innerHTML="Current Password *";
newpassw.innerHTML="New Password *";
secquest.innerHTML="If updating your password, you must answer your security question. *";
    return false;
    }
    
    /*function to check the mandatory password fields for Account Details when focus is lost*/
    function manPassFieldsOFF(){
var A=0;
if(isBlank(document.forms[0].oldPassword.value)&&isBlank(document.forms[0].password.value)&&isBlank(document.forms[0].password1.value)&&isBlank(document.forms[0].hintAnswer.value)){
currpassw = document.getElementById("currpass");
newpassw = document.getElementById("newpass");
secquest = document.getElementById("secques");
currpassw.innerHTML="Current Password";
newpassw.innerHTML="New Password";
secquest.innerHTML="If updating your password, you must answer your security question." 
    }
    return false;
    }
    
    
    
   /* Function for pagination */
   function dropDownSort(){
      var actionIndex = document.productSort.action.indexOf('?action');
     if( actionIndex!= -1){
        document.productSort.action = document.productSort.action.substring(0,actionIndex);
      }
      document.productSort.action=document.productSort.action+'?action=getSaleItems'+document.productSort.params.value;
     }  
      
     /* Function to check shopping List drop down value */
   function chkShopListVal(){
    if(document.dropDownListForm.itemName.value != "ShoppingList"){
        document.dropDownListForm.submit();
    }
   }
   
   /* Function to calculate the total DEA Products in the cart */
    function calculateDEA(formName){
    var deaProductsQty = 0;
        var productQty = 0;
        var controlCode = 0;
        var elm = document.forms[0].elements;
        var k=0;
        for(var l=0; l<elm.length;l++)
        {
            if(elm[l].name == 'qty')
            {
                k++;
            }
        }
        if(k>1)
        {
            for(var i=0;i<k;i++){
                controlCode = eval("document.forms[0].controlCode["+i+"].value");
                if(controlCode == 4){
                    productQty = eval("document.forms[0].qty["+i+"].value")
                    deaProductsQty = deaProductsQty + parseInt(productQty);
                }
            }
        }
        else{
            controlCode = eval("document.forms[0].controlCode.value");
            if(controlCode == 4){
                productQty = eval("document.forms[0].qty.value")
                deaProductsQty = deaProductsQty + parseInt(productQty);
            }
        }
        return deaProductsQty;
    }
    
    // Method to check dea limiting values
    function checkDEALimit(cartLiteForm,productId, prodQty, deaLimit){
        var deaProductsQty = 0;
        var productQty = 0;
        var controlCode = 0;
        var previousQty = 0;
        
	    var elm = cartLiteForm.elements;
	    var k=0;
	    if(elm != null && elm.length > 0){
	        for(var l=0; l < elm.length;l++)
	        {
	            if(elm[l].name == 'qty')
	            {
	                k++;
	            }
	        }
	    }else{
	    	if(parseInt(prodQty) > parseInt(deaLimit)){
				alert("There is a "+ parseInt(deaLimit) + " item maximum quantity for this item. Please try again.");
	            return parseInt(deaLimit);
	    	}else{
	    		return -1;
	    	}
	    }
	    if(k>1)
	    {
	        for(var i=0;i<k;i++){
	            controlCode = cartLiteForm.controlCode[i].value;
	            if(controlCode == 4){
	                if(productId == cartLiteForm.productId[i].value){
	                    previousQty = cartLiteForm.qty[i].value;
	                }
	                else{
	                    productQty = cartLiteForm.qty[i].value;
	                    deaProductsQty = deaProductsQty + parseInt(productQty);
	                }
	            }
	        }
	    }
	    else{
	        controlCode = cartLiteForm.controlCode.value;
	        if(controlCode == 4){
	        
	            if(productId == cartLiteForm.productId.value){
	                previousQty = cartLiteForm.qty.value;
	            }
	            else{
	                 productQty = cartLiteForm.qty.value;
	                 deaProductsQty = parseInt(productQty);
	            }
	        }
	    }
	    
	    if((parseInt(deaProductsQty) + parseInt(prodQty)) > parseInt(deaLimit)){
	        var allowableQty = parseInt(deaLimit) - parseInt(deaProductsQty) - parseInt(previousQty);
	        if(allowableQty > 0){
	            alert("There is a "+ allowableQty + " item maximum quantity for this item. Please try again.");
	            return allowableQty;
	        }
	        else{
	            alert("This item cannot be added to your cart  "+ '\n' +"due to restrictions on controlled substances.");
	            return previousQty;
	        }
	    }
	    return -1;
	    
        //return deaProductsQty;
    }
    
function lTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            s = s.substring(j, i);
        }
        return s;
}

/*function goToReservation(){
 alert("Inside common.js");
	  var status = checkCookie();
	  if(status){  
		  window.document.ProductListForm.urlToSend.value = window.parent.location.href;
		  window.document.ProductListForm.submit();
	  }
  }*/
 
 /* Gift Certificate Add To Cart Function */           
    function addGCToCart(formName,isCartPresent)  
  {           
     var elm = eval("document."+formName+".elements");
     var productId=null;
     var prodId=null;
     var k=0;
    
        for(var l=0; l<elm.length;l++)
        {
            if(elm[l].name == 'qty')
            {
                k++;
            }
        }
    
     var index=eval("document."+formName+".index.value");
     
     if(k>1)
     {
         productId=eval("document."+formName+".productId["+index+"].value");     
         qty=eval("document."+formName+".qty["+index+"].value");
         qty = parseInt(qty) + 1;
    }
    else
    {
         productId=eval("document."+formName+".productId.value");     
         qty=eval("document."+formName+".qty.value");
         qty = parseInt(qty) + 1;
    }                           
         eval("document.addToCartForm.productId.value='"+productId+"'");
         eval("document.addToCartForm.qty.value='"+qty+"'");
      
         if(!window.frames['cartFrame'].document.getElementById('prepage')){
                alert(CartLiteLoading);
                return false;
           }  
           if(window.frames['cartFrame'].document.getElementById('prepage').style.visibility=="hidden") 
           {      
                document.addToCartForm.submit();     
                 writetolayer(window.frames['cartFrame'].document,'newlayer','prepage');
                 window.frames['cartFrame'].document.getElementById('prepage').style.visibility="visible" ;
                 window.frames['cartFrame'].document.getElementById('postpage').style.visibility="hidden";   
                 return false;
           } 
                        
       
  }      
     
  // getting the product ID from denomination in the drop down box of Gift Certificate
   function changeAddToCart(ind)
  {
    document.GCCartForm.index.value= parseInt(ind) - 1;
    var pidIndex = parseInt(ind) - 1;
    var pid = document.GCCartForm.productId[pidIndex].value;
    document.GCContinueForm.productID.value = pid;
    document.GCContinueForm.purchaseQtyMax.value = document.GCCartForm.maxQty[pidIndex].value;
  } 
  
  //Continue button in Gift Certificate, if no product is selected,then by default it takes first one in drop down box
  function checkselected()
  {
    var pid = document.GCContinueForm.productID.value;
	var qty = document.GCContinueForm.purchaseQtyMax.value;
    if (pid == "" || pid == null)
     {            
         pid = document.GCCartForm.productId[0].value;
		 qty = document.GCCartForm.maxQty[0].value;            
     }
    var queryIndex = document.GCContinueForm.action.indexOf('&');
	if(queryIndex > 0){
		document.GCContinueForm.action = document.GCContinueForm.action.substring(0,queryIndex)
	}
	document.GCContinueForm.action = document.GCContinueForm.action + '&selectedProductId='+pid+"&maxPrdctQty="+qty;
    document.GCContinueForm.submit();
  } 
 
 // Change the images in drop down Box of Gift certificate
  function imageChange(selValue)
{

  if(selValue == "Happy Birthday!")
  
  {
  document.giftImg.src = "/eCommerceWeb/images/eCommerce/giftCertificate/gc_happybday_sm.gif";
  
  }else if (selValue == "Happy Holidays!")
  
  {
  document.giftImg.src = "/eCommerceWeb/images/eCommerce/giftCertificate/gc_happyholidays_sm.gif";
  
  }else if (selValue == "A Special Gift For You!")
  
  {
  document.giftImg.src = "/eCommerceWeb/images/eCommerce/giftCertificate/gc_aspecialgiftforyou_sm.gif";
  
  }else if (selValue == "Thank You!")
  {
  document.giftImg.src = "/eCommerceWeb/images/eCommerce/giftCertificate/gc_thankyou_sm.gif";
  
  }else
  {
   document.giftImg.src = "/eCommerceWeb/images/eCommerce/giftCertificate/gc_aspecialgiftforyou_sm.gif";
  }
}
/*function for zipCode in delivery areas page*/
function zipCodeSubmit(newZip)
 { 
        
    var formValid = true;
    var zipLength = true;
    var str ="Please enter valid"+"\n";
    var regZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
    if (document.getLoginAuthForm.newZip.value == '')
    {
        
        formValid = false;
        document.getLoginAuthForm.newZip.focus();
        
    }
    
    else if (document.getLoginAuthForm.newZip.value != '' && !regZip.test(document.getLoginAuthForm.newZip.value))
    {
        zipLength = false;
        document.getLoginAuthForm.newZip.focus();
        
    }
    
    else if (document.getLoginAuthForm.newZip.value.indexOf("00000") != -1)
    {
        formValid = false;
        document.getLoginAuthForm.newZip.focus();
        
    }
    else if(document.getLoginAuthForm.newZip.value.charAt(0)=="0" && document.getLoginAuthForm.newZip.value.charAt(1)=="0")
    {
       formValid = false;
       document.getLoginAuthForm.newZip.focus();
      
    }
    else if(isZipCode(document.getLoginAuthForm.newZip))
    {
       formValid = false;
       document.getLoginAuthForm.newZip.focus();
      
    }
    if(!zipLength) {
        alert("Your zip code must be five digits long. Please re-enter your zip code");
        return false;  
    }
    if(!formValid) {
        str = str+"-zip code"+"\n";
        alert(str);
        return false;  
    }
    else if(formValid || zipLength) {
     document.getLoginAuthForm.submit(); 
    }
 }
 /* This function is invoked to check for first 5 digits of the zipcode*/    
function isZipCode(field){
    var invalid = false;
    var checkOK = "0123456789";
    if ((field.value.length != 5) ){
        invalid = true;
    }    
    return invalid; 
}  
// validation for Gift Certifiicate recipient information
function recipientValidation()
{
	var cartQty = new Number(document.GCCartForm.qty.value);
    var maxQty = new Number(document.GCCartForm.purchaseQtyMax.value);
   if ( cartQty < maxQty){
        if(isBlank(document.GCCartForm.recipientName.value)){
           alert("Please enter Recipient's Name");
           document.GCCartForm.recipientName.focus();
        }else if(!isAlphaNumeric(document.GCCartForm.recipientName.value)) {
            alert("You entered special characters that cannot be read by our system. Please enter Recipient's Name");
           document.GCCartForm.recipientName.focus();
        }else if (isNumericOnly(document.GCCartForm.recipientName.value)){
            alert("Recipient's Name should not contain only numbers");
            document.GCCartForm.recipientName.focus();
        }else if(isBlank(document.GCCartForm.recipientEmail.value)){
            alert("Please enter recipient's e-mail address");
          document.GCCartForm.recipientEmail.focus();      
        }
       else if(checkemail(document.GCCartForm.recipientEmail)){
            alert(emailInvalid);
        document.GCCartForm.recipientEmail.focus();
        }else if (document.GCCartForm.greetingImage.options[document.GCCartForm.greetingImage.selectedIndex].value == "Name")
        {
         	alert("Please select an image");
        	document.GCCartForm.greetingImage.focus();
        }else  if(document.GCCartForm.customMessage.value.length > 500)
        {
            alert("Custom message must be 500 characters or less");
            document.GCCartForm.customMessage.focus();
        }
        else
        {
          document.GCCartForm.submit();
        }
        
    }else{
   alert("You cannot add more than "+document.GCCartForm.purchaseQtyMax.value+" quantity");
   }

}
//function for Continue button in gift certificate

function gcCommomContinue(formName)
{
  
    if (document.GCCartForm.test.value == "1") 
   {
        checkselected();
   }else{
         addGCToCart(formName,'true');
   }
}

//direct add to cart selected
function gcRadioClickAddToCart()
{
  document.GCCartForm.test.value = 0;
}

// Email option selected
function gcRadioClickEmail()
{
    document.GCCartForm.test.value = 1;
}


// Open a popup window
function winopen(url,stuff,morestuff) 
{
    var popwin = window.open(url,stuff,morestuff);
    
    // you may get "undefined" if a popup blocker did its thing...
    if( typeof(popwin) != "undefined" && popwin )
    {
        popwin.focus();
    }
    
    lastPopup = popwin;
}

/* Moved from contactUs.js to here*/
/* This function is invoked for validating signin */
function signin(){
    if(isBlank(document.UserDetailsForm.userName.value) && isBlank(document.UserDetailsForm.password.value))
    { 
    	 alert(userNameNPwdNull);
    	 document.UserDetailsForm.userName.focus();    	
    }else if(isBlank(document.UserDetailsForm.userName.value)){
        alert(userNameNull);
        document.UserDetailsForm.userName.focus();
    }else if(isBlank(document.UserDetailsForm.password.value)){
        alert(passwordNull);
        document.UserDetailsForm.password.focus();
    }else{   
        document.UserDetailsForm.submit();
    }
}                      

function clearForm()
{
   document.forms[0].searchText.value="";
}
function validateStreetAddress(addr){
	var isValidAddr = false;
	//newAddr = replaceAll(addr,'.','');
	isValidAddr = isAlphaNumStAd(addr);
	return isValidAddr;
}

function replaceAll(oldStr,findStr,repStr) {
  var srchNdx = 0;  
  var newStr = "";  
  while (oldStr.indexOf(findStr,srchNdx) != -1)  
  {
    newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
    newStr += repStr;
    srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
  }
  newStr += oldStr.substring(srchNdx,oldStr.length);
  return newStr;
}
/* This function is enable to reset the psc fields*/ 
function enablePscFields()
{
    document.forms[0].pscNumber.disabled= false;
    document.forms[0].pscPhoneNumber.disabled= false;
}

/* This function is invoked to disable the psc fields*/ 
function disablePscFields(){
    document.forms[0].pscNumber.disabled = true;
    document.forms[0].pscPhoneNumber.disabled = true;
    document.forms[0].pscNumber.value = "";
    document.forms[0].pscPhoneNumber.value = "";
}
/**     shopping List Enhancement
        AJAX Implamented Code
**/
// function for creating  XML HTTP object
function createRequestObject() {
var ro;
var browser = navigator.appName;
 if(browser == "Microsoft Internet Explorer"){
  ro = new ActiveXObject("Microsoft.XMLHTTP");
 }else{
  ro = new XMLHttpRequest();
 }
return ro;
}

// Initializing the object when page loads
var http = createRequestObject();
var ajaxIndicatorPosition;
var imgId = null;
var listAnchorId = null;

// function to perfor on click of add to list button
function addToList(url,statusCnt){
  var x = document.getElementById("addingToList").value;
	var appImgId = statusCnt;
  if (x =='true'){
    alert("Please wait till the product is added to List");
  }else{
    document.getElementById("addingToList").value = "true";
 if (statusCnt == "oneProduct"){
        var messagezone = "messagezone";
        ajaxIndicatorPosition = "";
        appImgId = "";
        }
        else{
       var messagezone = "messagezone" + statusCnt;
        ajaxIndicatorPosition = statusCnt;
    }
    document.getElementById(messagezone).style.visibility="visible";
    http.open('post', url);
    http.onreadystatechange = handleResponse;
    imgId = "addToList"+appImgId;
    listAnchorId = "listAnchorId"+appImgId;
    http.send(null);
  }
}
// Handling the server response
function handleResponse() {
    
   if(http.readyState == 4){
      if(http.status ==200){
            var messagezone = "messagezone" + ajaxIndicatorPosition;
            document.getElementById(messagezone).style.visibility="hidden";
            document.getElementById("addingToList").value = "false";
            if(document.getElementById(imgId) != null){
            document.getElementById(imgId).src = "/eCommerceWeb/images/eCommerce/common/saved-to-list.gif";
            document.getElementById(listAnchorId).href = "#";
            document.getElementById(listAnchorId).style.cursor = "none";            
            }
      }
   }
}  


function addToList1(url,statusCnt,form){
  var x = document.getElementById("addingToList").value;
  var prodIndex = "";
  var oldIndex = statusCnt;
  if(document.getElementById('prodIndex'+statusCnt) != null){
	prodIndex = document.getElementById('prodIndex'+statusCnt).value;
  } 
  var appImgId = statusCnt;
  if(prodIndex != ""){
	  appImgId = prodIndex;
  }
  var index=parseInt(appImgId)-1;
  var elm = eval("document."+form+".elements");	
  var qty = null;
  var k = null; 
    var reqObj=null;
  
   for(var l=0; l<elm.length;l++)
    {
        if(elm[l].name == 'qty')
        {
            k++;              
        }
    }

    
    if(k<=1){
  		qty = eval("document."+form+".qty.value");
  	}else{
  		qty = eval("document."+form+".qty[" + index + "].value");
  	}
 
	if (x =='true'){
    	alert("Please wait till the product is added to List");
  	}else{
  		if(qty==''){           
           alert("Please enter an item quantity.");
           if(k<=1){
          		eval("document."+form+".qty.value=''");           
           		eval("document."+form+".qty.focus()");  
           	}else{
           		eval("document."+form+".qty[" + index + "].value=''");           
           		eval("document."+form+".qty["+index+"].focus()"); 
           	}         
     	}else{
	    	document.getElementById("addingToList").value = "true";
	    	if (statusCnt == "oneProduct"){
	        var messagezone = "messagezone";
	        appImgId = "";
			oldIndex = "";
            
	        }else{
       		var messagezone = "messagezone" + statusCnt;
    		}  
            imgId = "addToList1"+oldIndex;
            listAnchorId = "listAnchorId"+oldIndex;  	
	    	
            document.getElementById('messagezone').style.display="";
            document.getElementById('shoppingListContent').style.display="none";
            if((reqObj=testBrowser(reqObj))!=null){
            if(navigator.appName=='Netscape'){
                reqObj.open('GET', url);
            }else{
                reqObj.open('POST', url);
            }
           }
            reqObj.onreadystatechange = function(){
             if(reqObj.readyState == 4){
		      if(reqObj.status ==200){
                var messagezone = "messagezone";
		        document.getElementById("addingToList").value = "false";
		        document.getElementById('shoppingListContent').style.display="";
                document.getElementById('messagezone').style.display="none";
		        if(document.getElementById(imgId) != null){
					document.getElementById(imgId).src = "/eCommerceWeb/images/eCommerce/common/saved-to-list.gif";                    
					document.getElementById(listAnchorId).href = "#";
					document.getElementById(listAnchorId).style.cursor = "none"; 
                    if(navigator.userAgent.indexOf("Safari")!=-1){
                    sleep(500);
                    }
					document.getElementById("shopListFrame").innerHTML=reqObj.responseText;         
				}
		      }
			 }
            };
           
			reqObj.send(null);
          
		}
	}

}

function handleResponse1() {
    
   if(http.readyState == 4){
      if(http.status ==200){
      	var messagezone = "messagezone";
      	document.getElementById("addingToList").value = "false";
        document.getElementById('shoppingListContent').style.display="";
 		document.getElementById('messagezone').style.display="none";
 		if(document.getElementById(imgId) != null){
 		document.getElementById(imgId).src = "/eCommerceWeb/images/eCommerce/common/saved-to-list.gif";
 		document.getElementById(listAnchorId).href = "#";
        document.getElementById(listAnchorId).style.cursor = "none"; 
        document.getElementById("shopListFrame").innerHTML=http.responseText;         
       }
      }
   }
}  


function checkValidFirst(field)
{
    var valid = true;
    var checkOK = "0123456789";
    if (
          (field.value.substr(0,1) == 1 || field.value.substr(0,1) == 0
        || field.value.substr(0,3) ==  800 || field.value.substr(0,3) ==  877
        || field.value.substr(0,3) ==  888 || field.value.substr(0,3) ==  900
        || field.value.substr(0,3) ==  976) )
    {
        valid = false;
    }
    else
    {
        if (field.value.charAt(0)=="0")
        {
            valid = false;
        }
       
    }
     return valid;
    }


function checkValidMiddle(field)
{
    var valid = true;
    var checkOK = "0123456789";
    if (field.value.substr(0,3) == 555)
    {
        valid = false;
    }
     return valid;
    }
function checkValidReplaceCard(field)
{
    var valid = false;
    var checkOK = "0123456789";
    
        if (field.value.charAt(0)=="4")
        {
            valid = true;
        }
        
    
    return valid;
    }
function checkEmailSubscription(){ 
  if(isBlank(document.forms[0].firstname.value)){ 
    alert(firstNameNull); 
           document.forms[0].firstname.focus(); 
  }else if(!isAlphaNumeric(document.forms[0].firstname.value)) { 
           alert(firstNameAlphaNumeric); 
           document.forms[0].firstname.focus(); 
       }else if (isNumericOnlyWithSpace(document.forms[0].firstname.value)){ 
           alert(firstNameOnlyNumber); 
           document.forms[0].firstname.focus(); 
       }else if(isBlank(document.forms[0].email.value)){ 
           alert(emailNull); 
           document.forms[0].email.focus(); 
       }else if(checkemail(document.forms[0].email)){ 
           alert(emailInvalid); 
           document.forms[0].email.focus(); 
       }else if(isBlank(document.forms[0].zip.value)){ 
           alert(zipNull); 
           document.forms[0].zip.focus(); 
       }else if(!checkLength(document.forms[0].zip.value, 5)){ 
           alert(zipLength); 
           document.forms[0].zip.focus(); 
       }else if(!checkValidZip(document.forms[0].zip.value, 5)){ 
           alert(zipInvalid); 
           document.forms[0].zip.focus(); 
       }else{ 
           //control to yesmail. 
           document.forms[0].submit(); 
       } 
  } 

// js for browse aisles starts here........

var k = null;
function switchMenu(obj) {
 /*alert(obj);
	var el = document.getElementById(obj);
	alert(el.text);
	alert(el.style.display);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	} 
	else {
		el.style.display = '';
	}
	*/
  document.getElementById('myvar').style.display = "none";
  document.getElementById('myvar').style.visibility = 'visible';;
	
}

 function collapseNExp(imageId)
{

if(imageId == 'collapse'){
   document.getElementById('collapse').id = 'expand';
   document.getElementById('expand').src="/eCommerceWeb/images/eCommerce/shoppingpath/expand_slide_btn.gif";
   document.getElementById('browseAisles').style.visibility ="hidden";  
   document.getElementById('listingAisleInfo').innerHTML= x;
   document.getElementById('listingAisleInfo').style.height = '1px'
   document.getElementById('breadCrumb').innerHTML = k;
     document.getElementById('breadCrumb').style.visibility = 'visible';
 }
 else if(imageId == 'expand'){
 x= document.getElementById('listingAisleInfo').innerHTML;
 k = document.getElementById('breadCrumb').innerHTML;
  document.getElementById('expand').id = 'collapse';
  document.getElementById('collapse').src="/eCommerceWeb/images/eCommerce/shoppingpath/collapse_slide_btn.gif";
  document.getElementById('browseAisles').style.visibility= 'hidden';
  //document.getElementById('listingAisleInfo').style.width = '720px';
  document.getElementById('listingAisleInfo').innerHTML= document.getElementById('productInfo').innerHTML;
  document.getElementById('breadCrumb').style.visibility = 'hidden';
  document.getElementById('breadCrumb').style.height = '1px';
  document.getElementById('breadCrumb').style.display='inline-block';
  document.getElementById('apple').style.background = '';
  document.getElementById('firstCol').style.filter="alpha(opacity=150)";
  document.getElementById('secondCol').style.filter="alpha(opacity=150)";
  document.getElementById('thirdCol').style.filter="alpha(opacity=150)";
 }
}


function SE_toggleSlide(objname,linkTextName){

  if(linkTextName == "collapsing"){
   document.getElementById('collapsing').id = 'expanding';
   document.getElementById('buttonx').innerHTML = "<img src ='/eCommerceWeb/images/eCommerce/shoppingpath/expand_slide_btn.gif' id='expand' />";
    //document.getElementById('content1').innerHTML =x;
    SE_slideup(objname);// div is not hidden, so slide up
    document.getElementById('content1').innerHTML =x;    
  }else{
   if(document.getElementById('splInd')!=null){
	  var id = document.getElementById('splInd').value;
	  var arr = id.split('_');
	  document.getElementById('arr0').value = arr[0];
	  document.getElementById('arr1').value = arr[1];
	  document.getElementById('arr2').value = arr[2];
	  document.getElementById('arr3').value = arr[3];
	  }
  x= document.getElementById('content1').innerHTML;
  document.getElementById('expanding').id = 'collapsing';

	document.getElementById('buttonx').innerHTML = "<img src ='/eCommerceWeb/images/eCommerce/shoppingpath/collapse_slide_btn.gif' id='collapse' />";
	
	SE_slidedown(objname);// div is hidden, so let's slide down
    document.getElementById('content1').innerHTML = document.getElementById('productInfo').innerHTML;
  }
}

 function changebgColor(id, type, selId){
	if(id != selId){
	if(type== 'in'){
	var img = document.getElementById(id+'img').src;
	var repImg = img.replace('.gif','_active.gif');
	document.getElementById(id).style.background = "#B3BF6D";
	document.getElementById(id+'span').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+repImg+"')";
	document.getElementById(id+'img').src = repImg;
	}
	else{
	var img = document.getElementById(id+'img').src;
	var repImg = img.replace('_active.gif','.gif');
	document.getElementById(id).style.background = "";
	document.getElementById(id+'span').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+repImg+"')";
	document.getElementById(id+'img').src = repImg;
	}
  }
}

function setSplAction(id,isJs){

if(isJs == 'true'){
setAisleTypeInfo(id);
}else{
location.href ="/eCommerceWeb/ShopOnlineAction.do?action=getShopOnlineAisles&aisleTypeId="+id;
}
}

function setAisleTypeInfo(aisleTypeId)
{
	var url = document.location.href;
		aisleTypeIdStr = "selAisleTypeId=" + aisleTypeId;
		if(url.indexOf("selAisleTypeId") != -1){
			var index = url.indexOf("selAisleTypeId");
			var indexTemp = url.indexOf("&",index);
			if(indexTemp == -1)
				indexTemp = url.length;			
			url = url.replace(url.substring(index,indexTemp),aisleTypeIdStr);
		}
	    else{
			url = url + "&" + aisleTypeIdStr;
		}		
		
		  bcActionStr = "bcAction=getAisles";
			var index = url.indexOf("bcAction");
			if(index != -1)	{
				var indexTemp = url.indexOf("&",index);
				if(indexTemp == -1)
				indexTemp = url.length;					
				url = url.replace(url.substring(index,indexTemp),bcActionStr);
			}else{
				url = url + "&" + bcActionStr;
			}
	document.location.href = url;
}

function setAisleInfo(aisleId, aisleName)
{
	var url = document.location.href;
		aisleIdStr = "selAisleId=" + aisleId;
		if(url.indexOf("selAisleId") != -1){
			var index = url.indexOf("selAisleId");
			var indexTemp = url.indexOf("&",index);
			if(indexTemp == -1)
				indexTemp = url.length;		
			url = url.replace(url.substring(index,indexTemp),aisleIdStr);
		}
	    else{
			url = url + "&" + aisleIdStr;
		}
			bcActionStr = "bcAction=getCategories";
			var index = url.indexOf("bcAction");
			if(index != -1)	{
				var indexTemp = url.indexOf("&",index);
				if(indexTemp == -1)
				indexTemp = url.length;					
				url = url.replace(url.substring(index,indexTemp),bcActionStr);
			}else{
				url = url + "&" + bcActionStr;
			}
	document.location.href = url;
}

function setCatInfo(categoryId, categoryName)
{
	 var url = document.location.href;
	 categoryStr = "selCategoryId=" + categoryId;
	   if(url.indexOf("selCategoryId") != -1){
			var index = url.indexOf("selCategoryId");
			var indexTemp = url.indexOf("&",index);
			if(indexTemp == -1)
				indexTemp = url.length;		
			url = url.replace(url.substring(index,indexTemp),categoryStr);
		}else{
			url = url + "&" + categoryStr;
		}

	        bcActionStr = "bcAction=getSubCategories";
			var index = url.indexOf("bcAction");
			if(index != -1)	{
				var indexTemp = url.indexOf("&",index);
				if(indexTemp == -1)
				indexTemp = url.length;			
				if(indexTemp == -1)
				indexTemp = url.length;				
				url = url.replace(url.substring(index,indexTemp),bcActionStr);
			}else{
				url = url + "&" + bcActionStr;
			} 
	    
    document.location.href = url;
}






var SE_timerlen = 1;
var SE_slideAniLen = 300;

var SE_timerID = new Array();
var SE_startTime = new Array();
var SE_obj = new Array();
var SE_endHeight = new Array();
var SE_moving = new Array();
var SE_dir = new Array();

function SE_slidedown(objname){
        if(SE_moving[objname])
                return;

        SE_moving[objname] = true;
        SE_dir[objname] = "down";
        SE_startslide(objname);
}

function SE_slideup(objname){
        if(SE_moving[objname])
                return;
		
        SE_moving[objname] = true;
        SE_dir[objname] = "up";
        SE_startslide(objname);
        
}

function SE_startslide(objname){
        SE_obj[objname] = document.getElementById(objname);

        if(SE_dir[objname] == "down"){
			SE_obj[objname].style.height = '128px';
		}
        SE_endHeight[objname] = parseInt(SE_obj[objname].style.height);
        SE_startTime[objname] = (new Date()).getTime();

        if(SE_dir[objname] == "down"){
                SE_obj[objname].style.height = "30px";
        }

        SE_obj[objname].style.display = "block";

        SE_timerID[objname] = setInterval('SE_slidetick(\'' + objname + '\');',SE_timerlen);
        
}

function SE_slidetick(objname){
        var elapsed = (new Date()).getTime() - SE_startTime[objname];

        if (elapsed > SE_slideAniLen)
                SE_endSlide(objname)
        else {
                var d =Math.round(elapsed / SE_slideAniLen * SE_endHeight[objname]);
                if(SE_dir[objname] == "up")
                        d = SE_endHeight[objname] - d;

                SE_obj[objname].style.height = d + "px";
        }

        return;
}

function SE_endSlide(objname){
        clearInterval(SE_timerID[objname]);
        if(SE_dir[objname] == "up"){
                SE_obj[objname].innerHTML = x;

        SE_obj[objname].style.height = "30px";
		}else{
		SE_obj[objname].style.height = "128px";
		}
        delete(SE_moving[objname]);
        delete(SE_timerID[objname]);
        delete(SE_startTime[objname]);
        delete(SE_endHeight[objname]);
        delete(SE_obj[objname]);
        delete(SE_dir[objname]);

        return;
}
//Added for Fresh IDeas
 function viewFreshIdea(){
  if(document.searchArchives.issueName.value == 'Select An Issue')
  {
   alert(" Please select an issue to view past ideas")
  }else
  {
    document.searchArchives.submit();
  }
 }


function validateHeaderSearch() { 
    if(isBlank(document.getElementById('searchText').value)){
    alert(searchTermNull); 
    document.getElementById('searchText').focus(); 
    }   else if(document.getElementById('searchText').value.length > 75)
    alert ("Search text cannot have a length of more than 75 characters");
    else 
    { 
     var searchStr = strCheck(document.getElementById('searchText').value);   
	 if(searchStr.length < 3){   
            alert("Search terms need to be at least 3 characters");
		 		document.getElementById('searchText').focus();  
           }else{
	           if(searchStr=="invalidStr"){                
		         document.getElementById('searchText').focus();  
	            }else{
				    if(document.getElementById('searchContext') == null || document.getElementById('searchContext').value=="productsOnline") 
				    { 
				    	window.parent.location.href = '/eCommerceWeb/ProductSearchAction.do?action=getProductSearchResults&btnClick=true&searchStr='+wfSearchCheck(document.getElementById('searchText').value);
				    } 
				    else
				    	window.parent.location.href = '/eCommerceWeb/SiteSearchAction.do?action=getSiteSearchResults&searchText='+wfSearchCheck(document.getElementById('searchText').value)+'&btnClick=true'+'&searchContext='+wfSearchCheck(document.getElementById('searchContext').value);
				    }  	
	   		 }
  		 }
}

function wfSearchCheck(name){
	var name = name;
	if(name.indexOf(',') != -1){
		name = replaceAll(name,",", "%2C")
	}
	if(name.indexOf('&') != -1){
		name = replaceAll(name,"&", "%26")
	}
	if(name.indexOf('(') !=-1){
		name = replaceAll(name,"(","%28")
	}
	if(name.indexOf(')') !=-1){
		name = replaceAll(name,")","%29")
	}	
	if(name.indexOf("'") !=-1){
		name = replaceAll(name,"'", "%27")
	}
	if(name.indexOf(";") !=-1){
		name = replaceAll(name,";", "%3B")
	}
	if(name.indexOf("$") !=-1){
		name = replaceAll(name,"$", "%24")
	}
	if(name.indexOf('"') !=-1){
		name = replaceAll(name,"\"", "%22")
	}
	return name;
}
function cartAction(index,productId,productName,qty,sizeDescription,controlCode,transType,formName)
{
	var oldIndex = index;
	var prodIndex = "";
	if(document.getElementById('prodIndex'+(index+1)) != null){
		prodIndex = document.getElementById('prodIndex'+(index+1)).value;  
	}
	
var k=0;
var bogo = null;
var specialItem = null;
var lcspecialPrice = null;

var newInd = parseInt(oldIndex)+1;
if(prodIndex != ""){
	index = prodIndex-1;
}
var s1 = qty;
var cartLitePresent = eval("document.addToCartForm.cartLitePresent.value");
var elm = eval("document."+formName+".elements");

 for(var l=0; l<elm.length;l++)
    {
        if(elm[l].name == 'qty')
        {
            k++;            
        }
    }
if( k<=1)
{
	bogo = eval("document."+formName+".bogo.value");
	
	if(bogo == 'yes')
	{
        if(s1<2 && document.getElementById('bogocheck')!=null && document.getElementById('bogocheck').checked)
        {
            qty = 2;
    
        } else {
            qty = s1;
        }
    } 
    else 
    {
    
	   specialItem =eval("document."+formName+".specialItems.value");
	   lcspecialPrice =eval("document."+formName+".lcspecialPrice.value");
		if(specialItem == 'yes'  && document.getElementById('specialcheck')!=null && document.getElementById('specialcheck').checked)
        {
            qty =lcspecialPrice;
        } else 
        {
            qty = s1;
        }
    }
	
	document.getElementById('PopUpText'+newInd).innerHTML = "";
	document.getElementById('PopUpText'+newInd).style.display = 'none';

}


else
{	
	
	bogo =eval("document."+formName+".bogo["+index+"].value");


    if(bogo == 'yes')
    {
		if(s1<2 && document.getElementById('bogocheck')!=null && document.getElementById('bogocheck').checked)
		{
			qty = 2;
	
		} 
		else
		{
			qty = s1;
		}
    } 
    else 
    {


		specialItem =eval("document."+formName+".specialItems["+index+"].value");
		lcspecialPrice =eval("document."+formName+".lcspecialPrice["+index+"].value");
		if(specialItem == 'yes'  && document.getElementById('specialcheck')!=null && document.getElementById('specialcheck').checked)
		{
			qty =lcspecialPrice;
			
		} 
		else 
		{
			qty = s1;
		}
    }
	document.getElementById('PopUpText'+newInd).innerHTML = "";
	document.getElementById('PopUpText'+newInd).style.display = 'none';
	
}


		eval("document.addToCartForm.productId.value='"+productId+"'");
        eval("document.addToCartForm.productName.value='"+productName+"'");
        eval("document.addToCartForm.sizeDescription.value='"+sizeDescription+"'");
        eval("document.addToCartForm.qty.value='"+qty+"'");
        if(formName == "browseAislesFeaturedItems")
        {
	        eval("document.addToCartForm.aisleId.value='"+aisleId+"'");
	        eval("document.addToCartForm.categoryId.value='"+categoryId+"'");
	    }
        

         if(transType == 'add')
         {
        //   eval("document."+formName+".action='/eCommerceWeb/AddToCartAction.do?action=addItemToCart'");
   //        eval("document.getElementById('" + formName+ind + "').innerHTML = \"<a href=javascript:addToCart('" + formName + "'," + ind + ",'update')><img src='/eCommerceWeb/images/eCommerce/common/cart_update.gif' alt='Update Cart' title='Update Cart'></a>\"");
 
          if(k>1)
          {
           var isCartPresent= eval("document."+formName+".isCartPresent["+index+"].value");
          	 eval("document."+formName+".isCartPresent["+index+"].value=true");             
          }
          else
           {
            var isCartPresent= eval("document."+formName+".isCartPresent.value");
            eval("document."+formName+".isCartPresent.value=true"); 
           }

         }                                                                  
 
           else 
           if(transType == 'update')
          {
           eval("document."+formName+".action='/eCommerceWeb/AddToCartAction.do?action=addItemToCart'");
          }
      
       else 
        {  
           
           //eval("document."+formName+".action='/eCommerceWeb/AddToCartAction.do?action=addItemToCart'");
      //     eval("document.getElementById('" + formName+ind + "').innerHTML = \"<a href='#' onclick=javascript:addToCart('" + formName + "'," + ind + ",'add')><img src='/eCommerceWeb/images/eCommerce/common/cart_add.gif' alt='Add To Cart'></a>\"");  
           
           
        }     
           
      if(cartLitePresent == 'false')  
        {
          document.addToCartForm.submit();
        }
        
       else
       {
           if(!window.frames['cartFrame'].document.getElementById('prepage')){
                alert(CartLiteLoading);
                return false;
           }  
           if(window.frames['cartFrame'].document.getElementById('prepage').style.visibility=="hidden") 
           {      
           
			if(controlCode == 4 ){
	            deaLimit = eval("document."+formName+".deaLimit.value");
	            var allowableQty = checkDEALimit(window.frames['cartFrame'].document.forms[0],productId,qty,deaLimit);
	            if(allowableQty == -1) {   
	            	 if(transType == 'add')
			         {
			        //   eval("document."+formName+".action='/eCommerceWeb/AddToCartAction.do?action=addItemToCart'");
			   //        eval("document.getElementById('" + formName+ind + "').innerHTML = \"<a href=javascript:addToCart('" + formName + "'," + ind + ",'update')><img src='/eCommerceWeb/images/eCommerce/common/cart_update.gif' alt='Update Cart' title='Update Cart'></a>\"");
			 
			          if(k>1)
			          {
			           	eval("document."+formName+".isCartPresent["+index+"].value=false");             
			          }
			          else
			           {
			             eval("document."+formName+".isCartPresent.value=false"); 
			           }
			
			         }
			         
	              	 document.addToCartForm.submit(); 
	              	 
	              	 if(transType == 'add')
			         {
				      writetolayer(window.frames['cartFrame'].document,'newlayer','prepage');
		             window.frames['cartFrame'].document.getElementById('prepage').style.visibility="visible" ;
		             window.frames['cartFrame'].document.getElementById('postpage').style.visibility="hidden";   
		             return false;
	             	}
	             	else if(transType == 'update')
	             	{
	             	writetolayer(window.frames['cartFrame'].document,'newlayer','updating');
		             window.frames['cartFrame'].document.getElementById('updating').style.visibility="visible" ;
		             window.frames['cartFrame'].document.getElementById('postpage').style.visibility="hidden";   
		             return false;
	             	}
	              	     
		             
	            }else{
	            	if(transType == 'add')
			         {
			        //   eval("document."+formName+".action='/eCommerceWeb/AddToCartAction.do?action=addItemToCart'");
			   //        eval("document.getElementById('" + formName+ind + "').innerHTML = \"<a href=javascript:addToCart('" + formName + "'," + ind + ",'update')><img src='/eCommerceWeb/images/eCommerce/common/cart_update.gif' alt='Update Cart' title='Update Cart'></a>\"");
			 
			          if(k>1)
			          {
			           	eval("document."+formName+".isCartPresent["+index+"].value=false");             
			          }
			          else
			           {
			             eval("document."+formName+".isCartPresent.value=false"); 
			           }
			
			         }   
	            }
	        }else{
	        	 document.addToCartForm.submit();
	        	 if(transType == 'add')
			         {
				      writetolayer(window.frames['cartFrame'].document,'newlayer','prepage');
		             window.frames['cartFrame'].document.getElementById('prepage').style.visibility="visible" ;
		             window.frames['cartFrame'].document.getElementById('postpage').style.visibility="hidden";   
		             return false;
	             	}
	             	else if(transType == 'update')
	             	{
	             	writetolayer(window.frames['cartFrame'].document,'newlayer','updating');
		             window.frames['cartFrame'].document.getElementById('updating').style.visibility="visible" ;
		             window.frames['cartFrame'].document.getElementById('postpage').style.visibility="hidden";   
		             return false;
	             	}
	             	
	        }       	 
           }              
       }
            
      if(transType == 'remove')
      {
        if(k>1)
          {
           var isCartPresent= eval("document."+formName+".isCartPresent["+index+"].value");
           eval("document."+formName+".isCartPresent["+index+"].value=false");     
                
          }
          else
           {
            var isCartPresent= eval("document."+formName+".isCartPresent.value");
            eval("document."+formName+".isCartPresent.value=false"); 
           
           }


//         eval("document."+formName+".isCartPresent.value=false");  
         
      }
} 

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}




function onChange3(index,prdQty,event)
{
	var key = event.keyCode;
	var elm =document.forms[0].elements;
	var k=0;
	for(var l=0; l<elm.length;l++)
	{
		if(elm[l].name == 'qty')
		{
		k++;
		}
	} 
	var ind=parseInt(index)-1; 
	if(k>1) { 
		var s3=document.forms[0].qty[ind].value;
		s3=trim(s3);
		if((isNaN(s3) || s3 == '-' )){ 
			alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
			document.forms[0].qty[ind].value=prdQty;
			eval("document.forms[0].qty["+ind+"].focus()");
			return false;
		}if(s3 =='' && key=='13'){
			alert("quantity field must not be empty");
			document.forms[0].qty[ind].value=prdQty;
		}if(s3=='0'){
			alert("quantity field must not be zero");
	    	document.forms[0].qty[ind].value=prdQty;
		} 
	}else{
		var s3=document.forms[0].qty.value;
		s3=trim(s3);
		if (( isNaN(s3) || s3 == ' ' || s3 == '-' )){ 
			alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
			document.forms[0].qty.value=prdQty;
			eval("document.forms[0].qty.focus()");
			return false;
		}if(s3 == '' && key=='13'){
			alert("quantity field must not be empty");
			document.forms[0].qty.value=prdQty;
		}if(s3=='0'){
			alert("quantity field must not be zero");
			document.forms[0].qty.value=prdQty;
		} 
	}
	var temp="0123456789" 
	for(var i=0;i<s3.length;i++){
	  var s4=""+s3.substring(i,i+1);
	  if((temp.indexOf(s4)=="-1")){
		  if(k>1){
			alert("Item quantity must be a whole number. Fractions and decimals are not allowed"); 
			document.forms[0].qty[ind].value=prdQty;
			return;
		  }else{
		        alert("Item quantity must be a whole number. Fractions and decimals are not allowed"); 
			    document.forms[0].qty.value=prdQty;
			    return;
		       }
		  }
   	} 
}

  function on_Change4(form,index,divId,maxQty,price,event){
	  var oldIndex = index;
	  var prodIndex = "";
	if(document.getElementById('prodIndex'+index) != null){
		prodIndex = document.getElementById('prodIndex'+index).value;	 
	}
	 //alert("index: "+index);
	 //alert("prodIndex: "+prodIndex);
	 
	 if(form=='PastPurchasesForm'){
	 		if(prodIndex != ""){
	 	   	divId = "PastPurchasesForm"+oldIndex;
      		index = prodIndex;
      	}
      		
     }else {
     	 if(prodIndex != ""){
     		divId = "ProductListForm"+oldIndex;
      		index = prodIndex;
     	 }
     }
	 //alert(form+","+index+","+divId+","+maxQty+","+price+","+event);
      //alert("prodIndex.."+prodIndex+"..divid..."+divId);
       var key = event.keyCode;
       var elm = eval("document."+form+".elements");
       var controlCode = null;
       var k=0;
       var elm = eval("document."+form+".elements");
       var controlCode = null;
       var discBogoVal = null;
        var k=0;
        for(var l=0; l<elm.length;l++)
        {
            if(elm[l].name == 'qty')
            {
                k++;
            }
        }
               
         var ind=parseInt(index)-1; 
         
         if(k>1)   
           {              
             var isCartPresent= eval("document."+form+".isCartPresent["+ind+"].value");
             var s3=eval("document."+form+".qty["+ind+"].value"); 
             discBogoVal= eval("document."+form+".discBogo["+ind+"].value");
             if (( isNaN(s3) || s3 == ' ' || s3 == '-' )) 
		    { 
		        alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
                eval("document."+form+".qty["+ ind +"].value=''");   
                eval("document."+form+".qty["+ind+"].focus()");
                return false;
		    } 
             
             var prodId = eval("document."+form+".productId["+ind+"].value");
             controlCode = eval("document."+form+".controlCode["+ind+"].value");     
	          if(s3 == '' && key=='13')
	            {
	             alert("quantity field must not be empty");
                 eval("document."+form+".qty["+ ind +"].value=''");   
                 if(discBogoVal == '4')
                 eval("document."+form+".qty["+ ind +"].value=''");     
	            }
	            
	             if(s3=='0')
	             	{
	             	alert("quantity field must not be zero");
	             	eval("document."+form+".qty["+ ind +"].value='1'");
					eval("document."+form+".qty["+ind+"].focus()");
					return false;
					}    
		                          
           } 
         else
           {
             var isCartPresent= eval("document."+form+".isCartPresent.value");
             var s3=eval("document."+form+".qty.value");
             discBogoVal= eval("document."+form+".discBogo.value");
             if (( isNaN(s3) || s3 == ' ' || s3 == '-' )) 
            { 
                alert("Item quantity must be a whole number. Fractions and decimals are not allowed");
                eval("document."+form+".qty.value=''"); 
                eval("document."+form+".qty.focus()");
                return false;
            } 
             var prodId = eval("document."+form+".productId.value");
             controlCode = eval("document."+form+".controlCode.value")
             if(s3 == '' && key=='13')
		        {
		         alert("quantity field must not be empty");
	 		     eval("document."+form+".qty.value=''");    
                 if(discBogoVal == '4')
                 eval("document."+form+".qty.value=''"); 
	            }
	            
	         if(s3=='0')
	         	{
	         	alert("quantity field must not be zero");
				eval("document."+form+".qty[" + ind + "].value='1'");
				eval("document."+form+".qty["+ind+"].focus()");
				return false;
				}             
           }
        
         var s4= new Number(s3);
         var temp="0123456789";
           
         for(var i=0;i<s3.length;i++)
            {
                var s5=""+s3.substring(i,i+1);
                if(temp.indexOf(s5)!="-1")
                    {
                 
                                               
                         if(s4<=0)
                             {
                             
                             if(isCartPresent == 'true')                                      
                               {
                              	s4=0;   
                                eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'#\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + oldIndex + ",\\'remove\\',\\'" + price + "\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_remove.gif\" alt=\"Remove Cart\" title=\"Remove Cart\"></a>'");                        
                              
                                }
                              else
                                {
                                  s4 = '';
                                  if(discBogoVal == '4')
                                  s4 = '';
                                }    
                                
                               
                                   if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + s4 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + s4 + "'");    
                                
                                
                             }  
         
                            else
                            {
                                 /*  if(controlCode == 4 ){
				                    deaLimit = eval("document."+form+".deaLimit.value");
					                var allowableQty = checkDEALimit(window.frames['cartFrame'].document.forms[0],prodId,s4,deaLimit);
                                    if(allowableQty > 0) {         
					                    s4 = allowableQty;
					                }else if(allowableQty == 0){
					                    s4 = 1;
					                }
                                    if(s4 > maxQty && allowableQty == -1 )
                                    {
                                      alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
                                      s4 = maxQty;
                                    }
					            }else {
	                                if(s4 > maxQty)
	                                {
	                                  alert("There is a "+ maxQty + " item maximum quantity for this item. Please try again.");
	                                  s4 = maxQty;
	                                }
                                }  */
                               if(isCartPresent == 'true') 
                               {
                                     eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'javascript:void(0);\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + oldIndex + ",\\'update\\',\\'" + price + "\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_update.gif\" alt=\"Update Cart\" title=\"Update Cart\"></a>'");
                                } 
                               else
                               {    
                                    eval("document.getElementById('" + divId + "').innerHTML = '<a href=\\'javascript:void(0);\\' onclick=\"javascript:addToCart(\\'" + form + "\\'," + oldIndex + ",\\'add\\',\\'" + price + "\\');\"><img src=\"/eCommerceWeb/images/eCommerce/common/cart_add.gif\" alt=\"Add To Cart\" title=\"Add To Cart\"></a>'");  
                                    
                                }
                                  if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + s4 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + s4 + "'");    
                            }        
                    }
            
                    else
                    {
                                if(k>1)
                                    
                                       eval("document."+form+".qty[" + ind + "].value='" + 1 + "'");
                                      
                                   else
                                    
                                       eval("document."+form+".qty.value='" + 1 + "'");    
                        alert("Item quantity must be a whole number. Fractions and decimals are not allowed");   
                        return;
                    }  
                           
                }    
               
      }
      
function collapse(incr){
document.getElementById('subcat'+incr).style.display="none";
document.getElementById('image'+incr).style.display="none";
document.getElementById('pl'+incr).style.display="";
}
function expand(incr){
document.getElementById('subcat'+incr).style.display="";
document.getElementById('image'+incr).style.display="";
document.getElementById('pl'+incr).style.display="none";
}
function exp(){
document.getElementById('relmatch').style.display="";
document.getElementById('minus').style.display="";
document.getElementById('plus').style.display="none";
}
function coll(){
document.getElementById('relmatch').style.display="none";
document.getElementById('minus').style.display="none";
document.getElementById('plus').style.display="";
}
function checkforhazcharbrowse(query){
	while(query.indexOf(' ') != -1){
    	query = query.replace(' ', '+');
    }
	while(query.indexOf(',') !=-1){
    	query = query.replace(',', '%2C');
    }
    	while(query.indexOf('\'') !=-1){
    	query = query.replace("'", "%27");
    }
		query = query.replace("+&+","+%26+");
		query = query.replace("(","%28");
		query = query.replace(")","%29");	
		query = query.replace("$","%24");	
		dropDownSort();
 }
 function testBrowser(xmlHttp){
	try{    
		// Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();
		return xmlHttp;    
	}catch (e){    
		// Internet Explorer    
		try{     
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
			return xmlHttp;  
		}catch (e){
			try{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
				return xmlHttp;       
			}catch (e){        
				alert("Your browser does not support AJAX!");        
				return null;        
			}      
		}    
	}  
}
    function divByPopUpCard(){
    var xmlHttp;
	var urlString = window.document.URL;
	var listId = document.forms["dropDownListForm"].listId.value;
	if((xmlHttp=testBrowser(xmlHttp))!=null){
		
		if(listId != null && listId !=''){
			var finalURL = "/eCommerceWeb/ShoppingListAction.do?action=getViewListPopUp&listId="+listId;		
		}else{
			var finalURL = "/eCommerceWeb/ShoppingListAction.do?action=getViewListPopUp";
		}
		xmlHttp.open("POST",finalURL,true);
    	xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){				
				document.getElementById("shopId").innerHTML = xmlHttp.responseText;
			}
		};
    	xmlHttp.send(null);
	}	
    }
    function submitForm(value){
    document.dropDownListForm.itemName.value=value;     
    document.dropDownListForm.submit();
    }
   function popUpClose(){ 
    document.getElementById("shopId").innerHTML="";   
    //document.getElementById("shopId").style.display='none';
    } 

   // CONDITIONS TO CHECK PSC NUMBER IN AVENU PAGES	
   function check_avenu(){
		var PSCNumber = document.forms[0].PSCNumber.value;
		var confirmPSCNumber = document.forms[0].confirmPSCNumber.value;
		
		if(document.forms[0].PSCNumber.value == ''){
			alert("Please enter your Preferred Card Number");
			document.forms[0].PSCNumber.focus();
		}else if(document.forms[0].confirmPSCNumber.value == ''){
			alert("Please re-enter your Preferred Card Number");
			document.forms[0].confirmPSCNumber.focus();
		}else if(document.forms[0].PSCNumber.value.length < '10'){    
			alert("Card number must be minimum of 10 to 12 digits");
		    document.forms[0].PSCNumber.focus();
		}else if(document.forms[0].confirmPSCNumber.value.length < '10'){
		  	alert("Card number must be minimum of 10 to 12 digits");
		    document.forms[0].confirmPSCNumber.focus();
		}else if(document.forms[0].PSCNumber.value.substring(0,1) != '4'){
			alert("Card number should start with digit 4");
		    document.forms[0].PSCNumber.focus();
		}else if(document.forms[0].confirmPSCNumber.value.substring(0,1) != '4'){
			alert("Card number should start with digit 4");
		    document.forms[0].confirmPSCNumber.focus();
		}else if(PSCNumber!=confirmPSCNumber){ 
		    alert("Card numbers entered did not match!");
		    document.forms[0].confirmPSCNumber.focus();
		    return false;
		}else{
		    var URL = document.forms[0].action;
		    var actionURL = URL + "groceries/LoginPage?lcCard="+PSCNumber+"&division=60&email=n";
		    document.forms[0].action=actionURL;
		    document.forms[0].submit();
		    return true;
		}
	}
    
    function completeOrder(){                
         if(document.getElementById("submitHidden").value != "true"){
	         document.forms[0].submit(); 
	         document.getElementById("submitHidden").value="true";
	         document.getElementById("messagezone1").style.visibility="visible";
	         document.getElementById("messagezone2").style.visibility="visible";
             document.getElementById("messagezone3").style.visibility="visible";             
	     }else{
	     	alert("Your order is being processed. To avoid duplicate orders, please only hit the submit button once.");
	     }
    }
    
     
  function popUpForCareer(url)
  {
    var newwindow='';
  if (!newwindow.closed && newwindow.location)
  {
  newwindow.location.href = url;
  }
  else
  {
  var w = 404
  var h= 309
  if (document.all) {
  w = document.body.clientWidth;
  h = document.body.clientHeight;
   }
  else if (document.layers) {
  w = window.innerWidth;
  h = window.innerHeight;
  }
  var popW = 300, popH = 200;
  var leftPos = (w-popW)/2,topPos = (h-popH)/5;
  var text = url;
  var popUpURL = "/eCommerceWeb/html/corporate/community/popUp.html?"+text;
  newwindow=window.open(popUpURL,"cm_ow","height=315,width=400,top="+topPos+",left="+leftPos);
  }
  if (!newwindow.opener) newwindow.opener = self;
  
   if (window.focus) {
  newwindow.focus()
  }
  return false;
  } 
function OpenWindowStrLoc(t1,t2,t3,t4,t5,t6,t7)
{
 var host = document.location.hostname;
 var protocol = document.location.protocol;
 var port = document.location.port;
 var context  = protocol + "//" + host ;
 if(port != ""){
    context += ":" + port;
 }
 var url = context+t1;
OpenWindow(url,t2,t3,t4,t5,t6,t7);

}

//Keane           Date: 04/24/ 2008(mm/dd/yyyy)                   Name: KalyanKiran Kaza(dpsdkxk)
// The following change has been incorporated with regards to RFC# 24666				
// The change is for Tutorial window size		
//________________________________________________________________-->
function popupTutorial(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=579,height=443,scrollbars=no, menubar=no, fullscreen=no');
return false;
}

function getPurchaseOrder()
{
 document.getElementById('selectPurchaseOrderFlag').value = "true";
 document.getElementById('viewAll').checked = false;
 document.forms[0].submit();
}

//End of Add

function addMultipleItems(addToOption){	
	var list ="list";
	var allUnchecked = "true"; 
    var qtyEntered = "true";   
    var qty = eval(document.GroupProductsForm.qty);  
    var submitted = "false";
          
    if (isFinite(document.GroupProductsForm.qty.length)){     		
        qty = eval(document.GroupProductsForm.qty);              
        for (var j=0;j<qty.length;j++){
			if (document.GroupProductsForm.qty[j].value !=''){				
            	allUnchecked= "false";                             
            }
        } 
		if(allUnchecked == "false"){
			for (var i=0;i<qty.length;i++){		
				if (document.GroupProductsForm.qty[i].value !=''){					
					eval("document.GroupProductsForm.addOption[" + i + "].value = 'add'");
					qty[i].value = trim(qty[i].value);
					if( qty[i].value == ''){
						if (addToOption == 'addToCart'){                            
                            alert("Please enter an item quantity.");
                        }
						qty[i].focus();
						qty[i].value=1;
						qtyEntered = "false";     
					}
				}else{
                    eval("document.GroupProductsForm.addOption[" + i + "].value = 'nill'");                    
                }   
			}
			if(qtyEntered == "true"){ 
				eval("document.GroupProductsForm.action='/eCommerceWeb/ShoppingCartMultipleAction.do?action=addMultipleItemsToCart&addToCart=true&target="+addToOption+"'");				
				if(document.getElementById("submitHidden").value != "true"){
					document.GroupProductsForm.submit();
    	            submitted = "true";    	    	                    
    	        }else{
					alert("Items are being added to your cart. Thank you for your patience.");
    	        }    	   
			}    
        }else{
			if (addToOption == 'addToCart'){				
				alert("Please choose the item before adding to Cart.");
			}
        }    
	}
	if(addToOption == "addToCart" && submitted == "true"){
    	document.getElementById("submitHidden").value="false";      
    }    
}