var bites = document.cookie.split("; "); // break cookie into array of bites

function onqGetCookie(name) {
    for (var i=0; i < bites.length; i++) {
      nextbite = bites[i].split("="); // break into name and value
      if (nextbite[0] == name) // if name matches
        return unescape(nextbite[1]); // return value
    }
    return null;
}

var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

function onqSetCookie(name, value) {
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
    bites = document.cookie.split("; "); // update cookie bites
}

function onqOpenPageAndSet(key, value, newurl) {
    onqSetCookie(key, value);
    return onqOpenPage(newurl);
}


function onqOpenPage(newurl) {
    location.href = newurl;
    return true;
}

function onqOpenNewPage(newurl) {
    var h = screen.availHeight;
    var w = screen.availWidth;
    var newwindow = window.open(newurl,"subwindow","resizable, statusbar");
    newwindow.moveTo(0,0);
    newwindow.resizeTo(w,h);
    newwindow.focus();
}



function onqOpenNTPage(newurl) {
    var newwindow = window.open(newurl,"subwindow", "HEIGHT=500, WIDTH=700, resizable, toolbar=false, scrollbars");
        newwindow.focus();
	 }

// These variables are global to the included page
var bMSIE = false;
var bMSIE3 = false, bMSIE4 = false, bMSIE4_beta = false, bMSIE4_01 = false, bMSIE5 = false, bMSIE5_01=false, bMSIE5_5=false, bMSIE6=false;
var bNetscape = false;
var bNetscape_2 = false, bNetscape_3 = false, bNetscape_4 = false;

function onqDetectBrowser()
{
    var ua = navigator.userAgent;
    var an = navigator.appName;

    // Is it IE?
    bMSIE = (ua.indexOf("MSIE")>=1);
    if (bMSIE)
    {
        // IE3
        bMSIE3 = (ua.indexOf("MSIE 3.0")>=1);

        // IE4
        var iMSIE4 = ua.indexOf("MSIE 4.0");
        bMSIE4 = (iMSIE4>=1);
        if (bMSIE4)
        {
            var sMinorVer = ua.charAt(iMSIE4+8);
            // Some folks are still running an IE4 beta!
            // (the Mac IE team used a 'p' to mark their beta)
            bMSIE4_beta = bMSIE4 && ((sMinorVer == "b") || (sMinorVer == "p"));

            // IE4.01
            bMSIE4_01 = bMSIE4 && (sMinorVer == "1");
        }
        // IE5
        bMSIE5 = (ua.indexOf("MSIE 5.0")>=1);
        bMSIE5_01 = (ua.indexOf("MSIE 5.01")>=1);
        bMSIE5_5 = (ua.indexOf("MSIE 5.5")>=1);
        bMSIE6 = (ua.indexOf("MSIE 6")>=1);
    }
    else if (an == "Netscape")
    {
        bNetscape = true;
        appVer = parseInt(navigator.appVersion);
        if (appVer >= 4)
            bNetscape_4 = true;
        else if (appVer >= 3)
            bNetscape_3 = true;
        else
            bNetscape_2 = true;
    }
}
