	var productPopupWidth  = 600;
	var productPopupHeight = 800;
	var httpRequest;
	function showImage(ImageNumber)
	{
	    //alert ('img no.: ' + ImageNumber)
		//alert('hello moto');
		//
		// Save the current image number for later
		//
		var hidImageNumber = document.getElementById("hidImageNumber");
		if (hidImageNumber)
			hidImageNumber.value = ImageNumber;
		else
		alert('Failed to find field hidImageNumber');
		//
		// Find the image details for the selected image
		//
		var ImageDetailsFieldName = "ctl00_mainContent_hidImage" + ImageNumber;
		var ImageDetailsField = document.getElementById(ImageDetailsFieldName)
		if (!ImageDetailsField)
		{
			alert('Failed to find field ' + ImageDetailsFieldName);
			return;
		}
		var ImageDetails = ImageDetailsField.value.split("¬")
		//
		// Find the product image field
		//
		var ImageFieldName = "ctl00_mainContent_imgProduct";
		var ImageField = document.getElementById(ImageFieldName);
		if (!ImageField)
		{
			alert('Failed to find field ' + ImageFieldName);
			return;
		}
		//
		// Display the new image
		//
		if (ImageDetails[0]!='')
		{
			ImageField.src = ImageDetails[0];
			if (ImageDetails[1])
				ImageField.Width = ImageDetails[1];
			if (ImageDetails[2])
				ImageField.Height = ImageDetails[2];
		}
		//
		// Find the thumbnail link field 
		//
		var ImageLinkFieldName = "ctl00_mainContent_aThumbnail" + ImageNumber;
		var ImageLinkField = document.getElementById(ImageLinkFieldName);
		if (!ImageLinkField)
		{
			alert('Failed to find field ' + ImageLinkFieldName);
			return;
		}
		//
		// Update the product image link field & zoom filed
		//
		var ProductImageLinkFieldName = "aProductImage";
		var ProductImageLinkField = document.getElementById(ProductImageLinkFieldName);
		//var ProductZoomLinkFieldName = "aProductZoomImg";
		//var ProductZoomLinkField = document.getElementById(ProductZoomLinkFieldName);
		if (!ProductImageLinkField)
		    {
		    // Check to see if the image has been made a server side control
            ProductImageLinkFieldName = "ctl00_mainContent_aProductImage";
            ProductImageLinkField = document.getElementById(ProductImageLinkFieldName);
    		if (!ProductImageLinkField)
    			alert('Failed to find field ' + ProductImageLinkFieldName);
    		else
    		    ProductImageLinkField.href = ImageLinkField.href;
			}
		else
			ProductImageLinkField.href = ImageLinkField.href;
		
//		if (!ProductZoomLinkField)
//		    {
//		    // Check to see if the zoom has been made a server side control
//            ProductZoomLinkFieldName = "ctl00_ContentPlaceHolder_aProductZoomImg";
//            ProductZoomLinkField = document.getElementById(ProductZoomLinkFieldName);
//    		if (!ProductZoomLinkField)
//    			alert('Failed to find field ' + ProductZoomLinkFieldName);
//    		else
//    		    ProductZoomLinkField.href = ImageLinkField.href;
//			}
//		else
//			ProductZoomLinkField.href = ImageLinkField.href;
	}
	function setProductPopup(width, height)
	{
		productPopupWidth = width;
		productPopupHeight = height;
	}
    function openProductPopup(source)
    {
   	    var popupPage = source.href + '?x=y';
//		popUpWindow(popupPage, 'Close_1', productPopupWidth, productPopupHeight, 'yes');   	    
	    popUpWindow(popupPage, 'ProductImage', 630, 800, 'yes');
	    return false;
    }	
    function theProductChanging() 
    {
    var url = '/product/Product_Image_Options.aspx?ProductID='+MM_findObj("ctl00$ContentPlaceHolder$theProdID").value +
              getDropdownOption(1) +
              getDropdownOption(2) +
              getDropdownOption(3) +
              getDropdownOption(4) +
              getDropdownOption(5);
    if (window.ActiveXObject) // for IE
      httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    else if (window.XMLHttpRequest) // for other browsers
      httpRequest = new XMLHttpRequest();

    httpRequest.open("GET", url, false);
    httpRequest.onreadystatechange = function() {processRequest('DoDynamicChanges'); } ;
    httpRequest.send(null);
    }

    function getDropdownOption(theOption)
    {
    if(MM_findObj("ctl00$ContentPlaceHolder$ddlOption"+theOption))
        return '&Option'+theOption+'='+MM_findObj("ctl00$ContentPlaceHolder$ddlOption"+theOption)[MM_findObj("ctl00$ContentPlaceHolder$ddlOption"+theOption).selectedIndex].value;
    else
        return '';
    }
    
    function openFinishPopup(FinishNumber, source)
	{
//	    var FinishIDFieldName = "ctl00_ContentPlaceHolder_hidSwatch" + FinishNumber;
//	    var FinishIDField = document.getElementById(FinishIDFieldName);
//	    var FinishID = FinishIDField.value;
//	    var ProductIDFieldName = "ctl00_ContentPlaceHolder_hidProductID";
//	    var ProductIDField = document.getElementById(ProductIDFieldName);
//	    var ProductID = ProductIDField.value;
//	    var popupPage = source.href + "p_" + ProductID + "f_" + FinishID + ".aspx"; // + '?x=y';
		
		popUpWindow(source.href, 'Close_1', productPopupWidth, productPopupHeight, 'yes');
	    
	    return false;
	}
	
	function openStylePopup(StyleNumber)
	{
	    var StyleIDFieldName = "ctl00_mainContent_hidStyle" + StyleNumber;
	    var StyleIDField = document.getElementById(StyleIDFieldName);
	    var StyleID = StyleIDField.value;
	    
	    
	    alert("openStylePopup(); StyleID = " + StyleID);
	    
	    return false;
	}
	
	function getValueFromXML(sTagName, xXML) 
	{
        if (xXML.getElementsByTagName(sTagName)[0].childNodes.length > 0)  
          return (xXML.getElementsByTagName(sTagName)[0].childNodes[0].nodeValue); 
    }
    
    function processRequest(sHandlerName)
    {
      if (httpRequest.readyState == 4)
      {
        if(httpRequest.status == 200)
          eval(sHandlerName + '(httpRequest.responseXML);');
        else
          alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
      }
    } 
    
    function DoDynamicChanges(xXML) 
    {
    alert(" IN Product.JS DoDynamicChanges!");
        if(getValueFromXML('ItemImage', xXML))
            {
            theImage=getValueFromXML('ItemImage', xXML);
            MM_findObj("ctl00_mainContent_imgProduct").src='http://h4d-website.multimedia.co.uk/Gallery/'+theImage;
            ItemRetailPrice=getValueFromXML('ItemRetailPrice', xXML);
            MM_findObj("ctl00_mainContent_lblRRP").innerHTML="&pound;"+parseFloat(ItemRetailPrice,2);
            ItemPrice=getValueFromXML('ItemPrice', xXML);
            MM_findObj("ctl00_mainContent_lblPrice").innerHTML="&pound;"+parseFloat(ItemPrice,2);
            }
    }