function strpos( haystack, needle, offset){
// Finds position of first occurrence of a string within another  
// 
// version: 810.1317
// discuss at: http://phpjs.org/functions/strpos
// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// +   improved by: Onno Marsman    
// *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
// *     returns 1: 14
var i = (haystack+'').indexOf( needle, offset ); 
return i===-1 ? false : i;
}


function news_process_width()
{
	var w = 0;
	var h = 0;
	var content;
	var contentwidth = 680;
	var building_minimum = 280;
	var buildingwidth = 290;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}

	content = document.getElementById('news_content').offsetWidth; //add exposed building width
	buildingTicker = document.getElementById('building_ticker');
	
	difference = Math.round((w - (content + buildingwidth))/2);
	newwidth = difference + building_minimum;
	newoffset = -1 * (contentwidth - newwidth);
	
	if (difference > 0) {
	
		if (newwidth < building_minimum) { //we've reached our minimum.
			newwidth = building_minimum;
			newoffset = -building_minimum;
		} else if (newwidth > contentwidth) {
			newoffset = newwidth - contentwidth;
		}

		document.getElementById('newspage_body').style.backgroundPosition = newoffset + 'px -90px';
		if (strpos(navigator.userAgent, 'MSIE') > 0 || strpos(navigator.userAgent, 'Chrome') > 0) 
			buildingTicker.style.marginLeft = (newwidth - 310) + 'px';
		else if (strpos(navigator.userAgent, 'Firefox/2') > 0 || strpos(navigator.userAgent, 'Firefox/3') > 0 || (strpos(navigator.userAgent, 'Version/4') > 0 || strpos(navigator.userAgent, 'Version/5') > 0) && strpos(navigator.userAgent, 'Safari') > 0)
			buildingTicker.style.marginLeft = (newwidth - 310) + 'px';
		else 
			buildingTicker.style.Left = (newwidth - 262) + 'px';

		//wrapper_x = document.getElementById('news_content').offsetLeft;
		//inner_x = document.getElementById('news_content_inner').offsetLeft;
		
		//document.getElementById('debug').innerHTML = w + '<br>diff ' + difference + '<br>width ' + newwidth + '<br>offset ' + newoffset;
		//document.getElementById('debug').innerHTML = buildingTicker.style.Left;

	}//end if difference > 0
	if (strpos(navigator.userAgent, 'Firefox/2') > 0 || strpos(navigator.userAgent, 'Firefox/3') > 0)
		setTimeout("news_process_width();",100);
	
}

//FF fires the onresize only after mouseup.  So do this for FF: 
/* FireFox resize workaround start*/

if (strpos(navigator.userAgent, 'Firefox/2') > 0 || strpos(navigator.userAgent, 'Firefox/3') > 0) {
	
	//window.onload = news_process_width;///setTimeout("news_process_width();",100); /*** original 200 ***/
	
} else {
	window.onresize = news_process_width;
}


