﻿function setFilter(FilterID, FilterValue) {
    var qURL = location.href;
    qURL = qURL.replace(/\?.*/, "");
    if (FilterValue != '') {
        if (location.href.indexOf("?") == "-1") {
            qURL = qURL + '?&f' + FilterID + '=' + urlencode(FilterValue);
        }
        else {
            qURL = qURL + '?&f' + FilterID + '=' + urlencode(FilterValue);
        }
        location.href = qURL;
    }
}

function setNoFilter() {
    var URL = location.href;
    URL = URL.replace(/\?.*/,"");
    location.href = URL;
}

function urlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson

    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };

    var ret = '',
            unreserved = /[\w.-]/;
    str = (str + '').toString();

    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            if (code === 32) {
                ret += '+';
            }
            else if (code < 128) {
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) {
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) {
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;

}

function RemoveFilter(variable) {
    var URL = RemoveQuery(variable);
    location.href = "productlist.aspx" + URL;
}

function GetAdditionalProducts(StockID, Qty) {
    var counter = 0;
    var i = 0;
    var url = '';
    var input_obj = document.getElementsByTagName('input');
    for (i = 0; i < input_obj.length; i++) {
        if (input_obj[i].type == 'checkbox' && input_obj[i].checked == true) {
            counter++;
            url = url + ', ' + input_obj[i].value;
        }
    }
    if (counter > 0) {
        // remove first '&' from the generated url string
        url = url.substr(1);
        // display final url string
        setTimeout(function () {
            window.location = '/basket/addmultipletobasket.aspx?StockID=' + StockID + '&Stock_Qty=' + Qty + '&AddProductID=' + url
        }, 0);
    } else {
        //FIREFOX DOES NOT LIKE &AMP;
        setTimeout(function () {
            window.location = '/basket/addmultipletobasket.aspx?StockID=' + StockID + '&Stock_Qty=' + Qty;
        }, 0);

    }

}

function showhide(id) {
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            //obj.style.display = "";
            $('#' + id).fadeIn(); 
            document.getElementById("Arrow").src = '/userpages/images/buttons/ArrowUp.jpg';
        }
        else {
            //obj.style.display = "none";
            $('#' + id).fadeOut();
            document.getElementById("Arrow").src = '/userpages/images/buttons/Arrow.jpg';
        }
    }
}
function ValidateLogin() {
    alert("validation here");
}

function setShipping(varID) {
    var URL = self.location.href.replace(/(\?.*)/, "");
    self.location.href = URL + "?ShippingID=" + varID;
}

function SetShippingWrapper(varID) {
try {
    document.getElementById("ShippingDisplayInfo_" + varID).style.display = "";
    document.getElementById("ShippingWrapper_" + varID).setAttribute("class", "ShippingWrapperBorder");
} catch(e)
{}
}

function popUp(URL, width, height, scroll) {
    var settings
    settings = "width=" + width + ",height=" + height + ",scrollbars=" + scroll + ",toolbar=no";
    popwin = window.open(URL, "FAFSPORT", settings);
    popwin.focus();
}

function ShowChangePasswords() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_ChangePassword").checked == true) {
        document.getElementById("ChangePassword").style.display = 'block';
        document.getElementById("ChangePasswordC").style.display = 'block';
    } else {
        document.getElementById("ChangePassword").style.display = 'none';
        document.getElementById("ChangePasswordC").style.display = 'none';
    }
}

function ValidateEditMyDetails() {
    var sMsg = '';
    if (document.getElementById("ctl00_ContentPlaceHolder1_TitleEdit").value == '') { sMsg = sMsg + 'Please enter your title.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_FirstName").value == '') { sMsg = sMsg + 'Please enter your first name.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Surname").value == '') { sMsg = sMsg + 'Please enter your surname.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Address1").value == '') { sMsg = sMsg + 'Please enter the first line of your address.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Town").value == '') { sMsg = sMsg + 'Please enter your town/city.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Postcode").value == '') { sMsg = sMsg + 'Please enter your postcode.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Email").value == '') { sMsg = sMsg + 'Please enter your email address.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Telephone").value == '') { sMsg = sMsg + 'Please enter your telephone number.\n'; }
    if (sMsg == '') { return true; } else { alert(sMsg); return false; }
}

function ShowOther() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_TitleEdit").value == 'Other') {
        document.getElementById("OtherDescription").style.display = 'block';
    } else {
        document.getElementById("OtherDescription").style.display = 'none';
    }
}

function ShowIntrests() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_CheckBox1").checked == true) {
        document.getElementById("Intrests").style.display = 'block';
    } else {
        document.getElementById("Intrests").style.display = 'none';
    }
}

function ValidateNewsletter() {
    var sMsg = '';
    if (document.getElementById("Email").value == '') { sMsg = sMsg + 'Please enter your Email.\n'; }
    if (isValidEmail(document.getElementById("Email").value) == false) { sMsg = sMsg + "Invalid email address\n"; }

    if (sMsg == '') { return true; } else { alert(sMsg); return false; }
}

function isValidEmail(str) {
    return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function CheckSearch(e) {
    if (e.keyCode == 13) {
        searchProducts();
    }
}
function searchProducts() {
    location.href = "/productlist.aspx?searchstring=" + document.getElementById("SearchBox").value;
    return false;
}
function searchBrands() {
    location.href = "/productlist.aspx?searchstring=" + document.getElementById("Brands").value;
    return false;
}

/****************left nav*****************/

function ShowLeftMenu(varID) {
    try {
        document.getElementById(varID).style.display = 'block';
    }
    catch (e) { }
}

function HideLeftMenu(varID) {
    try {
        document.getElementById(varID).style.display = 'none';
    }
    catch (e) { }
}

/*********PRODS PER PAGE**********/

function SetProdsPerPage(varValue) {
    var strPrefix = "?";
    var URL = RemoveQuery("PP");
    if (URL.substring(0, 1) == "?") { strPrefix = "&"; }
    location.href = "/productlist.aspx" + URL + strPrefix + 'PP=' + varValue;
}

function RemoveQuery(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    var URL = "";
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0].toString().toLowerCase() != variable.toString().toLowerCase()) {
            URL = URL + '&' + pair[0] + '=' + pair[1];
        }
    }
    if (URL.toString().substring(0, 1) == '&') {
        URL = '?' + URL.toString().substring(1, URL.toString().length);
    }
    if (URL == "?=undefined") { URL = ""; }
    return URL;
}

function SetSortBy(varSortValue) {
    var strPrefix = "?&";
    var URL = RemoveQuery("SortBy");
    if (URL.substring(0, 1) == "?") { strPrefix = "&"; }
    location.href = window.location + strPrefix + 'SortBy=' + varSortValue;
}

/*************PERSONALIDATION****************/

function ShowPersonalisation(varID) {
    if (document.getElementById) {
        obj = document.getElementById(varID);
        if (obj.style.display == "none") {
            obj.style.display = "";
        }
        else {
            obj.style.display = "none";
        }
    } 
}

/* ************************************ QUICK SHOP ************************************* */
function moveOption(fromID, toID, idx) {
    if (isNaN(parseInt(idx))) {
        var i = document.getElementById(fromID).selectedIndex;
    }
    else {
        var i = idx;
    }

    var o = document.getElementById(fromID).options[i];
    var theOpt = new Option(o.text, o.value, false, false);
    document.getElementById(toID).options[document.getElementById(toID).options.length] = theOpt;
    document.getElementById(fromID).options[i] = null;
}

function GetDetails(RowCount) {
    var replacedfirst = false;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            document.getElementById("ProductName_" + RowCount + "").innerHTML = document.getElementById("QuickOrderCheckProductName").value;
            document.getElementById("RRP_" + RowCount + "").innerHTML = document.getElementById("QuickOrderCheckProductRRP").value;
            document.getElementById("Price_" + RowCount + "").innerHTML = document.getElementById("QuickOrderCheckProductSelling").value;
            document.getElementById("Stock_" + RowCount + "").innerHTML = document.getElementById("QuickOrderCheckStockLevel").value;
            document.getElementById("cboQty_" + RowCount + "").disabled = false;

            document.getElementById("ColourID_" + RowCount + "").options.length = 0;
            AddOptions2(document.getElementById("ColourID_" + RowCount + ""), "Select Colour", "Select Colour");
            for (var x = document.getElementById("QuickOrderCheckProductColour").options.length - 1; x >= 0; x--) { moveOption("QuickOrderCheckProductColour", "ColourID_" + RowCount + "", x); }

            document.getElementById("ColourID_" + RowCount + "").disabled = false;

        }
    }
    xmlhttp.open("GET", "quickshoplookup.aspx?PID=" + document.getElementById("ProdCode_" + RowCount + "").value + "", true);
    xmlhttp.send();
}

function QuckShop_UpdateColour(RowCount, ColourID) {
        var replacedfirst = false;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;

                document.getElementById("SizeID_" + RowCount + "").options.length = 0;
                AddOptions2(document.getElementById("SizeID_" + RowCount + ""), "Select Size", "Select Size");
                for (var x = document.getElementById("Stock_QuickOrderCheckProductSize").options.length - 1; x >= 0; x--) { moveOption("Stock_QuickOrderCheckProductSize", "SizeID_" + RowCount + "", x); }

                document.getElementById("SizeID_" + RowCount + "").disabled = false;
            }
        }
        if (ColourID != 'Select Colour') {
            xmlhttp.open("GET", "QuickShopLookupSize.aspx?PID=" + document.getElementById("ProdCode_" + RowCount + "").value + "&ColourID=" + ColourID + "", true);
            xmlhttp.send();
        } else {
            document.getElementById("SizeID_" + RowCount + "").options.length = 0;
            AddOptions2(document.getElementById("SizeID_" + RowCount + ""), "Select Size", "Select Size");
            document.getElementById("SizeID_" + RowCount + "").disabled = true;
        }
}

function QuckShop_UpdateStock(RowCount, SizeID) {
    var ColourID = document.getElementById("ColourID_" + RowCount + "").value;
    var replacedfirst = false;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            document.getElementById("Price_" + RowCount + "").innerHTML = document.getElementById("UpdateStock_QuickOrderCheckProductSelling").value;
            document.getElementById("Stock_" + RowCount + "").innerHTML = document.getElementById("UpdateStock_QuickOrderCheckStockLevel").value;
            document.getElementById("StockID_" + RowCount + "").value = document.getElementById("UpdateStock_QuickOrderCheckStockID").value;
        }
    }
    xmlhttp.open("GET", "QuickShopLookupStock.aspx?PID=" + document.getElementById("ProdCode_" + RowCount + "").value + "&ColourID=" + ColourID + "&SizeID=" + SizeID + "", true);
    xmlhttp.send();
}

function AddOptions2(sel, text, value) {
    var opt = new Option(text, value);
    sel.options[sel.options.length] = opt;
}

function ValidateQuickShop(){
    var sMsg = '';
    var i = 1;
    for (i = 1; i <= 10; i++) {
        if (document.getElementById("StockID_" + i).value != "") {
            if (document.getElementById("ColourID_" + i + "").value == 'Select Colour') { sMsg = sMsg + 'Please select a colour for line ' + i + '.\n'; }
            if (document.getElementById("SizeID_" + i + "").value == 'Select Size') { sMsg = sMsg + 'Please select a size for line ' + i + '.\n'; }
            if (document.getElementById("cboQty_" + i + "").value == '') { sMsg = sMsg + 'Please enter a quantity for line ' + i + '.\n'; }
            if (document.getElementById("cboQty_" + i + "").value == '0') { sMsg = sMsg + 'Please enter a quantity for line ' + i + '.\n'; }
        }
    }
    if (sMsg == '') { return true; } else { alert(sMsg); return false; }
}

/* ************************************ PRODUCT REVIEW ************************************* */

function AddProductReview() {
    document.getElementById("ProductAddReview").style.display = "";
    window.location.hash = "Reviews";
}

function AjaxGetDataProductReview(url, responseHandler) {
    if (window.XMLHttpRequest) {        
        reqMail = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {          
        reqMail = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (reqMail) {
        reqMail.onreadystatechange = responseHandler;
        reqMail.open('get', url, true);
        reqMail.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        reqMail.setRequestHeader("Cache-Control", "no-cache");
        reqMail.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        reqMail.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler_ProductReview() {
    try { 
        if (reqMail.readyState == 4 ||
            reqMail.readyState == 'complete') {
            document.getElementById('ProductReviewResponse').innerHTML = reqMail.responseText;
            document.getElementById('ProductReviewResponse').style.display = 'block';
            document.getElementById('ProductAddReview').style.display = 'none';
            alert("Thank you for submitting a product review.")
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + reqMail.readyState);
    }

}

function SubmitProductReview() {
    var Message = "";
    var Action = "";
    var Code = document.getElementById("ProductCode").value;
    var Name = document.getElementById("ProductReviewName").value;
    var Email = document.getElementById("ProductReviewEmail").value;
    var Rating = document.getElementById("ProductReviewRating").value;
    var Review = document.getElementById("ProductReview").value;

    if (Name == "") { Message = Message + "Please enter your Name\n"; }
    if (Rating == "" || Rating == "0") { Message = Message + "Please enter your Rating\n"; }
    if (Review == "") { Message = Message + "Please enter your Review\n"; }
    if (Message == "") { Action = "True"; } else { Action = "False"; }
    if (Action == "True") { AjaxGetDataProductReview("/productreviewsave.aspx?Code=" + Code + "&Name=" + Name + "&Rating=" + Rating + "&Email=" + Email + "&Review=" + Review, AjaxHandler_ProductReview); } else { alert(Message); }
}


/* ************************************ LEFT NAVIGATION ************************************* */

function CheckMailing() {
    if (window.event.keyCode == 13) {
        MailingConfirm()
    }
}

function AjaxGetDataMail(url, responseHandler) {
    if (window.XMLHttpRequest) {          
        reqMail = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {        
        reqMail = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (reqMail) {
        reqMail.onreadystatechange = responseHandler;
        reqMail.open('get', url, true);
        reqMail.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        reqMail.setRequestHeader("Cache-Control", "no-cache");
        reqMail.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        reqMail.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler_Mailing() {
    try {
        if (reqMail.readyState == 4 ||
            reqMail.readyState == 'complete') {
            alert(reqMail.responseText);
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + reqMail.readyState);
    }

}

function MailingConfirm1() {
    var Message = "";
    var Action = "";
    var Email = document.getElementById("MailingList").value;

    if (Email == "") { Message = Message + "Please enter your Email Address\n"; }
    if (Message == "") { Action = "True"; } else { Action = "False"; }
    if (Action == "True") { AjaxGetDataMail("/userpages/MailingSave.aspx?Email=" + Email, AjaxHandler_Mailing); } else { alert(Message); }
}

function MailingConfirm() {
    var exdate = new Date();
    var pattern = /^[\w\.=-]+@[\w\.-]+\.[\w]{2,4}$/;
    var expiredays = 1;
    var test = pattern.test(document.getElementById("MailingList").value);
    if (test = true) {
        var value = document.getElementById("MailingList").value;
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = "MailingList=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
    window.location = "/pages/mailing_list"
    } else {
    alert('Please enter a valid email address');
    }
}

/* ************************************ RIGHT NAVIGATION ************************************* */

function EmailaFriend() {
    AjaxGetData("/userpages/emailfriendsend.aspx", AjaxHandler_EmailFriend)
}
function EmailaFriendConfirm() {
    var Name = document.getElementById("ProductEmail_txtName").value;
    var Email = document.getElementById("ProductEmail_txtEmail").value;
    var FriendName = document.getElementById("ProductEmail_FriendtxtName").value;
    var FriendEmail = document.getElementById("ProductEmail_FriendtxtEmail").value;
    var Code = document.getElementById("ProductEmail_Code").value;
    var Action;
    var Message = "";

    if (Name == "") { Message = Message + "Please enter your Name\n"; }
    if (Email == "") { Message = Message + "Please enter your Email Address\n"; }
    if (FriendName == "") { Message = Message + "Please enter your Friends Name\n"; }
    if (FriendEmail == "") { Message = Message + "Please enter your Friends Email Address\n"; }

    if (Message == "") { Action = "True"; } else { Action = "False"; }

    if (Action == "True") { AjaxGetData("/userpages/emailfriendconfirm.aspx?Name=" + Name + "&Email=" + Email + "&FriendName=" + FriendName + "&FriendEmail=" + FriendEmail + "&ProductCode=" + Code + "", AjaxHandler); } else { alert(Message); }
}
function AjaxHandler_EmailFriend() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 || req.readyState == 'complete') {
            EmailaFriendConfirm();
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }
}
function EmailFriend() {
    document.getElementById("ProductDetail_EmailFriend").style.display = 'block';
}
function GetEmailFriend(ProductCode) {
    AjaxGetData("/userpages/emailfriend.aspx?Code=" + ProductCode + "", AjaxHandler);
}
function AjaxGetData_MiniBasket(url, MiniresponseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        Minireq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        Minireq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (Minireq) {
        Minireq.onreadystatechange = MiniresponseHandler;
        Minireq.open('get', url, true);
        Minireq.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        Minireq.setRequestHeader("Cache-Control", "no-cache");
        Minireq.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        Minireq.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}
function AjaxGetData(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req) {
        req.onreadystatechange = responseHandler;
        req.open('get', url, true);
        req.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        req.setRequestHeader("Cache-Control", "no-cache");
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}
function AjaxHandler() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 ||
            req.readyState == 'complete') {
            document.getElementById('EmailFriend').innerHTML = req.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }
}
function AjaxHandler_MiniBasket() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (Minireq.readyState == 4 ||
            Minireq.readyState == 'complete') {
            document.getElementById('MiniBasket').innerHTML = Minireq.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + Minireq.readyState);
    }

}
function GetMiniBasket() {
    AjaxGetData_MiniBasket("/userpages/basketwebservice.aspx", AjaxHandler_MiniBasket);
}
function CloseEmailFriend() {
    document.getElementById("EmailFriend").style.display = "none";
}

function ShowThumb(varThumb) {
    var Image1;
    var Image2;
    var Image3;
    Image1 = document.getElementById("imgMain").src;
    Image2 = document.getElementById(varThumb.id).src.replace("_Small", "_Large");
    Image2 = Image2.replace("_small", "_large");
    document.getElementById("imgMain").src = Image2;

    Image3 = Image2.replace("_large", "_zoom");
    Image3 = Image3.replace("_Large", "_Zoom");
    document.getElementById("imgMain").src = Image2;
    document.getElementById("MainZoomImage").href = Image3;
}

function ShowThumbAlternative(varThumb) {
    var Image1;
    var Image2;
    var Image3;
    Image1 = document.getElementById("imgMainAlt").src;
    Image2 = document.getElementById(varThumb.id).src.replace("_Small", "_Zoom");
    Image2 = Image2.replace("_small", "_zoom");
    document.getElementById("imgMainAlt").src = Image2;

    Image3 = Image2.replace("_large", "_zoom");
    Image3 = Image3.replace("_Large", "_Zoom");
    document.getElementById("imgMainAlt").src = Image2;
}

function SetEnlargeImage(img) {
    document.getElementById("MainZoomImage").href = img;
}

function AddLinkedToBasket(pid, Qty) {

}


function GetCustomerCreations() {
    AjaxGetData_CustomerCreations("/userpages/CustomerCreation.aspx", AjaxHandler_CustomerCreations);
}

function AjaxGetData_CustomerCreations(url, MiniresponseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        Createreq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        Createreq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (Createreq) {
        Createreq.onreadystatechange = MiniresponseHandler;
        Createreq.open('get', url, true);
        Createreq.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        Createreq.setRequestHeader("Cache-Control", "no-cache");
        Createreq.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        Createreq.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler_CustomerCreations() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (Createreq.readyState == 4 ||
            Createreq.readyState == 'complete') {
            document.getElementById('CreateCustomerCreation').innerHTML = Createreq.responseText;
        }
    }
    catch (e) {
        //alert('Error in Ajax respone:' + Createreq.readyState + '\nErrorCode: ' + Createreq.status);
    }
}


var TestimonialArray = new Array(
'Thank you so much for the papers, I have to say that your customer service has been excellent and I will be telling my friends about you and this excellent decal paper. It is a pleasure to do business with Crafty Computer Paper. Eileen',
'I ought to be a spokes person for your lovely material! I was at Miniatura yesterday and told a few dealers about you. I had taken some pictures of my work and they we all impressed with the material I had printed to upholster my little bedroom chair! It really is a fab product and I am SO pleased I found you. Regards and best wishes, A very satisfied customer Katina',
'I have recently had cause to speak with two of your staff and have received the very best in customer service! These two people are to be commended in there help and approach to solving problems. I have managed a recruitment consultancy for 10 years and speak to thousands of people per week I must say these guys are defiantly the best!! Thank you to Richard and Emma for helping sort out my goods and get them tested so quickly!! WELL DONE Scot',
'Your customer service at Crafty Computer Paper is brilliant! Really lovely to be looked after so well. Hayley',
'I\'d tried various means of decaling models that I assemble and paint and one day when moaning about my decals peeling off a friend recommended Crafty Computer Paper. I have to admit it sounded like a website that I should stay away from \'crafty computers!!!\' but I\'m pleased I didn\'t. The CCP paper doesn\'t curl, tear or break up under application or bleed when immersed in water. I particularly like the way it clings to fit around cast in lines and shapes and maintains the important shapes of the object it\'s applied to. Stuart',
'To date I have used the TAP Paper, cotton inkjet and the organza inkjet sheets and am thrilled with the results! I find them really easy to use and excellent quality. I used the TAP Paper for the first time on the Silver Birch quilt and found it really interesting to work with. I\'m looking forward to trying more new products from you in the future. Thanks again! Angela',
'Because of your quick response to my first email and how kind and helpful you have been I have just placed another order for some more sticky back decal paper and I shall carry on using your company every time I need craft goods. Yours Faithfully Ian',
'I have been using your temporary tattoo paper and these are the best tattoo transfers I have ever tried and I keep recommending them to everyone! What your tutorial doesn\'t show is that if you brush them with iso-propyl alcohol and then with a damp sponge you can get movie quality tattoos! The alcohol will take the shine and stiffness away and they simply look real. I have sold this type of tattoos to several films now and they have been happier than any other system they have used. All the Best. Lars',
'Just want to say thank you for sorting out my order. Customer service seems to be a thing of the past with many companies, but I will certainly be coming back to Crafty Computer Paper. Alice',
'I have recently used your water slide decal paper on my radio controlled helicopter. It’s looking fantastic with your decal paper. I will definitely be buying your paper again it’s so easy to work with. Regards David',
'I just wanted to let you know that the TAP paper is superb! Thanks so much for your advice. Thanks again - and I\'ll certainly be buying this in future, as the quality of other transfer papers just hasn\'t come near the TAP! Jackie',
'\'It is a brilliant service\' Alan, Finance officer',
'\'I can\'t possibly imagine how you can improve your service! You seem to have everything covered and i love that you are constantly introducing new products and that I get a newsletter announcing new stock.\' Jane, Classroom assistant',
'\'I thought the on-line ordering service was very good, clear and simple to use.\' Bridget, Designer, teacher and student',
'\'You have a very user friendly web site with lots of practical info plus a range of interestinf products - well done.\' Tom self employed',
'\'Brilliant service and good quality paper. Worth the money.\' Richard, London, Scrap booking',
'\'excellent site and I shall buy in the near future. Reasonably priced inkjet card - matt and gloss would make for one stop shopping !! Difficult to find this basic item in larger than a small packet.\' Mary, medical secretary',
'\'Your service was excellent - and you kept me informed when there was a delay\' Janice Owner, interior Decorating Store',
'\'very pleased that I can buy so many things in small amounts that i had to buy in bulk when doing my textile defree 3 year ago. Excellent variety of papers of which I hope to try them all.\' Textile artist',
'\'I haven\'t bought yet but would like to in the future - your website is very interesting and infomative and you are obviously very willing to help and give advice\' Ruth, shop assistant',
'\'..I can\' t wait to try your papers.... they look gorgeous\' Clare, writer',
'\'I am delighted to have found Crafty Computer paper, I have had great fun using the papers. They are very easy to use and always produce a good, professional item. I think the service is first class too. my orders have always been dispatched propmpty. Customer services are very friendly and helpful and I very much enjoyed the 8 week course. i have recommended Crafty Computer paper to friends and relatives.\' Carole, artist and designer.',
'\'Used fabric sheets and was very pleased with them\' Rachael, Northampton',
'\'I was not sure embossing paper would work, so put it in Craft cupbaord. tried it last week and was amazed with results. will be using this again and agian.\' Cherly, card maker.',
'Many thanks for my order received this morning. From ordering to receiving the order in only 21 hours is fantastic.If only other companies were so efficient! I hope you are receiving orders from members of the Model Bus Federation, as I posted a message on their Forum a few months ago praising your product. I am in regular contact with a member in Australia (Canberra) who asked me to send him a couple of sheets, with which he is very pleased. Many thanks again , Bill Mather.',
'Hello, I just wanted to let you know how much better my life is since finding your website! I have been using all the paper and bits and pieces that I\'ve ordered to do all sorts of things for my family and for School PTA things. I am bandying your name around like anything. Thank you for a really simple yet very effective website! Kate Catlow',
'Dear Sirs, I bought some white decal paper from you last week. I am just writing to say that I am absolutely delighted. I have previously used JetCal which you must know is absolute rubbish. Have you advertised in the model aircraft magazines? You should. Your decals shown below. Lancaster is six feet wingspan so the wing roundels particularly were a good test.I will be ordering more. Power to your elbow. Thanks again.Best regards, John Wheater, York',
'Hello Charlotte, It\'s that Runemaker fellow again. I just wanted to let you know that as a result of using your dry rub-off decals I am having the best Christmas season ever. Sales have more than doubled because I can now do a lot more work in a shorter time than before when I was hand-painting everything. Kindest regrads, Bob Oswald',
'I just wanted to let you know that your shrink plastic is great. I have printed loads of images off the interent, cans of lager, pints of beer, images of fish and made plaques with words on. So many embellishments can be made. I use a heat gone and its so easy. Brilliant. I last ordered 10 sheets as I intend to make a lot more things with it. June Chatterton'
);


function SetTestimonial() {
    var r = Math.floor(Math.random() * (TestimonialArray.length - 1));
    document.getElementById('Testimonials').innerHTML = TestimonialArray[r];
}


function ReadCustComments() {
    var TestimonialArray = new Array();
    pageURL = "/userpages/templates/static/customer_comments.htm";
    document.write('<a href="' + pageURL + '">Test</a>');
    CustComms = fopen(pageURL, 0);
    if(fh!=-1) { // If file is opened
        length = flength(CustComms); // Get the file's length
        str = fread(CustComms, length);
        fclose(CustComms);
        }
}

function ShowSubMenu(MenuID) {
    try {
        document.getElementById("MainZoomImage").style.position = "";
        document.getElementById("wrap").style.position = "";
        $('.mousetrap').css('display', 'none');

    } catch (err) { }

    try {
        if(MenuID==0){
            document.getElementById(MenuID).className = "Icon_HomeIconHover"
            document.getElementById(MenuID).style.color = "#ffffff";
        }else{
            document.getElementById(MenuID).style.background = "url('/userpages/images/static/topnav_hover.jpg')"
            document.getElementById(MenuID).style.color = "#ffffff";
            document.getElementById("Topcat_" + MenuID).style.display = "";
        }
    } catch (err) { }
}

function HideSubMenu(MenuID) {
    try {
        document.getElementById("MainZoomImage").style.position = "relative";
        document.getElementById("wrap").style.position = "relative";
        $('.mousetrap').css('display', 'block');
    } catch (err) { }
    
    try {
        if (MenuID == 0) {
            document.getElementById(MenuID).className = "Icon_HomeIcon"
            document.getElementById(MenuID).style.color = "#000000";
        } else {
            document.getElementById(MenuID).style.background = "url('/userpages/images/static/topnav.jpg')"
            document.getElementById(MenuID).style.color = "#000000"
            document.getElementById("Topcat_" + MenuID).style.display = "none";
        }

    } catch (err) { }
}


function SeeMore(divid) {
    var visible = document.getElementById(divid).style.display;
    if (visible == "none") {
        document.getElementById(divid).style.display = "";
        document.getElementById(divid + "Link").innerHTML = "<a href=\"javascript:void(0)\" onclick=\"javascript:SeeMore('" + divid + "');\">See Less</a>";
    } else {
        document.getElementById(divid).style.display = "none";
        document.getElementById(divid + "Link").innerHTML = "<a href=\"javascript:void(0)\" onclick=\"javascript:SeeMore('" + divid + "');\">See More</a>";
    }
}

function ShowSwatch(StockID) {
    try {
        document.getElementById("MainZoomImage").style.position = "";
        document.getElementById("wrap").style.position = "";
        $('.mousetrap').css('display', 'none');
    } catch (err) { }

    document.getElementById("Swatch_" + StockID).style.display = "";
}

function HideSwatch(StockID) {
    try {
        document.getElementById("MainZoomImage").style.position = "relative";
        document.getElementById("wrap").style.position = "relative";
        $('.mousetrap').css('display', 'block');
    } catch (err) { }

    document.getElementById("Swatch_" + StockID).style.display = "none";
}

function ClearMailingList() {
    document.getElementById("MailingList").value = "";
}

/* ******* Redmine Feature #13510 ******* */

function RemoveRecentlyViewed(ProductCode) {
    document.getElementById('Recent' + ProductCode).style.display = "none";
    var URL = "/RemoveRecently.aspx?c=" + ProductCode;
    AjaxGetData_RemoveRecently(URL, AjaxHandler_Recently)
}

function AjaxHandler_Recently() {
    try {
        if (RecentlyReq.readyState == 4 || RecentlyReq.readyState == 'complete') {
        }
    } catch (e) {
        alert('ERROR: ' + e + '\r\nReady State: ' + RecentlyReq.State);
    }
}

function AjaxGetData_RemoveRecently(URL, ResponseHandler) {
    if (window.XMLHttpRequest) {
        RecentlyReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        RecentlyReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (RecentlyReq) {
        RecentlyReq.onreadystatechange = ResponseHandler;
        RecentlyReq.open('get', URL, true);
        RecentlyReq.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        RecentlyReq.setRequestHeader("Cache-Control", "no-cache");
        RecentlyReq.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        RecentlyReq.send('');
    } else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}

function BasketLoginEnter(e) {
    if (e.keyCode == 13) {
        document.getElementById('ctl00_ContentPlaceHolder1_CheckoutLogin').click(); return false;
    }
}


function ViewAll(ProdPerPage) {
    var URL = window.location;
    URL = URL + '?&PP=' + ProdPerPage;
    window.location = URL;
}


var CheckVideo;
function HideVideo() {
    ChangeParam("off")
}


