﻿// Used to filter out non numeric chars from a textbox input control.
function CheckQuantity(evt)
{
    if (evt)
    {
        var charCode = (evt.charCode) ? evt.charCode :
            ((evt.keyCode) ? evt.keyCode :
            ((evt.which) ? evt.which : 0));
        if (((charCode >= 48) && (charCode <= 57)) || ((charCode >= 96) && (charCode <= 105)) || (charCode==8) || (charCode==9) || (charCode==127) ||(charCode==13))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    return false;
}



function fixHeight() 
{
    if (document.getElementById('tblMainPanel')) {
        mainPanelHeight = document.getElementById('tblMainPanel').offsetHeight;
    }
    else {
        mainPanelHeight = 0;
    } 
    if (mainPanelHeight < 470) {
        mainPanelHeight = 470;
    }
    else {
        mainPanelHeight = mainPanelHeight - 30;
    }
    if (document.getElementById('divLeftPromo')) {
        document.getElementById('divLeftPromo').style.height = mainPanelHeight + "px";
    }
    if (document.getElementById('divRightPromo')) {
        document.getElementById('divRightPromo').style.height = mainPanelHeight + "px";
    }
}


function SendFormEmail_onclick() 
{
    arg = "";
    if (document.getElementById('Text1')) {
        arg += document.getElementById('Text1').title + ": " + document.getElementById('Text1').value + ",";
    }
   if (document.getElementById('Text2')) {
        arg += document.getElementById('Text2').title + ": " + document.getElementById('Text2').value + ",";
    }
    if (document.getElementById('Text3')) {
        arg += document.getElementById('Text3').title + ": " + document.getElementById('Text3').value + ",";
    }
    if (document.getElementById('Text4')) {
        arg += document.getElementById('Text4').title + ": " + document.getElementById('Text4').value + ",";
    }
   if (document.getElementById('Text5')) {
        arg += document.getElementById('Text5').title + ": " + document.getElementById('Text5').value + ",";
    }
    if (document.getElementById('Text6')) {
        arg += document.getElementById('Text6').title + ": " + document.getElementById('Text6').value + ",";
    }
    if (document.getElementById('Text7')) {
        arg += document.getElementById('Text7').title + ": " + document.getElementById('Text7').value + ",";
    }
   if (document.getElementById('Text8')) {
        arg += document.getElementById('Text8').title + ": " + document.getElementById('Text8').value + ",";
    }
    if (document.getElementById('Text9')) {
        arg += document.getElementById('Text9').title + ": " + document.getElementById('Text9').value + ",";
    }
    if (document.getElementById('Text10')) {
        arg += document.getElementById('Text10').title + ": " + document.getElementById('Text10').value + ",";
    }
    if (document.getElementById('htxtEmail')) {
        arg += document.getElementById('htxtEmail').value + ",";
    }
    if (document.getElementById('htxtSubject')) {
        arg += document.getElementById('htxtSubject').value;
    }
    __doPostBack('btnSendFormEmail',arg);
}


// This code makes the loading image visible for the cart for a specified amount of time.
// This replaces the standard UpdateProgress AJAX server control which will only display the 
// loading image while the server code is processing (which is too quick for this task).
function AddCartLoadingBeginRequestHandler()
{
    var requestManager = Sys.WebForms.PageRequestManager.getInstance();
    requestManager.add_beginRequest(CartLoadingBeginRequestHandler);  
}


function CartLoadingBeginRequestHandler(sender, args)
{
    LoadCartLoadingImage();
}
   
            
function LoadCartLoadingImage() 
{
    var imgCart = document.getElementById('imgCartLoading');
    if (imgCart != null)
    {
        document.getElementById('imgCartLoading').style.display='block';
        setTimeout(UnloadCartLoadingImage,750);
    }
}

            
function UnloadCartLoadingImage() 
{
    document.getElementById('imgCartLoading').style.display='none';
}