/*
 * All java script logic for the Demandware reference application.
 *
 * The code relies on the prototype.js and scriptaculous.js libraries to
 * be also loaded.
 */


/*
 * Register more initializations here
 */

/*

window.onload = function()
{
shoh('1.00');
}
 */
 
document.observe('load',function(){
	/* preload css based images */
	$$('.primaryNavigation a, .utilityNavigation a').each(function(el){
		var bgImg=el.getStyle('backgroundImage'); 
		var over = new Image(); 
		over.src=bgImg.substring(4,bgImg.length-5)+"_ov.gif"; 
	});
	/* fix IE6 disabled options */
	enableIE6DisabledItems();
});
 
function enableIE6DisabledItems( root ) {
	var node = root || $$('body')[0];
	
	node.getElementsBySelector('select').each(function(el){
		hidedisabledoptions( el );
	});
} 
 
function dwSubmitForm(form, buttonName)
{
       var el = document.createElement("INPUT");
       el.type="hidden";
       el.name=buttonName;
       el.value="x"; // whatever
       form.appendChild(el);
       form.submit();
       return false;
}

/*
	Opens a new window with the provided url and dimension. Used
	for Scene7 and other situations.

	@param url the url to open
	@param width the window width
	@param height the window height
*/
function openPopup( url, width, height )
{
	if (url != null)
	{
		if (width != null && height != null)
		{
			window.open(url, "", "width=" + width +", height=" + height +", scrollbars=no, resizable=yes");
		}
		else
		{
			window.open(url, "", "scrollbars=no, resizable=yes");
		}
	}
}

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/ 

var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div background="white" border="1" id="trailimageid" style="padding:2px; z-index: 10; text-align:bottom; position:absolute;visibility:hidden;left:0px;width:1px;height:1px;border:1px solid #888888;background:white;"><img style="padding-bottom:4px;" id="ttimg" src="' + spacegif + '" /><br/><div VALIGN=BOTTOM style="align:bottom;padding-bottom:2px;" id="poptitle"></div></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	document.getElementById('ttimg').src='/images/space.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-2000
	gettrailobj().top=-400
}


function showtrail(width,height,file,description)
{
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		w=width
		h=height
		
		followmouse()
	
		document.getElementById('ttimg').src=file
		document.getElementById('poptitle').innerHTML=description;
		document.onmousemove=followmouse
		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().height=h+"px"
		
		


	}
}


function followmouse(e)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{

		var xcoord=20
		var ycoord=-30

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+3>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h>truebody().clientHeight)
		ycoord=ycoord-h-20;

		gettrailobj().left=xcoord-40+"px"
		gettrailobj().top=ycoord-100+"px"

	}

}

/*
 * Support for the compare window
 */
ProductCompare = {
	openPopup: function( url ) {
		window.open(
			url,
			'product_compare',
			'width=800,height=600,scrollbars=yes,resizable=yes',
			true /* replace history in the popped up window */
		).focus();
	}
}


/*
 * Functionality around the mini cart.
 */
var MiniCart = {
	// flag, whether cart is open or not
	state: 0,

	// during page loading, the Demandware URL is stored here
	url: '',

	// timer for automatic close of cart item view
	timer: null,

	cartAdd: function( form, progressImageSrc, form2, form3, form4, form5,form6, form7, form8,form9,form10,form11,form12, buttonid )
	{
		// get the data of the form as serialized string
		var postdata = Form.serialize(form);
		
		var temp = 'Out of Stoc'
		//var tempData = document.body.innerHTML.substring(document.body.innerHTML.indexOf(temp)+12);
		//var tempData2 = tempData.substring(tempData.indexOf(temp));
//alert(document.body.innerHTML.substring(document.body.innerHTML.indexOf(temp)));
		if(document.body.innerHTML.indexOf(temp)>=0)
		{
			Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Out  Of  Stock Items can not be added to the shopping bag.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
		}
		
		tempData = postdata.substring(postdata.indexOf('pid=')+4);
		if (tempData.indexOf('&')>=0)
			tempData = tempData.substring(0, tempData.indexOf('&'));
		
		if (tempData.indexOf('_') <0)
		{
	        Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Please select appropriate options before adding this product to the shopping bag.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
        }
                  
		
		
		
		if (form2!=null)
		{
			var postdata2 = Form.serialize(form2);	
			postdata2 = postdata2.replace("pid=", "pid2=");
			postdata2 = postdata2.replace("Quantity=", "Quantity2=");
			postdata= postdata2 + "&"+postdata;
		}
		
		if (form3!=null)
		{
			var postdata3 = Form.serialize(form3);			
			postdata3 = postdata3.replace("pid=", "pid3=");
			postdata3 = postdata3.replace("Quantity=", "Quantity3=");
			postdata=postdata+"&" + postdata3;
		}
		
		if (form4!=null)
		{
			var postdata4 = Form.serialize(form4);	
			postdata4 = postdata4.replace("pid=", "pid4=");
			postdata4 = postdata4.replace("Quantity=", "Quantity4=");
			postdata=postdata+"&" + postdata4;
		}
		
		if (form5!=null)
		{
			var postdata5 = Form.serialize(form5);	
			postdata5 = postdata5.replace("pid=", "pid5=");
			postdata5 = postdata5.replace("Quantity=", "Quantity5=");
			postdata=postdata+"&" + postdata5;
		}
		
		if (form6!=null)
		{
			var postdata6 = Form.serialize(form6);	
			postdata6 = postdata6.replace("pid=", "pid6=");
			postdata6 = postdata6.replace("Quantity=", "Quantity6=");
			postdata=postdata+"&" + postdata6;
		}
		
		if (form7!=null)
		{
			var postdata7 = Form.serialize(form7);	
			postdata7 = postdata7.replace("pid=", "pid7=");
			postdata7 = postdata7.replace("Quantity=", "Quantity7=");
			postdata=postdata+"&" + postdata7;
		}
		if (form8!=null)
		{
			var postdata8 = Form.serialize(form8);	
			postdata8 = postdata8.replace("pid=", "pid8=");
			postdata8 = postdata8.replace("Quantity=", "Quantity8=");
			postdata=postdata+"&" + postdata8;
		}
		if (form9!=null)
		{
			var postdata9 = Form.serialize(form9);	
			postdata9 = postdata9.replace("pid=", "pid9=");
			postdata9 = postdata9.replace("Quantity=", "Quantity9=");
			postdata=postdata+"&" + postdata9;
		}
		if (form10!=null)
		{
			var postdata10 = Form.serialize(form10);	
			postdata10 = postdata10.replace("pid=", "pid10=");
			postdata10 = postdata10.replace("Quantity=", "Quantity10=");
			postdata=postdata+"&" + postdata10;
		}
		if (form11!=null)
		{
			var postdata11 = Form.serialize(form11);	
			postdata11 = postdata11.replace("pid=", "pid11=");
			postdata11 = postdata11.replace("Quantity=", "Quantity11=");
			postdata=postdata+"&" + postdata11;
		}
		if (form12!=null)
		{
			var postdata12 = Form.serialize(form12);	
			postdata12 = postdata12.replace("pid=", "pid12=");
			postdata12 = postdata12.replace("Quantity=", "Quantity12=");
			postdata=postdata+"&" + postdata12;
		}
		//if ${buttonid} != null
		
		
		
		// get button reference
		var addButtons = Form.getInputs(form, 'image', 'add');
	
		// the button to update
		var addButton = null;
		
		// disable form
		Form.disable(form);
		

		// it is an array of buttons, but we need only one all
		// other combinations are strange so far
		if (addButtons.length == 1)
		{
			addButton = addButtons[0];	
		}
	
		var previousImageSrc = null;
	
		// show progress indicator
		if (addButton != null)
		{
			previousImageSrc = addButton.src;
			addButton.src = progressImageSrc;
		}
	
		var handlerFunc = function(req)
		{
			// hide progress indicator
			if (addButton != null)
			{
				addButton.src = previousImageSrc;
			}
			Form.enable(form);
		
			// Get the position before the innerHTML is set. After
			// the set the elements have no coordinates. A display
			// refresh from the browser is necessary.
			var minicarttotal = $('minicarttotal');
			var pos = Position.cumulativeOffset(minicarttotal);
			var dim = Element.getDimensions(minicarttotal);


			
			
			// replace the content
			var minicart = $('minicart');
			minicart.innerHTML = req.responseText;

			if( MiniCart.suppressSlideDown && MiniCart.suppressSlideDown() )
			{
				// do nothing
				// the hook 'MiniCart.suppressSlideDown()' should have done the refresh
			}
			else
			{
				// show the item
				// this display is optimized for Firefox. IE6/7 display the 
				// sliding down cart with an offset of -1
				
				var minicartcontent = $('minicartcontent');
	
				minicartcontent.style.left = pos[0] + 0 + 'px';
				if (navigator.appVersion.indexOf("MSIE")!=-1)
				{
					minicartcontent.style.top = pos[1] + dim.height   +1 + 'px';
				}
				else
				{
					minicartcontent.style.top = pos[1] + dim.height  +1 + 'px';
				}
				
				minicartcontent.style.width = dim.width - 2 + 'px';
	
				new Effect.SlideDown('minicartcontent');
	
				// after a time out automatically close it
				MiniCart.timer = setTimeout( 'MiniCart.cartClose()', 6000 );
			}
		}

		var errFunc = function(req)
		{
			// hide progress indicator
			if (addButton != null)
			{
				addButton.src = previousImageSrc;
			}
			Form.enable(form);
		}

		// close a product QuickView
		// if ( QuickView ) QuickView.closeQuickView();

		// cloes a previous mini cart
		MiniCart.cartClose();

		// add the product
		new Ajax.Request( MiniCart.url, {method:'post', postBody:postdata, onSuccess:handlerFunc, onFailure:errFunc});
	},

	cartClose: function()
	{
		if ( MiniCart.timer != null )
		{
			clearTimeout( MiniCart.timer );
			MiniCart.timer = null;
			Effect.SlideUp('minicartcontent');
		}
	},
	
	showCartNoClose: function()
	{
		if(!Element.visible('minicartcontent'))
		{
				var minicartcontent = $('minicartcontent');
				var minicarttotal = $('minicarttotal');
				var pos = Position.cumulativeOffset(minicarttotal);
				var dim = Element.getDimensions(minicarttotal);
	
				minicartcontent.style.left = pos[0] + 0 + 'px';
				
				
				if (navigator.appVersion.indexOf("MSIE")!=-1)
				{
					minicartcontent.style.top = pos[1] + dim.height   +1 + 'px';
				}
				else
				{
					minicartcontent.style.top = pos[1] + dim.height  +1 + 'px';
				}
				
				minicartcontent.style.width = dim.width +12 + 'px';
	
				new Effect.SlideDown('minicartcontent');
	
				// after a time out automatically close it
				//MiniCart.timer = setTimeout( 'MiniCart.cartClose()', 4000 );
		}
	},
	
	showCartWithDelay: function()
	{
	    if(MiniCart.timer)
	    {
		  window.clearTimeout(MiniCart.timer);
		  MiniCart.timer=null;
	    }

	  	if(!Element.visible('minicartcontent'))
	  	{
	    	MiniCart.timer=window.setTimeout('MiniCart.showCartNoClose()',300); //0.3 seconds
	    }
	},
	
	closeCartWithDelay: function()	
	{
	    if(MiniCart.timer)
		{
		  window.clearTimeout(MiniCart.timer);
		  MiniCart.timer=null;
		}
	  	if(Element.visible('minicartcontent'))
		{
			MiniCart.timer = setTimeout( 'MiniCart.cartClose()', 4000 );
		}
  	},

	// hook which can be replaced by individual pages/page types (e.g. cart)
	suppressSlideDown: function()
	{
		return false;
	}
}


var WishList = {
	// flag, whether cart is open or not
	state: 0,

	// during page loading, the Demandware URL is stored here
	url: '',

	// timer for automatic close of cart item view
	timer: null,

	makeGetParameter : function( form, index )
	{
		return "pid" + index + "=" + form.pid.value + "&Qt" + index + "=" + form.Quantity.value;
	},
	
	wishlistAdd: function( form, progressImageSrc, form2, form3, form4, form5,form6, form7, form8,form9,form10,form11,form12, buttonid )
	{
		var postdata  = this.makeGetParameter( form, 1 );
		if (postdata.indexOf('_') < 0 )
		{
	        Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Please select appropriate options before adding this product to Wish List.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
        }
        
		var arr = new Array( form2, form3, form4, form5, form6, form7, form8, form9,form10, form11, form12 );
		var tempData;
		for ( i = 0; i < arr.length; i++ )
		{
			if ( arr[i] != null )
			{
				tempData = this.makeGetParameter( arr[i], i + 2 );
				if ( tempData.indexOf('_') > 0 )
					postdata= postdata + "&" + tempData;
			}
		}
		
		/*
alert( "QTY: " + form2.Quantity.value );
alert( "PID: " + form2.pid.value );
		
		// get the data of the form as serialized string
		var postdata = Form.serialize(form);
		postdata = postdata.replace("Quantity=", "Q_=");
		
		var tempData = postdata.substring(postdata.indexOf('pid=')+4);
		
		if (tempData.indexOf('&')>=0)
			tempData = tempData.substring(0, tempData.indexOf('&'));
		
		if (tempData.indexOf('_') <0)
		{
	        Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Please select appropriate options before adding this product to Wish List.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
        }
        
        
		if (form2!=null)
		{
			var postdata2 = Form.serialize(form2);	
			
			tempData = postdata2.substring(postdata2.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata2 = postdata2.replace("pid=", "pid2=");
			postdata2 = postdata2.replace("Quantity=", "Q_2=");
			
			if (tempData.indexOf('_') >0)
				postdata= postdata + "&" + postdata2;
		}
		
		if (form3!=null)
		{
			var postdata3 = Form.serialize(form3);	
			
			tempData = postdata3.substring(postdata3.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			
			postdata3 = postdata3.replace("pid=", "pid3=");
			postdata3 = postdata3.replace("Quantity=", "Q_3=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata3;
		}
		if (form4!=null)
		{
			var postdata4 = Form.serialize(form4);	
			
			tempData = postdata4.substring(postdata4.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			
			postdata4 = postdata4.replace("pid=", "pid4=");
			postdata4 = postdata4.replace("Quantity=", "Q_4=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata4;
		}
		
		if (form5!=null)
		{
			var postdata5 = Form.serialize(form5);	
			
			tempData = postdata5.substring(postdata5.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata5 = postdata5.replace("pid=", "pid5=");
			postdata5 = postdata5.replace("Quantity=", "Q_5=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata5;
		}
		
		if (form6!=null)
		{
			var postdata6 = Form.serialize(form6);	
			
			tempData = postdata6.substring(postdata6.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata6 = postdata6.replace("pid=", "pid6=");
			postdata6 = postdata6.replace("Quantity=", "Q_6=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata6;
		}
		
		if (form7!=null)
		{
			var postdata7 = Form.serialize(form7);	
			
			tempData = postdata7.substring(postdata7.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata7 = postdata7.replace("pid=", "pid7=");
			postdata7 = postdata7.replace("Quantity=", "Q_7=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata7;
		}
		if (form8!=null)
		{
			var postdata8 = Form.serialize(form8);	
			
			tempData = postdata8.substring(postdata8.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata8 = postdata8.replace("pid=", "pid8=");
			postdata8 = postdata8.replace("Quantity=", "Q_8=");
			if (tempData.indexOf('_') >0)
			postdata = postdata + "&" + postdata8;
		}
		if (form9!=null)
		{
			var postdata9 = Form.serialize(form9);	
			
			tempData = postdata9.substring(postdata9.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata9 = postdata9.replace("pid=", "pid9=");
			postdata9 = postdata9.replace("Quantity=", "Q_9=");
			if (tempData.indexOf('_') >0)
			postdata = postdata + "&" + postdata9;
		}
		if (form10!=null)
		{
			var postdata10 = Form.serialize(form10);	
			
			tempData = postdata10.substring(postdata10.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata10 = postdata10.replace("pid=", "pid10=");
			postdata10 = postdata10.replace("Quantity=", "Q_10=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata10;
		}
		if (form11!=null)
		{
			tempData = postdata11.substring(postdata11.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata11 = postdata11.replace("pid=", "pid11=");
			postdata11 = postdata11.replace("Quantity=", "Q_11=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata11;
		}
		if (form12!=null)
		{
			tempData = postdata12.substring(postdata12.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata12 = postdata12.replace("pid=", "pid12=");
			postdata12 = postdata12.replace("Quantity=", "Q_12=");
			if (tempData.indexOf('_') >0)
				postdata = postdata + "&" + postdata12;
		}
		
		// the button to update
		var addButton = null;
		var handlerFunc = function(req)
		{
		}
		*/
		//alert((WishList.url+"\?" + postdata).length);
		// add the product
		if (postdata.length> 3500)
			postdata = postdata.substr(3500);
			
// alert( "Length : " + postdata.length + "\nGot postData: " + postdata );
		document.location= WishList.url+"\?" + postdata;
		//new Ajax.Request( WishList.url, {method:'post', postBody:postdata, onSuccess:handlerFunc, onFailure:handlerFunc});
	}
}

var Registry = {
	// flag, whether cart is open or not
	state: 0,

	// during page loading, the Demandware URL is stored here
	url: '',

	// timer for automatic close of cart item view
	timer: null,

	makeGetParameter : function( form, index )
	{
		return "pid" + index + "=" + form.pid.value + "&Qt" + index + "=" + form.Quantity.value;
	},
	
	registryAdd: function( form, progressImageSrc, form2, form3, form4, form5,form6, form7, form8,form9,form10,form11,form12, buttonid )
	{
		var postdata  = this.makeGetParameter( form, 1 );
		if (postdata.indexOf('_') < 0 )
		{
	        Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Please select appropriate options before adding this product to Gift Registry.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
        }
        
		var arr = new Array( form2, form3, form4, form5, form6, form7, form8, form9,form10, form11, form12 );
		var tempData;
		for ( i = 0; i < arr.length; i++ )
		{
			if ( arr[i] != null )
			{
				tempData = this.makeGetParameter( arr[i], i + 2 );
				if ( tempData.indexOf('_') > 0 )
					postdata= postdata + "&" + tempData;
			}
		}
		
/*
		// get the data of the form as serialized string
		var postdata = Form.serialize(form);
		postdata = postdata.replace("Quantity=", "Q_=");
		
		var tempData = postdata.substring(postdata.indexOf('pid=')+4);
		
		if (tempData.indexOf('&')>=0)
			tempData = tempData.substring(0, tempData.indexOf('&'));
		
		if (tempData.indexOf('_') <0)
		{
	        Dialog.alert('<table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"middle\" colspan=\"2\">Please select appropriate options before adding this product to Gift Registry.</td></tr></table>', {windowParameters: {className: 'alphacube', height: 90, width: 250}, okLabel: 'Close'});
	        return false;
        }
        
        
		if (form2!=null)
		{
			var postdata2 = Form.serialize(form2);	
			
			tempData = postdata2.substring(postdata2.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata2 = postdata2.replace("pid=", "pid2=");
			postdata2 = postdata2.replace("Quantity=", "Q_2=");
			
			if (tempData.indexOf('_') >0)
				postdata= postdata + "&"+postdata2;
		}
		
		if (form3!=null)
		{
			var postdata3 = Form.serialize(form3);	
			
			tempData = postdata3.substring(postdata3.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			
			postdata3 = postdata3.replace("pid=", "pid3=");
			postdata3 = postdata3.replace("Quantity=", "Q_3=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata3;
		}
		if (form4!=null)
		{
			var postdata4 = Form.serialize(form4);	
			
			tempData = postdata4.substring(postdata4.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			
			postdata4 = postdata4.replace("pid=", "pid4=");
			postdata4 = postdata4.replace("Quantity=", "Q_4=");
			if (tempData.indexOf('_') >0)
			postdata=postdata+"&" + postdata4;
		}
		
		if (form5!=null)
		{
			var postdata5 = Form.serialize(form5);	
			
			tempData = postdata5.substring(postdata5.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata5 = postdata5.replace("pid=", "pid5=");
			postdata5 = postdata5.replace("Quantity=", "Q_5=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata5;
		}
		
		if (form6!=null)
		{
			var postdata6 = Form.serialize(form6);	
			
			tempData = postdata6.substring(postdata6.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata6 = postdata6.replace("pid=", "pid6=");
			postdata6 = postdata6.replace("Quantity=", "Q_6=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata6;
		}
		
		if (form7!=null)
		{
			var postdata7 = Form.serialize(form7);	
			
			tempData = postdata7.substring(postdata7.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata7 = postdata7.replace("pid=", "pid7=");
			postdata7 = postdata7.replace("Quantity=", "Q_7=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata7;
		}
		if (form8!=null)
		{
			var postdata8 = Form.serialize(form8);	
			
			tempData = postdata8.substring(postdata8.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata8 = postdata8.replace("pid=", "pid8=");
			postdata8 = postdata8.replace("Quantity=", "Q_8=");
			if (tempData.indexOf('_') >0)
			postdata=postdata+"&" + postdata8;
		}
		if (form9!=null)
		{
			var postdata9 = Form.serialize(form9);	
			
			tempData = postdata9.substring(postdata9.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata9 = postdata9.replace("pid=", "pid9=");
			postdata9 = postdata9.replace("Quantity=", "Q_9=");
			if (tempData.indexOf('_') >0)
			postdata=postdata+"&" + postdata9;
		}
		if (form10!=null)
		{
			var postdata10 = Form.serialize(form10);	
			
			tempData = postdata10.substring(postdata10.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata10 = postdata10.replace("pid=", "pid10=");
			postdata10 = postdata10.replace("Quantity=", "Q_10=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata10;
		}
		if (form11!=null)
		{
			tempData = postdata11.substring(postdata11.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata11 = postdata11.replace("pid=", "pid11=");
			postdata11 = postdata11.replace("Quantity=", "Q_11=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata11;
		}
		if (form12!=null)
		{
			tempData = postdata12.substring(postdata12.indexOf('pid=')+4);
			if (tempData.indexOf('&')>=0)
				tempData = tempData.substring(0, tempData.indexOf('&'));
			postdata12 = postdata12.replace("pid=", "pid12=");
			postdata12 = postdata12.replace("Quantity=", "Q_12=");
			if (tempData.indexOf('_') >0)
				postdata=postdata+"&" + postdata12;
		}
		
		
		// the button to update
		var addButton = null;
		var handlerFunc = function(req)
		{
		}
		if (postdata.length> 3500)
			postdata = postdata.substr(3500);
			
*/
		document.location= Registry.url.replace('http:', 'https:')+"\?" + postdata;
		// add the product
		//new Ajax.Request( WishList.url, {method:'post', postBody:postdata, onSuccess:handlerFunc, onFailure:handlerFunc});
	}
}

imgout=new Image(9,9);
imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="/on/demandware.static/Sites-FoH-Site/-/default/v1219265240671/images/u.gif";
	imgin.src ="/on/demandware.static/Sites-FoH-Site/-/default/v1219265240671/images/d.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}



function buttonLink(form, buttonName, values)
{
       var el = document.createElement("INPUT");
       el.type="hidden";
       el.name=buttonName;
       el.value="x"; // whatever
       form.appendChild(el);

       if ( values != null )
       {
           if ( values instanceof Array && values.length > 0 )
           {
               if ( values[0] instanceof Array && values[0].length > 0 )
               {
                   // Array of Array with key/value pairs
                   for ( var i = 0; i < values.length; i++ )
                   {
                       el = document.createElement("INPUT");
                       el.type = "hidden";
                       el.name = values[i][0];
                       el.value = values[i][1];
                       form.appendChild(el);
                   }
               }
               else
               {
                   // just one array with key/value
                   el = document.createElement("INPUT");
                   el.type = "hidden";
                   el.name = values[0];
                   el.value = values[1];
                   form.appendChild(el);
               }
           }
       }

       form.submit();
       return false;
}


function editAddressPopup(popupURL, h, w)
{
	var height1 = (h==null?"220":h);
	var width1 = (w==null?"535":w);
      Dialog.alertNoButtons({url: popupURL}, {windowParameters: {className: 'alphacube', height: height1, width: width1}}); 

      return false;

}

function checkdisabled(el) {
  if (el.options[el.selectedIndex].disabled) {
     el.options.selectedIndex = 0;
     return false;
  }
  return true;
}
function hidedisabledoptions(el) {
  if (document.all && !window.opera) {
     for (var i = 0; i < el.options.length; i++) {
        if (el.options[i].disabled)
           el.options[i].style.backgroundColor = 'lightgrey';
     }
  }
}

var Tmp = {};
