// set the street date for pre/post street read

streetDate=[2007,6,19];
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 openPage(targURL, hb) {
	if (hb>=0){

	}
	terabithiaWin = window.open(targURL,'terabithiapop');
	terabithiaWin.window.focus(); 
}
function openExitPage(targURL, hb) {
	if (hb>=0){

	}
	terabithiaWin = window.open(targURL,'terabithiapop');
	terabithiaWin.window.focus(); 
}

function launchBuddy(targURL) {

	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;
	terabithiaWin = window.open(targURL,'terabithiapop',coords);
	terabithiaWin.window.focus();
}
function launchAudiobook() {

	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;
	terabithiaWin = window.open('popups/audiobook.html','terabithiapop',coords);
	terabithiaWin.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 openSweepsWinners() { //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_winners.html","ruleswin",coords);
}

function launchWpaper(targURL, 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;
	terabithiaWin = window.open(targURL,'terabithiapop',coords);
	terabithiaWin.window.focus();
}

function launchTeacherGuide() {

	var w = 620;
	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;
	terabithiaWin = window.open('http://adisney.go.com/disneyvideos/liveaction/bridgetoterabithia/popups/educators_guide.pdf','terabithiapop',coords);
	terabithiaWin.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 (nowAvailable) {
		var streetImg = "textonly_poststreet.jpg";
	} else {
		var streetImg = "textonly_prestreet.jpg";
	}
	document.write("<img src='images/"+streetImg+"' alt='Bridge To Terabithia' width='994' height='190' hspace='0' vspace='1' border='0' usemap='#orderMap'>");
}

//link to disney mom's registration
function openDisclaimer(targURL, hb){
	if (hb>=0){

	}
	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/Bridge_To_Terabithia_buynow"></s'+'cript>');

	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(orderPage,'orderpoop', coords,'scrollbars=no,resizable=no');
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function launchTrailer(hb) {

	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;
	terabithiaWin = window.open('http://www.totaleclips.com/player/splash.aspx?custid=3&playerid=2&clipid=e31223','terabithiapop',coords);
	terabithiaWin.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();
}


//-->