var isIOS = ((navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)));

if (window.addEventListener) 
{
	window.addEventListener("resize", resizedWindow, false);
	window.addEventListener("load", loadedDocument, false);
	window.addEventListener("scroll", scrollWindow);
}
else if (window.attachEvent) 
{
	window.attachEvent("onresize", resizedWindow);
	window.attachEvent("onload", loadedDocument);
	window.attachEvent("onscroll", scrollWindow);
}
else 
{
	window.onresize = resizedWindow;
	window.onload = loadedDocument;
	window.onscroll = scrollWindow;
}

scrollWindow();



function loadedDocument()
{
	resizedWindow({});
}

function resizedWindow(e)
{
	var small_width = (getWindowSize().width < 1000)
	var small_height = (getWindowSize().height < 570)
	var desired_classname = (small_width ? 'small_width ' : '')+(small_height ? 'small_height ' : '')+'ben';
	if (document.getElementById('container').className != desired_classname)
	{
		// this "if" gets around several ie6 issue
		document.getElementById('container').className = desired_classname;
	}
}

function scrollWindow(e)
{
	if (isIOS)
		document.getElementById('beyondedge_navigation').style.top=(window.innerHeight+window.pageYOffset-70)+'px';
}

function getWindowSize()
{
	var myWidth = 0, myHeight = 0;
	if (typeof(window.innerWidth) == 'number') 
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) 
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {
		width: myWidth,
		height: myHeight
	};
}
