﻿var errorCount = 0;
function checkImage(img) {
    errorCount++;
    //if (!img && window.event) var img = window.event.srcElement;
    //if (!img && this) var img = this;
    if (img == null) var img = document.getElementById('ProductImage');
    // DEBUG
    if (errorCount < 3) {
        img.width = 200;
        img.src = "/images/noImageAvailable.jpg";
    }
}

function notify(str) {
    var blockoutDiv = document.getElementById("backgroundPopup");
    var notifyDiv = document.getElementById("popupContact");
    var messageArea = document.getElementById("messageBody");
    messageArea.innerHTML = str;
    blockoutDiv.style.height = 1000;
    blockoutDiv.style.display = "inline";
    notifyDiv.style.display = "inline";
    notifyDiv.style.height = 207;
    

    var width = (document.body.offsetWidth) / 2;
    width = width - (notifyDiv.clientWidth / 2);
    notifyDiv.style.left = (width) + "px";

    //var messageSpan = document.createElement("SPAN");
    //messageArea.appendChild(messageSpan);
}
function closeNotify() {
    var blockoutDiv = document.getElementById("backgroundPopup");
    var notifyDiv = document.getElementById("popupContact");
    notifyDiv.style.display = "none";
    blockoutDiv.style.display = "none";
}
function collectionItems_onLoad() {
    // SHOW TOP BUTTON
    //document.getElementById("topOrderButtonArea").style.display = 'inline';
    // SHOW COLLECTION ITEMS BANNER
    document.getElementById("collectionItemsBanner").style.display = 'inline';
    // HIDE BOTTOM BUTTON
    //document.getElementById('bottomOrderButtonArea').style.display = 'none';
    // CHANGE BOTTOM CHECKOUT BUTTON
    //document.getElementById('customerAppreciationOrderButtonArea').style.display = 'inline'; 
}
function showSoldOutLabels() {
    document.getElementById("soldOutLabel").style.display = "inline";
    document.getElementById('ctl00_MainContent_ProductDetails_AddToCartButton').style.display = 'none';
    //document.getElementById('customerAppreciationOrderButtonArea').style.display = 'inline'; 

}
function addLoadEventHandler(func) {
    //alert(0);
    var previous_handler = window.onload;
    if (typeof window.onload != "function") window.onload = func;
    else window.onload = function() {
        previous_handler();
        func();
    }
}
addLoadEventHandler(checkDescriptionLength);
function checkDescriptionLength() {
    var moreLink = document.getElementById("moreDescriptionLink");
    var sd = document.getElementById("shortDescription");
    var sh = sd.scrollHeight;
    if (sh > 54) {
        sd.style.height = "40px";
        sd.style.overflow = "hidden";
        //height:53px; overflow:hidden; 

        moreLink.style.display = "inline";
    }
    var desc = document.getElementById("productDescriptionArea");
    //var img = document.getElementById("Img1");
    //var fitWidth = ((960 - img.clientWidth) - 100)
    //desc.style.width = fitWidth + "px";
    //sd.style.width = (fitWidth - 20) + "px";
    //alert(desc.style.width);
}
function showMoreDescription() {
    var sd = document.getElementById("shortDescription");
    sd.style.height = sd.scrollHeight + "px";
    var moreLink = document.getElementById("moreDescriptionLink");
    moreLink.style.display = "none";
}

