// boscovs.js
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	
	function openAboutCoupons()
	{
		window.open('AboutCoupons.bos','newwindow','menubar=no,width=400, height=600, resizable=yes,scrollbars=no');
	}
	
	function checkCountry()
    {
	   	var country = document.getElementById("country");
		delivery = (country.value == 'USA'); 
    	if(!delivery)	
    		alert("We currently do not ship to locations outside the continental United States, including Alaska and Hawaii.");
    } 
    
    function checkBillingState()
	{
    		var state   = document.getElementById('billingAddress.state');
   			delivery = !(state.value == 'AK' || state.value == 'HI');
    		if(delivery == false)
    		{
    			alert("We currently do not ship to locations outside the continental United States, including Alaska and Hawaii.");
     		}
	} 
    
  	function checkState()
	{
    		var state   = document.getElementById('state');
   			delivery = !(state.value == 'AK' || state.value == 'HI');
    		if(delivery == false)
    		{
    			alert("We currently do not ship to locations outside the continental United States, including Alaska and Hawaii.");
     		}
	} 
	
	function openRebate(rebateId)
	{
		window.open('Rebate.bos?rebateId='+rebateId,'newwindow','menubar=no,height=400,width=300,resizable=yes,scrollbars=no');
	}
	
	function openGiftWrap()
	{
		window.open('GiftWrapping.bos','newwindow','menubar=no,height=500,width=500,resizable=yes,scrollbars=yes');
	}
	
	function openSecurePaymentAuth()
	{
		window.open('SecurePaymentAuthorization.bos','pauth','menubar=no,height=400,width=390,resizable=no,scrollbars=no');
	}
	
	function openDelivery()
	{
		window.open('ShippingAssistant.bos','newwindow','menubar=no,height=500,width=500,resizable=yes,scrollbars=yes');
	}
	
	function openReturn()
	{
		window.open('ReturnPolicy.bos','newwindow','menubar=no,height=500,width=500,resizable=yes,scrollbars=yes');
	}
	
	function openGuarantee()
	{
		window.open('Guarantee.bos','newwindow','menubar=no,height=500,width=500,resizable=yes,scrollbars=yes');
	}
	
	function openCustomerService()
	{
		javascript:window.open('FAQ.bos','newwindow','menubar=no,height=800,width=800,resizable=yes,scrollbars=yes');
	}
	
	function openShoppingAssistant(){
		window.open('ShoppingAssistant.bos','newwindow','menubar=no,height=500,width=500,resizable=yes,scrollbars=yes');
	}
	
	function openCVV2(){
		window.open('CVV2.bos','newwindow','menubar=no,width=350,height=390,resizable=yes,scrollbars=no');
	}
	
	function openWhatsAPin()
	{
		window.open('WhatsAPin.bos','newwindow','menubar=no,height=400,width=400,resizable=yes,scrollbars=no');
	}
		
	function openAlternate(imageName)
	{
		window.open('AltImage.bos?altImageName='+imageName,'newwindow','menubar=no,height=460,width=420,resizable=yes,scrollbars=no');
	}
	
	function changeProductButtonValue(bv)
	{
		document.addForm.productSubmitButton.value=bv;
		return true;
	}
	
	function changeButtonAndPostAddToCartForm(bv)
	{
	
		changeProductButtonValue(bv);
		return postAddToCartForm();
	}
	
	function postAddToCartForm()
	{
		document.addForm.submit();
	}
	
	function popup(url) 
	{
    	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	    self.name = "mainWin";
    }
    
    function popupCreditApplication(url) 
	{
    	creditWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=800,height=575');
	    self.name = "mainWin";
    }
    
    function applyHSBC()
	{
		document.Form1.submit();
	}
    
    function replyHSBC()
	{
		document.reply.submit();
	}
    
    function autoTab(input,len, e) 
	{
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		if(input.value.length >= len && !containsElement(filter,keyCode)) 
		{
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
	
		function containsElement(arr, ele) 
		{
			var found = false, index = 0;
			while(!found && index < arr.length)
			if(arr[index] == ele)
			{
				found = true;
			}
			else
			{
				index++;
			}
			return found;
		}
		
		function getIndex(input) 
		{
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
			if (input.form[i] == input)
			{
				index = i;
			}
			else 
			{
				i++;
			}
			return index;
		}
		return true;
	}
	
	function handleCardTypeChange()
	{
		var sel = document.getElementById("cctype");
		
		if(sel.options[sel.selectedIndex].value == "Boscov's")
		{
			document.getElementById("cvv2").disabled = true;
			document.getElementById("expmonth").disabled = true;
			document.getElementById("expyear").disabled = true;
		}
		else
		{
			document.getElementById("cvv2").disabled = false;
			document.getElementById("expmonth").disabled = false;
			document.getElementById("expyear").disabled = false;
		}		
	}
	
	function submitMarcoleRegistry()
	{
		document.forms['marcolenavform'].submit();
	}	
	
	function changeFormActionAndSubmit(formName, formAction)
	{
		var formObj = document.getElementById(formName);
		formObj.action = formAction;
		formObj.submit();
	}
	
	function popUp(url) 
	{
		popupWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,width=570,height=450');
		self.name = "mainWin"; 
	}
	
	function writeExternalLinkageForm(serverUrl,sessionid, styleid, regid)
	{
       gol = new GenericOnlineLinker();
       gol.setServerURL(serverUrl);
       gol.setNavKey( 'guest.registryDetail' );
       gol.setTransaction( 'RegistryDetail' );
       gol.setLastTransaction( 'InitializeRetailer' );
       gol.setViewId( 'jsp' );
       gol.setSessionId(sessionid);
       gol.setStyleId( styleid );
       gol.setRegistryId( regid );
       gol.setRetailerId( '0' );
       gol.setApplId( 'gol' );
       gol.setStoreId( '80001' );
	   
       gol.writeForm();
	}
	
	function backToRegistry()
	{
		document.navform.submit();
	}
	