// JavaScript Document

// This function fetches the body tag id from the parent for use in style top level navigation
// links to show when a link is actually the active page.


function resetContent(newSrcPg, newPageId, newImg, inChild) {
	var newObj, newImgObj;
	if (inChild == true) {
		window.parent.document.body.id = newPageId;
		newObj = window.parent.document.getElementById("curcontent");
		newImgObj = window.parent.document.getElementById("sidebarimg");
	} else {
		window.document.body.id = newPageId;
		newObj = document.getElementById("curcontent");
		newImgObj = document.getElementById("sidebarimg");
	}
	newObj.src = newSrcPg;
	newImgObj.src = "images/" + newImg;
}


function swapbio(newBio) {
	var parentElement = document.getElementById("curbio");
	parentElement.src = "bios/" + newBio + ".html";
}


function showWin() {
	var targetObj = document.getElementById("hovertext");
	targetObj.style.display = "block";
	//targetObj.setAttribute("style", "display: block; ");
}

function hideWin() {
		var targetObj = document.getElementById("hovertext");
		targetObj.style.display = "none";
		//targetObj.setAttribute("style", "display:none;");
	}
	
function testParent (levelsDeep, winTitle, contentPage, bodyId) {
	if (window.parent.document.getElementById("curcontent")) return;
	var newURLStr;
	var newRelPath = "";
	for (idx = 1; idx<=levelsDeep; idx++) {
		newRelPath = newRelPath + "../";
	}
	newURLStr = newRelPath + "index.html" + "?winTitle=" + winTitle + "&contentPage=" + contentPage + "&bodyId=" + bodyId;
	window.location.replace(newURLStr);
}

function getSearchAsArray() {
	var results = new Array();
	var input = unescape(location.search.substr(1));
	if (input) {
		var srchArray = input.split("&");
		var tempArray = new Array();
		for (var i = 0; i < srchArray.length; i++) {
			tempArray = srchArray[i].split("=");
			results[tempArray[0]] = tempArray[1];
		}
	}
	return results;
}

function setIframeSrc () {
	var newObj = document.getElementById("curcontent");
	if (location.search) {
		var srchArray = getSearchAsArray();
		if (srchArray["contentPage"]) {
			newObj.src = srchArray["contentPage"];
		}
		if (srchArray["winTitle"]) {
			window.document.title = srchArray["winTitle"];
		}
		if (srchArray["bodyId"]) {
			parent.frames["naviframe"].document.body.id= srchArray["bodyId"];
		}
	} else {
	newObj.src = "home.html";
	window.document.title = "musician2you - Home";
	window.document.body.id = "home";
	}
}

