// ==========================================
// General DOM Functions
//
function getElementObject(e){
	if( document.getElementById )
		return document.getElementById(e);
	else if( document.all )
		return document.all[e];
	else 
		return null;
}

function removeElementChildren(element){
	if(document.getElementById && document.removeChild){
		var el = document.getElementById(element);
		while( el.hasChildNodes() )
			el.removeChild( el.lastChild );
		
		return true;
	} else if (document.getElementById && document.innerHTML){
		document.getElementById(element).innerHTML = "";
		
		return true;
	}
	
	return false;
}

function closeElement( element ){
	getElementObject( element ).style.display = "none";
}

function showElement( element ){
	getElementObject( element ).style.display = "block";
}

function setAttributeClass( objElement, strValue, bAdd ){	
	var strClass = objElement.className;
	if( strClass != null && strClass.length > 0 && bAdd ){
		objElement.className += " " + strValue;
		return;
	} 
	
	objElement.className = strValue;
}

function removeFromClassAttribute( objElement, strValue ){
	if( objElement.className.indexOf( strValue ) < 0 )
		return;
	
	if( objElement.className.indexOf( strValue ) > 0 )
		strValue = " " + strValue;
		
	objElement.className = objElement.className.replace( strValue, "" );
}
// End DOM Functions
//===========================================
// ==========================================
// Add push Function
//
if(Array.prototype.push == null){
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}
// ==========================================
// Window Functions
//
var arrWindowLoad = new Array();
arrWindowLoad.push( window.onload );

window.onload = function( ev ){
	for( var i = 0; i < arrWindowLoad.length; i++ ){
		var fn = arrWindowLoad[i];
		
		if( fn )
			fn( ev );
	}
}

function windowOnLoad( fn ){
	arrWindowLoad.push( fn );
}

function getWindowSize() {
	var win = new Object();
	win.width = 0; 
	win.height = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) { 
		//Non-IE
		win.width = window.innerWidth;
		win.height = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		win.width = document.documentElement.clientWidth;
		win.height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		win.width = document.body.clientWidth;
		win.height = document.body.clientHeight;
	}
	
	return win;
}
// End Window Functions
//==========================================
//===========================================
// Page Utilities
//
function addTargetToAnchors(){
	if( !document.getElementsByTagName )
		return;
	
	anchors = document.getElementsByTagName( "A" );
	for( var i = 0; i < anchors.length; i++){
		if( anchors[i].href != "" && anchors[i].rel == "new-win" )
			anchors[i].target = "_blank";
	}
}
windowOnLoad( addTargetToAnchors );

function setUsabilityButtons(){
	var obj = getElementObject( "txt-norm" );
	var objContent = getElementObject( "content" ) ? getElementObject( "content" ) : getElementObject( "content-only" );
	if( obj ){
		obj.onclick = function(){objContent.style.fontSize = "100%";return false;};
		obj.title = "Normal Text"
	}
	
	obj = getElementObject( "txt-larg" );
	if( obj ){
		obj.onclick = function(){objContent.style.fontSize = "115%";return false;};
		obj.title = "Large Text";
	}
	
	obj = getElementObject( "txt-xlp" );
	if( obj ) {
		obj.onclick = function(){objContent.style.fontSize = "130%";return false;};
		obj.title = "Larger Text";
	}
	
	obj = getElementObject( "btn-print" );
	if( obj ){
		obj.onclick = function(){if(window.print){window.print();return false;}};
	}
}

/*
currentload = window.onload;
window.onload = function( ev ){
	if( currentload )
		currentload( ev );
	
	setUsabilityButtons();
}*/

// ==========================================
