
/*
	The INT3R.workingz
	
	Written by Design Technologist
		- Seth Van Booven [svanbooven@sacbee.com]
	
	Copyright © The Sacramento Bee
	Created by the New Media Department
	Created: July 01, 2001 (sv)  /  Last update: 10/27/02 (sv)
	
	****************************************************
		IF YOU DON'T KNOW WHAT YOU ARE DOING
		THEN YOU DON'T BELONG HERE.
		.........................CLOSE IMMEDIATELY!
	****************************************************
------------------------------------------------------------*/

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

var d   = document;
var agt = navigator.userAgent.toLowerCase();
var w3c = (d.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) && (d.all) && !w3c && !xxx) ? true : false;
var ns6 = ((agt.indexOf('gecko') != -1) && w3c && !xxx) ? true : false;
var ns4 = (d.layers && !w3c && !xxx) ? true : false;

var isWin = (navigator.appVersion.indexOf('Windows') != -1) ? true : false;

var domain = 'http://www.sacbee.com';
if (location.href.indexOf('https://') > -1) {
	domain = '';
}

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

if (ieX) d.write('<link rel="stylesheet" type="text/css" href="' + domain + '/static/css/ieX.css" />');
else if (ie4) d.write('<link rel="stylesheet" type="text/css" href="' + domain + '/static/css/ie4.css" />');
else if (ns6) d.write('<link rel="stylesheet" type="text/css" href="' + domain + '/static/css/ns6.css" />');
else d.write('<link rel="stylesheet" type="text/css" href="' + domain + '/static/css/ie4.css" />');


/*
	Function to Show/Hide/Toggle Layers
----------------------------------------*/

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

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

function togDisplay(id) {
	var elm = d.getElementById ? d.getElementById(id) : d.all ? d.all(id) : null;
	if (elm) elm.style.display = (elm.style.display == 'block') ? 'none' : 'block';
}


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

function goHere(s) {
	var URL = s.options[s.selectedIndex].value;
	if (URL != '') d.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);
}

function popGallery(u, n, s, ss, p) {
	var qs = '';
	if (n != null) qs += "&n=" + n;
	if (s != null) qs += "&s=" + s;
	if (ss != null) qs += "&ss=" + ss;
	if (p != null) qs += "&p=" + p;
	popWin(u + "?" + qs, '', 720, 450, 1);
}


/*
	Misc Functions
----------------------------------------*/

function toggleInput(o, elm) {
	o.className = (o.className == elm) ? elm + 'On' : elm;
}

function togClass(o, elm) { 
	o.className = elm; 
}

function nixErr() { 
	return true; 
}

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

if (d.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.
----------------------------------------*/

wLoad = null;   // Sets a null value if Weather is not present
ticker = null;   // Sets a null value if Ticker is not present

indexPop = null;
beePop = null;
rELoad = null;
ABPopUnder = null;
ABPopUp = null;
randomSurvey = null;
carsPop = null;

function initialize() {
	if (wLoad != null) wInit();
	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
window.onerror = nixErr; // global onerror
