

//window.onload = init;

function init(){
	resizer();
	checkBrowserWidth();
	attachEventListener(window, "resize", checkBrowserWidth, false);
}



function resizer(){
	if (window.innerWidth){
		var browseW =  window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0){
		var browseW =  document.documentElement.clientWidth;
	}
	else if (document.body){
		var browseW =  document.body.clientWidth;
	}
if(browseW<800){window.resizeTo(800,600);}
}



function setupVid(){

var targ = document.getElementById("movie");

targ.innerHTML = "<object id=\"MediaPlayer\" width=\"184\" height=\"182\" classid=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" standby=\"Loading Windows Media Player components...\" type=\"application/x-oleobject\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\"><param name=\"filename\" value=\"http://www.wineinvestmentfund.com/lunzer.wmv\"><param name=\"Showcontrols\" value=\"true\"><param name=\"autoStart\" value=\"True\"><embed type=\"application/x-mplayer2\" src=\"http://www.wineinvestmentfund.com/lunzer.wmv\" autostart=\"1\" showdisplay=\"0\" showcontrols=\"1\" name=\"MediaPlayer\" width=\"184\" height=\"182\"></embed></object>"

}


var theWidth
function checkBrowserWidth()
{
	var h1 = document.getElementsByTagName("h1");
	if (h1[0]){var h1I = h1[0].getElementsByTagName("img");}
	


	theWidth = getBrowserWidth();
	
	if (theWidth == 0)
	{
		var resolutionCookie = document.cookie.match(/(^|;)fc_layout[^;]*(;|$)/);

		if (resolutionCookie != null)
		{
			setStylesheet(unescape(resolutionCookie[0].split("=")[1]));
		}
		
		addLoadListener(checkBrowserWidth);
		
		return false;
	}

	if (theWidth > 1020)
	{
		setStylesheet("Large");
		document.cookie = "wif_layout=" + escape("Large");
		if(h1[0]){
		if(h1[0].className=="home"){h1I[0].src="assets/images/h-home.gif";}
		if(h1[0].className=="others"){h1I[0].src="../assets/images/h-what-others-say.gif";}
		if(h1[0].className=="we-aim"){h1I[0].src="../assets/images/h-performance.gif";}
		if(h1[0].className=="latest"){h1I[0].src="../assets/images/h-latest-figures.gif";}
		if(h1[0].className=="institutional"){h1I[0].src="../assets/images/h-institutional.gif";}
		if(h1[0].className=="about-directors"){h1I[0].src="../assets/images/h-directors.gif";}
		if(h1[0].className=="application"){h1I[0].src="../assets/images/h-application.gif";}
		if(h1[0].className=="portfolio"){h1I[0].src="../assets/images/h-wine-portfolio.gif";}
		}
	}
	else
	{
		setStylesheet("");
		document.cookie = "wif_layout=";
		if(h1[0]){
		if(h1[0].className=="home"){h1I[0].src="assets/images/h-home-sm.gif";}
		if(h1[0].className=="others"){h1I[0].src="../assets/images/h-what-others-say-sm.gif";}
		if(h1[0].className=="we-aim"){h1I[0].src="../assets/images/h-performance-sm.gif";}
		if(h1[0].className=="latest"){h1I[0].src="../assets/images/h-latest-figures-sm.gif";}
		if(h1[0].className=="institutional"){h1I[0].src="../assets/images/h-institutional-sm.gif";}
		if(h1[0].className=="about-directors"){h1I[0].src="../assets/images/h-directors-sm.gif";}
		if(h1[0].className=="application"){h1I[0].src="../assets/images/h-application-sm.gif";}
		if(h1[0].className=="portfolio"){h1I[0].src="../assets/images/h-wine-portfolio-sm.gif";}
		}
	}
	
	return true;
};




function getBrowserWidth()
{
	if (window.innerWidth)
	{
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0)
	{
		return document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		return document.body.clientWidth;
	}
	
	return 0;
};




function setStylesheet(styleTitle)
{
	var currTag;

	if (document.getElementsByTagName)
	{
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
		{
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
			{
				currTag.disabled = true;

				if(currTag.getAttribute("title") == styleTitle)
				{
					currTag.disabled = false;
				}
			}
		}
	}
	
	return true;
};