﻿// JScript File

function setColour(dropdown, productOptionID)
{
var spnColour = document.getElementById("colour_" + productOptionID);
var myIndex = dropdown.selectedIndex;
var colourCode
var split

split = dropdown.options[myIndex].value.split("_");
colourCode = split[3];
spnColour.innerHTML = "<img src='/assets/user/colours/" + colourCode + ".jpg' height='30' width='40' />";
}

function doSearch() {
    var objQ = document.getElementById("q");

    //  Redirect.
    window.location = "/products/search.aspx?q=" + objQ.value;
}

function doSearchKeypress(e) {
    var intKeyCode;

    if (window.event) // IE
    {
        intKeyCode = e.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        intKeyCode = e.which;
    }

    if (intKeyCode == 13) {
        document.getElementById("searchbutton").focus()
        doSearch();
    }
}

function setCommand( strCommandName, strCommandValue, strConfirm ) {
    var bConfirm;

    //  Request confirmation if necessary.
    if ( strConfirm != null ) {
        bConfirm = confirm( strConfirm );
    } else {
        bConfirm = true;
    }
    
    if ( bConfirm == true ) {

        //  Set the command.
        document.getElementById( "command_name" ).value = strCommandName;
        document.getElementById( "command_value" ).value = strCommandValue;

        //  Submit the form.
        document.getElementById( "aspnetForm" ).submit();
    }
}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) || (key==32) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;
   
else
   return false;
}