
function load () {
	setRefCookie();
	repositionPage ();
	placeNavDivs();
	activateCurrNavBut();
	initPage(); //these 2 funcs are defined in the individual pages' js file
	placePageDivs();
	addNavButListeners();
	xAddEventListener (window, 'Resize', repositionPage,false);
}

function repositionPage() {
	//Each page must define a "divBG" and a "divNavbar" (latter usually found in "nav.shtml")
	var winWidth=xClientWidth();
	var winHeight=xClientHeight();
	var navBarHeight = xHeight("divNavbar");
	var bgTopMargin = 14;
	var contentHeight = navBarHeight + bgTopMargin + xHeight("divBG");
	var contentWidth=xWidth("divNavbar"); 
	var newTop, newLeft;

	if (contentHeight > winHeight) {
		newTop = 8;
	} else {
		newTop = (winHeight - contentHeight) / 2;
	}

	if (contentWidth > winWidth) {
		newLeft=0;
	} else {
		newLeft = (winWidth - contentWidth) /2;
	}
	xMoveTo("divNavbar", newLeft, newTop);
	xMoveTo("divBG", newLeft, newTop + bgTopMargin + navBarHeight);
	if (xGetElementById("divCoverRollovers")) {
		xWidth("divCoverRollovers", (winWidth - contentWidth)/2);
		xHeight("divCoverRollovers", contentHeight);
		xMoveTo("divCoverRollovers", 0, newTop);
	}
}

function activateCurrNavBut() {
	var scriptName=getScriptName();
	var currButImg=xGetElementById("img_"+scriptName);
	if (currButImg) {
		currButImg.src="img/nav_button_on.gif";
	}
	xColor("ln_"+scriptName, "#CCCC00");
}

function placeNavDivs () {
	xMoveTo ("div_index", 30, 7);
	xMoveTo ("div_production", 30, 32);
	xMoveTo ("div_glow", 120, 7);
	xMoveTo ("div_lyrics", 120, 32);
	xMoveTo ("div_instruction", 210, 7);
	xMoveTo ("div_news_info", 210, 32);
	xMoveTo ("imgLogo", 322, 10);
	xMoveTo ("div_mail_list", 550, 7);
	xMoveTo ("div_contact", 550, 32);
	xMoveTo ("div_bio", 640, 7);
	xMoveTo ("div_photos", 640, 32);
	xMoveTo ("div_links", 730, 7);
	xMoveTo ("div_gigs", 730, 32);
}

function setRefCookie() {
	var referred_by=getQueryVariable("referred_by")
	if (referred_by) {
		document.cookie = "jk_referred_by=" +referred_by + ";";
	}
}

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}

function getScriptName() {
	var url = window.location + "";
	var script = url.replace(/\?.*/, "");
	script=script.replace(/.*\//,"");
	script=script.replace(/\..*/, "");
	return script;
}
	
function openPicWin (link) {
	window.open("show_pic.php?pic=" + escape(link.href),link.target, 'scrollbars=no,resizable=yes,width=640,height=480, top=0, left=0');
	return false;
}

function addNavButListeners() {
	return;
	var navLinks=xGetElementsByClassName("nav_link");
	for (var i in navLinks) {
		//var foo= "function () {playsound(\"" + navLinks[i].href "\", \"sound/Button.wav\"" + ")}";
		xAddEventListener(navButtons[i],"click", foo, true);
	}
}

function playSound(url) {
	if (document.all.sndSound) {
		document.all.sndSound.src="sound/Button.wav";
	}
}

function chgloc () {

}

