/*
File name: Hungry Browser global javascript file
Version: 1.0
Author: Ben Ellis
Author URI: http://www.hungrybrowser.co.uk
Created: 23/04/2008
Updated: 05/05/2008
*/

/* 
	Title: hideEmail()
	Description: Function to add custom behaviours to the main navigation
	Arguments: 
		$name: name for email
		$domain: domain for email
*/
function hideEmail(name,domain){
   document.write("<a href=\"mailto");
   document.write(":" + name + "@");
   document.write(domain + "\" title=\"Contact me\">" + name + "@" + domain + "<\/a>");
}

// Function to toggle an element 
// @param: myTarget = the object to target
// @param: myControl = the object used to toggle the target element
function toggleElement (myTarget,myControl){
	var mySlide = new Fx.Slide(myTarget);
	$(myControl).addEvent('click', function(e){
		e = new Event(e);
		mySlide.toggle();
		e.stop();
	});
}

/* Execute the function
window.addEvent('domready', function() {
	toggleElement ('element_0','control_0');
	toggleElement ('element_1','control_1');
	toggleElement ('element_2','control_2');
	toggleElement ('element_3','control_3');
//	toggleElement ('element_4','control_4');
	toggleElement ('element_5','control_5');
	toggleElement ('element_6','control_6');
	toggleElement ('element_7','control_7');
});
*/

/*
	Title: showContent()
	Description: Function to show the side navigation content and active nav state
	Arguments: photographer id
*/
function showContent(id){

	// Get the element
	if (document.getElementById){
	
		// Create the variables
		var content_parent = "";
		var content_item = "";
		var nav_parent = "";
		var nav_item = "";
				
		// Get the objects through the DOM
		content_parent = document.getElementById("sidebar_nav_container");
		content_item = document.getElementById('content_'+id);
		
		nav_parent = document.getElementById("sidebar_nav");
		nav_item = document.getElementById('control_'+id);
		
		// Hide content elements
		for (i=0; i<content_parent.childNodes.length; i++) {
		node = content_parent.childNodes[i];
			if (node.nodeName=="DIV") node.className = "hidden";
		}
		
		// Deactivate the nav elements
		for (i=0; i<nav_parent.childNodes.length; i++) {
		node = nav_parent.childNodes[i];
			if (node.nodeName=="LI") node.className = "";
		}
				
		// Highlight the current nav item
		if(nav_item) nav_item.className = "active";
		
		// Show the current content item
		if(content_item) content_item.className = "show";

	}
}
