﻿// JScript File

   
    function ClearValue(field, strCheck)
        {
	        if(field.value == strCheck)
	        field.value = "";				
        }
    function Repopulate(field, strCheck)
        {
	        if(field.value == "")
	        field.value = strCheck;
        }	


    function doClick(buttonName,e)
    {

        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
   }


    function doClick(buttonName,e)
    {

        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
   }


    function handleError() {
	    return true;
    }

//    window.onerror = handleError;

    function switchMenu(obj, linkText) {
        var el = document.getElementById(obj);
        var filterstore = document.getElementById('filter_FilterDrops');
        var switchlink = document.getElementById(obj + 'link');

        
        if ( el.style.display != "none" ) {
            // close it
	        el.style.display = 'none';
	        filterstore.value += obj + 'c|';
	        switchlink.innerHTML = '» Show' + linkText;
        }
        else {
            // open it
	        el.style.display = '';
	        filterstore.value += obj + 'o|';
	        switchlink.innerHTML = '» Hide' + linkText;
        }
    }


    function closeMenu(obj) {
        var el = document.getElementById(obj);
	        el.style.display = 'none';
    }

    function openMenu(obj) {
    var el = document.getElementById(obj);
	        el.style.display = '';
    }


    function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
      var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
      return newnumber; // Output the result to the form field (change for your purposes)
    }

    function getXMLHTTP() {
        var XMLHTTP = null;
        if (window.ActiveXObject) {
            try {
                XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                }
            }
        } else if (window.XMLHttpRequest) {
            try {
                XMLHTTP = new XMLHttpRequest();
            } catch (e) {
            }
        }
        return XMLHTTP;
    }
    
        function stateChanged() {
            if (XMLHTTP.readyState == 4 &&
                XMLHTTP.status ==200) {
                if (XMLHTTP.responseText == 'diff') {
                    window.alert("When choosing products to compare, they must be of the same type. For example, you can only compare laminate products with other laminate products. To compare a different type of product you must first remove the other products from your comparison range. To view your current compared products, please click on the 'Compare Selected' link.");
                }
            }
        }
        
	    var XMLHTTP = getXMLHTTP();

        function addToCompareBasket(productID) {
            if (XMLHTTP != null) {
                XMLHTTP.open("GET", "process.aspx?sendData=ok&mode=ADDCOMPARE&productid=" + productID, true);
                XMLHTTP.onreadystatechange = stateChanged;
                XMLHTTP.send(null);
            }
        }


    function textboxMultilineMaxNumber(txt,maxLen){   
        try{   
            if(txt.value.length > (maxLen-1))

            return false;   
           }catch(e){   
           }   
    }   
    
