﻿function validZip(oSrc, args) {
    args.IsValid = isZipValid(args.Value)
}

function isZipValid(zip) {
    if (zip.match(/^[0-9]{5}$/))
        return true;

    if (zip.match(/[0-9]{5}\-[0-9]{4}$/))
        return true;

    zip = zip.toUpperCase();

    if (zip.match(/^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$/))
        return true;

    if (zip.match(/^[A-Z][0-9][A-Z].[0-9][A-Z][0-9]$/))
        return true;

    return false;
}

// product gallery

function SaveSwatch(sProductType, sStyle, sColor, sConsumerId) {
    //used for hardwood & laminate
    var ret = ConsumerWS.SaveSwatch(sProductType, sStyle, sColor, sConsumerId, '');
    var hidCounter = document.getElementById('ctl00_ctl00_hidCartCounter');
    var lblCounter = document.getElementById('ctl00_ctl00_lblCartCounter');
    var ct = parseInt(hidCounter.value);
    hidCounter.value = ct + 1;
    lblCounter.value = ct + 1;
    //alert('set value as ' + lblCounter.value);
    $('#ctl00_ctl00_lblCartCounter').contents().remove();
    $('#ctl00_ctl00_lblCartCounter').append(ct + 1);
    loadStatus('Product saved');
}
function SaveSwatch2(sProductType, sStyle, sColor, sConsumerId, sProductId) {
    //used for carpet and ceramic
    var ret = ConsumerWS.SaveSwatch(sProductType, sStyle, sColor, sConsumerId, sProductId);
    var hidCounter = document.getElementById('ctl00_ctl00_hidCartCounter');
    var lblCounter = document.getElementById('ctl00_ctl00_lblCartCounter');
    var ct = parseInt(hidCounter.value);
    hidCounter.value = ct + 1;
    lblCounter.value = ct + 1;
    //alert('set value as ' + lblCounter.value);
    $('#ctl00_ctl00_lblCartCounter').contents().remove();
    $('#ctl00_ctl00_lblCartCounter').append(ct + 1);
    loadStatus('Product saved');
}


function PrintSwatch(style,color) {
    var p = "/product-search/print/print-carpet.aspx?Style=" + style + "&Color=" + color
    window.open(p, 'SwatchPrint', 'left=10, top=10, height=800, width=1000, status=no, resizable=yes, scrollbars=yes, toolbar=no,location=no, menubar=no');
    return false;
}
function PrintHardwood(style, color) {
    var p = "/product-search/print/print-hardwood.aspx?Style=" + style + "&Color=" + color
    window.open(p, 'SwatchPrint', 'left=10, top=10, height=800, width=1000, status=no, resizable=yes, scrollbars=yes, toolbar=no,location=no, menubar=no');
    return false;
}
function PrintLaminate(style, color) {
    var p = "/product-search/print/print-laminate.aspx?Style=" + style + "&Color=" + color
    window.open(p, 'SwatchPrint', 'left=10, top=10, height=800, width=1000, status=no, resizable=yes, scrollbars=yes, toolbar=no,location=no, menubar=no');
    return false;
}
function PrintCeramic(style, color, id) {
    var p = "/product-search/print/print-ceramic.aspx?Style=" + style + "&Color=" + color + "&id=" + id;
    window.open(p, 'SwatchPrint', 'left=10, top=10, height=800, width=1000, status=no, resizable=yes, scrollbars=yes, toolbar=no,location=no, menubar=no');
    return false;
}
function clearMe(obj) {
    obj.value = "";
}

function MasterCarpetFeaturePostback(obj) {
    var itm = obj.value;
    if (itm.length > 0) {
        document.forms[0].submit();
    }
}



