var win = null;
var baseURL;
window.onerror = null;
baseURL = window.location.protocol + "//" + window.location.hostname + "/";


// NEW WINDOW
function newWindow(mypage, myname, w, h, scroll) {
	closePopWin();
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',noresize';
	win = window.open(mypage, myname, winprops);
	//if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// CLOSE POPUP
function closePopWin()  {
	if(win != null) {
		if(!win.closed) {
			win.close();
			win = null;
		} else {
			win = null;
		}
	}
}

// GET OBJECT BY ID.. OLDER METHOD
function getObject(id) {
	var object = null;
	if( document.layers ) object = document.layers[id];
	else if( document.all ) object = document.all[id];
	else if( document.getElementById )  object = document.getElementById(id);
	return object;
}

// GOOGLE ANALYTICS
if (typeof(_gat) == "object") { 
	var pageTracker = _gat._getTracker("UA-5192063-3");
	pageTracker._initData(); 
	pageTracker._trackPageview(); 
}

function analyticTrack( address ){ pageTracker._trackPageview( address ); }

// SPOTLIGHT
function spotlight(src) {
	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	var url = src + a + '?';
	getObject('spotlight_pixel').innerHTML = '<img src=' + url + ' />';
}

// DEBUGING
function getDebugDiv() {
	var id = "ChR1sm1ths0m3th1ngc0l0rfulDeBuGv4r14bl3s";
	if(getObject(id)==null || getObject(id)==undefined){
		document.write("<div style='z-index:8000;width=0;height=0' id="+id+"></div>");
		getObject(id).innerHTML = "DEBUG:<br/>";
	} 
	return getObject(id);
}
function addDebugVariables(v) { 
	var o = getDebugDiv();
	var inner = o.innerHTML;
	inner += v+"<br/>"
}


