// PEN Productions Inc. 

/*****************************************
Used to show information on the index page map
Currently this is also local to the index page
******************************************/
function mapData(toolTip)
{
	//alert (place)
	switch(toolTip)
	{
		case "Australia":
		{
			return "Native Flame Pictures";
			break;
		}
		case "Brazil":
		{
			return "GP2";
			break;
		}
		case "England":
		{
			return "Studio Liddell, Manchester, England | " +
			"Real Time UK, London, England | CG Academy";
			break;
		}
		case "Germany":
		{
			return "Elliott Animation / Berlin Film Company";
			break;
		}
		case "Greece":
		{
			return "Adventurine Games";
			break;
		}
		case "India":
		{
			return "Trine Games";
			break;
		}
		case "Ireland":
		{
			return "University Of Ulster";
			break;
		}
		case "California":
		{
			return "Focus 360 | Wit Animation | 5000 Feet | 2K Games | TigarHare Studios | "+
			"Erick Geisler";
			break;
		}
		case "Minnesota":
		{
			return "Rankin Innovations";
			break;
		}
		case "New York":
		{
			return "Stuart Simms Productions | 1stAveMachine | Eyeball NYC";
			break;
		}
		case "Quebec":
		{
			return "Evolver/Darwin Dimensions";
			break;
		}
		case "Oregon":
		{
			return "Pipe Works Software";
			break;
		}
		case "Ontario":
		{
			return "Hatch Studios | Pseudo Interactive | Elliott Animation & Elliott Interactive | "+
			"Nelvana Studios | Big Studios | Rock Star Games | Draxhal/Elliott | Red Rover Studios | Walt Disney Animation | "+
			"Toybox | Rogers Sportsnet | Global Television | Keyframe Digital";
			break;
		}
		case "British Columbia":
		{
			return "Next Level Games | Enigma Studios | Ubisoft";
			break;
		}
		case "Spain":
		{
			return "Pasozebra Producciones | 23Lunes";
			break;
		}
		case "Netherlands":
		{
			return "Freek van Haagen";
			break;
		}
	}
}

/*******************************************
Functions for displaying tool tips on index map. 
Will try and make it more generic so that it can be used
else where in the site. 
********************************************/
var mapToolTip;

/*
	Creates the dialog and stores it in toolTip
	The dialog has a toolTipHeader for a title and a toolTipBody
	Need to make a container toolTip that every thing ca be deleted from. 
*/
function enableToolTipDialog()
{
	//Tooltip container
	mapToolTip=document.createElement("div");
	mapToolTip.setAttribute("class","mapToolTip");
	mapToolTip.setAttribute("id","mapToolTip");
	mapToolTip.style.position="absolute";
	
	//Tooltip header
	var ttHeader=document.createElement("div");
	ttHeader.setAttribute("class","mapToolTipHeader");
	ttHeader.setAttribute("id","mapToolTipHeader");
	
	//Tooltip body
	var ttBody=document.createElement("div");
	ttBody.setAttribute("class","mapToolTipBody");
	ttBody.setAttribute("id","mapToolTipBody");

	//Tooltip footer
	var ttFooter=document.createElement("div");
	ttFooter.setAttribute("class","mapToolTipFooter");
	ttFooter.setAttribute("id","mapToolTipFooter");

	//Add the divs as children
	mapToolTip.appendChild(ttHeader);
	mapToolTip.appendChild(ttBody);
	mapToolTip.appendChild(ttFooter);
	
	//Initialize any elements with name="toolTip"
//	initToolTipElements();
	initToolTipRecursive(document.getElementsByTagName("body")[0]);

}

/*
	Recurse body element and add event handlers to any toolTip
	enabled elements. 
	!To make the recursion work var had to be added before i in the for loop to make it local. 
*/
function initToolTipRecursive(el)
{
	for (var i=0;i<el.children.length;i++)
	{
		var tt=el.children[i].getAttribute('toolTip');
		if (tt!=null)
		{
			el.children[i].onmouseover=addMapToolTip;
			el.children[i].onmousemove=Locate;
			el.children[i].onmouseout=removeToolTip;
		}
		initToolTipRecursive(el.children[i]);
	}
}


/*
	Removes map tooltip
*/
function removeToolTip()
{
	var d=document.getElementById("mapToolTip");
	if (d!=null)
	{
		d.parentNode.removeChild(d);
	}
}

/*
Adds a map tooltip to the current page at the location of the mouse
Not being called in Explorer. 
*/
function addMapToolTip()
{
//	alert("addMapToolTip");
	if (mapToolTip==null) {enableToolTipDialog();}
	if (mapToolTip!=null)
	{
//		mapToolTip.innerHTML=mapData(this.getAttribute('toolTip'));
		document.getElementsByTagName("body")[0].appendChild(mapToolTip);
		var ttHeader=document.getElementById("mapToolTipHeader");
		ttHeader.innerHTML=this.getAttribute('toolTip');
		var ttBody=document.getElementById("mapToolTipBody");
		ttBody.innerHTML=mapData(this.getAttribute('toolTip'));
		setOpacity(ttHeader);
		setOpacity(ttBody);
		setOpacity(document.getElementById("mapToolTipFooter"));
	}
}

/*
Used to locate the toolTip on screen. 
*/
function Locate(e)
{
	var posx=0,posy=0;
	if(e==null) e=window.event;
	if(e.pageX || e.pageY)
	{
		posx=e.pageX; 
		posy=e.pageY;
	}
	else if(e.clientX || e.clientY)
	{
		if(document.documentElement.scrollTop)
		{
			posx=e.clientX+document.documentElement.scrollLeft;
			posy=e.clientY+document.documentElement.scrollTop;
		}else
		{
			posx=e.clientX+document.body.scrollLeft;
			posy=e.clientY+document.body.scrollTop;
		}
	}
	document.getElementById("mapToolTip").style.top=(posy+10)+"px";
	document.getElementById("mapToolTip").style.left=(posx+10)+"px";
}

/*
	Tool Tip opacity settings. 
	Instead of doing it the maps 
*/
function setOpacity(el)
{
	el.style.filter="alpha(opacity:90)";
	el.style.KHTMLOpacity="0.90";
	el.style.MozOpacity="0.90";
	el.style.opacity="0.90";
}

/********************************************************
Nav button functions.
Called when page loads. 
*********************************************************/
function enableNavButtons()
{
//	alert("enableNavButtons");
	
	//Loop through an array of names for the buttons. 
	//Need a way to pass a link to those buttons as well. 
	//Might want to have all buttons call on a case statement that tells the button what it will do when 
		//pressed so that buttons could call on links to other pages or call other functions. 
	//Need to find some way to make a lookup table in JS. 
	makeLeftNavButton("test");
}
/*
	Makes a single nave button and adds it to the leftNav div
*/
function makeLeftNavButton(name)
{
	var leftNav=document.getElementById("leftNav");
	navButton=document.createElement("div");
	navButton.setAttribute("class","leftNavButton");
	
	document.getElementsByTagName("body")[0].appendChild(navButton);
}




