function getElem(x) {
	var elem;
	if(document.getElementById) elem = document.getElementById(x);
	else if(document.all) elem = document.all[x];
	else if(document.layers) elem = document.layers[x];
	return elem;
}
var vpw,vph;
function setImg(){
	if (typeof window.innerWidth != 'undefined'){
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		vph = window.innerHeight; vpw = window.innerWidth;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth!='undefined' && document.documentElement.clientWidth!=0){
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		vph = document.documentElement.clientHeight; vpw = document.documentElement.clientWidth;
	}
	else{
	// older versions of IE
		vph = document.getElementsByTagName('body')[0].clientHeight; vpw = document.getElementsByTagName('body')[0].clientWidth;
	}
	if(vpw<500||vph<450){
		getElem('shtml').style.overflow="auto";
		getElem('sbody').style.overflow="auto";
		getElem('bg').style.display="none";
		getElem('breakfast').style.display="none";
		getElem('logo').style.left="45px";
		getElem('logo').style.top="30px";
		getElem('mainnav').style.top="135px";
		getElem('mainnav').style.width="322px";
		//getElem('orders').style.styleFloat="left";
		//getElem('about').style.styleFloat="left";
		//getElem('menu').style.styleFloat="left";
		//getElem('fans').style.styleFloat="left";
		//getElem('orders').style.cssFloat="left";
		//getElem('about').style.cssFloat="left";
		//getElem('menu').style.cssFloat="left";
		//getElem('fans').style.cssFloat="left";
		getElem('orders').style.marginBottom="0";
		getElem('content').style.left="40px";
		getElem('content').style.top="296px";
		getElem('content').style.width="316px";
		getElem('contentbkg').style.height="auto";
		getElem('subnav2').style.marginLeft="10px";
		//getElem('subnav').style.left="48px";
		//getElem('subnav').style.width="322px";
		//getElem('subnav').style.top="10px";
		//getElem('subnav').style.bottom="auto";
	}
	else{
		getElem('shtml').style.overflow="hidden";
		getElem('sbody').style.overflow="hidden";
		getElem('bg').style.display="block";
		getElem('breakfast').style.display="block";
		getElem('logo').style.left="50%";
		getElem('logo').style.top="10%";
		getElem('mainnav').style.top="30%";
		getElem('mainnav').style.width="170px";
		//getElem('orders').style.styleFloat="none";
		//getElem('about').style.styleFloat="none";
		//getElem('menu').style.styleFloat="none";
		//getElem('fans').style.styleFloat="none";
		//getElem('orders').style.cssFloat="none";
		//getElem('about').style.cssFloat="none";
		//getElem('menu').style.cssFloat="none";
		//getElem('fans').style.cssFloat="none";
		getElem('orders').style.marginBottom="40px";
		getElem('content').style.left="230px";
		getElem('content').style.top="30%";
		getElem('content').style.width="55%";
		getElem('contentbkg').style.height="50%";
		getElem('subnav2').style.marginLeft="-10px";
		//getElem('subnav').style.left="215px";
		//getElem('subnav').style.width="100%";
		//getElem('subnav').style.top="auto";
		//getElem('subnav').style.bottom="40px";
	}
}
window.onload = function() {
  setMainImage();
  setImg();
};
window.onresize=setImg;






	var imageArray = Array('images/bg.jpg','images/bg2.jpg','images/bg3.jpg','images/bg4.jpg');
	var linkArray = Array('','','','','');

	var popupArray = Array('0','0','0','0');
				// Scott: Rowland, in case you want to re-use this:
				// Scott: Rowland, in case you want to re-use this:
	var autoSwitch = true; 	// automatically switch images
	var callBackFunction = "";

	var fadeInt;
	var autoSwitchInt;
	var currentOp;
	var currentImage = 0;
	var loadStatus = 1;
	var didCallBack;
	if (!autoSpeed) {	
		var autoSpeed = 4000;
	}
	if (!fadeSpeed) {
		var fadeSpeed = 2;
	}
	function getImageLink() {
		if (linkArray.length > 0) {
			loadStatus = 1;
			if (popupArray[currentImage] == 1) {
				var curTime = Date();
				window.open(linkArray[currentImage],curTime,'width=800,height=600,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes')
			}
			else {
				document.location = linkArray[currentImage];
			}
		}
	}
	function setMainImage() {
		if (autoSwitch) {
			autoSwitchInt = setInterval("step(1)",autoSpeed);
		}
		var topImage = document.getElementById("topLayerImage");
		topImage.src = imageArray[0];
		// alert(imageArray[0]);
/*
*/
		
	}
	function step(direction) {
		clearInterval(autoSwitchInt);
		if (loadStatus == 1) {
			loadStatus = 0;
			currentImage = currentImage + direction;
			if (currentImage >= imageArray.length) {
				currentImage = 0;
			}
			else if (currentImage < 0) {
				currentImage = imageArray.length - 1;
			}
			loadImage();
		}
	}
	function loadImage() {
		var top = document.getElementById("topLayer");
		setOpacity(top, 100);
		clearInterval(fadeInt);
		didCallBack = false;
		var newImage = document.getElementById("bottomLayerImage");
		newImage.onload = function() {
			var top = document.getElementById("topLayer");
			setOpacity(top, 100);
			currentOp = 100;
			fadeInt = setInterval("fadeTop()",10);
		}
		newImage.src = imageArray[currentImage];
	}
	function fadeTop() {
		currentOp = currentOp - fadeSpeed;
		if ((currentOp <= 50)&&(! didCallBack)&&(callBackFunction)) {
			eval(callBackFunction+"()");
			didCallBack = true;
		}
		if (currentOp >= 0) {
			var top = document.getElementById("topLayer");
			setOpacity(top, currentOp);
		}
		else {
			var newImage = document.getElementById("topLayerImage");
			newImage.onload = function() {
				document.getElementById("topLayer").style.opacity = 1;
				loadStatus = 1;
/*
				if (callBackFunction) {
					eval(callBackFunction+"()");
				}		
*/
			}
			newImage.src = imageArray[currentImage];
			clearInterval(fadeInt);
			if (autoSwitch) {
				autoSwitchInt = setInterval("step(1)",autoSpeed);
			}
		}
	}
	function setOpacity(obj, opacity) {
  		opacity = (opacity == 100)?99.999:opacity;
	  	// IE/Win
  		obj.style.filter = "alpha(opacity:"+opacity+")";
  		// Safari<1.2, Konqueror
  		obj.style.KHTMLOpacity = opacity/100;
  
  		// Older Mozilla and Firefox
  		obj.style.MozOpacity = opacity/100;
  
  		// Safari 1.2, newer Firefox and Mozilla, CSS3
  		obj.style.opacity = opacity/100;
	}