
    function ci(p1, p2) { // changeimage
       document[p1].src = "res/img/" + p2;
    }

    function getStyleObject(objectId) {
        // checkW3C DOM, then MSIE 4, then NN 4.
        if(document.getElementById && document.getElementById(objectId)) {
   	        return document.getElementById(objectId).style;
        }
        else if (document.all && document.all(objectId)) {  
            return document.all(objectId).style;
        } 
        else if (document.layers && document.layers[objectId]) { 
   	        return document.layers[objectId];
        } else {
   	        return false;
        }
    }
    function removeitem(sID,sTitle) {
        if (confirm("Remove\n\n'" + sTitle + "'\n\nfrom your shopping cart?")) {
            document.location.href = "_removefromcart.aspx?id=" + sID;
        }
    }
    function obsolete_add2cart(sProduct,sOptions) {
        //alert(sProduct + ":" + sOptions);
        document.location.href = "_add2cart.aspx?pc=" + sProduct + "&opt=" + sOptions;
        
        //http://www.codingforums.com/archive/index.php/t-71252.html
        //http://bytes.com/groups/javascript/92393-problem-dynamicaly-adding-hidden-form-element-ie-vs-nn
        //http://www.trans4mind.com/personal_development/JavaScript2/createSelectDynamicallyCODe.htm
        //mypara=document.getElementById("moreform");
        //myform=document.createElement("form");
        //myform.setAttribute("name",   "theForm"); // give form a name
        //myform.setAttribute("action", "product.aspx"); // give form an action
        //myform.setAttribute("method", "post"); // give form a method
        //newField = document.createElement("input");
        //newField.type = "hidden";
        //newField.name = "pc";
        //newField.value = sProduct;
        //myform.appendChild(newField);
        //mypara.appendChild(myform);
        //myform.submit(); 
    }
    function more(sProduct) {
        document.location.href = "product.aspx?pc=" + sProduct;
    }
    function IsValidEmail(EmailAddr) {
        return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(EmailAddr))
    }
    function Trim(str) { // trim leading and trailng whitespace
        if (!str) return "";
        return str.replace(/^\s+/, "").replace(/\s+$/, "");
    }
    function emailme(sPage,sQuery) {
        // '/course-description.aspx','cc=CAB-08&ccid=TELEC'
        var sBit = "?page=" + sPage;
        if (sQuery != "") sBit += "&" + sQuery;
        emailwindow = window.open("_emailpage.aspx" + sBit ,'emailwindow','width=500,height=300,screenX=200,screenY=200,left=200,top=200,scrollbars=yes,toolbars=no,menubar=no,resizable=yes');
        emailwindow.focus();
    }
    function changeObjectVisibility(objectId, newVisibility) {
        // first get a reference to the cross-browser style object 
        // and make sure the object exists
        var styleObject = getStyleObject(objectId);
        if(styleObject) {
    	    styleObject.visibility = newVisibility;
    	    return true;
        } else {
    	    // we couldn't find the object, so we can't change its visibility
    	    return false;
        }
    }
    
function IsNumeric(strString) {      //  check for valid numeric strings  
 
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;
    var i;
      
      strString = strString.replace(/ /g, ""); // remove spaces
      if (strString.length == 0) return false;
   
      //  test strString consists of valid characters listed above
      for (i = 0; i < strString.length && blnResult == true; i++) {
         strChar = strString.charAt(i);
         if (strValidChars.indexOf(strChar) == -1) blnResult = false;
      }
      return blnResult;
   }

    
    function showPanel2(PanelName,ImageName,xoffset,yoffset) {
        var menuPosition = imgXY(ImageName);                                    /* detect the coordinates of the specified image */
        showPanel(PanelName, menuPosition.x+xoffset, menuPosition.y+yoffset);   /* display the menu x-offset and y-offset from upper left corner of image */
    }

    function imgXY(imgID) {                                                     /* This function returns the upperleft x,y coordinates of the specified image */
        var XY = new Object();
        var imgObj = document.images[imgID];
        if (document.layers) {
            XY.x = eval(imgObj).x;
            XY.y = eval(imgObj).y;
        } else {
            var x,y, tempEl;
            x = eval(imgObj).offsetLeft;
            y = eval(imgObj).offsetTop;
            tempEl = eval(imgObj).offsetParent;
            while (tempEl != null) {
                x += tempEl.offsetLeft;
                y += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
            }
            XY.x = x;
            XY.y = y;
        }
        return XY;
    }

    // Calculate real offset values of elements
    function xgetOffset(el, offsetType) {
        var offset = 0;
        while(el) {
            offset += el[offsetType]; 
            el = el.offsetParent;
        }
        return offset;
    }
    
    function showPanel3(ezMenu,oCell,xAdjust,yAdjust) {
        var posy = xgetOffset(oCell, 'offsetTop') + oCell.offsetHeight;
        var posx = xgetOffset(oCell, 'offsetLeft');
        showPanel(ezMenu, posx+xAdjust, posy+yAdjust);
    }
    
    function boldit(oHref,bBold) {
        var oStyle = getStyleObject(oHref);
        if (bBold)
            oStyle.fontWeight="bold";
        else
            oStyle.fontWeight="normal";
    }
    
    function addToFavorites(urlAddress,pageName) {
        if (window.external) {
            window.external.AddFavorite(urlAddress,pageName)
        } else { 
            alert("Sorry! Your browser doesn't support this function.");
        }
    }
    
    function GetDeliveryCharge() {
        var pop_win = window.open("", "win2","width=400 height=400");
        pop_win.document.open("text/html", "replace");
        pop_win.document.write("<HTML><HEAD><title>Divine Equine Delivery Costs</title>");
        pop_win.document.write("<style>body,td {font-size:10pt;font-family:verdana}</style></HEAD>");
        pop_win.document.write("<body bgcolor=#EEE7CB leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0>");
        pop_win.document.write("<br><br>&nbsp;&nbsp;&nbsp;Enter your postcode <input type=text size=10 maxlength=10>");
        pop_win.document.write("<br><br>&nbsp;&nbsp;&nbsp;<input type=submit value='Calculate Delivery Charge'><br><br>");
        pop_win.document.write("&nbsp;&nbsp;&nbsp;<a href='javascript:self.close();'>Close</a>");
        pop_win.document.write("</body></HTML>");
        pop_win.focus();
    }    
    
    function SetPass() {
        var cPass = prompt("Well?",'');
        document.cookie="divine=" + escape(cPass) + ";path=/;";
        history.go(); 
    } 
       
    function intOnly(fld, e) {
        var strCheck = '0123456789';
        var whichCode = (window.Event) ? e.which : e.keyCode;
        if (whichCode == 13) return true; // Enter
        if (whichCode == 8) return true; // Delete (Bug fixed)
        key = String.fromCharCode(whichCode); // Get key value from key code
        if (strCheck.indexOf(key) == -1) return false; // Not a valid key
        return fld.value.length < 5 ? true : false;
    }
    
    function decimalOnly(fld, e) {
        var strCheck = '0123456789.';
        var whichCode = (window.Event) ? e.which : e.keyCode;
        if (whichCode == 13) return true; // Enter
        if (whichCode == 8) return true; // Delete (Bug fixed)
        key = String.fromCharCode(whichCode); // Get key value from key code
        if (strCheck.indexOf(key) == -1) return false; // Not a valid key
        return fld.value.length < 10 ? true : false;
    }
    function OpenCalc(iWeight) {
        var freight_win = window.open("freightcalculator.aspx?weight=" + iWeight + "","freightcalc","width=400 height=400");
    }
    
    
    
    
    