function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
};

function MM_preloadImages() { //v3.0
  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_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
};

/*========================================================================
similarColour	 	 used to search for items of similar colour
similarProducts 	 used to search for items of similar type
=========================================================================== */

function similarColours() {
 	document.productQuery.reset();
	window.parent.leftFrame.startLoading();
	document.productQuery.queryType.value = 2;
 	var colourNo;
 	colourNo = tableData[currentIndex][6];
 	document.productQuery.colourName.value = colourNo;
 	document.productQuery.productType.value = 0;
  	document.productQuery.productSubType.value = 0;
  	document.productQuery.pageToDisplay.value = -1;
 	document.productQuery.submit();
 };
 
function similarProducts() {
 	document.productQuery.reset();
	window.parent.leftFrame.startLoading();
	document.productQuery.queryType.value = 2;
 	var productNo;
 	productNo = tableData[currentIndex][4];
 	document.productQuery.productType.value = productNo;
   	document.productQuery.productSubType.value = 0;
	document.productQuery.colourName.value = 0;
 	document.productQuery.pageToDisplay.value = -1;
 	document.productQuery.submit();
 };
 
/*========================================================================
displayAPage	 	 used to navigate to a specific page
displayNextPage  	 used to display next page
displayPreviousPage  used to display previous page. If you are dealing
					 with Netscape browser then display a specific page
					 otherwise go back in history
=========================================================================== */
function displayAPage(aPageNo) {
        
		document.productQuery.reset();
		document.productQuery.pageToDisplay.value = aPageNo;
		document.productQuery.submit() ;
};
function displayPage() {
		anObject = findObject("selectList",0);
		aValue = anObject.value;
		displayAPage(aValue);
};

function displayNextPage() {
		anObject = findObject("selectList",0);
		aValue = anObject.value;
		aValue = parseInt(aValue) + 1;
		displayAPage(aValue);
};

function displayPreviousPage() {
		anObject = findObject("selectList",0);
		aValue = anObject.value;
		aValue = parseInt(aValue) -1;
		displayAPage(aValue);
	 };

/*========================================================================
Used to control the opening / closing of the personalisation page
when you are displaying a set of products.
personalise	 	 	is called when you slect the tools icon
openPersonalise		opens the personalisation layer
hidePersonalise		hides the Layer
=========================================================================== */

function personalise(xPos,yPos)
 { if (pageHasFinished)
      { openPersonalise(xPos,yPos);
	  };
 };
 
 function openPersonalise(xPos,yPos)
  {var temp = findObject("personalise",1);
  if (temp.visibility == 'visible')
      temp.visibility = 'hidden'
   else
      {	temp.left = xPos,
   		temp.top  = yPos;
    	document.configForm.incStep.value = parseInt(document.productQuery.incStep.value)+1;
 		document.configForm.productDim.value = document.productQuery.productDimensions.value;;
  		document.configForm.userCcy.value = document.productQuery.userCcy.value;
		if (!cookiesAreAllowed())
	  		{anObject = findObject("cookiesOption",1);
	    	  anObject.display = "none";
			  
	  		};
		temp.zIndex = 1;
   		temp.visibility = 'visible'; };
  };
   
  function hidePersonalise()
  {var temp = findObject("personalise",1);
   temp.visibility = 'hidden';
  };

/*========================================================================
Used to control the configuration setting of the personalisation page
displayProductsUsingSettings()	is called when you select options on the 
								product personalisation page
displayProductsUsingDefaults()	is called when you select the default options  
								on the product personalisation page
setPersonalisationDefaults()	is called when you select the defaults in
								the personalisation page
setPersonalisationOptions()		is called when you select options on the 
								personalisation page								
=========================================================================== */

 function displayProductsUsingSettings()
  {
   var newStep = parseInt(document.configForm.incStep.value) - 1;
   var newDim  = document.configForm.productDim.value;
   var newCcy  = document.configForm.userCcy.value;
   
   if (document.configForm.saveDataCheckBox.checked)
     		{setCookie('clientOptions',newStep+'|'+newCcy+'|'+newDim,false);
			 document.productQuery.saveData.value = '1'}
   else
     		{document.productQuery.saveData.value = '0'};    
	
   document.productQuery.incStep.value 				= newStep;
   document.productQuery.userCcy.value 				= newCcy;
   document.productQuery.productDimensions.value 	= newDim; 
   document.productQuery.pageToDisplay.value 		= -1;
   window.parent.leftFrame.setConfigValues(newStep,newCcy,newDim);
   document.productQuery.submit();
   };
   
function displayProductsUsingDefaults()
  {
	
   document.productQuery.incStep.value 				= 8;
   document.productQuery.userCcy.value 				= 'EUR';
   document.productQuery.productDimensions.value 	= 0; 
   document.productQuery.saveData.value 			= 0;  
   document.productQuery.pageToDisplay.value 		= -1;
   window.parent.leftFrame.setConfigValues(8,'EUR',0);
   document.productQuery.submit();
   };
   
function setPersonalisationDefaults()
  {
   document.configForm.incStep.value = 8;
   document.configForm.userCcy.value = 'EUR';
   document.configForm.productDim.value = 0; 
   document.configForm.saveData.value = 0; 
     window.parent.leftFrame.setConfigValues(8,'EUR',0); 
   document.configForm.submit();  
   };
   
 function setPersonalisationOptions()
  {
  newStep = parseInt(document.configForm.incStep.value) - 1;
  newCcy  = document.configForm.userCcy.value;
  newDim  = document.configForm.productDim.value; 
  if (document.configForm.saveDataCheckBox.checked)
     {setCookie('clientOptions',newStep+'|'+newCcy+'|'+newDim,false);
	  document.configForm.saveData.value = '1'}
  else
     {document.configForm.saveData.value = '0'};    
  	window.parent.leftFrame.setConfigValues(newStep,newCcy,newDim);
    document.configForm.submit();  
   };


/*========================================================================
displayProduct  is used to display a product
displaySubType  is used to displa a sub product
getCookieFlag   is ised to return the value of the cookie flag which is set 
  				by the leftFrame on startup
=========================================================================== */

 function displayProduct(aType)
   { window.parent.leftFrame.startLoading();
     document.productQuery.productType.value = aType;
   	 document.productQuery.productSubType.value = 0;
	 document.productQuery.incStep.value 		= window.parent.leftFrame.incStep
	 document.productQuery.userCcy.value 		= window.parent.leftFrame.userCcy	 
	 document.productQuery.productDimensions.value = window.parent.leftFrame.productDimensions
	 document.productQuery.submit();
   };

function displaySubType(aType,aSubType)
   { window.parent.leftFrame.startLoading();
     document.productQuery.productType.value = aType;
     document.productQuery.productSubType.value = aSubType;
	 document.productQuery.incStep.value 		= window.parent.leftFrame.incStep
	 document.productQuery.userCcy.value 		= window.parent.leftFrame.userCcy	 
	 document.productQuery.productDimensions.value = window.parent.leftFrame.productDimensions
	 document.productQuery.submit();
   };


/*========================================================================
checkForm			used to check the validity of the search form
listChanged 		is used to check whether the selection is valid and to 
					enable the submit button
=========================================================================== */

function checkForm() {

  if (priceRangeIsOkay() && dimensionsIsOkay())
     {	document.searchForm.incStep.value    = window.parent.leftFrame.incStep;
	 	document.searchForm.userCcy.value 	  = window.parent.leftFrame.userCcy;	 
	 	document.searchForm.productDim.value = window.parent.leftFrame.productDimensions;
   		window.parent.leftFrame.startLoading();
		return true; //should be true;
	  }
  else
      return false;
 };
 
 function dimensionsIsOkay() {
   var width 	= document.searchForm.width1.value
   var diameter = document.searchForm.diameter1.value
   var length	= document.searchForm.length1.value
   var height   = document.searchForm.height1.value
   
   	if (width =='')
        width = 0
   	else 
   		width = parseInt(width);
		
  	if (diameter =='')
        diameter = 0
   	else 
   		diameter = parseInt(diameter);
 
  	if (length =='')
        length = 0
   	else 
   		length = parseInt(length);

 	if (height =='')
        height = 0
   	else 
   		height = parseInt(height);

 	if ((width < 0) || (diameter < 0) || (height < 0) || (length < 0))
       	{alert('Dimensions must be greater than zero (0).');
        	return false};	 
 		  
   document.searchForm.width.value = width;
   document.searchForm.diameter.value = diameter;
   document.searchForm.height.value = height;   
   document.searchForm.length.value = length;
 
   return true;
 };
      
   
function priceRangeIsOkay() {
   var tDefault = false;
   var fDefault = false;
   var fPrice = document.searchForm.fromPrice1.value
   var tPrice = document.searchForm.toPrice1.value
   if (fPrice == '')
       {fPrice = 0
	   fDefault = true; }
   else
       fPrice = parseFloat(fPrice);

   if (tPrice == '')
       {tPrice = 0
	   tDefault = true; }
   else 
       tPrice = parseFloat(tPrice);
   
   if (((tPrice < 0) && (tDefault == false))  || ((fPrice < 0) &&  (fDefault == false)))
	      {alert('Prices must be grater than zero (0).');
        return false};
		
   if ((tPrice < fPrice) && (tDefault == false) && (fDefault == false))
       {alert('The From Price must be greater or equal to the To Price');
        return false};
   if ((tPrice - fPrice) > 20.00)
	   {alert('Maximum difference between prices must be 20.00.');
	    return false};
 	
	//alert(fPrice);
	//alert(tPrice);
   if ((fPrice > 0) && (tPrice <= 0))
   	  	{tPrice = fPrice + 20.00};
		 
   if ((tPrice > 0) && (fPrice <= 0))
   	  	{fPrice = tPrice - 20.00;
		 if (fPrice < 0)
		     {fPrice = 0}
	    };
   		
   fPrice = fPrice - ((fPrice * 17.5)/100);
   tPrice = tPrice - ((tPrice * 17.5)/100);	 
   document.searchForm.fromPrice.value = fPrice;
   document.searchForm.toPrice.value = tPrice;
   return true;
  };
  
  function listChanged(anObject) {
//  alert(anObject.value);
  var product 	= document.searchForm.productType.value;
  var colour  	= document.searchForm.colourName.value;
  var fPrice  	= document.searchForm.fromPrice1.value;
  var tPrice  	= document.searchForm.toPrice1.value;
  var width 	= document.searchForm.width1.value
  var diameter 	= document.searchForm.diameter1.value
  var length	= document.searchForm.length1.value
  var height   	= document.searchForm.height1.value
   
  if ((product > 0 ) || (colour > 0) ||  (fPrice > 0) || (tPrice > 0) || (width > 0) || (diameter > 0) || (length > 0) || (height > 0))
      document.searchForm.Submit.disabled = false;
  else
      document.searchForm.Submit.disabled = true;   
  };
  
  
/*========================================================================
findObject 			find an object reference wither withStyle (1) or without (0)
isBrowserNetscape 	test to see if the browser is Netscape

=========================================================================== */

function findObject(objectID,withStyle) {


var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
if (document.getElementById) 
          {isID = 1; isDHTML = 1;}
     else {if (document.all) {isAll = 1; isDHTML = 1;}
             else {browserVersion = parseInt(navigator.appVersion);
                   if((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) 
                        {isLayers = 1; isDHTML = 1;}
                  }
          };

 if (withStyle == 1) 
	{if (isID) { return(document.getElementById(objectID).style) ; }		
            else { if (isAll) { return (document.all[objectID].style); }	
                       else {if (isLayers) { return (document.layers[objectID]); }};
                 }
        }
	
    else {if (isID) { return (document.getElementById(objectID)) ; }		
             else {if (isAll) { return (document.all[objectID]); }		
                       else {if (isLayers) { return (document.layers[objectID]); }};
          }
     }
};

function isBrowserNetscape() 
	{
	 var nav = navigator.appName.indexOf("Netscape");
	 return nav;
	};

/*========================================================================
displayProduct  is used to display a product
displaySubType  is used to displa a sub product
getCookieFlag   is ised to return the value of the cookie flag which is set 
  				by the leftFrame on startup
=========================================================================== */

 function printProduct()
   { window.parent.leftFrame.startLoading();
    
	 var winl = 665;
	 var wint = 570;  //570
     winprops = 'height='+wint+',width='+winl+',top='+0+',left='+0+',scrollbars='+'yes'+',resizable='+'yes'+',menubar='+'yes';
	 win = window.open("", "PrintView", winprops);
	 
     document.productQuery.action = "../asp/processPrintRequest.asp";
	 document.productQuery.target = "PrintView";

	 aType    = tableData[currentIndex][4];
	 aSubType = tableData[currentIndex][7];
	 aColour  = tableData[currentIndex][6];
//	 alert(aType+' | '+aSubType+' | '+aColour);
	 document.productQuery.queryType.value = 2;
     document.productQuery.productType.value = aType;
   	 document.productQuery.productSubType.value = aSubType;
	 document.productQuery.colourName.value = aColour;
	 document.productQuery.incStep.value 		= window.parent.leftFrame.incStep
	 document.productQuery.userCcy.value 		= window.parent.leftFrame.userCcy	 
	 document.productQuery.productDimensions.value = window.parent.leftFrame.productDimensions
//	 alert(document.productQuery.action);
//	 alert(document.productQuery.target);
	 document.productQuery.submit();
	 document.productQuery.action = "../asp/processUserSearch.asp";
	 document.productQuery.target = "mainFrame";
	 window.parent.leftFrame.stopLoading();
   };
   
   function printProduct1(aType)
   { window.parent.leftFrame.startLoading();
    
	 var winl = 665;
	 var wint = 570;  //570
     winprops = 'height='+wint+',width='+winl+',top='+0+',left='+0+',scrollbars='+'yes'+',resizable='+'yes'+',menubar='+'yes';
	 win = window.open("", "PrintView", winprops);
	 
     document.productQuery.action = "../asp/processPrintRequest.asp";
	 document.productQuery.target = "PrintView";
	 alert(aType);
	 document.productQuery.queryType.value = 2;
     document.productQuery.productType.value = aType;
   	 document.productQuery.productSubType.value = 10;
	 document.productQuery.colourName.value = 18;
	 document.productQuery.incStep.value 		= window.parent.leftFrame.incStep
	 document.productQuery.userCcy.value 		= window.parent.leftFrame.userCcy	 
	 document.productQuery.productDimensions.value = window.parent.leftFrame.productDimensions
//	 alert(document.productQuery.action);
//	 alert(document.productQuery.target);
	 document.productQuery.submit();
	 document.productQuery.action = "../asp/processUserSearch.asp";
	 document.productQuery.target = "mainFrame";
   };