﻿//***********************
//*** Browser Related
//***********************

function PopWindow(sURL, width) {
    if (width == null) {
        width = 800;
    }
    window.open(sURL, null, "top=50, left=50, height=600,width=" + width + ",status=yes,toolbar=no,scrollbars=yes, menubar=no,resizable=yes");
}

function OpenBrowserWindow(sURL) {
    window.open(sURL, null, "top=50, left=50, height=800,width=1200,status=yes, location=yes, toolbar=yes,scrollbars=yes, menubar=yes,resizable=yes");
}
function addOptionDDL(ddl, v, d) {
    opt = new Option();
    opt.text = d;
    opt.value = v;

    insertIndex = $get(ddl).options.length;
    $get(ddl).options[insertIndex] = opt;
}

function clearDDL(ddl) {
    while ($get(ddl).options.length > 0) {
        deleteIndex = $get(ddl).options.length - 1;
        $get(ddl).options[deleteIndex] = null;
    }
}

function getQuerystring(key) {
    var default_ = "";

    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)", "i");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}


function CopyToClipBoard(sText) {
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", sText);
    }
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function sBGC(ctrlID, color) {
    try {
        $get(ctrlID).style.backgroundColor = color;
    }
    catch (e) { }
}

function buttonMouseOver(o) {
    o.style.backgroundColor = menuColorHighlight;
    o.style.cursor = "pointer";
}

function buttonMouseOut(o) {
    o.style.backgroundColor = "";

}
