var Otitle = null;
var Ocontent = null;
var Oflash = null;
var OhomeFlash = null;
var OhomeMessage = null;
var Obackground = null;
var OtitleOffset = 40;
var OcontentOffset = 20;
var OflashOffset = 570;
var OhomeFlashOffset = 20;
var OhomeMessageOffset = 160;
var OflashVideoOffset = 570;
var ObackgroundWidth = 1950;
var widthMinimum = 994;
var videoMode = false;
var homeMode = false;

function reposition() {
	var winW = widthMinimum;
	var extra = 0;

	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") 
			winW = window.innerWidth;
		if (navigator.appName.indexOf("Microsoft")!=-1)
			winW = document.body.offsetWidth;
	}
	if(winW > widthMinimum) {
		extra = Math.floor((winW - widthMinimum)/2);
		if(Otitle != null)
			Otitle.style.left = (OtitleOffset + extra) + "px";
		if(Ocontent != null)
			Ocontent.style.left = (OcontentOffset + extra) + "px";
		if(videoMode) {
			if(Oflash != null)
				Oflash.style.left = (OflashVideoOffset + extra) + "px";
		}
		else {
			if(Oflash != null)
				Oflash.style.left = (OflashOffset + extra) + "px";
		}
		if(homeMode) {
			if(OhomeFlash != null) {
				OhomeFlash.style.left = (OhomeFlashOffset + extra) + "px";
				OhomeMessage.style.left = (OhomeMessageOffset + extra) + "px";
			}
		}
		else {
			if(Oflash != null)
				Oflash.style.left = (OflashOffset + extra) + "px";
		}
		if(Obackground != null)
			Obackground.style.backgroundPosition = "-" + (Math.floor((ObackgroundWidth - winW) / 2) + 10) + "px bottom"; 
	}

}

function setupReposition(mode) { // Lay out page elements once page has loaded.
	Otitle = document.getElementById("pageTitle");
	if(mode != "home") {
		Ocontent = document.getElementById("content");
	} else {
		OhomeFlash = document.getElementById("homeFlash");
		OhomeMessage = document.getElementById("homeMessage");
	};
	Oflash = document.getElementById("flash");
	Obackground = document.getElementById("background");

	Otitle.style.display = "block";
	if(mode != "home")
		$('content').removeClass('hidden-stuff');
	else
		OhomeFlash.style.display = "block";
	Oflash.style.display = "block";

	if(mode == "video")
		videoMode = true;
	if(mode == "home") {
		homeMode = true;
	}
	reposition();
	window.onresize = reposition;
	
	
	// Run sIFR and SWFObject only once reposition script has made the elements that need to be replaced visible
	
	if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
		sIFR.setup();
		sIFR.replaceElement(named({sSelector: "h1#pageTitle", sFlashSrc: "media/marsbld.swf", sColor: "#ffffff", sBgColor: "#000000", sWmode: "opaque"}));
	};
	if(typeof sIFR == "function"){
    	sIFR();
	}; 
	if (swfobject.hasFlashPlayerVersion("9.0.0")) {
		var att = { data:"media/menu.swf", width:"419", height:"461" };
		var par = null;
		if (activeMenu != null)
			par = { flashvars:"focus=" + activeMenu, salign:"br", bgcolor:"#000000", wmode:"opaque"};
		else
			par = { salign:"br", bgcolor:"#000000" };
		var id = "flashMenuElement";
		var myObject = swfobject.createSWF(att, par, id);
		if(mode == "video") {
			att = { data:"media/videoCanvas.swf", width:"399", height:"224" };
			par = { flashvars:"videofilename=" + videoSource + "&videolength=" + videoLength, bgcolor:"#000000"};
			id = "flashVideoElement";
			myObject = swfobject.createSWF(att, par, id);
		}
		if(mode == "home") {
			att = { data:"media/FTG-Homev2.swf", width:"500", height:"250" };
			par = { salign:"br", bgcolor:"#000000", wmode:"transparent"};
			id = "homeFlashElement";
			myObject = swfobject.createSWF(att, par, id);
		}
		
		att = { data:"swf/logos.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-chocolate.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-chocolate";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-petcare.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-petcare";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-ballarat2.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-ballarat";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-sydney.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-sydney";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-melbourne.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-melbourne";
		myObject = swfobject.createSWF(att, par, id);
		
				
		att = { data:"swf/logos-bathurst.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-bathurst";
		myObject = swfobject.createSWF(att, par, id);
		
			att = { data:"swf/logos-wacol.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-wacol";
		myObject = swfobject.createSWF(att, par, id);
		
					att = { data:"swf/logos-food.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-food";
		myObject = swfobject.createSWF(att, par, id);
		
		att = { data:"swf/logos-wodonga.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-wodonga";
		myObject = swfobject.createSWF(att, par, id);
		
			att = { data:"swf/logos-wyong.swf", width:"140", height:"100" };
		par = { salign:"br", wmode:"transparent"};
		id = "logos-wyong";
		myObject = swfobject.createSWF(att, par, id);
		

//		document.getElementById("flashMenuElement").focus(); // this is supposed to make everything perfect.
	
	}
}
