/*
	
	Copyright 2007 Artlogic Media Limited - http://www.artlogic.net/
	All rights reserved.

*/


//	COOKIE FUNCTIONS


	function setCookie(cookieName,cookieValue,nDays,path) {
		var today = new Date();
		var expire = new Date();
		if (nDays==null || nDays==0) {
			nDays=1;
		}
		expire.setTime(today.getTime() + 3600000*24*nDays);
		if (typeof path=="undefined") {
			document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
		} else {
			document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString()+";path="+escape(path);
		}
	}

	function readCookie(cookieName) {
		var theCookie=""+document.cookie;
		var ind=theCookie.indexOf(cookieName);
		if (ind==-1 || cookieName=="") {
			return ""; 
		}
		var ind1=theCookie.indexOf(';',ind);
		if (ind1==-1) {
			ind1=theCookie.length;
		}
		return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}



//	ARE COOKIES ENABLED?

	var cookiesEnabled = true;
	
	setCookie("cookiesEnabled", "true", 30, "/");
	if (readCookie(cookiesEnabled) == "" ) {
		cookiesEnabled = false;
	}




//	PAGE FUNCTIONS

	doOnLoadOnResize = function() {
		resizePage();
	}
	
	







//	FUNCTIONS WHICH HANDLE THE WINDOW RESIZE

	var resizePage = function() {
		if (cookiesEnabled) {
			document.body.style.overflow = "hidden";
			var winW = (document.body.clientWidth) ? document.body.clientWidth : window.innerWidth;
			var winH = (document.body.clientHeight) ? document.body.clientHeight : window.innerHeight;
			document.body.style.overflow = "auto";
			var offsetHorizontal = 60;
			var offsetVertical = 20
			/*	Note: Firefox does not correctly calculate the inner height (it only calculates the *used* content), so we just test for the width. */
			var winSize = (winW < 980 + offsetHorizontal) ? "small" : "large";
			var prevWinSize = readCookie("winSize");		
			if (prevWinSize != winSize) {
				setCookie("winSize", winSize, 30, "/");
				document.body.style.visibility = "hidden";
				document.location.href = document.location.href.split("#")[0].split("?")[0];
		}
		}
	}
 





//	FUNCTIONS FOR LOADING / PLAYING MOVIES...

	var loadMovie = function(url, w, h) {
		if (slides) {
			if (slides.stop) {
				slides.stop();	
			}
			if ($("footerToolbar")) {
				$("footerToolbar").style.display = "none";
			}
		}
		url = unescape(url);
		w = parseInt(unescape(w));
		h = parseInt(unescape(h)) + 16;
		var html = '<div style="float: right">\
					<object width="' + w + '" height="' + h + '" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">\
					<param name="src" value="' + url + '">\
					<param name="controller" value="true">\
					<param name="autoplay" value="true">\
					<embed src="' + url + '" width="' + w + '" height="' + h + '" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/">\
					</embed>\
					</object>\
					</div>';
		$("projectSlideshow").innerHTML = html;
	}