// PRODUCTS - restock message
function products_restockMessage(show) {

    new Effect.toggle('restock', 'appear', { duration: 0.3 });

    

}

// PRODUCTS - notify message
function product_Show(show) {

    new Effect.toggle('productdetails', 'appear', { duration: 0.3 });

    if (show == true) {
        $('body_fog').style.display = 'block';
    } else {
        $('body_fog').style.display = 'none';
    }
    
}

var lastProduct = '';
// PRODUCTS - notify message
function productPreview(product, show) {

    productPreviewClear();
    
    if (show == false) {
        $(product + '_').style.display = 'none';
        //alert('hide standard');
        $(product).style.display = '';        
        //new Effect.Appear(product, { duration: 0.6 });
        //alert('show zoom');
        lastProduct = product;
    }
    
    

    if (show == true) {
        $(product).style.display = 'none';
        //alert('hide zoom');
        $(product + '_').style.display = 'block';
       
        //alert('show standard');
        lastProduct = '';
    }

}

var lastViewed = '';
function productPreviewClear() {

    if (lastProduct != '') {
        $(lastProduct).style.display = 'none';
        $(lastProduct + '_').style.display = 'block';
    
    }
}

function productViewerShow(id, div) {

    if (lastViewedProduct == id)
        return;
    else
        lastViewedProduct = id;
        
    ///disable all product arrows
    var subProducts = div;  //document.getElementById('ctl_div_ProductThumbs');

    for (i = 0; i < subProducts.childNodes.length; i++) {
        nownode = subProducts.childNodes[i];
        nownode.className = 'product_viewer_inactive';
    }

    ///hide all product images
    var subProductViews = document.getElementById('ctl_div_ProductViews');

    for (i = 0; i < subProductViews.childNodes.length; i++) {

        nownode = subProductViews.childNodes[i];
        if (nownode.tagName == "IMG") {
            nownode.style.display = 'none';
        }
    }

    ///show selected product view
    new Effect.toggle('img' + id, 'appear', { duration: 0.6 });
//document.getElementById('img' + id).style.display = 'block';
    ///show selected product arrow
    var obj = document.getElementById('ctl_div_id' + id);

    obj.className = 'product_viewer_active';
    //obj.onclick = null;

    
}

// PRODUCTS - restock message
function products_addToBag(show) {

    if (show) {
        showElement('body_fog');
        showElement('shopping_bag_layer');
    }
    else {
        hideElement('body_fog');
        hideElement('shopping_bag_layer');
    }

    var ScrollTop = document.body.scrollTop;


    if (ScrollTop == 0) {
        if (window.pageYOffset)
            ScrollTop = window.pageYOffset;
        else
            ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;

    }
    
    var sb = document.getElementById('shopping_bag_inner')
    
    sb.style.marginTop = ScrollTop + 20;

         
    

}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PRODUCTS - ensure the quantity is validated number by harry
function products_validateQty(source, value) {
    var qtyStr = value.Value;
    
    if (qtyStr == '') {
        value.IsValid = false;
        return false;
    }
    
    var qtyNum = new Number(qtyStr);

    var type = typeof (qtyNum);
    if (isNaN(qtyNum) || qtyNum <= 0) {
        value.IsValid = false;
        return false;        
    }

    value.IsValid = true;
    return true;
}

// PRODUCTS - size select
function products_toggleSelect(id) {
    id = (id == null) ? "size_options" : id + "_options";
    if ($(id)) {
        new Effect.toggle(id, 'appear', {
            delay: 0,
            duration: .25,
            afterFinish: function() {

            }
        });
    }
}

function products_toggleSelectValue(input, value, text) {
    $(input + "_input").value = value;
    $(input + "_title").innerHTML = text;
    products_toggleSelect(input);
}




function receipt_Popup(ordernumber) {
    window.open('/PrintReceipt.aspx?OrderNumber=' + ordernumber, 'glossary','scrollbars=yes,toolbar=no,menubar=no,status=no,width=580,height=600');
}

function hide_Cart() {
    //hideElement('shopping_bag_layer');
    new Effect.toggle('shopping_bag_layer', 'appear', { duration: 0.3 });
}

function shopping_Cart(show) {
    new Effect.toggle('shopping_bag_layer', 'appear', { duration: 0.3 });

    if (show) {
        showElement('body_fog');
    }
    else {
        hideElement('body_fog');
    }
}

function email_Friend(show) {
    new Effect.toggle('emailtofriend', 'appear', { duration: 0.3 });

//    if (show)
//        showElement('emailtofriend');
//    else
//        hideElement('emailtofriend');

}

function hide_Press() {
    

    

    //    if (show)
    //        showElement('emailtofriend');
    //    else
    //        hideElement('emailtofriend');

}

function show_Press(path) {

    $('img_press').style.display = 'none';
    
    var img = document.getElementById('img_press');

    img.src = path;

    $('img_press').appear({ duration: 0.5 });


}


