
/*
        Init layers for 4+ Browsers
----------------------------------------*/

var agt = navigator.userAgent.toLowerCase();
var w3c = (document.getElementById) ? true : false;
var xxx = ((agt.indexOf('opera') != -1) || (agt.indexOf('webtv') != -1) || (agt.indexOf('omniweb') != -1)) ? true : false;

var ieX = ((agt.indexOf('msie')  != -1) && w3c && !xxx) ? true : false;
var ie4 = ((agt.indexOf('msie')  != -1) && (document.all) && !w3c && !xxx) ? true : false;
var ns6 = ((agt.indexOf('gecko') != -1) && w3c && !xxx) ? true : false;
var ns4 = (document.layers && !w3c && !xxx) ? true : false;


/*
        Dynamic Browser Specific CSS
----------------------------------------*/

if      (ieX) document.write('<link rel="stylesheet" type="text/css" href="http://www.bmsl.net/css/ieX.css" />');
else if (ie4) document.write('<link rel="stylesheet" type="text/css" href="http://www.bmsl.net/css/ie4.css" />');
else if (ns6) document.write('<link rel="stylesheet" type="text/css" href="http://www.bmsl.net/css/ns6.css" />');
else if (ns4) document.write('<link rel="stylesheet" type="text/css" href="http://www.bmsl.net/css/ns4.css" />');
else          document.write('<link rel="stylesheet" type="text/css" href="http://www.bmsl.net/css/ie4.css" />');


/*
        Function to Show Layers
----------------------------------------*/

function show(id)
{
        if (ieX || ns6) document.getElementById(id).style.visibility = 'visible';
        if (ie4) document.all[id].style.visibility = 'visible';
        if (ns4) document.layers[id].visibility = 'show';
};


/*
        Function to Hide Layers
----------------------------------------*/

function hide(id)
{
        if (ieX || ns6) document.getElementById(id).style.visibility = 'hidden';
        if (ie4) document.all[id].style.visibility = 'hidden';
        if (ns4) document.layers[id].visibility = 'hide';
};


/*
        Redirect in Sacbee
----------------------------------------*/

function goHere(s)
{
        var URL = s.options[s.selectedIndex].value;
        if (URL != '') document.location.href = URL;
};


/*
        Redirect outside Sacbee
----------------------------------------*/

function goThere(s)
{
        var URL = s.options[s.selectedIndex].value;
        if (URL != '') window.open(URL);
};


/*
        Pop Up Window
----------------------------------------*/

function popWin(url, winName, w, h, scroll)
{
        if (agt.indexOf('mac') != -1) h += 17;
        var sw = screen.width;
        var sh = screen.height;
        var cx = ( .5 * sw ) - ( w * .5 );
        var cy = ( .5 * sh ) - ( h * .5 );
        var values = 'toolbar=no,status=yes,menubar=no,scrollbars=' + scroll + ',resizable=yes,screenX=' + cx + ',screenY=' + cy + ',left=' + cx + ',top=' + cy + ',width=' + w + ',height=' + h + '';
        child = window.open(url, winName, values);
};


/*
        Netscape Resize CSS Fix
----------------------------------------*/

if (document.layers)
{
        origSelfWidth  = innerWidth;
        origSelfHeight = innerHeight;
        onresize = function() { if (innerWidth != origSelfWidth || innerHeight != origSelfHeight) location.reload() };
};


/*
        Global Initialize
                - Anything that uses an
                        onload event needs to be
                        defined here.
----------------------------------------*/

stLoad     = null;   // Sets a null value if Story Toolbar is not present
ccLoad     = null;   // Sets a null value if classadsClippings is not present
ticker     = null;   // Sets a null value if Ticker is not present

indexPop   = null;
beePop     = null;
rELoad     = null;
ABPopUnder = null;

function initialize()
{
        if (stLoad     != null) stInit();
        if (ccLoad     != null) ccInit();
        if (ticker     != null) changecontent();

        if (indexPop   != null) GenRandomIntercept();
        if (beePop     != null) loadPop();
        if (rELoad     != null) loadRESurvey();
        if (ABPopUnder != null) loadPopUnder();
};

window.onload = initialize; // global onload

