var active = null;
//
var agent = navigator.userAgent.toLowerCase(); 
var isMac = (agent.indexOf("mac") != -1) ? true : false;
var isMSIE = (navigator.appVersion.indexOf("MSIE")!=-1) ? true : false;
//
toCamelCase=function (s) {
	for (var exp = /-([a-z])/; exp.test(s); s=s.replace(exp, RegExp.$1.toUpperCase())) {
	}
	return s;
}
//
getStyle=function (el, style) {
	if (!document.getElementById) {
		return;
	}
	var value = el.style[toCamelCase(style)];
	if (!value) {
		if (document.defaultView) {
			value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		} else if (el.currentStyle) {
			value = el.currentStyle[toCamelCase(style)];
		}
	}
	return value;
}
//
getElement=function(id){	
	if (!document.getElementById){
	 return;
	}
	//
	if (document.getElementById){
		// this is the way the standards work
		var el = document.getElementById(id);
	}else if (document.all){
		// this is the way old msie versions work
		var  el = document.all[id];
	}else if (document.layers){
		// this is the way nn4 works
		var el = document.layers[id];
	}
	return el;
}
//
toggleDisplay=function(el){
	el.style.display = el.style.display ? "" : "block";
}
//
switchContent=function(id){
	//turn off last active
	if(active){
		toggleDisplay(active);
	}
	active=getElement(id);
	toggleDisplay(active);
	trackEvent(window.location.host, "/"+id+".ajaxPage", id, '');
	if(isMSIE){
		fixscroll();
	}
}
//
writeToolbar=function(src){
	(getElement('toolbar')).innerHTML='<iframe src="'+src+'" name="toolbarframe" height="26" width="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>';
}
//
window.getsize = function () {
	var w = 0, h = 0;
	if (typeof (this.innerWidth) == 'number') {
		//Non-IE
		w = this.innerWidth;
		h = this.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	return({w:w,h:h});
}
//s
fixscroll=function(){	
	var h=this.getsize().h-Number(getStyle(getElement('toolbar'), "height").split("px")[0])-Number(getStyle(getElement('nav'), "height").split("px")[0]);
	(getElement('content')).style.height=h+"px";
}
//
jukebox=writeSender=function(message){
	var fo = new FlashObject("sender.swf", "senderf", "100", "100", "6", "#ffffff");
	fo.addVariable("lcName", lcName);
	fo.addVariable("message", message);
	fo.write("sender");
}
//
getQueryVariable = function (variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i<vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
};
//
replaceAnchors=function(){
	if (document.getElementById) {
		var atags = document.getElementsByTagName("A");
		for (var i = 0; i<atags.length; i++) {
			var ca = atags[i];
			var index=ca.href.indexOf("#");
			var hash=ca.href.substring(index+1);
			if (index>-1 &&	hash.length>0) {
				ca.link=hash;
				ca.onclick = function() {	
					var b = getElement('content');
					b.scrollTop = getElement(this.link).offsetTop;
					return false;
				};
			}
		}
	}
}
//
function trackEvent(domain, URL, Title, offSite) {
	dcsMultiTrack('DCS.dcssip',domain,'DCS.dcsuri',URL,'WT.ti',Title,'WT.os',offSite);
}
//
if(isMSIE){
	document.onresize = window.onresize=fixscroll;
}
