/*
*	© 2010 Kitigan Zibi Anishinabeg. All Rights Reserved.
*	JavaScript document for specific page functions
*	Author: Kevin Brascoupe
*			kbrascoupe@gmail.com
*/

/*
* Function that opens a separate window and displays information about the Kitigan Zibi Website
*/
function openAbout()
{
	var propertyWidth=490;
	var propertyHeight=540;
	var winLeft = (screen.width-propertyWidth)/2;
	var winTop = (screen.height-propertyHeight)/2;
	var winOptions = "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no";
	winOptions += ",width=" + propertyWidth;
	winOptions += ",height=" + propertyHeight;
	winOptions += ",left=" + winLeft;
	winOptions += ",top=" + winTop;
	var aboutWindow = window.open("./about.html", "propertyInfo", winOptions);
	aboutWindow.focus();
}

/*
* Function that opens a separate window and displays a sorry note for pages under construction
*/
function openSorry()
{
	var propertyWidth=330;
	var propertyHeight=280;
	var winLeft = (screen.width-propertyWidth)/2;
	var winTop = (screen.height-propertyHeight)/2;
	var winOptions = "toolbar=no,menubar=no,location=no,scroolbars=yes,resizable=no";
	winOptions += ",width=" + propertyWidth;
	winOptions += ",height=" + propertyHeight;
	winOptions += ",left=" + winLeft;
	winOptions += ",top=" + winTop;
	var confirmWindow = window.open("./sorry.html", "propertyInfo", winOptions);
	confirmWindow.focus();
}

/*
* Function that opens a separate window and displays the Flyers archive
*/
function openFlyerArchive()
{
	var propertyWidth=450;
	var propertyHeight=500;
	var winLeft = (screen.width-propertyWidth)/2;
	var winTop = (screen.height-propertyHeight)/2;
	var winOptions = "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no";
	winOptions += ",width=" + propertyWidth;
	winOptions += ",height=" + propertyHeight;
	winOptions += ",left=" + winLeft;
	winOptions += ",top=" + winTop;
	var confirmWindow = window.open("./flyers_archive.php", "propertyInfo", winOptions);
	confirmWindow.focus();
}

/*
* Function that sets a CSS property to hide the specified element
* @param name The name of the element to be hidden
*/
function hideElement(name)
{
	document.getElementById(name).style.display = "none";
}

/*
* Function used on the historical photo gallery pages to display the specified page
* @param name The name of the element to be displayed
*/
function showElement(name)
{
	for (var i = 1; i < 5; ++i)
	{
		if (name != "page" + i)
		{
			hideElement("page" + i);
		}
	}
	document.getElementById(name).style.display = "inline";
}

/*
* Function used on the community poem page to display the specified poem
* @param poemNumber The number of the poem to be displayed, ex: poem6
*/
function showPoem(poemNumber)
{
	for (var k = 1; k < 28; k++)
	{
		if (poemNumber != k)
		{
			hidePoem("poem" + k);
		}
	}
	document.getElementById("poem" + poemNumber).className = "poemDisplay";
}

/*
* Function that changes the CSS class of the specified element to hide it
* @param name The name of the poem to be hidden
*/
function hidePoem(name)
{
	document.getElementById(name).className = "poem";
}

/*
* Function used on the learning Algonquin page to display the specified learning scene
* @param index The number of the scene to be displayed, ex: scene12
*/
function showScene(index)
{
	document.getElementById("algonquinFlash").innerHTML = '<h4>Scene ' + index + '</h4><object type="application/x-shockwave-flash" data="assets/learning_scenes/sc' + index + '.swf" width="550" height="400"><param name="movie" value="assets/learning_scenes/sc' + index + '.swf" /></object>';
}

/*
* Function used on the panoramic page to switch between panoramic views and display the specified location
* @param image The name of the panoramic image to be displayed
* @param location A brief description of the destination being displayed
*/
function displayPanoramic(image, location)
{
	document.getElementById("panoramic").innerHTML = '<applet code="uPixScreen.class" archive="./assets/scripts/uPixScreen.jar" width="400" height="150">'+
	'<param name="url" id="url" value="./assets/images/panoramic/' + image + '.jpg" />'+
	'<param name="autoPan" value="yes" />'+
	'<param name="startYaw" value="0.0" />'+
	'<param name="startPitch" value="0.0" />'+
	'<param name="startFov" value="60.0" />'+
	'<param name="partialStitch" value="no" />'+
	'<param name="horFov" value="360.0" />'+
	'</applet>'+
	'<p>' + location + '</p>';
}

/*
*  The initializeGMap function creates a Google Map and puts it on the page
*  for users to get a visual of where and how to get to the Kitigan Zibi Powwow.
*  All credits go to Google for providing the free Google Map Service.
*  Note: Will only work for the URL "www.kza.qc.ca"
*  Must register a different key with Google for a different URL
*/
function initializeGMap()
{
	// Check if browser is compatible with Google Maps software  
		if (GBrowserIsCompatible())
		{
 
	// Create a map object
		var map = new GMap2(document.getElementById("map_canvas"));
 
	// Set the center of the map's initial focus
		map.setCenter(new GLatLng(46.3637, -76.0014), 13);
 
	// Add a zoom and movement control to the map
		map.addControl(new GLargeMapControl());
 
	// Create a latitude and longitude object and give it the coordinates of Kitigan Zibi Kikinamadinan
		var latlng = new GLatLng(46.3437, -76.0014);
 
	// Add a marker icon to the map to display the location of the Powwow
		map.addOverlay(new GMarker(latlng));
 
		} // End of if clause
 
	// If the client browser does not support Google Maps, perform a substitution
		else
		{
 
	// Set a picture map in the place of the Google Maps object
		document.getElementById("map_canvas").innerHTML = '<img src="./assets/images/mapottawa.jpg" alt="Map to Kitigan Zibi from Ottawa" height="500" width="500" />';
 
		} // End of else clause
 
} // End of initialize() function

/*
*  The initializeStaticGMap function puts a static image (mapottawa.jpg) in the map area.
*/
function initializeStaticGMap()
{
	document.getElementById("map_canvas").innerHTML = '<img src="./assets/images/mapottawa.jpg" alt="Map to Kitigan Zibi from Ottawa" height="500" width="500" />';
}

/*
*  The initializeKZRoadMap function puts a static image (KZRoadMap.jpg) in the map area.
*/
function initializeKZRoadMap()
{
	document.getElementById("map_canvas").innerHTML = '<img src="./assets/images/KZRoadMap.jpg" alt="Local Map to School" height="659" width="500" />';
}

/*
*  The initializeKZSchoolMap function puts a static image (KZSchoolMap.jpg) in the map area.
*/
function initializeKZSchoolMap()
{
	document.getElementById("map_canvas").innerHTML = '<img src="./assets/images/KZSchoolMap.jpg" alt="Local Map of the School" width="600" height="441" />';
}


function activateStep(step)
{
	var MAX_STEPS = 4;
	var images = document.images;
	for (var i = 1; i <= MAX_STEPS; ++i)
	{
		if (step != i)
		{
			document.getElementById("step" + i + "btn").className = "stepInactive";
			document.getElementById("step" + i).className = "hide";
			images[i].width = 83;
			images[i].height = 66;
		}
	}
	images[step].width = 103;
	images[step].height = 82;
	document.getElementById("step" + step + "btn").className = "stepActive";
	document.getElementById("step" + step).className = "show";
}