// set the street date for pre/post street read

streetDate=[2007,6,19];
vaultDate=[2009,1,30];
function checkAvailability() {
	var year=streetDate[0];
	var month=streetDate[1]-1;
	var date=streetDate[2];
	var today=new Date();
	var todaysYear=today.getFullYear();
	var todaysMonth=today.getMonth();
	var todaysDate=today.getDate();
	todayDateTime = today.getTime();
	var availableDate = new Date();
	availableDate.setFullYear(year);
	availableDate.setMonth(month);
	availableDate.setDate(date);
	availableDateTime = availableDate.getTime();
	if(todayDateTime >= availableDateTime){
		nowAvailable=true;
	}else{
		nowAvailable=false;
	}
}
checkAvailability();

function compareDate(yr,mo,dt) {
	var mo=mo-1;
	var today=new Date();
	var userDateAt = location.search.substring().indexOf("today=");
	if (userDateAt > 0) {
		var userDateStr = location.search.substr(userDateAt+6);
		var userDateEnd =  userDateStr.indexOf("&");
		if (userDateEnd > 0) {
			userDateStr = userDateStr.substring (0,userDateEnd);
		}
		userDate = userDateStr.split(",");
		today.setFullYear(userDate[0]);
		today.setMonth(Number(userDate[1])-1);
		today.setDate(userDate[2]);
	}
	today.setMinutes(today.getMinutes()+10);
	var checkDate = new Date();
	checkDate.setFullYear(yr);
	checkDate.setMonth(mo);
	checkDate.setDate(dt);
	if(today >= checkDate) {
		return true;
	}else{
		return false;
	}
}

function launch800Popup(hb) {
	// hitbox.Set_hbLink(exitLinkArray[hb]);
	var w = 390;
	var h = 270;
	var winl = (screen.width - w) / 3;
	var wint = (screen.height - h) / 3;
	coords = 'width='+w+',height='+h+',top='+wint+',left='+winl;
	orderWin = window.open('http://disneyvideos.disney.go.com/moviefinder/calltoorder.html','orderpop', coords,'scrollbars=no,resizable=no');
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function openPage(targURL, hb) {
	if (hb>=0){hitbox.Set_hbPageView(pageArray[hb], contentArray[hb]);}
	neverlandWin = window.open(targURL,'neverlandpop');
	neverlandWin.window.focus(); 
}
function openExitPage(targURL, hb) {
	if (hb>=0){hitbox.Set_hbLink(exitLinkArray[hb]);}
	neverlandWin = window.open(targURL,'neverlandpop');
	neverlandWin.window.focus(); 
}

function launchBuddy(targURL) {
	hitbox.Set_hbPageView(pageArray[16], contentArray[16]);
	var w = 360;
	var h = 500;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	coords = 'toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl;
	neverlandWin = window.open(targURL,'neverlandpop',coords);
	neverlandWin.window.focus();
}
function launchAudiobook() {
	// hitbox.Set_hbPageView(pageArray[36], contentArray[36]);
	var w = 360;
	var h = 360;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	coords = 'toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl;
	neverlandWin = window.open('popups/audiobook.html','neverlandpop',coords);
	neverlandWin.window.focus();
}
function openSweepsRules() { //v2.0
var w = 790;
var h = 530;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
coords = 'toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl;
win = window.open("sweeps_rules.html","ruleswin",coords);
}

function launchWpaper(targURL, hb) {
	hitbox.Set_hbPageView(pageArray[hb], contentArray[hb]);
	var w = 940;
	var h = 500;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	coords = 'toolbar=yes,location=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl;
	neverlandWin = window.open(targURL,'neverlandpop',coords);
	neverlandWin.window.focus();
}

function noflashImg() {
	if (nowAvailable) {
		document.write('<td align="center" valign="top" class="noflash" id="noflashPoststreet">');
	} else {
		document.write('<td align="center" valign="top" class="noflash" id="noflashPrestreet">');
	}
	
}
function textonlyStreet() {
	if (compareDate(vaultDate[0],vaultDate[1],vaultDate[2])) {
		var streetImg = "textonly_postvault.jpg";
	} else {
		var streetImg = "textonly_poststreet.jpg' usemap='#orderMap";
	}
	document.write("<img src='images/"+streetImg+"' alt='Peter Pan in Return To Never Land' width='994' height='190' hspace='0' vspace='1' border='0' name='&lid=exit_return+to+neverland_order'>");
}

//link to disney mom's registration
function openDisclaimer(targURL, hb){
	if (hb>=0){hitbox.Set_hbLink(exitLinkArray[hb]);}
	disclaimerWinwin = window.open('http://disney.go.com/disneyvideos/javascript/disclaimer/disclaimer.html?'+ targURL, 'intermediate', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=370,height=210');
	disclaimerWin.window.focus();
}
function launchOrder(orderPage, hb) {
	// document.write('<s'+'cript language="JavaScript" src="http://switch.atdmt.com/action/Peter_Pan_Return_To_Neverland_buynow"></s'+'cript>');
	var orderWin = window.open(orderPage,'orderpop');
	orderWin.window.focus();
}

function launchTrailer(hb) {
	hitbox.Set_hbPageView(pageArray[21], contentArray[21]);
	var w = 360;
	var h = 480;
	var winl = (screen.width - w) / 3;
	var wint = (screen.height - h) / 3;
	coords = 'toolbar=yes,location=no,menubar=yes,status=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl;
	neverlandWin = window.open('http://www.totaleclips.com/player/splash.aspx?custid=3&playerid=2&clipid=e31223','neverlandpop',coords);
	neverlandWin.window.focus();
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// from union studio

// Supress ugly js errors
// This should be commented back in when placed in a production environment
function errorHandler() {
	return true;
}
window.onerror = errorHandler;

// popup window
// if no left and top values are passed it automatically centers

function openNewWin(url,myname,w,h,winl,wint,scroll) {
	var win;
	if (!myname) {
		myname = "opener";
	}
	if (!winl) {
		var winl = (screen.width-w)/2;
	}
	if (!wint) {
		var wint = (screen.height-h)/2;
	}
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars='+scroll+',';
	settings +='resizable=clino';
	win = window.open(url,myname,settings);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}


// close flash popup, refresh opener

function refreshWin(winurl) {
	window.opener.location.href = winurl;
	window.close();
}


// close window

function closeMe() {
	window.close();
}


//-->