	var productPopupWidth  = 590;
	var productPopupHeight = 800;
	var httpRequest;
	function showImage(ImageNumber)
	{
		//
		// 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_ContentPlaceHolder_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_ContentPlaceHolder_imgProductImage";
		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];
		}

	}
	function setProductPopup(width, height)
	{
		productPopupWidth = width;
		productPopupHeight = height;
	}
	function openProductPopup(source)
	{
		var popupPage = source.href;// + '?x=y';
		popUpWindow(popupPage, 'Close_1', productPopupWidth, productPopupHeight, '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 RepeaterProductChanging(Price,  ProdID, Opt1, Opt2, Opt3, pWas, pSave) 
    {
    
    alert(' ');
    
    var options =''
    
    if (Opt1 > ' ')
    {
        options += '&Option1=' + MM_findObj(Opt1)[MM_findObj(Opt1).selectedIndex].value;
    }
    
    if (Opt2 > ' ')
    {
        options += '&Option2=' + MM_findObj(Opt2)[MM_findObj(Opt2).selectedIndex].value;
    }
    
    if (Opt3 > ' ')
    {
        options += '&Option3=' + MM_findObj(Opt3)[MM_findObj(Opt2).selectedIndex].value;
    }
    

    var url = '/product/Product_Image_Options.aspx?ProductID='+ ProdID + options;

    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() {processRepeaterRequest("DoRepeaterDynamicChanges(httpRequest.responseXML, '" + Price + "', '"  + pWas +"', '"  + pSave +"')")} ;
    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(source)
	{
	    //var StyleIDFieldName = "ctl00_ContentPlaceHolder_hidStyle" + StyleNumber;
	    //var StyleIDField = document.getElementById(StyleIDFieldName);
	   // var StyleID = StyleIDField.value;
	    //var popupPage = source.href;// + '?x=y';
		popUpWindow(source, 'Close_1', productPopupWidth, productPopupHeight, 'yes');
	    //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 processRepeaterRequest(sHandlerName)
    {
    
      if (httpRequest.readyState == 4)
      {
        if(httpRequest.status == 200)
        {
          //alert(sHandlerName);
          eval(sHandlerName + ";");
          }
        else
        {
          alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
          }
      }
      
    } 
    
    function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
    }
    
    function DoDynamicChanges(xXML) 
    {
        if(getValueFromXML('ItemImage', xXML))
            {
            theImage=getValueFromXML('ItemImage', xXML);
            MM_findObj("ctl00_ContentPlaceHolder_imgProductImage").src='http://www.handles4doors.co.uk/Gallery/'+theImage;
            ItemRetailPrice=getValueFromXML('ItemRetailPrice', xXML);
            MM_findObj("ctl00_ContentPlaceHolder_lblRRP").innerHTML="&pound;"+formatAsMoney(ItemRetailPrice);
            ItemPrice=getValueFromXML('ItemPrice', xXML);
            MM_findObj("ctl00_ContentPlaceHolder_lblPrice").innerHTML="&pound;"+formatAsMoney(ItemPrice);
            WasPrice=getValueFromXML('WasPrice', xXML);
            MM_findObj("ctl00_ContentPlaceHolder_lblWasPrice").innerHTML="&pound;"+formatAsMoney(WasPrice);
            WasSaving=getValueFromXML('WasSaving', xXML);
            MM_findObj("ctl00_ContentPlaceHolder_lblWasSaving").innerHTML="&pound;"+formatAsMoney(WasSaving);
            }
    }
    
      function DoRepeaterDynamicChanges(xXML, Price, pWas, pSave) 
    {
                
        //if(getValueFromXML('ItemImage', xXML))
            //{
            //theImage=getValueFromXML('ItemImage', xXML);
            //MM_findObj("ctl00_ContentPlaceHolder_imgProductImage").src='http://h4d-website.multimedia.co.uk/Gallery/'+theImage;
            
                        
            wasprice=getValueFromXML('WasPrice', xXML);
            ItemRetailPrice=getValueFromXML('ItemRetailPrice', xXML);
            ItemPrice=getValueFromXML('ItemPrice', xXML);
            Save=getValueFromXML('WasSaving', xXML);
            
                           
            if (wasprice > '')
            {
                if (wasprice > ItemPrice)
                {
                    MM_findObj(pWas).innerHTML="WAS:" + "&pound;"+parseFloat(wasprice,2);
                    MM_findObj(Price).innerHTML="&pound;"+parseFloat(ItemPrice,2);
                    return;
                }
            }
            
            if (ItemRetailPrice > ItemPrice)
            {
                MM_findObj(pWas).innerHTML="RRP:" + "&pound;"+parseFloat(ItemRetailPrice,2);
                MM_findObj(Price).innerHTML="&pound;"+parseFloat(ItemPrice,2);
                return;
            }
            
           
            

            
            //}
    }