﻿//highslide
hs.showCredits = false;
hs.align = 'center';
hs.preserveContent = false;
hs.zIndexCounter = 10000;
hs.graphicsDir = 'highslide/graphics/';
hs.numberOfImagesToPreload = 0;
hs.Expander.prototype.preloadNext = function() { };
hs.cacheAjax = false;




function AddToBasket(listingId, variantId) {
//    var vProdcutId = document.getElementById ? document.getElementById(hdnProductId) : document.all ? document.all[hdnProductId] : null;
//    vProdcutId.value = listingId;
//    var vVariantId = document.getElementById ? document.getElementById(hdnVariantId) : document.all ? document.all[hdnVariantId] : null;
    //    vVariantId.value = variantId;
    hdnProductId.value = listingId;
    hdnVariantId.value = variantId;
    var vform = document.getElementById ? document.getElementById('aspnetForm') : document.all ? document.all['aspnetForm'] : null;
    vform.submit();
}


function AddRelatedToBasket(listingId, variantId) {
    //    var vProdcutId = document.getElementById ? document.getElementById(hdnProductId) : document.all ? document.all[hdnProductId] : null;
    //    vProdcutId.value = listingId;
    //    var vVariantId = document.getElementById ? document.getElementById(hdnVariantId) : document.all ? document.all[hdnVariantId] : null;
    //    vVariantId.value = variantId;
    hdnRelatedProductId.value = listingId;
    hdnRelatedVariantId.value = variantId;
    var vform = document.getElementById ? document.getElementById('aspnetForm') : document.all ? document.all['aspnetForm'] : null;
    vform.submit();
}



function setvariantid(variantId) {
   // var vVariantId = document.getElementById ? document.getElementById(hdnVariantId) : document.all ? document.all[hdnVariantId] : null;
    hdnVariantId.value = variantId;
}



function AddedToBasket() {
    window.setTimeout(function() {
        $("#basket").effect("pulsate", { times: 2 }, 700);
    }, 1200);

}

// tabs

function InitTabs(DefaultTab, HasRelated) {

    jQuery(function() {

        jQuery("#tabsContainer").tabs({ selected: DefaultTab });
        if (HasRelated)
        { jQuery("#tabsContainer").tabs('add', '#relatedListings', 'Related Products'); }
    });


}


// end tabs

// search box

function ClearTxtKeyword() {
  txtKeyword.value = "";
}
function DecorateSearchString(rsInputString) {
    if (rsInputString != null)
        return escape(rsInputString.replace(/(\.|\s|,)+/g, "+"));
    else
        return "";
}

function SearchTextKeyword() {
  //  var objtxtKeyword = document.getElementById('<%=txtKeyword.ClientID%>');
    if (txtKeyword != null && txtKeyword.value.length > 0 && txtKeyword.value != 'Enter keywords and press enter') {
        window.location.href = baseLocation + '=' + DecorateSearchString(txtKeyword.value);
    }
    else {
        window.location.href = baseLocation + "search.aspx";
    }
    return true;
}

function SetTextKeyword() {
    //var txtCodeKeyword = document.getElementById("<%=txtKeyword.ClientID%>");
    if (txtKeyword.value != 'Enter keywords and press enter' && txtKeyword.value == '')
        txtKeyword.value = 'Enter keywords and press enter';

}

function ClearTextkeyword() {
   // var txtKeyword = document.getElementById("<%=txtKeyword.ClientID%>");

    if (txtKeyword != null)
        if ("Enter keywords and press enter" == txtKeyword.value)
            txtKeyword.value = "";
        txtKeyword.focus();

}


// end search box

// category


function ChangePageSize() {
   // var cboNoOfResultPerPage = document.getElementById('<%=cboNoOfResultPerPage.ClientID %>');
    var sQueryString = window.location.search.replace("?", "");
    var bIsFirst = true;

    var sURL = hdnPageURL.value;
    for (var i = 0; i < sQueryString.split("&").length; i++) {
        if (sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_SIZE_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_NO_KEY) < 0
					 && sQueryString != ""
					) {
            if (bIsFirst) {
                sURL += "?";
                bIsFirst = false;
            }
            else
                sURL += "&";
            sURL += sQueryString.split("&")[i];
        }

    }

    if (cboNoOfResultPerPage.value != PAGE_SIZE_DEFAULT) {
        if (bIsFirst)
            sURL += "?";
        else
            sURL += "&";
        sURL = sURL + PAGE_SIZE_KEY + '=' + cboNoOfResultPerPage.value;
    }
    window.location.href = sURL;
    return false;
}

function orderBy(vOption) {

    var sQueryString = window.location.search.replace("?", "");
    var bIsFirst = true;

    var sURL = hdnPageURL.value;

    for (var i = 0; i < sQueryString.split("&").length; i++) {
        if (sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_SIZE_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_NO_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf('ord') < 0
					 && sQueryString != ""
					) {
            if (bIsFirst) {
                sURL += "?";
                bIsFirst = false;
            }
            else
                sURL += "&";
            sURL += sQueryString.split("&")[i];
        }

    }

    if (bIsFirst)
        sURL += "?";
    else
        sURL += "&";
    sURL = sURL + 'ord=' + vOption;

    window.location.href = sURL;
    return false;

}


function LoadByManufacturer(vId, vcheckBox) {
    var vManufacturers = hdnManufactureCSV.value;

    if (vcheckBox.checked == true) {
        if (vManufacturers.length > 0)
            vManufacturers = vManufacturers + ',' + vId
        else
            vManufacturers = vId
    }
    else {
        var vArray = vManufacturers.split(",");
        vManufacturers = "";
        for (var i = 0; i < vArray.length; i++) {
            //if (vArray[i].indexOf(vId) < 0)
            if (vArray[i] != vId) {
                vManufacturers += vArray[i] + ',';

            }
        }
    }

    if (vManufacturers.charAt(vManufacturers.length - 1) == ',')
        vManufacturers = vManufacturers.substr(0, vManufacturers.length - 1);


    hdnManufactureCSV.value = vManufacturers;
    var sQueryString = window.location.search.replace("?", "");
    var bIsFirst = true;
    var sURL = hdnPageURL.value;

    for (var i = 0; i < sQueryString.split("&").length; i++) {
        if (sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_SIZE_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_NO_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(MANUFACTURER_KEY) < 0
					 && sQueryString != ""
					) {
            if (bIsFirst) {
                sURL += "?";
                bIsFirst = false;
            }
            else
                sURL += "&";
            sURL += sQueryString.split("&")[i];
        }
    }

    if (vManufacturers != '') {
        if (bIsFirst)
            sURL += "?";
        else
            sURL += "&";
        sURL = sURL + MANUFACTURER_KEY + '=' + vManufacturers;
    }

    window.location.href = sURL;
    return false;

}


function LoadByPriceBand(vId) {
    var sQueryString = window.location.search.replace("?", "");
    var bIsFirst = true;
    var sURL = hdnPageURL.value;

    for (var i = 0; i < sQueryString.split("&").length; i++) {
        if (sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_SIZE_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_NO_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PRICEBAND_KEY) < 0
					 && sQueryString != ""
					) {
            if (bIsFirst) {
                sURL += "?";
                bIsFirst = false;
            }
            else
                sURL += "&";
            sURL += sQueryString.split("&")[i];
        }
    }

    if (bIsFirst)
        sURL += "?";
    else
        sURL += "&";
    sURL = sURL + PRICEBAND_KEY + '=' + vId;

    window.location.href = sURL;
    return false;

}


function LoadByFeature(vId, vcheckBox) {

    var vFeatureoptions = hdnFeatureCSV.value;
    if (vcheckBox.checked == true) {
        if (vFeatureoptions.length > 0)
            vFeatureoptions = vFeatureoptions + ',' + vId
        else
            vFeatureoptions = vId
    }
    else {
        var vArray = vFeatureoptions.split(",");
        vFeatureoptions = "";
        for (var i = 0; i < vArray.length; i++) {
            if (vArray[i].indexOf(vId) < 0) {
                vFeatureoptions += vArray[i];
            }
        }
        if (vFeatureoptions.charAt(vFeatureoptions.length - 1) == ',')
            vFeatureoptions += vFeatureoptions.substr(0, vFeatureoptions.length - 1);

    }

    var sQueryString = window.location.search.replace("?", "");
    var bIsFirst = true;
    var sURL = hdnPageURL.value;

    for (var i = 0; i < sQueryString.split("&").length; i++) {
        if (sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_SIZE_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(PAGE_NO_KEY) < 0
					 && sQueryString.split("&")[i].split("=")[0].indexOf(FEATURE_KEY) < 0
					 && sQueryString != ""
					) {
            if (bIsFirst) {
                sURL += "?";
                bIsFirst = false;
            }
            else
                sURL += "&";
            sURL += sQueryString.split("&")[i];
        }
    }

    if (vFeatureoptions != '') {
        if (bIsFirst)
            sURL += "?";
        else
            sURL += "&";
        sURL = sURL + FEATURE_KEY + '=' + vFeatureoptions;
    }

    window.location.href = sURL;
    return false;

}


// end category

function KeyDownHandler(btn) {

    // process only the Enter key

    if (event.keyCode == 13) {

        // cancel the default submit

        event.returnValue = false;

        event.cancel = true;



        var obj = document.getElementById(btn);

        obj.click();

    }


}

function bankTransferConfirm() {

    var ret = confirm("GB: Click OK only if you have already sent your bank transfer payment.\n\nFR: Cliquez sur OK uniquement après avoir envoyé votre paiement par transfert bancaire.\n\nDE: Falls Sie Ihre Zahlung per Banküberweisung bereits überwiesen haben, klicken Sie auf „OK“.\n\nIT: Fare clic sul pulsante OK se è già stato effettuato il pagamento tramite bonifico bancario.\n\nNL: Klik alleen op OK als u uw bankoverschrijving al heeft uitgevoerd.\n\nPT: Clique apenas em OK se já tiver enviado o seu pagamento por transferência bancária.\n\nES: Haga clic en OK únicamente si ya ha enviado su pago por transferencia bancaria.");
return ret;
}


