  
   
 
    function setObjVis(objectID,vis) {
    var objs = xDOM(objectID,1); 
    objs.visibility = vis;} 

    // you may copy this code but please keep the copyright notice as well
    var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
    if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
    var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
    && (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
    function xDOM(objectId, wS) {
    if (stdDOM) return wS ? document.getElementById(objectId).style:
    document.getElementById(objectId);
    if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
    if (nsDOM) return document.layers[objectId];
    }                   

	function resizebody() {
		// FIX FOR IE RESIZE ISSUE - BODY NEEDS TO HAVE "STATIC" POSITION FOR THE ZOOM FUNCTION TO WORK
		// BUT THAT THEN CAUSES IMAGES TO JUMP AROUND WHEN THE PAGE IS RESIZED IN IE - Nick
		document.body.style.position = "relative";
		document.body.style.position = "static";
	}

	/* ==========================================================================
	Function Name: product()
	Description:   Create a product using the constructor function
	Coded By:      Matt Hall
	Date:          2001-09-03
	========================================================================== */
	function product (
		                id,
		                size,
		                colour,
		                availability,
		                backOrder,
		                price,
		                salePrice,
		                promoPrice,
		                altPrice,
		                altSalePrice,
		                altPromoPrice,
		                stocklevel,
		                stocklevelconstrained,
		                expectedstock,
		                priceDisplayFlag,
		                labelColour,
		                localsizecomment,
		                productTitle,
		                productMiniImage,
		                productColourID,
		                productCode
		                
	                )
	{
		// Initialise the properties for the object
		this.id                    = id;
		this.size                  = size;
		this.colour                = colour;
		this.availability          = availability;
		this.backOrder             = backOrder;
		this.price                 = price;
		this.salePrice             = salePrice;
		this.altPrice              = altPrice;
		this.altSalePrice          = altSalePrice;
		this.stocklevel            = stocklevel;
		this.stocklevelconstrained = stocklevelconstrained;
		this.expectedstock         = expectedstock;

		// Additional properties to make promo prices work
		this.promoPrice            = promoPrice;
		this.altPromoPrice         = altPromoPrice;
		this.priceDisplayFlag      = priceDisplayFlag;
		
		// for colour products section
		this.labelColour		   = labelColour;
		this.productTitle          = productTitle;
		this.productMiniImage      = productMiniImage;
		this.productColourID       = productColourID;
		this.productCode           = productCode;
		this.localsizecomment      = localsizecomment;
		
	}


	/* ==========================================================================
	Function Name: getObj()
	Description:   Cross browser DOM referencing.
	Coded By:      Richard Weeks
	Date:          2006-05-01
	========================================================================== */
	function getObj(sName) {
		if (document.getElementById) {
			this.obj   = document.getElementById(sName);
			this.style = document.getElementById(sName).style;
		} else if (document.all) {
			this.obj   = document.all[sName];
			this.style = document.all[sName].style;
		} else if (document.layers) {
			this.obj   = document.layers[sName];
			this.style = document.layers[sName];
		}
	}

	/* ==========================================================================
	Function Name: changeStyleById()
	Description:   Change DOM property cross browser.
				Retires previous 'zpu...' functions.
	Coded By:      Richard Weeks
	Date:          2006-05-09
	========================================================================== */
	function changeStyleById(sID, sColour) {
		var nodeObj = new getObj(sID)
		nodeObj.style.color = sColour;
	}

	/* FUNCTION ===================================================================
	Name:        getVariantNo()
	Description: Function to return the index of the variant that matches the size
				and colour passed in.
	Coded By:    Matt Hall
	Date:        2001-12-13
	============================================================================ */
	function getVariantNo(iPV, Size, Colour) {
		var j       = new Number();
		var strtemp = new String();

		for (j = 0; j < productVariants[iPV].length; j++) {
			if (Size == productVariants[iPV][j].size && Colour == productVariants[iPV][j].colour) {
				return j;
			}
		}
		return -1;
	}

    //##DEBUG## - TODO 1. Fix below.
	function getColourVariantNo(iPV, Size, Colour) {
		var j       = new Number();
		var i       = new Number();
		var strtemp = new String();

		for(i = 0; i < colourVariants.length; i++) {
				for (j = 0; j < colourVariants[i].length; j++) {
					if ((Size == colourVariants[i][j].size) && (Colour == colourVariants[i][j].colour)) {
						j=colourVariants[i][j].id;
						return j;
					}
				}
		}
		return -1;
	}

	/* FUNCTION ==================================================================
	Name:        getFirstVarianNoForColour()
	Description: CR #6162 - Function to return the index of the variant that
				matches the colour passed in.
	Date:        2004-05-25
	=========================================================================== */
	function getFirstVariantNoForColour(Colour) {
		var j;
		for(j = 0; j < CONST_VARIANTS; j++) {
			if(Colour == productVariants[j].colour) {
				return j;
			}
		}
		return -1;
	}

	// == Build Suggest Panel ==
	function buildSuggestPanel() {
		buildColours();
		buildSizes();
		buildQuantities();
	}

	function buildColours() {
		// Function that builds the list of colours available for suggested products
		var oColours;
		var iColour;
		var bFound = false;

		for (v=1; v<=CONST_SUGGESTIONS; v++) {
			oColours = eval('document.getElementById("selColour' + v + '")');
			
			iColour = 0;
			
			if (oColours != null) {
				emptyOptions(oColours);
				
				//check each SKU
				for (i=0; i<productVariants[v].length; i++) {
					//check for duplicates in new list
					bFound = false;
					for (j=0; j < oColours.length; j++) {
						if (oColours[j].text == productVariants[v][i].colour) {
							bFound = true;
							
							;
						}
					}
					if (!bFound) {	
						insertOption(oColours, productVariants[v][i].colour, iColour);
						iColour++;
					}
				}
			}
		}
	}
	
	function buildSizes() {
		// Function that builds the list of sizes available
		
		for (var v=0; v<=CONST_SUGGESTIONS; v++) {
			buildSizesByProduct(v);
			
		}
	}

	function buildSizesByProduct(iPV) {
		var sColour;
		var bInList = false;
		var iSize = 0;
		var oSize;
		var stock_message = '';
		var due_in_date_array = [];

        //If iPV=0, i.e. if you are on the main product then run through the radio buttons and see what colour is selected; else select the colour and size as per the original method
        if (iPV==0) 
        {
            if (document.frmProduct.selColour0.length > 1)//the main product has more than one colour
             {
                for (var i = 0; i < document.frmProduct.selColour0.length; i++) {
               
                        if (document.frmProduct.selColour0[i].checked) {
                        
                        //Get main Selected colour
                        sColour	= eval('document.frmProduct.selColour0[i].value;');
                        break
                        }
                    }
            } 
            else 
            {
                sColour	= eval('document.frmProduct.selColour0.value;');
		    } 
		}
		else 
		{
		    sColour = eval('getSelectText("selColour' + iPV + '")'); 
        }     
			
	    oSize = eval('document.getElementById("selSize' + iPV + '")');
				
		iSize = 0;

		if (oSize != null) {
			emptyOptions(oSize);

			insertOption(oSize, 'Select size', 'Select size'); //##DEBUG##
			
			for (var i=0; i<productVariants[iPV].length; i++) {
				//check for duplicates
				bInList = false;
				for (var j=0; j < oSize.length; j++) {
					if (oSize[j].text==productVariants[iPV][i].size) {
						bInList = true;
						break;
					}
				}

				//alert('bInList='+bInList)
				//alert('productVariants[iPV][i].colour ='+productVariants[iPV][i].colour)
	            //alert('sColour='+sColour)
				if (!bInList && productVariants[iPV][i].colour == sColour) {
				
				   switch(parseInt(productVariants[iPV][i].stocklevel))
					{
					    case 0:
					        stock_message = ' -- Temporarily out of stock';
					        break;
					    case 1: case 2:
					        stock_message = ' -- Hurry low stock';
					        break;
					    default:
					        break;
					}   
					  //if (iPV ==0){  alert( productVariants[iPV][i].backOrder.toLowerCase() + ' '+   productVariants[iPV][i].backOrder.toLowerCase().indexOf('expected'))}
					if(productVariants[iPV][i].backOrder.toLowerCase().Trim().indexOf('expected')>=0){
					    due_in_date_array = productVariants[iPV][i].backOrder.split(' ');
					    stock_message = ' -- Due in ' + due_in_date_array.slice(due_in_date_array.length-3).join(',').replace(/,/gi,' ')  ;
					}
					
					insertOption(oSize, productVariants[iPV][i].size + stock_message, iSize);
					iSize++;
					stock_message = '';
				}
			}
		}
		
		if (CONST_SIZE != '') {
			
			for(var i=0;i<=oSize.length-1;i=i+1) {
				var txtText=oSize.options[i].text

				if(CONST_SIZE.toUpperCase()==txtText.toUpperCase()) {
					oSize.selectedIndex=i;
					break;
				}
			}
		}
	}

	function buildQuantities() {
		// Function that builds the list of quantities
		var sSize    = new String();
		var sColour  = new String();

		for (var v=1; v<=CONST_SUGGESTIONS; v++) {
			// Get the selected size & colour
			var oSize = eval('document.getElementById("selSize' + v + '")');
			var oColour = eval('document.getElementById("selColour' + v + '")');

			if (oSize != null) {
				sColour = eval('getSelectText("selColour' + v + '")');
				sSize	= eval('getSelectText("selSize' + v + '")');

				var oQuant = eval('document.getElementById("selQuantity' + v + '")');
				var bQuantityUpdated = false;
				var iStock;

				for (var i=0; i<productVariants[v].length; i++) {
					iStock = productVariants[v][i].stocklevel;
					if((productVariants[v][i].colour.toUpperCase() == sColour.toUpperCase()) &&  productVariants[v][i].size == sSize) {
					    insertOptionQuantity(oQuant, iStock);
						bQuantityUpdated = true;
						break;
					}
				}
				if(bQuantityUpdated==false) {
					insertOptionQuantity(oQuant, 0);
				}
			}
		}
	}
	
	
	// == Reusable Functions ==
	function getSelectText(sObjectName) {
		// Get the selected 
		var oObj = document.getElementById(sObjectName);
		var sText = "";

		if (oObj != null) {
			if (oObj.selectedIndex > -1) {
				sText = oObj.options[oObj.selectedIndex].text;
			}
		}
		return sText;
	}

	function insertOption(oSel, sText, sValue) {
		var oOpt = document.createElement('option');
		oOpt.text = sText;
		oOpt.value = sValue;

		try {
			oSel.add(oOpt,null);	// standards compliant
		} catch(ex) {
			oSel.add(oOpt);			// IE only
		}
	}

	function emptyOptions(oSel) {
		for(var o=oSel.length; o>=0; o--) { oSel.remove(o); }
	}

	function insertOptionQuantity(oQuant, iAdd) {
	    emptyOptions(oQuant);
		if(iAdd > 0) 
		{
			oQuant.disabled = false;//enabled
			insertOption(oQuant,'Select Quantity...',0);
			//alert(oQuant.options.length)
			//alert('stopped');
			//return;
			
			//if(oQuant.name.toLowerCase() =='selquantity0')
			//{
                for(var n=1; n<=iAdd; n++) 
                { 
                    insertOption(oQuant,n,n) 
                }
		} 
		else 
		{
			oQuant.disabled = true;
		}	
	}

	/* FUNCTION ==================================================================
	Name:        updateDisplay()
	Description: Function to update the display of variants of the page. This is
				called when initialising the page and changing the size.
	Coded By:    Matt Hall
	Date:        2001-12-13
	=========================================================================== */
	function updateDisplay(iPV, bColourChanged) {	
	
		var strSize				= new String();
		var strColour			= new String();
		var i					= new Number();
		var oQuant				= document.getElementById('selQuantity' + iPV );
		var iStock				= 0;
		var iExpectedStock      = 0;
		var bQuantityUpdated = false;
		var strSugSize			= new String();
		var strSugColour		= new String();
		var sCvSize				= new String();
		var sCvColour			= new String();
		var size_array          = [];
		
    if (bColourChanged != true) 
    { 
        CONST_SIZE=getSelectText('selSize0');
        
        if(CONST_SIZE.indexOf(" --"))    
        {
            size_array = CONST_SIZE.split(' --');
            CONST_SIZE = size_array[0];
        }
    }
		// -- Main Product --
		// Get selected Colour and Size
			
			 //If iPV=0, i.e. if you are on the main product then run through the radio buttons and see what colour is selected; else select the colour and size as per the original method
        if (iPV==0) 
        {
            if (document.frmProduct.selColour0.length > 1)//the main product has more than one colour
             {
                for (var i = 0; i < document.frmProduct.selColour0.length; i++) {
               
                        if (document.frmProduct.selColour0[i].checked) {
                        
                        //Get main Selected colour
                       var strColour	= eval('document.frmProduct.selColour0[i].value;');
                        break
                        }
                    }
            } 
            else 
            {
               var strColour	= eval('document.frmProduct.selColour0.value;');
		    } 
		}
		else 
		{
		   var  strColour = eval('getSelectText("selColour' + iPV + '")'); 
        }     
		
 
        
        strSize 	= getSelectText('selSize' + iPV);
        
          if(strSize.indexOf(" --"))    
            {
                size_array = strSize.split(' --');
                strSize = size_array[0].Trim();
            }    
        
		if(typeof productVariants[0] != 'undefined') {
					
			// Show Price Normal and Price Alternative for SKU

			setPricing(strColour, strSize, CONST_VARIANTS, 0);

			//----------------------------------------------------------------------------------------------------
			// Show Quantity for SKU - just updated the main product in the centre of the page.
			//----------------------------------------------------------------------------------------------------
			for(var i=0;i < CONST_VARIANTS; i++) {
			    iStock = productVariants[0][i].stocklevel;
			    iExpectedStock = productVariants[0][i].expectedstock;
				if((productVariants[0][i].colour.toUpperCase() == strColour.toUpperCase()) && (productVariants[0][i].size == strSize)) {
				    if (document.frmProduct.availability_status.value == 'D') {
				        insertOptionQuantity(oQuant, iExpectedStock);
				    }
				    else {
				        insertOptionQuantity(oQuant, iStock);
				    }
					bQuantityUpdated = true;
					break;
				}
			}
		}

		if (bQuantityUpdated == false) {
		    insertOptionQuantity(oQuant, 0);
		}
		
		// Show Size Label for SKU
		var bShowLabel = false;
		if(typeof productVariants[0] != 'undefined') {
			for(var i=0;i < CONST_VARIANTS; i++) {
			// check if this item in the array is actually an object - otherwise, break out of the loop.
				if (productVariants[0][i]) {
					if(productVariants[0][i].size == strSize) {
						if(productVariants[0][i].localsizecomment != "") {
						//alert(i);
					//	alert(productVariants[0][i].localsizecomment);
							document.getElementById('size_label0').innerHTML = productVariants[0][i].localsizecomment;
							document.getElementById('size_label0').style.display = "block";
							bShowLabel = true;
						}
						break;
					}
				} else { break; }
			}
		}		
		
		if(bShowLabel == false) {
			document.getElementById('size_label0').innerHTML = "";
			document.getElementById('size_label0').style.display = "none";
		}
		bShowLabel = false;	//reset for next label
									
		// Show Availability/Back Order for SKU
		if(typeof productVariants[0] != 'undefined') {

			for(var i=0;i < CONST_VARIANTS; i++) {
				if((productVariants[0][i].size == strSize) && (productVariants[0][i].colour.toUpperCase() == strColour.toUpperCase())) {
								
					if((productVariants[0][i].availability != "") || (productVariants[0][i].backOrder != "")) {
												
						document.getElementById('availability' + iPV + '').innerHTML = productVariants[0][i].availability;
						document.getElementById('backOrder' + iPV + '').innerHTML = productVariants[0][i].backOrder;
						
						document.getElementById('availability' + iPV + '').style.display = "inline";
						document.getElementById('backOrder0').style.display = "inline";
						
						if (productVariants[0][i].stocklevel < 1) {
							document.getElementById('availability' + iPV + '').style.color = "red";
							document.getElementById('backOrder' + iPV + '').style.color = "red";
						}
						else {

								document.getElementById('availability' + iPV + '').style.color = "#210a36";
								document.getElementById('backOrder' + iPV + '').style.color = "#210a36";

						}
						bShowLabel = true;
						break;
					}
				}
			}
		}
		if(bShowLabel == false) {
			document.getElementById('availability' + iPV + '').innerHTML = ""; 
			document.getElementById('backOrder' + iPV + '').innerHTML = ""; 
			document.getElementById('availability' + iPV + '').style.display = "none";
			document.getElementById('backOrder' + iPV + '').style.display = "none";	
		}

		// -- Suggested Products --
		for(var v=0;v <=CONST_SUGGESTIONS; v++) {
		    var oColour
			if (v==0) {
				// Get selected Colour
			            for (var i = 0; i < document.frmProduct.selColour0.length; i++) {
                            if (document.frmProduct.selColour0[i].checked) {
                            
                            //Get main Selected colour
                                oColour = eval('document.frmProduct.selColour0[i];')
                                break
                            }
                        }
                    }
            else {// Get the colour of the suggested products
                    oColour = eval('document.getElementById("selColour' + v + '")');
                  }
			
			var oSize	= eval('document.getElementById("selSize' + v + '")');
			var oQuant	= eval('document.getElementById("selQuantity' + v + '")');
			var bSizesUpdated = false;
			var iStock	= 0;
			var bQuantityUpdated = false;
			
			if (oColour != null) {
				
				// Match to the main product colour, then get selected Suggest Colour
				if (iPV == 0) {
					for(var c=0;c < oColour.length; c++) {
						if (strColour.toUpperCase() == oColour.options[c].text.toUpperCase()) {
							oColour.selectedIndex = c;
							
							if(bColourChanged) {
							
								// Update the list of sizes for this Product.
								// For when the main product colour has changed.
								
								buildSizesByProduct(v);
								bSizesUpdated = true;
							}
						}
					}	
				}

				if((v == iPV) && bColourChanged && !bSizesUpdated) {
					// Update the list of sizes for this Product, if the list hasn't been yet.'
					// For when the suggested product colour has changed.
					buildSizesByProduct(v);
					eval('setSelectedColourSuggestedImage(getSelectText("selColour' + v + '"), v)');
				}
				
				// Get selected Colour and Size
				strSugColour	= eval('getSelectText("selColour' + v + '")');
				strSugSize		= eval('getSelectText("selSize' + v + '")');
				
				if(strSugSize.indexOf(" --"))    
                {
                    size_array = strSugSize.split(' --');
                    strSugSize = size_array[0].Trim();
                }

				if(typeof productVariants[v] != 'undefined') {
					var iLenPV = productVariants[v].length;

					// Show Price Normal and Price Alternative for SKU
					setPricing(strSugColour, strSugSize, iLenPV, v);

                    var bShowLabel = false;
		            var sizlab

					// Show Quantity for SKU
					for(var i=0;i < iLenPV; i++) {
						if(productVariants[v][i].size == strSugSize) {
						  
						        if(productVariants[v][i].localsizecomment != "") {
						        //alert(i);
					            //alert(productVariants[v][i].localsizecomment);
							        sizlab = eval('document.getElementById("size_label' + v + '")');
							        sizlab.innerHTML = productVariants[v][i].localsizecomment;
							        sizlab.style.display = "block";
							        bShowLabel = true;
						        }
						        
					    }
					        
					    iStock = productVariants[v][i].stocklevel;
						if((productVariants[v][i].colour.toUpperCase() == strSugColour.toUpperCase()) && (productVariants[v][i].size == strSugSize)) {
						  	insertOptionQuantity(oQuant, iStock);
							bQuantityUpdated = true;
							break;
						}

					}
				}
				if(bShowLabel == false) {
				    sizlab = eval('document.getElementById("size_label' + v + '")');
				    sizlab.innerHTML = "";
			        sizlab.style.display = "none";
		        }
		        bShowLabel = false;	//reset for next label
		       
			}
		}	
	}
	

	function setPricing(sColour, sSize, iPVs, iPV) {
	//Size no longer used as price is at colour level BP 19/09/2009
	
		var oNowSale = eval('document.getElementById("pricing_now_sale' + iPV + '")');
		var oNow = eval('document.getElementById("pricing_now' + iPV + '")');
		var oWas = eval('document.getElementById("pricing_was' + iPV + '")');
		
		var bPriceFound = false;
		
		for(var i=0;i < iPVs; i++) {
			if((productVariants[iPV][i].colour.toUpperCase() == sColour.toUpperCase())) {
				if (productVariants[iPV][i].priceDisplayFlag == 'isondiscount') {
					oNowSale.innerHTML = productVariants[iPV][i].promoPrice;
					oNow.innerHTML = "";
					oWas.innerHTML = productVariants[iPV][i].price;

					if(showAltPrice) {
						oNowSale.innerHTML = oNowSale.innerHTML + ' (' + productVariants[iPV][i].altPromoPrice + ')';
						oWas.innerHTML = oWas.innerHTML + ' (' + productVariants[iPV][i].altPrice + ')';
					}
					oNowSale.style.display = "inline";
					oNow.style.display = "none";
					oNow.style.margin = "0px";
					oWas.style.display = "inline";

				} else if (productVariants[iPV][i].salePrice) {
					oNowSale.innerHTML = productVariants[iPV][i].salePrice;
					oNow.innerHTML = "";
					oWas.innerHTML = productVariants[iPV][i].price;
							
					if(showAltPrice) {
						oNowSale.innerHTML = oNowSale.innerHTML + ' (' + productVariants[iPV][i].altSalePrice + ')';
						oWas.innerHTML = oWas.innerHTML + ' (' + productVariants[iPV][i].altPrice + ')';
					}
					oNowSale.style.display = "inline";
					oNow.style.display = "none";
					oNow.style.margin = "0px";
					oWas.style.display = "inline";
					
				} else { 
					oNowSale.innerHTML = "";
					oNow.innerHTML = productVariants[iPV][i].price;
					oWas.innerHTML = "";

					if(showAltPrice) {
						oNow.innerHTML = oNow.innerHTML + ' (' + productVariants[iPV][i].altPrice + ')';
					}
					oNowSale.style.display = "none";
					oNowSale.style.margin = "0px";
					oNow.style.display = "inline";
					oWas.style.display = "none";
					oWas.style.margin = "0px";
				}
				
				// a price was found based on the size and colour. Set a flag, and get out of the loop.
				bPriceFound = true;
				break;
			}		
		}
	}

	function setSelectedColourImages(sColour, sImageType, bMain) {
		
		//alert(sColour + '_ProductColour' + sImageType + 'Image_medium');
		//Get Medium image
		var oMedium = eval('document.getElementById("' + sColour + '_ProductColour' + sImageType + 'Image_medium")');

		//Set image paths
		var oImg = eval('document.getElementById("img' + sImageType + '")');

		//test if Medium image exists
		if (oMedium != null) {
	
			var oThumb = eval('document.getElementById("' + sColour + '_ProductColour' + sImageType + 'Image_lthumbnail")');
			var oZoom = eval('document.getElementById("' + sColour + '_ProductColour' + sImageType + 'Image_large")');

			if (bMain) {
				var oImgThumb	= eval('document.getElementById("img' + sImageType + 'Thumb")');
				oImg.src		= oMedium.value;
				oImg.alt		= oZoom.value
				oImgThumb.value = oThumb.value;
				$('.jqzoom').attr('href', oZoom.value);
				/*		var options = {
				zoomWidth: 365,
				zoomHeight: 425,
				xOffset: 10,
				yOffset: 0,
				position: "right" //and MORE OPTIONS
				};

				jQuery(".jqzoom").jqzoom(options);*/
			} else {
				var oImgZoom	= eval('document.getElementById("img' + sImageType + 'Zoom")');
				oImg.src		= oThumb.value;
				oImg.alt		= oMedium.value;
				oImgZoom.value	= oZoom.value;
				
				//ensure the image is displayed
				oImg.style.display = "inline";
}
	
		} else if(!bMain) {
			oImg.style.display = "none";
		}
	}

	function setSelectedColourSuggestedImages(sColour) {
		//Get Suggested Products images
		for (var v=1; v<=CONST_SUGGESTIONS; v++) {
			setSelectedColourSuggestedImage(sColour, v);
		}
	}
	
	function setSelectedColourSuggestedImage(sColour, iPV) {
		if (colourExists(sColour, iPV)) {
			$('#panel' + iPV).show();
			var oShortImage = eval('document.getElementById("' + sColour + '_shortimage' + iPV + '")');
			// Get suggested image
			var oImgSug = eval('document.getElementById("imgSuggested' + iPV + '")');	
			//test if Short Image image exists, otherwise dont change the image
			if (oShortImage != null) {
				oImgSug.src = oShortImage.value;
			}			
		}
		else {
			$('#panel' + iPV).hide();
		}
	}
	
	// Added function to check whether the selected colour existed for other item in range, it is does, show it, if it does not, skip over it.
	function colourExists(sColour, iPV) {
		var objSelect = document.getElementById('selColour' + iPV);
		var bResult = false;		
		if(typeof objSelect != 'undefined' && objSelect != null) {
			for (var i = 0; i < objSelect.length; i++) {
				if (objSelect[i].text == sColour) {
					bResult = true;
					break;
				}
			}		
		}
		return bResult;
	}
		    
    //------------------------------------------------------------------------------------------------------
	// This is called when the page first loads, and also when the colour of any main item is changed.
	// It updates the main product images, and sets the suggested items, and any complete the outfit items.
    //------------------------------------------------------------------------------------------------------
	function updateDisplayByColour(bSingle) {

		//Get main Selected colour
		var sColour	= getSelectText('selColour0');
				
		// Set Main images to match the colour selected
		setSelectedColourImages(sColour, 'Front', true);
		setSelectedColourImages(sColour, 'Back', false);
		setSelectedColourImages(sColour, 'Alternate', false);
		setSelectedColourImages(sColour, 'Set', false);

		// Set Suggested images to match the colour selected
		setSelectedColourSuggestedImages(sColour);
		
		// If there are 'complete the look' items, run the following...
		
		if(typeof colourVariants[0] != 'undefined') {
			updateRHSColourVariants();
		}
		updateDisplay(0, true);
	}
	
	
	//------------------------------------------------------------------------------------------------------
	// This is called when the page first loads, and also when the colour of any main item is changed.
	// This is the new function used with radio buttons instead of the select list.
    //------------------------------------------------------------------------------------------------------
	function updateDisplayByColourRadio(bSingle) {


	    if (document.frmProduct.selColour0.length == undefined) {
	        var sColour = document.frmProduct.selColour0.value; //Only one product colour
	    }
	    else {
	        for (var i = 0; i < document.frmProduct.selColour0.length; i++) {
	            if (document.frmProduct.selColour0[i].checked) {

	                //Get main Selected colour
	                var sColour = document.frmProduct.selColour0[i].value;
	                break
	            }
	        }
	    }
         // alert('sColour='+sColour);
            // Set Main images to match the colour selected
            
		setSelectedColourImages(sColour, 'Front', true);
		setSelectedColourImages(sColour, 'Back', false);
		setSelectedColourImages(sColour, 'Alternate', false);
		setSelectedColourImages(sColour, 'Set', false);

		// Set Suggested images to match the colour selected
		setSelectedColourSuggestedImages(sColour);
		
		// If there are 'complete the look' items, run the following...
		
		if(typeof colourVariants[0] != 'undefined') {
			updateRHSColourVariants();
		}
		updateDisplay(0, true);
	}
	

	//**********************************************************************************************************************************
	// Set of functions to manage the RHS products.
	//**********************************************************************************************************************************

    //-------------------------------------------------------------------------------------------
    // This function is called by the RHS CV Colour-drop-down, when it is changed.
    // It's purpose is to update all the details for the CV, based on the colour change.
    //-------------------------------------------------------------------------------------------
   	
	//------------------------------------------------------------------------------------------
	// This function runs on page load.
	// This is also called when a main product colour is changed - it updates what is displayed
	// and selected in the RHS complete the outfit accordion, based on colour matches.
	//------------------------------------------------------------------------------------------	
	function updateRHSColourVariants(){
	    
		var i,j,x;
	
		var iNumOfMatchingProducts = 0;
		
		
            if (document.frmProduct.selColour0.length > 1)//the main product has more than one colour
             {
                for (var i = 0; i < document.frmProduct.selColour0.length; i++) {
               
                        if (document.frmProduct.selColour0[i].checked) {
                        
                        //Get main Selected colour
                       var sColour	= eval('document.frmProduct.selColour0[i].value;');
                        break
                        }
                    }
            } 
            else 
            {
               var sColour	= eval('document.frmProduct.selColour0.value;');
		    } 
		
            
		//		alert(sColour);
		var sSelectedLabelColour = sColour
		
		var iMatchingCVIndex = 0;
		var sMatchingVariantColour = "";
		
		// Filter the LabelColour - filter out brackets, and replace spaces with underscores
		// 'availableColours' is an objects with items such as 'Black', and 'Pomegranate' in it. These objects in turn have up to 4 ProductColourIDs in.
		
	    sSelectedLabelColour = sSelectedLabelColour.replace(/[(0-9)-]|\,| |\)|\.|\/|\\/gi,'')
	    
	    if ((availableColours) && (sSelectedLabelColour)) {
			if (eval("availableColours." + sSelectedLabelColour)) {
				//alert("this item has options");
				
				// Get the number of matching products from the array, by checking the colour Variant label colour against the currently selected.
				for (i=0; i < colourVariants.length; i++){	
							
					if (colourVariants[i].labelColour == sColour) {
					
						// We've found a matching product.
						// 1. Determine which product variant matched the colour
						
						// Loop through the product variants for this product
						
						iMatchingCVIndex = -1;
						sMatchingVariantColour = "";
						
						for (j=0 ; j<colourVariants[i].length ; j++){
						
							// Loop through the available colours.
							for (x = 0; x< eval("availableColours." + sSelectedLabelColour).length ; x++) {
							
								// Check if the product in the available colours matches the variant								
								if ((eval("availableColours." + sSelectedLabelColour)[x]) == (colourVariants[i][j].productColourID)) {
									iMatchingCVIndex = j;
									sMatchingVariantColour = colourVariants[i][j].colour;
									break;
								}
							}
							
							// drop out of loop if match has been found.
							if (iMatchingCVIndex != -1) { break; }
						}
						if (iMatchingCVIndex==-1) { iMatchingCVIndex = 0; } 
						// 2. Update the RHS items, using the product number in the array, the variant array number, and the sequence number (0 - 3)
						
						updateCVItemFromMain(i, iMatchingCVIndex, iNumOfMatchingProducts, sMatchingVariantColour);
												
						// Increment the count of matching items.
						iNumOfMatchingProducts++;
					}
				}
				
				// number of matching products = (iNumOfMatchingProducts)
			}
		}
	//if (iNumOfMatchingProducts > 2)  {
	//iNumOfMatchingProducts = 2
	//}
    	showCVPanels(iNumOfMatchingProducts);
	}
	
	function showCVPanels(iNumPanelsToShow) {
	//alert(iNumPanelsToShow);
	document.getElementById('cvProductPanel0').style.display = "none";
	document.getElementById('cvProductPanel0').style.visibility = "hidden";
	document.getElementById('cvProductPanel1').style.display = "none";
	document.getElementById('cvProductPanel1').style.visibility = "hidden";
	document.getElementById('cvProductPanel2').style.display = "none";
	document.getElementById('cvProductPanel2').style.visibility = "hidden";
	document.getElementById('cvProductPanel3').style.display = "none";
	document.getElementById('cvProductPanel3').style.visibility = "hidden";

	    var i;
	    for (i=0; i < iNumPanelsToShow; i++) {
	    //alert(iNumPanelsToShow);
	    
    	    document.getElementById('cvProductPanel' + i).style.display = "block";
    	    document.getElementById('cvProductPanel' + i).style.visibility = "visible";
    	}
    	
    	//JR - 10-06-2010 display was set to block?? meant you could always scroll to the 2nd section of products even if there was none to show
    	for (i=iNumPanelsToShow; i < 2; i++) {
    	    document.getElementById('cvProductPanel' + i).style.display = "none";
    	    document.getElementById('cvProductPanel' + i).style.visibility = "hidden";
    	}
    	
    	if (iNumPanelsToShow<=0) {
    	
    	    // No items to show in Complete the Look - so hide the second accordion.

            document.getElementById('Accordion2Title').style.display = 'none';
            document.getElementById('Accordion2Content').style.display = 'none';
        } else {
    	
            document.getElementById('Accordion2Title').style.display = 'block';
            document.getElementById('Accordion2Content').style.display = 'block';

//    	    document.getElementById('Accordion2Title').style.visibility = "visible";
//    	    document.getElementById('Accordion2Content').style.visibility = "visible";
    	}
	}
	
	
	//------------------------------------------------------------------------------------------
	// This function updates the drop down and display items for a specified Colour Variant.
	// This function should only be called FROM the main product, as it also sets the default matching colour in the RHS drop-downs
	// It will be called the first time the page loads, and whenever the colour is changed.
	//------------------------------------------------------------------------------------------
	function updateCVItemFromMain(iArraySeq_Product, iArraySeq_Variant, iDisplaySequence, sMatchingVariantColour) {
		var objSelect
		// Update the reference array (currentlyDisplayedCVs[])
		// This allows unique identification of the currently displayed products, without having to loop
		// through matching size/colour, etc...
			
		currentlyDisplayedCVs[iDisplaySequence].arraySeq_product = iArraySeq_Product;
		currentlyDisplayedCVs[iDisplaySequence].arraySeq_variant = iArraySeq_Variant;
		
		// Update the individual item	
        //---------------------------------------
		// First, update the colours
		//buildCvColour(iArraySeq_Product, iDisplaySequence);
		// Then, update the sizes
		//buildCvSizesByProduct(iArraySeq_Product, iDisplaySequence);
		// Next, update the quantities.
		//buildCvQuantity(iArraySeq_Product, iDisplaySequence);		
		// Next, update the images
		updateCVImages(iDisplaySequence);
		// Lastly, update the data for this CV.
		updateCVData(iDisplaySequence);			
    	    	
		// Set the selected item to be - sMatchingVariantColour - Removed 10-06-2010 by JR, no longer displaying the colour in the CV panel so not needed
		//objSelect = eval('document.getElementById("selCvColour' + iDisplaySequence + '")');
		//setSelectedDropDown(objSelect, sMatchingVariantColour);
		
	}
	
	function updateCVImages(iDisplaySequence) {
	
	    // Retrieve the image name from the array, and swap it in.
	    
		var iArraySeq_Product = currentlyDisplayedCVs[iDisplaySequence].arraySeq_product;
		var iArraySeq_Variant = currentlyDisplayedCVs[iDisplaySequence].arraySeq_variant;
		
		var sImageStr = "";
		
		if (colourVariants[iArraySeq_Product][iArraySeq_Variant]) {
		
    		sImageStr = colourVariants[iArraySeq_Product][iArraySeq_Variant].productMiniImage;
		    document.getElementById('imgCv' + iDisplaySequence).src = sImageStr;
		    
    	}
	}

    // This updates the Title and Link for a CV specified by display sequence (1 - 4).
	function updateCVData(iDisplaySequence) {
	
		var iArraySeq_Product = currentlyDisplayedCVs[iDisplaySequence].arraySeq_product;
		var iArraySeq_Variant = currentlyDisplayedCVs[iDisplaySequence].arraySeq_variant;
		
		// Update Title
		if (colourVariants[iArraySeq_Product][iArraySeq_Variant]) {
		    var sProductTitle = colourVariants[iArraySeq_Product][iArraySeq_Variant].productTitle;
		    document.getElementById('cvProduct_title' + iDisplaySequence).innerHTML = sProductTitle;
		}

		// Update the HREF on the image
		if (colourVariants[iArraySeq_Product][iArraySeq_Variant]) {
		    var sHREF = "?product_id=" + colourVariants[iArraySeq_Product][iArraySeq_Variant].productCode;
		    document.getElementById('cv_anchor' + iDisplaySequence).href = sHREF;
		}
		
		
		// Reset the price for this item to be that of the 1st variant for the product.
		setCvPricing(iArraySeq_Product, 0, iDisplaySequence);
		
	}


	//-------------------------------------------------------------------------------------------------------------------------------------------------
	// This function is called by a RHS Colour Variation product (complete the look), when the size drop-down is changed. (selCvSize0, selCvSize1, etc.)
	// It's purpose is to update the available quantities in the selCvQuantity drop-down. This data comes from the colourVariants[][] array,
	// in the stocklevel parameter.
	// The colourVariants array consists of a product sequence, and SKU sequence - e.g colourVariants[0][0] is the 1st SKU for the 1st product.
	// This function also calls a function to update the price on the product.
	//-------------------------------------------------------------------------------------------------------------------------------------------------
	function updateCvQuantity(iDisplaySequence) {
				
		var iFound = 0;
		var oSize	= eval('document.getElementById("selCvSize' + iDisplaySequence + '")');
		var oQuant = eval('document.getElementById("selCvQuantity' + iDisplaySequence + '")');
			
		// Loop through each product in the colour variants array.
		for(var i=0; i<colourVariants.length; i++) {
			
			// Loop through each SKU in the colour variant identified by 'i'
			for(var j=0; j<colourVariants[i].length; j++) {
				
				// if the item in the array identified by i,j is equal to the newly selected size (selCvSize), then 
				// update the quantity drop-down with the stock level, from the array.
				
				if (colourVariants[i][j].id == oSize.options[oSize.selectedIndex].value) {
				    // Clear out, then re-populate 'selCvQuantity0/1/2/3' with the stock level.
				    insertOptionQuantity(oQuant, colourVariants[i][j].stocklevel);
					// bail out of the 'j' loop
					iFound = 1;
					break;
				}
			}
			// the stock level was found - so bail out of the 'i' loop.
			if (iFound == 1) break;
		}
		
		setCvPricing(i,j,iDisplaySequence);
	}


    // Sets the price for a given product variant
    function setCvPricing(iArraySeq_Product, iArraySeq_Variant, iDisplaySequence) {	

		var oNowSale = eval('document.getElementById("cv_pricing_now_sale' + iDisplaySequence + '")');
		var oNow = eval('document.getElementById("cv_pricing_now' + iDisplaySequence + '")');
		var oWas = eval('document.getElementById("cv_pricing_was' + iDisplaySequence + '")');	
		
        // Check to the see if this variant is on promotion.
		if (colourVariants[iArraySeq_Product][iArraySeq_Variant].priceDisplayFlag == 'isondiscount') {
			oNowSale.innerHTML = colourVariants[iArraySeq_Product][iArraySeq_Variant].promoPrice;
			oNow.innerHTML = "";
			oWas.innerHTML = colourVariants[iArraySeq_Product][iArraySeq_Variant].price;

			if(showAltPrice) {
				oNowSale.innerHTML = oNowSale.innerHTML + ' (' + colourVariants[iArraySeq_Product][iArraySeq_Variant].altPromoPrice + ')';
				oWas.innerHTML = oWas.innerHTML + ' (' + colourVariants[iArraySeq_Product][iArraySeq_Variant].altPrice + ')';
			}
			oNowSale.style.display = "inline";
			oNow.style.display = "none";
			oWas.style.display = "inline";

        // Check if variant is on sale...
		} else if (colourVariants[iArraySeq_Product][iArraySeq_Variant].salePrice) {
			oNowSale.innerHTML = colourVariants[iArraySeq_Product][iArraySeq_Variant].salePrice;
			oNow.innerHTML = "";
			oWas.innerHTML = colourVariants[iArraySeq_Product][iArraySeq_Variant].price;
					
			if(showAltPrice) {
				oNowSale.innerHTML = oNowSale.innerHTML + ' (' + colourVariants[iArraySeq_Product][iArraySeq_Variant].altSalePrice + ')';
				oWas.innerHTML = oWas.innerHTML + ' (' + colourVariants[iArraySeq_Product][iArraySeq_Variant].altPrice + ')';
			}
			oNowSale.style.display = "inline";
			oNow.style.display = "none";
			oWas.style.display = "inline";
			
		// Not on promo or sale
		} else { 
			oNowSale.innerHTML = "";
			oNow.innerHTML = colourVariants[iArraySeq_Product][iArraySeq_Variant].price;
			oWas.innerHTML = "";

			if(showAltPrice) {
				oNow.innerHTML = oNow.innerHTML + ' (' + colourVariants[iArraySeq_Product][iArraySeq_Variant].altPrice + ')';
			}
			oNowSale.style.display = "none";
			oNow.style.display = "inline";
			oWas.style.display = "none";
		}
    }

	function buildCVPanelItems(){
	
		var sHTML = "";	
		var sProductTitle = "";
        //sHTML = sHTML + "<li id=\"cvProductPanel0\">";
        for (iDisplaySequence = 0; iDisplaySequence < 4; iDisplaySequence++) {
			// left panel - Changed to display in one panel rather than two side by side. JR 10-06-2010
			 sHTML = sHTML + "<li id=\"cvProductPanel" + iDisplaySequence + "\">";
			sHTML = sHTML + "<div class=\"cvpanel_left\">";
			sHTML = sHTML + "<a href=\"?product_id=#\" id=\"cv_anchor" + iDisplaySequence + "\">";
			sHTML = sHTML + "<img src=\"\" alt=\"\" title=\"\" id=\"imgCv" + iDisplaySequence + "\" border=\"0\" class=\"product_suggestion\" /></a>";
					
			// right panel
			
			sHTML = sHTML + "<p class=\"item_title\" id=\"cvProduct_title" + iDisplaySequence + "\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_now" + iDisplaySequence + "\" class=\"cvprice\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_was" + iDisplaySequence + "\" class=\"cvprice\" style=\"text-decoration: line-through; padding-right: 20px;\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_now_sale" + iDisplaySequence + "\" class=\"cvprice_former\"></p>";
			sHTML = sHTML + "</div>";
            sHTML = sHTML + "</li>";
		}
		
		/*//sHTML = sHTML + "<li id=\"cvProductPanel1\">";
        for (iDisplaySequence = 2; iDisplaySequence < 4; iDisplaySequence++) {
			// left panel - Changed to display in one panel rather than two side by side. JR 10-06-2010
			sHTML = sHTML + "<li id=\"cvProductPanel1\">";
			sHTML = sHTML + "<div class=\"cvpanel_left\">";
			sHTML = sHTML + "<a href=\"?product_id=#\" id=\"cv_anchor" + iDisplaySequence + "\">";
			sHTML = sHTML + "<img src=\"\" alt=\"\" title=\"\" id=\"imgCv" + iDisplaySequence + "\" border=\"0\" class=\"product_suggestion\" /></a>";
					
			// right panel
			
			sHTML = sHTML + "<p class=\"item_title\" id=\"cvProduct_title" + iDisplaySequence + "\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_now" + iDisplaySequence + "\" class=\"cvprice\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_now_sale" + iDisplaySequence + "\" class=\"cvprice_former\"></p>";
			sHTML = sHTML + "<p id=\"cv_pricing_was" + iDisplaySequence + "\" class=\"cvprice\"></p>";
			sHTML = sHTML + "</div>";
			sHTML = sHTML + "</li>";
		}
		//sHTML = sHTML + "</li>";*/

		if (document.getElementById('mycarousel2')) {
    		document.getElementById('mycarousel2').innerHTML = sHTML;
    	}
	
	}
	
	function buildCVPanelItemsV2(){
	
		var sHTML = "";	
		var sProductTitle = "";
                
        for (iDisplaySequence = 0; iDisplaySequence < 4; iDisplaySequence++) {
		    // left panel - Changed to display in one panel rather than two side by side. JR 10-06-2010
		     sHTML = sHTML + "<li id=\"cvProductPanel" + iDisplaySequence + "\">";
		    sHTML = sHTML + "<div class=\"product_image\">";
		    sHTML = sHTML + "<a href=\"?product_id=#\" id=\"cv_anchor" + iDisplaySequence + "\">";
		    sHTML = sHTML + "<img src=\"\" alt=\"\" title=\"\" id=\"imgCv" + iDisplaySequence + "\" border=\"0\" class=\"product_suggestion\" /></a>";
		    sHTML = sHTML + "</div>";
		    // right panel
		    sHTML = sHTML + "<div class=\"product_info\">";
		    sHTML = sHTML + "<p class=\"item_title\" id=\"cvProduct_title" + iDisplaySequence + "\"></p>";
		    sHTML = sHTML + "<p id=\"cv_pricing_now" + iDisplaySequence + "\" class=\"cvprice\"></p>";
		    sHTML = sHTML + "<p id=\"cv_pricing_now_sale" + iDisplaySequence + "\" class=\"cvprice_former\"></p>";
		    sHTML = sHTML + "<p id=\"cv_pricing_was" + iDisplaySequence + "\" class=\"cvprice\"></p>";
		    sHTML = sHTML + "</div>";
            sHTML = sHTML + "</li>";
	    }

		if (document.getElementById('mycarousel2')) {
    		document.getElementById('mycarousel2').innerHTML = sHTML;
    	}
	
	}



	//**********************************************************************************************************************************
	// Helper functions for the section above.
	
	//------------------------------------------------------------------------------------------
	// This function change a combo box selected value, by the text (rather than the value)
	//------------------------------------------------------------------------------------------
	function setSelectedDropDown(objSelect, sTextToFind) {
		var i;
		
		for (i = 0; i < objSelect.options.length ; i++) {
			if (objSelect.options[i].text == sTextToFind) {
				objSelect.options[i].selected = true;
				break;
			}
		}
	}
	//------------------------------------------------------------------------------------------
	
	

	//**********************************************************************************************************************************
	//**********************************************************************************************************************************



	// == Generic functions ==
	function MM_preloadImages() {
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) {
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && document.getElementById) x=document.getElementById(n); return x;
	}

	function MM_swapImage() {
	    var i, j = 0, x, a = MM_swapImage.arguments;
	    document.MM_sr = new Array; 
		for(i=0;i<(a.length-2);i+=3)
		    if ((x = MM_findObj(a[i])) != null) {
		        document.MM_sr[j++] = x;
		        if (!x.oSrc)
		            x.oSrc = x.src;
		        x.src = a[i + 2];
		    }
	}

	function MM_swapImagecycle() {
		intcycle++;
		if(intcycle > 3){intcycle=0;}
		if(intcycle > (aImages.length-1)){intcycle=0;}
		MM_swapImage('prodImage','',aImages[intcycle],1);
	}

	function submitQwiserSearch() {
		var searchTerm;
		searchTerm = document.frmProduct.qwterm.value;
		searchTerm = searchTerm.replace(/&amp;/g, "%26");
		window.location = "nsf/qwiser.asp?term=" + searchTerm;
	}

	// START: Shopping Cart Pop-up
	var popUpTimerId;

	function showPopUp() {
		showTimedPopUp();
		//popUpTimerId = setTimeout("hideTimedPopUp()", 3000);
	}

	function showTimedPopUp() {
		var oPopUp = document.getElementById('item_added');

		//display pop up
		oPopUp.style.display = "inline";

		// center pop up
		oPopUp.style.left = parseInt(oPopUp.offsetWidth / 2) + "px";
		oPopUp.style.top = parseInt(oPopUp.offsetHeight / 2) + "px";

		//display overlay
		document.getElementById("overlay").style.display = "inline";
	}

	function hideTimedPopUp() {
		document.getElementById("item_added").style.display = "none";
		document.getElementById("overlay").style.display = "none";
	}

	function cShop() {
		//clearTimeout(popUpTimerId);
		hideTimedPopUp();
	}

	function cCart() {
		//clearTimeout(popUpTimerId);
		var pth = window.location.protocol + '//' + window.location.host + window.location.pathname.substring(0, 4);
		window.location.href = "basket/bsk_basket.asp?cm_re=header-_-textlink-_-viewcart&ShowXSell=on&redirect=" + escape((window.location.href.replace(pth, "")).replace("&added=1",""));
	}
	// END: Shopping Cart Pop-up



	function swapImage(sImageType) {
		// Main product image
		var oImgMain		= document.getElementById('imgFront');
		var oImgMainThumb	= document.getElementById('imgFrontThumb');
		
		// Thumb to swap with
		var oImgThumb		= eval('document.getElementById("img' + sImageType + '")');
		var oImgThumbZm		= eval('document.getElementById("img' + sImageType + 'Zoom")');

		//set the current main image
		sCurrentImg			= oImgMain.src;
		sCurrentZm			= oImgMain.alt;
		sCurrentThumb		= oImgMainThumb.value;

		//set the next main image
		sNextMainImg		= oImgThumb.alt;
		sNextMainZm			= oImgThumbZm.value;
		sNextMainThumb		= oImgThumb.src;
		
		//set main image
		oImgMain.src		= sNextMainImg;
		oImgMain.alt		= sNextMainZm;
		oImgMainThumb.value	= sNextMainThumb;
		
		//replace thumb image
		oImgThumb.src		= sCurrentThumb;
		oImgThumb.alt		= sCurrentImg;
		oImgThumbZm.value = sCurrentZm;

		$('.jqzoom').attr('href', sNextMainZm);
/*		var options = {
		    zoomWidth: 365,
		    zoomHeight: 425,
		    xOffset: 10,
		    yOffset: 0,
		    position: "right" //and MORE OPTIONS
		};

		jQuery(".jqzoom").jqzoom(options);*/
	}

	function toggle_info(iShow) {
		var oInfo1 = document.getElementById("toggle_info1");
		var oInfo2 = document.getElementById("toggle_info2");
		var oInfo3 = document.getElementById("toggle_info3");
		var oText1 = document.getElementById("toggle1text");
		var oText2 = document.getElementById("toggle2text");
		var oText3 = document.getElementById("toggle3text");
		var tab1 = document.getElementById("tab1");
		var tab2 = document.getElementById("tab2");
		var tab3 = document.getElementById("tab3");

		oInfo1.style.display = "none";
		oInfo2.style.display = "none";
		oInfo3.style.display = "none";
		eval("oInfo" + iShow + ".style.display = 'block'");

		oText1.style.borderBottom = '0px';
		oText2.style.borderBottom = '0px';
        oText3.style.borderBottom = '0px';
        
        tab1.className = 'not_selected';
		tab2.className = 'not_selected';
        tab3.className = 'not_selected';
        eval("tab" + iShow + ".className = 'selected'");
	}

function createAtgRenderer() {

    //ATGSvcs.rec_builder("custom_li",
      //function(slot_name, rec_data) {

          // create a new LI element that we will return when we are done
        //  var recommendation = document.createElement("li");

          // create a div to hold the image
        //  var imgDiv = document.createElement("div");
        //  $(imgDiv).attr('class', 'product_image');

          // create a new A element linking to this item's detail page
        //  var link = document.createElement("a");
         // $(link).attr("class", "img");
         // link.href = rec_data.url;

          // Create image element
        //  var img = document.createElement("img");
        //  img.src = rec_data.image;
        //  link.appendChild(img);

         // imgDiv.appendChild(link);

          // create the div containing name and price
        //  var div = document.createElement("div");
        //  $(div).attr("class", "product_info");

          // create the link
        //  var p = document.createElement("p");
        //  $(p).attr("class", "item_title");
        //  var title = document.createTextNode(rec_data.name);
        //  p.appendChild(title);

          // create a new textNode with the item's formatted price
        //  var p2 = document.createElement("p");
        //  $(p2).attr("class", "cvprice");
        //  $(p2).attr("style", "display:inline");
        //  var price = document.createTextNode(ATGSvcs.price(slot_name, rec_data.price));
        //  p2.appendChild(price);

        //  div.appendChild(p);
        //  div.appendChild(p2);

          // add the data elements to the recommendation element we will return
        //  recommendation.appendChild(imgDiv);
        //  recommendation.appendChild(div);

          // (REQUIRED) set the id and class of the element we will return
        //  recommendation.id = ATGSvcs.rec_id(slot_name, rec_data.productId);
        //  recommendation.className = "cs-rec";

          // return the recommendation element
       //   return recommendation;
    //  });


//    ATGSvcs.renderer("custom_ul",
   // function(slot_element) {

   //     var ul = document.createElement("ul");
   //     $(ul).attr("class", "jcarousel-skin-completelook");
   //     $(ul).attr("id", "recommendationsUl");

   //     for (var i = 0; i < this.recs.length; i++) {
   //         ul.appendChild(ATGSvcs.build_rec(slot_element.id, this.recs[i]));
   //     }

   //     slot_element.appendChild(ul);
        
   //     jQuery('#recommendationsUl').jcarousel({
   //       vertical: true,
   //       scroll: 1,
    //      buttonNextHTML: null,
    //      buttonPrevHTML: null,
   //       initCallback: productcarousel_recommendations_initCallback
   //     });    
   // });
}

function productcarousel_recommendations_initCallback(carousel){

    $('#upImgRecommendations').bind('click', function(){
        carousel.prev();
    });

    $('#downImgRecommendations').bind('click', function(){
        carousel.next();
    });
}

     
