
/*
	The INT3R.workingz
	
	Written by Design Technologist
		- Seth Van Booven [svanbooven@sacbee.com]
	
	Copyright © The Sacramento Bee
	Created: March 1, 2006 (sv)  /  Last update: 03/01/06 (sv)
	
	****************************************************
		IF YOU DON'T KNOW WHAT YOU ARE DOING
		THEN YOU DON'T BELONG HERE.
		.........................CLOSE IMMEDIATELY!
	****************************************************
------------------------------------------------------------*/

var userAgent = navigator.userAgent.toLowerCase();

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 = '';
}

/*
/////////////////////////////

/////////////////////////////
*/

var uber = 1;
var uberURL = 'http://search.sacbee.com/search?ie=&site=sacbee_search&output=xml_no_dtd&client=sacbee_search&lr=&proxystylesheet=sacbee_search&oe=&q=';
function doUber1(v) {
	uberURL = 'http://search.sacbee.com/search?ie=&site=sacbee_search&output=xml_no_dtd&client=sacbee_search&lr=&proxystylesheet=sacbee_search&oe=&q=' + v;
	doUberReq(v, 'google');
}
function doUber2(v) {
	uberURL = 'http://localsearch.sacbee.com/sp?keywords=' + v;
	doUberReq(v, 'shopping');
}
function doUber3(v) {
	uberURL = 'http://local.sacramento.com/search?pg=sr&style=sacbee&dt=10&s=0&v=3.1&inad=1&inaddr=1&q=' + v;
	doUberReq(v, 'sacramento');
}
function doUberReq(v, w) {
	if (isReqCompatible()) {
		var r = new loadRequest('/dyn/top_search/search.html?word=' + v + '&location=' + w, 'uberWhereTo');
	} else {
		uberWhereTo();
	}
}
function uberWhereTo() {
	location.href = uberURL;
}
function setUber(v) {
	uber = v;
}
function submitUber() {
	var q = document.uber_search.q.value;
	if (uber == 2) {
		doUber2(q);
	} else if (uber == 3) {
		doUber3(q);
	} else {
		doUber1(q);
	}
}
function showSearch() {
	var o = document.getElementById('search_field');
	if (!o) return;
	o.style.backgroundPosition = '0 2px';
	showElm('search_now');
}
function hideSearch() {
	var o = document.getElementById('search_field');
	if (!o) return;
	if (o.value == '') {
		o.style.backgroundPosition = '0 -30px';
	}
	hideElm('search_now');
}
function loadSearch() {
	var o = document.getElementById('search_field');
	if (!o) return;
	setTimeout('hideSearch()', 1000);
	o.onfocus = function() {
		showSearch();
	}
}

/*
/////////////////////////////

/////////////////////////////
*/

function isReqCompatible() {
	var ro;
	try {
		ro = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		ro = false;
	}
	if (typeof ro == "object") return true;
	else return false;
}

function loadRequest(url, method) {
	var _this = this;
	this.url = url;
	this.method = method
	if (window.XMLHttpRequest) {
		this.req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		this.req = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (this.req) {
		this.req.onreadystatechange = function() {
			_this.getRequest();
		};
		this.req.open('GET', this.url, true);
		this.req.send(null);
	} else {
		return;
	}
}
loadRequest.prototype.getRequest = function() {
    if (this.req.readyState == 4) {
        if (this.req.status == 200) {
			var m = eval(this.method);
			m(this.req.responseText);
        } else {
			//alert('There was a problem retrieving your request. ' + this.req.statusText);
        }
    }
}

function reqLoadAd(o, s) {
	var obj = o.parentNode;
	obj.innerHTML = s;
	//alert(s);
}

/*
/////////////////////////////

/////////////////////////////
*/

function showElm(o) {
	var obj = document.getElementById(o);
	if (!obj) return;
	obj.style.visibility = 'visible';
}

function hideElm(o) {
	var obj = document.getElementById(o);
	if (!obj) return;
	obj.style.visibility = 'hidden';
}

function showDisplay(o) {
	var obj = document.getElementById(o);
	if (!obj) return;
	obj.style.display = 'block';
}
function hideDisplay(o) {
	var obj = document.getElementById(o);
	if (!obj) return;
	obj.style.display = 'none';
}

function popWin(url, winName, w, h, scroll) {
	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);
}

/*
/////////////////////////////

/////////////////////////////
*/

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

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

function nixErr() {
	return true;
}

window.onerror = nixErr;  // global onerror

