//common javascript methods for hp
var d = document;
//Pop Up in a new window
/*<a href="javascript:popupWindow('http://www.harrypotter.com','width=570, height=550, scrollbars=yes, resizable=yes, screenX=200, screenX=0, left=200, top=0');"></a>*/
function popupWindow(url,specs) {
	/* Custom Browser Attributes:
	width	number
	height	number
	* the default to these yes|no ones, is no *
	directories	yes | no (or 1 | 0)
	location	yes | no (or 1 | 0)
	menubar		yes | no (or 1 | 0)
	resizable	yes | no (or 1 | 0)
	scrollbars	yes | no (or 1 | 0)
	status		yes | no (or 1 | 0)
	toolbar		yes | no (or 1 | 0)
	*browser specific*
	screenX (NN4+)	number
	screenY (NN4+)	number
	left (IE4+)		number
	top	(IE4+)		number
	fullscreen (IE4+)	yes | no (or 1 | 0)
	*/
	window.open(url, "_blank", specs);
}
//SECTION ID'S INCLUDE: ?section=  mapHome, mapOff, mapLower, mapUpper, mapQuidditch...
//For pop up windows returning to the home page
function gotoMAP() {
//Pop-Up Window
//IE version
	if (browser == "Microsoft Internet Explorer"){
		var newWindow = window.open("/main/homepage/home.html?section=mapHome", "hpmainwindow");
		self.close();
//Netscape (and any other browser type) version
	} else {
//If the parent window has been closed, open a new window
		if (window.opener == null){
			var newWindow = window.open("/main/homepage/home.html?section=mapHome");
			self.close();
//If the parent window is still there, redirect it
		} else {
			var newWindow = window.opener.location.replace("/main/homepage/home.html?section=mapHome");
			self.close();
		}
	}
}
//For pop up windows going elsewhere
//get browser
var browser = navigator.appName;
//Open tout_url in mainwindow and close the popup
function gotoTOUT(tout_url, specs) {
//Pop-Up Window
//IE version
	if (browser == "Microsoft Internet Explorer"){
		var newWindow = window.open(tout_url, "hpmainwindow");
		self.close();
//Netscape (and any other browser type) version
	} else {
//If the parent window has been closed, open a new window
		if (window.opener == null){
			var newWindow = window.open(tout_url);
			self.close();
//If the parent window is still there, redirect it
		} else {
			var newWindow = window.opener.location.replace(tout_url);
			self.close();
		}
	}
}

//Functions used in Personalization
//Hogwarts
function launchHogwarts(){
     window.open("/web/hogwarts/sortinghat/index.jsp", "hogwarts","toolbar=0,scrollbars=0,menubar=0,resizable=1,width=570,height=550, screenX=200, screenX=0, left=200, top=0");
}
//Wand Shopping
function launchWandshop(){
     window.open("/diagonalley/wandshop/", "hogwarts","toolbar=0,scrollbars=0,menubar=0,resizable=1,width=570,height=550,screenX=200, screenX=0, left=200, top=0");
}
//Newsletter Sign Up
function launchNewsletter(){
     window.open("/main/nlsignup/signup.html", "hogwarts","toolbar=0,scrollbars=0,menubar=0,resizable=0,width=450,height=200,screenX=200, screenX=50, left=200, top=50");
}
//Personalization
function launchPersonalization(popUrl){
     window.open(popUrl, "hogwarts","toolbar=0,scrollbars=0,menubar=0,resizable=1,width=570,height=550,screenX=200, screenX=0, left=200, top=0");
}
//Whos_Who Pop Up
function launchWhoswho(){
     window.open("/hogwarts/dailyprophet/whos_who/index.html", "hogwarts","toolbar=0,scrollbars=0,menubar=0,resizable=1,width=570,height=550,screenX=200, screenX=0, left=200, top=0");
}
//Image Rollover
function over(imgName, img_src) {
	d[imgName].src=img_src;
}
function out(imgName, img_src) {
	d[imgName].src=img_src;
}

//Image Rollover for layers
function layerOver(layerName, imgName, img_src) {
	this.layer=document.layers?document[layerName].document[imgName].src=img_src:document[imgName].src=img_src;
	}
function layerOut(layerName, imgName, img_src) {
	this.layer=document.layers?document[layerName].document[imgName].src=img_src:document[imgName].src=img_src;
	}
	
//Countdown Clock

function writeTo(content) {
    var lyrObj = (d.layers)?d.dvdLyr.document:d.all?d.all.dvdLyr:d.getElementById('dvdLyr');
    if (d.layers) {
        lyrObj.close();
        lyrObj.write("<span class=text>" + content + "</span>");
        lyrObj.close();
    } else {
        lyrObj.innerHTML = content;
    }
}
// Begin Clock
function getCountdown() {
now = new Date();
y2k = new Date("June 16 2004 00:00:00 GMT");
days = (y2k - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? "s" : "s";
min = (minutesRound == 1) ? "m:" : "m:";
hr = (hoursRound == 1) ? "h:" : "h:";
dy = (daysRound == 1)  ? " Days " : " Days "

daysRound = (daysRound < 10)?"0" + daysRound:(daysRound < 1)?"00":daysRound;
hoursRound = (hoursRound < 10)?"0" + hoursRound:(hoursRound < 1)?"00":hoursRound;
minutesRound = (minutesRound < 10)?"0" + minutesRound:(minutesRound < 1)?"00":minutesRound;
secondsRound = (secondsRound < 10)?"0" + secondsRound:(secondsRound < 1)?"00":secondsRound;


//writes content
var cd = " " + daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;
writeTo(cd);

newtime = window.setTimeout("getCountdown();", 1000);
}
//  End -->



