//////// FLASH OVERLAY VARIABLES //////// 
var uid;
var flashProxy;
var tag;
//////// ONLOAD EVENT HANDLER //////// 
var onLoadArray = new Array();
var windowloaded = false;
window.onload = onloadfunctions;
function onloadfunctions() { windowloaded = true; for(i=0;i<onLoadArray.length;i++) { eval(onLoadArray[i]); } }

//////// FLASH POPUPS //////// 
function repositionFlash(){
	if (document.all) {
		if(document.body.clientWidth < 750) { document.all.d.style.left = '0px'; } else { document.all.d.style.left = Math.ceil((document.body.clientWidth)/2)-376 + 'px'; }
	} else if (document.getElementById) {
		if(window.innerWidth < 750) { document.getElementById("d").style.left = 0; } else { document.getElementById("d").style.left = window.innerWidth/2-386; }
	}
}
function loadFlash(filename,width,height) {
	uid = new Date().getTime();
	flashProxy = new FlashProxy(uid, webpath+'JavaScriptFlashGateway.swf');
	tag = new FlashTag(webpath+'images'+filename,width,height);
    tag.setFlashvars('lcId='+uid);
    tag.write(document.getElementById("d"));
}
function unloadFlash() {
	document.getElementById("d").innerHTML= '';
}
function sendDataToFlash(varname,value) {
	if(flashProxy)
		flashProxy.call('setVar',varname,value);
}
onLoadArray[onLoadArray.length] = 'sendDataToFlash("htmlloaded","yes")';

//////// NAV ROLLOVERS //////// 
var NavArrayOver = new Array();
var NavArray = new Array();
if (document.images) {
  for(i=1;i<=6;i++) {
   NavArrayOver[i] = new Image(); 	NavArrayOver[i].src = webpath+'img/hvnav' + i + 'o.gif'; 
   NavArray[i] = new Image();  		NavArray[i].src = webpath+'img/hvnav' + i + '.gif';
  }
}
var currentnav = 0;
function navover(i) { if(i!=currentnav) document.images["nav" + i].src = NavArrayOver[i].src; }
function navout(i) { if(i!=currentnav) document.images["nav" + i].src = NavArray[i].src; }

//////// COOKIE READ AND WRITE FUNCTIONS //////// 
/* 
// usage: Writing cookie 
var expdate = new Date (); 
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
SetCookie('DemoName', 'myvalue', expdate); 
// usage: Reading cookie
if (GetCookie('DemoName') != null) {
	document.write(GetCookie('DemoName'));
}
*/
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function DeleteCookie () {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
	var cval = GetCookie ('character');
	document.cookie ='character' + "=" + cval + "; expires=" + exp.toGMTString();
}

//////// CHANGE CHARACTER CURSOR AND LOAD MOUSETRAILER //////// 
function changecharacter(character,pageid) {
	var expdate = new Date (); 
	expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
	SetCookie('character', character, expdate, '/','disneyvideos.com.au'); 
	window.location='index.cfm?P='+pageid;
}
//if (navigator.appName =="Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") < 0) { // IE only
	if (GetCookie('character') != null && !ispopup) {
		document.write('<script type="text/javascript" language="javascript" src="'+webpath+'characters/'+GetCookie('character')+'/mousetrailer.js">');
		document.write('<\/script>');
	}
//}

//////// MOUSE POSITION VARIABLES //////// 
var mouseX = 0;
var mouseY = 0;
function getCursorPosition(e) {
	if (!e) var e = window.event;
	if(navigator.appName.indexOf("Netscape") != -1) {
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else if(document.all) {
		if (document.getElementById) {
			mouseX = event.x + document.body.scrollLeft;
			mouseY = event.y + document.body.scrollTop;
		} else {
			mouseX = event.x;
			mouseY = event.y;
		}
	} 
}

//////// OPINION POLL SUBMIT //////// 
function submitOpinionPoll(fObj,pollID,path) {
	if(arguments.length < 3) {path = '';}
	var checkedVal = "";
	if(fObj.length == 1) { if(fObj.checked) { checkedVal=fObj.value; } }
	else { for(i=0;i<fObj.length;i++) { if(fObj[i].checked) { checkedVal=fObj[i].value; } } }
	if(checkedVal == "") { alert("Please select your answer"); }
	else { mainPop(path+'poll.cfm?PollID='+pollID+'&Answer='+checkedVal); }
}

function popup(url,width,height){
	window.open(url,'popWindow','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width='+width+',height='+height);
}