function getObj(id) {
	return document.getElementById(id)
}
		
function DHTML_SetClass(id, classname) {
	getObj(id).classNameOld = "";
	getObj(id).className = classname;
}
			
function DHTML_ShowHide(id, visible) {
	if (id == null || id == "") return;
	var obj = getObj(id);
	if (obj == null) return;
	if (obj.style) obj = obj.style;
	if (visible == null) visible = !(obj.display=="block" || obj.display=="");
	if (visible) { obj.display = "block"; }
	else { obj.display = "none"; }
}
function isVisible(id) {
	if (id == null || id == "") return null;
	obj = getObj(id);
	if (obj == null) return null;
	if (obj.style) obj = obj.style;
	return (obj.display=="block" || obj.display=="");
}

function DHTML_ToggleVisible(id, label, ontext, offtext) {
	obj = getObj(id);
	if (obj.style) obj = obj.style;
	visible = (obj.display == "none");
	if (visible) { obj.display = "block"; DHTML_SetText(label, ontext); }
	else { obj.display = "none"; DHTML_SetText(label, offtext); }
}

			
function clientLeft(obj) {
	if (obj == null) return 0;
	return obj.offsetLeft + clientLeft(obj.offsetParent);
}
function clientTop(obj) {
	if (obj == null) return 0;
	return obj.offsetTop + clientTop(obj.offsetParent);
}

function clientArea() {
	// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}

function getWindowScroll() {
	// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

// addEvent function by John Resig:
// http://ejohn.org/projects/flexible-javascript-events/
function addEvent( obj, type, fn ) {
	if ( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else {
		obj.addEventListener( type, fn, false );
	}
}
                  
function DHTML_SetText(obj, text) {
	getObj(obj).innerHTML = DHTML_Escape(text);
}

function DHTML_Escape(text) {
	text = text.replace("&lt;", "&amp;lt;");
	text = text.replace("&gt;", "&amp;gt;");
	return text;
}

function placead() {
	var ad_1 = document.documentElement.clientWidth >= 1100;
	if (document.getElementById('ad1')) DHTML_ShowHide('ad1', ad_1);
	if (document.getElementById('ad2')) DHTML_ShowHide('ad2', !ad_1);
}
window.onresize = placead;

function lt(a, b) {
	return a < b;
}
function and(a, b) {
	return a && b;
}

function ajax(elemid, immediate_html, qs, onfinish) {
	if (qs == null) qs = { };
	qs["ajax_element"] = elemid;
	AjaxElement(elemid, immediate_html, document.location.href + (document.location.href.indexOf('?') == -1 ? "?" : "") + makeArrayQueryString(qs), onfinish)
}
