function ActiveItem(el, DescBox, colour) { el.style.cursor = 'pointer'; }
function changeimage(srcval, el, smallsrc, ImgName, URLPartCode) {
    document.getElementById('extraimage').src = srcval; document.getElementById('extraimage').width = '200'; document.getElementById('extraimage').height = '200'; el.src = smallsrc; el.width = '40'; el.height = '40'; if (ImgName == 'Original')
    { document.getElementById('ImageLink').href = 'ProductImages.asp?pn=' + URLPartCode; }
    else
    { document.getElementById('ImageLink').href = 'ProductImages.asp?pn=' + URLPartCode + '&img=' + ImgName; } 
}
function ActiveItemout(elval, colour) { }
function tabbgchange(el, colourstr)
{ el.style.backgroundColor = colourstr; el.style.color = '#FF3399'; el.style.cursor = 'pointer'; }
function tabbgchangeback(el, colourstr)
{ el.style.backgroundColor = colourstr; el.style.color = '#333333'; }
function Homepagehover(el, colourstr)
{ el.style.cursor = 'pointer'; el.style.backgroundColor = colourstr; }
function Homepagehoverout(el, colourstr)
{ el.style.backgroundColor = colourstr; }
function leftmenuhover(el, colourstr)
{ el.style.cursor = 'pointer'; el.style.backgroundColor = colourstr; }
function leftmenuhoversubout(el, colourstr, BlockCell)
{ el.style.cursor = 'pointer'; el.style.backgroundColor = colourstr; document.getElementById(BlockCell).style.display = 'none'; }
function leftmenuhoversub(el, colourstr, BlockCell)
{ el.style.cursor = 'pointer'; el.style.backgroundColor = colourstr; document.getElementById(BlockCell).style.display = 'block'; }
function gotoLink(link) { location.href = link; }
function image_display(Value) {
    tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("images/products/"); location = location + id; if (tools.FileExists(location))
    { image = "images/products" + Value + ".jpg" }
    else {
        tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("images/smallopenproducts/"); location = location + id; if (tools.FileExists(location))
        { image = "images/smallopenproducts" + Value + ".jpg" }
        else {
            if (session("MAccount Code") != null)
            { image = "systemsassurance/images/blank.gif" }
            else
            { image = Session("shop") + "/images/blank.gif" } 
        } 
    }
    tools = "nothing"; Value = 0; Response.Write(image);
}
function systems_image_display(Value) {
    tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("productimages/products/"); location = location + id; if (tools.FileExists(location))
    { image = "productimages/products" + Value + ".jpg" }
    else {
        tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("productimages/smallopenproducts/"); location = location + id; if (tools.FileExists(location))
        { image = "productimages/smallopenproducts" + Value + ".jpg" }
        else {
            if (session("MAccount Code") != null)
            { image = "/images/blank.gif" }
            else
            { image = "/images/blank.gif" } 
        } 
    }
    tools = "nothing"; Value = 0; Response.Write(image);
}
function systems_image_nonedisplay(Value_check, code_check) {
    tools_check = Server.CreateObject("scripting.FilesystemObject"); id_check = Value_check + ".jpg"; location_check = Server.Mappath("productimages/products/"); location_check = location_check + id_check; if (tools_check.FileExists(location_check))
    { image_check = "productimages/products" + Value_check + ".jpg" }
    else {
        if (session("MAccount Code") != null)
        { image_check = "/images/blank.gif" }
        else
        { image_check = Session("shop") + "/images/blank.gif" } 
    }
    tools_check = "nothing"; Value_check = 0; return image_check;
}
function image_display1(Value) {
    tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("images/largeproducts/"); location = location + id; if (tools.FileExists(location))
    { image = "images/largeproducts" + check_hash(Value) + ".jpg" }
    else {
        tools = Server.CreateObject("scripting.FilesystemObject"); name = Value + ".jpg"; position = Server.Mappath("images/openproducts/"); position = position + name; if (tools.FileExists(position))
        { image = "/images/openproducts/" + check_hash(Value) + ".jpg" }
        else {
            tools = Server.CreateObject("scripting.FilesystemObject"); name2 = Value + ".jpg"; position2 = Server.Mappath("images/products/"); position2 = position2 + name2; if (tools.FileExists(position2))
            { image = "/images/products/" + check_hash(Value) + ".jpg" }
            else
            { image = "/images/largeproducts/noimage.jpg" } 
        } 
    }
    tools = "nothing"; Value = 0; Response.Write(image);
}
function systems_image_display1(Value) {
    tools = Server.CreateObject("scripting.FilesystemObject"); id = Value + ".jpg"; location = Server.Mappath("productimages/largeproducts/"); location = location + id; if (tools.FileExists(location))
    { image = "productimages/largeproducts" + check_hash(Value) + ".jpg" }
    else {
        tools = Server.CreateObject("scripting.FilesystemObject"); name = Value + ".jpg"; position = Server.Mappath("productimages/openproducts/"); position = position + name; if (tools.FileExists(position))
        { image = "/productimages/openproducts" + check_hash(Value) + ".jpg" }
        else {
            tools = Server.CreateObject("scripting.FilesystemObject"); name = Value + ".jpg"; position = Server.Mappath("productimages/products/"); position = position + name; if (tools.FileExists(position))
            { image = "/productimages/products" + check_hash(Value) + ".jpg" }
            else
            { image = "/productimages/largeproducts/noimage.jpg" } 
        } 
    }
    tools = "nothing"; Value = 0; Response.Write(image);
}
function delete_for(form, name) {
    test = eval("document.all." + form + "." + name + ".value"); d = "document.all." + form + "." + name + ".value"; test1 = eval("document.all." + form + "." + name); pos = 0; leng = test.length
    count = 0; for (pos = 0; pos < leng; pos++) {
        if (isNaN(test.substring(pos, pos + 1)) == true)
        { count = 1; rExp = /\D*/g; newstring = new String(""); checker = test.replace(rExp, newstring); eval(d + "=" + "'" + checker + "'"); } 
    }
    if (count == 1)
    { again = setTimeout("delete_for('" + form + "','" + name + "')", 1); } 
}
function somethingthere(form, name) {
    change = eval("document." + form + "." + name + ".value.length"); if (change < 1)
    { eval("document." + form + "." + name + ".value = 1"); } 
}
function dont() {
    if (event.keyCode == 13)
    { alert("Please don't press Enter or Return during this process"); event.keyCode = 0; } 
}
function somethingthere(form, name) {
    change = eval("document." + form + "." + name + ".value.length"); if (change < 1)
    { eval("document." + form + "." + name + ".value = 1"); } 
}
function format_page()
{ document.submitorder.CardHolder.value = ""; document.submitorder.CreditCard.value = ""; document.submitorder.CCNo.value = ""; document.submitorder.IssueNo.value = ""; document.submitorder.aboutus.value = ""; }
function brands() { document.getElementById('brands').style.display = 'block'; document.getElementById('categories').style.display = 'none'; document.getElementById('brandssub').style.display = 'block'; document.getElementById('categoriesssub').style.display = 'none'; }
function categories() { document.getElementById('categories').style.display = 'block'; document.getElementById('brands').style.display = 'none'; document.getElementById('brandssub').style.display = 'none'; document.getElementById('categoriesssub').style.display = 'block'; }
function checkshop(shop, el, link) { el.style.background = '#F3f3f3'; el.innerHTML = shop + " - Loading"; location.href = link; }
function changeActiveLink(el, colour) { el.style.background = colour; el.style.cursor = 'pointer'; }
function changeNormalLink(el, colour) { el.style.background = colour; }
function gotoActiveLink(link) { location.href = link; }
function checkLength() {
    if (document.advancedsearch.query_info.value.length > 1)
    { return true; }
    else
    { alert("please be more specific"); return false; } 
}
function pagerefine(action)
{ document.getElementById('refine').action = action; document.getElementById('refine').submit(); }
function nextpage(pagenum) { document.SalesAssistant.PageNo.value = pagenum; document.SalesAssistant.submit(); }
function OpenWindow2(url) { window.open(url, "_blank", "toolbar=Yes, location=No, directories=Yes, status=Yes, menubar=Yes, scrollbars=yes, resizable=Yes, copyhistory=yes, top=0, Left=0") }
function OpenWindow(url) { window.open(url, "_blank", "toolbar=Yes, location=No, directories=Yes, status=Yes, menubar=Yes, scrollbars=yes, resizable=Yes, copyhistory=yes, top=0, Left=0") }
function addBookMark() {
    who = '<%=session("strpagetosend")%>'; title = 'Morecomputers Product <%=server.HTMLEncode(altstrtitle)%>'; ver = navigator.appName
    num = parseInt(navigator.appVersion)
    if ((ver == 'Microsoft Internet Explorer') && (num >= 4))
    { window.external.AddFavorite(who, title); }
    else
    { alert("Please press ctrl+D to bookmark this page"); } 
}
function MM_openBrWindow(theURL, winName, features)
{ window.open(theURL, winName, features); }
function RunLoadingGifProductPage()
{ var imageObj = document.getElementById("loadingProductPageGif"); imageObj.style.display = 'inline'; setTimeout(function() { imageObj.src = imageObj.src; }, 50); }

function DelSelectErr() {
    alert("Please select a delivery option");
    $("#DelErrAst").get(0).style.display = "inline";
    $("#DelErrMsg").get(0).style.display = "block";
}

function GetMonName(d) {

    var month = new Array(12);
    month[0] = "January";
    month[1] = "Febuary";
    month[2] = "March";
    month[3] = "April";
    month[4] = "May";
    month[5] = "June";
    month[6] = "July";
    month[7] = "August";
    month[8] = "September";
    month[9] = "October";
    month[10] = "November";
    month[11] = "December";

    return month[d.getUTCMonth()];

}

function SetUpShoppingAround() {

    $("#ShoppingAround").get(0).style.display = "block";

    $('#ShopAround').click(function() {
        //$('#').bPopup(); return false;
    });

    $('#ShopAround').get(0).href = "javascript:void(0);";
    
}

var xmlhttpLoadXMLDoc;
var xmlDocLoadXML;
var xhrTimeout;

function loadXMLDocFunction(url) {

    xmlhttpLoadXMLDoc = null;

    $('#CheckingStockArea').get(0).style.display = 'block';
    $('#QtyBox').get(0).style.display = 'none';
    $('#BuyImg').get(0).style.display = 'none';

    if (window.XMLHttpRequest) {
        xmlhttpLoadXMLDoc = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        xmlhttpLoadXMLDoc = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
    }

    if (xmlhttpLoadXMLDoc != null) {
        xmlhttpLoadXMLDoc.onreadystatechange = state_ChangeFunction;
        xmlhttpLoadXMLDoc.open("GET", url, true);
        xmlhttpLoadXMLDoc.send(null);

        xhrTimeout = setTimeout("ajaxTimeout();", 3000);

    }
    else {
        $("#CheckingStockArea").get(0).style.display = 'none';
        $("#QtyBox").get(0).style.display = 'block';
        $("#BuyImg").get(0).style.display = 'block';
    }
    
}

function ajaxTimeout() {

    xmlhttpLoadXMLDoc.abort();

    $("#CheckingStockArea").get(0).style.display = 'none';
    $("#QtyBox").get(0).style.display = 'block';
    $("#BuyImg").get(0).style.display = 'block';

}


function state_ChangeFunction() {
    if (xmlhttpLoadXMLDoc.readyState == 4) {
        if (xmlhttpLoadXMLDoc.status == 200) {

            clearTimeout(xhrTimeout);
            
            try {
                xmlDocLoadXML = xmlhttpLoadXMLDoc.responseXML;

                var x = xmlDocLoadXML.getElementsByTagName("product");

                for (i = 0; i < x.length; i++) {
                    var ErrMsgStr = x[i].getAttribute("ERRMsg");

                    if (ErrMsgStr == "rln") {
                        window.setTimeout('location.reload()', 500);
                    }

                    if (ErrMsgStr != "Not Run") {

                        var d1 = new Date();

                        var MinuteVal = d1.getMinutes().toString();

                        try {
                            if (MinuteVal.toString().length == 1) {
                                MinuteVal = '0' + d1.getMinutes().toString();
                            }
                        }
                        catch (ex) {
                        }

                        $("#AvailabilityDateTimeStamp").get(0).innerHTML = 'Availability checked: ' + d1.getUTCDate() + ' ' + GetMonName(d1) + ' ' + d1.getHours() + ':' + MinuteVal;
                        $("#CheckedSection").get(0).style.display = 'inline';

                    }

                    $("#DespatchStock").get(0).innerHTML = x[i].getElementsByTagName("stock")[0].childNodes[0].nodeValue;
                    $("#CheckingStockArea").get(0).style.display = 'none';
                    $("#QtyBox").get(0).style.display = 'block';
                    $("#BuyImg").get(0).style.display = 'block';
                    $(".ExVatPrice").get(0).innerHTML = '&pound;' + x[i].getElementsByTagName("priceExVAT")[0].childNodes[0].nodeValue + ' ex. VAT<br />';
                    $(".MainIncVat").get(0).innerHTML = '&pound;<span>' + x[i].getElementsByTagName("priceIncVAT")[0].childNodes[0].nodeValue.replace('.', '</span>.') + '<img src="/images/incVAT.gif" alt="Inc Vat" style="border: 0px none; padding-left: 3px;"><br />';
                }
            }
            catch (err) {
            }
        }
        else { 
        }
    }
}
