// browser check, only for crappy IE and to test for DOM compatible browsers...
	var agent = navigator.userAgent.toLowerCase();
//	Mac IE.5x a.k.a Satan's browser doesn't support objects constructors so we need to do this.
	var satansBw = agent.match( /msie/i ) ? agent.match( /mac/i ) ? true : false : false;
	
	function check( agent )
	{
//	check for DOM Script enabled browsers
		this.dom = document.getElementsByTagName( "body" ) ? 1 : 0;
//	check for XML DOM
		this.xmlDom = window.XMLHttpRequest ? 1 : new ActiveXObject( "Microsoft.XMLHTTP" ) ? 1 : 0;
//	check for popular yet crappy browsers
		this.agent = agent;
		this.ie5 = ( this.agent.indexOf( "msie 5" ) > -1 && !this.op5 && !this.op6 );
		this.ie55 = ( this.ie5 && this.agent.indexOf( "msie 5.5" )> -1 );
		this.ie6 = ( this.agent.indexOf( "msie 6" ) > -1 && !this.op5 && !this.op6 );
/*	for some reason Satan's browser (i.e. Mac IE5.x) does not like objects
	so we need to use an old fashioned check for it.
	*/
		this.satan = ( this.agent.indexOf( "msie 5" ) > -1 && this.agent.indexOf( "mac" ) > -1 );
		this.ie = ( this.ie5 || this.ie55 || this.ie6 || this.satan );
		return this;
	}
	var got = !satansBw ? new check( agent ) : new Object();

//alert ( got.xmlDom );
	
	function _XMLHttpRequest()
	{
		this.req = new ActiveXObject( "Microsoft.XMLHTTP" ) ? new ActiveXObject( "Microsoft.XMLHTTP" ) : new XMLHttpRequest();
	}
//	var xml = new _XMLHttpRequest();
	
/*	control page layout here. valid options are...
	left/ center ...for alignment of master-wpr div on screen and all its children	*/
	var alignStyle = "left";
/*	fixed/ liquid ...for fixed width or liquid width	*/
	var widthStyle = "fixed";
/*	l-c-r/ l-c/ c-r/ c ...to control which columns appear on the page
	l = left, c = center, r = right */
	var columnStyle = "l-c-r";
	
//	you don't need to touch this...
	var ieWidthStyle = "narrow";
	
// run function on load and resize
	if ( got.dom || satansBw ) window.onload = init;
//	window.onunload = exitwindow;
/*	if ( got.ie || satansBw ) window.onresize = resize;
	
	function resize()
	{
		alert( document.getElementById( "container" ).clientWidth );	
	}*/
	function init()
	{
//	declare objects
		var oBody = document.getElementsByTagName( "body" )[0];
			var oAnchors = oBody.getElementsByTagName( "a" );
			var oTables = oBody.getElementsByTagName( "table" );
			var oContainer = document.getElementById( "container" );
				var oTimeInc1 = document.getElementById( "timeinc1" );
				var oTimeInc3 = document.getElementById( "timeinc3" );
				var oTimeInc4 = document.getElementById( "timeinc4" );
				var oAddFavourite = document.getElementById( "addfavourite" );
				var oForumLink = document.getElementById( "forumlink" );
//	load dynamic ads		
/*		if ( exist( oTimeInc1 ) )
		{
			loadDynamicAd( oTimeInc1, "script", 1, "http://adremote.timeinc.net/js.ng/site=hh&channel=ipchhhome&adsize=468x60&pagepos=top?ord=" ); 
			loadDynamicAd( oTimeInc1, "script", 0, "http://adremote.timeinc.net/js.ng/site=hh&channel=ipchhhome&adsize=1x1&pagepos=popupentry?ord=" ); 
		}
		if ( exist( oTimeInc3 ) ) loadDynamicAd( oTimeInc3, "script", 1, "http://adremote.timeinc.net/js.ng/site=hh&channel=ipchhhome&adsize=120x60&pagepos=topleft?ord=" ); 
		if ( exist( oTimeInc4 ) ) loadDynamicAd( oTimeInc4, "script", 1, "http://adremote.timeinc.net/js.ng/site=hh&channel=ipchhhome&adsize=120x60&pagepos=topright?ord=" ); 
*/
//	create javascript popup links
		if ( exist( oAnchors ) ) makePopUps( oAnchors );
		if ( exist( oTables ) && !satansBw )
		{
			formatDataTables( oTables );
			formatContactTables( oTables );
		}
		if ( exist( oAddFavourite ) && got.ie && !satansBw ) addLink( oAddFavourite, "javascript:window.external.addfavorite(location.href, document.title)" , "Add to your favourites" );
		if ( exist( oForumLink ) ) addLink( oForumLink, forum_link , '' );
		
//		oBody.className = alignStyle + " " + widthStyle;
//		oContainer.className = "section " + columnStyle;
	}
	
//	if an object exists (i.e. is not null or undefined)
	function exist( obj )
	{
		return obj == null ? false : obj == "undefined" ? false : true ;
	}

/*	create a new HTML element
	( you'd probably want to limit it to iframe, script and img tags or and tag that has the src attribute)
	with a remote adserving URL
	and append it to an existing object or replace the static ad with it
	*/
	function loadDynamicAd( obj, el, addType, url, elClass )
	{
		var bust = Math.floor( 1000000 * Math.random() );
		
		var elTemp = document.createElement( el );
		elTemp.src = url + bust;
		if ( elClass != null ) elTemp.className = elClass;
		
		switch( addType )
		{
			case 1 : obj.replaceChild( elTemp, obj.getElementsByTagName( "a" )[0] );
				break;
			default : obj.appendChild( elTemp );
		}
	}

	var popupAttr = "location=1,menubar=1,personalbar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1";
	var nearestPopupAttr = "height=140,width=325,screenX=100,screenY=100,location=0,menubar=0,status=0";
	var helpPopupAttr = "location=1,menubar=1,personalbar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,height=480,width=640";
	
	function makePopUps( obj )
	{
		var attrRel;
		for ( var i = 0 ; i < obj.length ; i++ )
		{
			if ( obj[i].rel.indexOf( "popup" ) > -1 )
			{
				attrRel = obj[i].rel.split( "|" );
								
				if ( attrRel.length > 1 ) obj[i].setAttribute( "href", "javascript:openWindow( '" + obj[i].href + "','" + attrRel[1] + "','" + eval( attrRel[1] + "PopupAttr" )  + "' );" );
				else obj[i].setAttribute( "href", "javascript:openWindow( '" + obj[i].href + "','" + attrRel + "','" + popupAttr + "' );" );
				
				obj[i].removeAttribute( "target" );
			}
		}
	}
	
	var tbodyTemp, trTemp, thTemp, tdTemp;
	var dataTableClass = "data";
	
	function formatDataTables( obj )
	{
//	make all tables with class="data" have interlaced rows
		for ( var i = 0 ; i < obj.length ; i++ )
		{
//	if the table is well formatted and has a tbody tag then do this
			if ( obj[i].className.indexOf( dataTableClass ) > -1 )
			{
				tbodyTemp = obj[i].getElementsByTagName( "tbody" );
				if ( exist( tbodyTemp ) )
				{
					for ( var j = 0 ; j < tbodyTemp.length ; j++ )
					{
						trTemp = tbodyTemp[j].getElementsByTagName( "tr" );
						for ( var k = 0 ; k < trTemp.length ; k++ ) if ( k % 2 != 0 ) trTemp[k].className += " even";
					}
				}
//	if this the table is not well formated do this
				else
				{
					trTemp = obj[i].getElementsByTagName( "tr" );
//	starts at (j = 1) because I'm assuming that the first row is a table header (th) tag 
					for ( j = 1 ; j < trTemp.length ; j++ ) if ( j % 2 == 0 ) trTemp[j].className += " even";
				}
			}
		}
	}
	
	var contactTableClass = "contact";
	
	function formatContactTables( obj )
	{
//	make all tables with class="contact" have interlaced rows
		for ( var i = 0 ; i < obj.length ; i++ )
		{
//	if the table is well formatted and has a tbody tag then do this
			if ( obj[i].className.indexOf( contactTableClass ) > -1 )
			{
				trTemp = obj[i].getElementsByTagName( "tr" );
				for ( var j = 0 ; j < trTemp.length ; j++ )
				{
					thTemp = trTemp[j].getElementsByTagName( "th" );
					for ( var k = 0 ; k < thTemp.length ; k++ )
						if ( k % 2 != 0 ) thTemp[k].className += " even";
						
					tdTemp = trTemp[j].getElementsByTagName( "td" );
					for ( k = 0 ; k < tdTemp.length ; k++ )
						if ( k % 2 != 0 ) tdTemp[k].className += " even";
				}
			}
		}
	}
	
	function addLink( obj, url, text )
	{
		if ( url )
		{
			var oLink = document.createElement( "a" );
			var oDelimetre = document.createTextNode( " | " );
			oLink.href = url;
			oLink.innerHTML = text == "" ? url : text;
			obj.replaceChild( oLink, obj.firstChild );
			obj.parentNode.insertBefore( oDelimetre, obj );
		}
	}
