﻿function clearTextbox(el) {
    if (el.defaultValue == el.value)
        el.value = "";
}

function fillTextbox(el) {
    if (el.value == "") {
        el.value = el.defaultValue;
    }
}

function popUp(strURL, strType, strHeight, strWidth) {
    var strOptions = "";
    if (strType == "console") strOptions = "resizable,scrollbars,height=" + strHeight + ",width=" + strWidth;
    if (strType == "fixed") strOptions = "status,height=" + strHeight + ",width=" + strWidth;
    if (strType == "elastic") strOptions = "toolbar,menubar,scrollbars,resizable,location,height=" + strHeight + ",width=" + strWidth;
    window.open(strURL, 'newWin', strOptions);
}

// for app.aspx
function productsBoxClick(el) {
    var elLength = el.children.length;

    for (i = 0; i < elLength; i++) {
        if (el.children[i].className == "productsBoxSummary") {
            window.location.href = el.children[i].children[0].href;
            return true;
        }
    }

}

function toggleDiv(divId,duration) {
    $("#" + divId).slideToggle(duration);
}

function setCookie(name, value, days) {
    if (days) {
        var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";

    document.cookie = name + "=" + value + expires + "; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }

    return null;

}
function deleteCookie(name) {
    setCookie(name, "", -1); 
        }
