//give global scope to this variable
var hidden_content = "imglobal";
//global variable to track the state of the visibility
var content_fadestate = "0";
//other global variables
var navigation_node = "imglobal";
var core_contentpane = "imglobal";

var setupSlideshowNaviDisplacerVars = function(){
	//variables needed by the content toggling function
	//var magnify_tooltip = dojo.byId("magnify_tooltip");
	navigation_node = dojo.byId("slideshow_navigation");
	// define some bogus object to be assigned to these variables. They are used for tracking connect/disconnect events relative to the magnify button
	core_contentpane = dijit.byId("the_content");
};



// define some bogus object to be assigned to these variables. They are used for tracking connect/disconnect events relative to the magnify button


//function to use to toggle the content, icons, navigation, and so on
var togglecontent = function() {

	if (content_fadestate == "1") {

		core_contentpane.domNode.style.opacity = "0";
		core_contentpane.domNode.style.display = "block";
		

		var hidenavigation = dojo.animateProperty({node: navigation_node, duration: 500, properties: {opacity: { end: 0 }}, onEnd: function(){ dojo.style(navigation_node, "display", "none");} });
		var hidehiddencontent = dojo.animateProperty({node: hidden_content, duration: 500, properties: {opacity: { end: 0 }}, onEnd: function(){ dojo.style(hidden_content, "display", "none");} });
		var showcontent = dojo.animateProperty({node: core_contentpane.domNode, duration: 500, properties: {opacity: { end: 1 }} });



		var combinehider = dojo.fx.chain([hidenavigation,hidehiddencontent,showcontent]);

		combinehider.play();

		content_fadestate = "0";


	}
	else if (content_fadestate == "0") {


		hidden_content.style.opacity = "0";
		hidden_content.style.display = "block";
		navigation_node.style.opacity = "0";
		navigation_node.style.display = "block";	

		var hidecontent = dojo.animateProperty({node: core_contentpane.domNode, duration: 500, properties: {opacity: { end: 0 }}, onEnd: function(){ dojo.style( core_contentpane.domNode, "display", "none");} });
		var showhiddencontent = dojo.animateProperty({node: hidden_content, duration: 500, properties: {opacity: { end: 1 }}, onEnd: function(){dijit.byId("the_content_title").domNode.style.overflow = "visible";} });
		var shownavigation = dojo.animateProperty({node: navigation_node, duration: 500, properties: {opacity: { end: 1 }} });



		var combineshower = dojo.fx.chain([hidecontent,showhiddencontent,shownavigation]);

		combineshower.play();

		content_fadestate = "1";
	}
};



var slideshowNaviDisplacer = function(){
	//DISPLACE SLIDESHOW NAVIGATION
	var initnavmenuxpos = dijit.getViewport().w / 2 + 60;
	var initnavmenuypos = dijit.getViewport().h - 40;

	//we have to do this twice otherwise its not positioned correctly the first time.
	dijit.placeOnScreen(navigation_node, {x: initnavmenuxpos, y: initnavmenuypos}, ["TR", "BL"]);
	dojo.style(navigation_node, "z-index", 4);
	dojo.style(navigation_node, "opacity", 0);

	dojo.connect(window,"onresize", function(){
		var navmenuxpos = dijit.getViewport().w / 2 + 60;
		var navmenuypos = dijit.getViewport().h - 40;
		dijit.placeOnScreen(navigation_node , {x: navmenuxpos, y: navmenuypos}, ["TR", "BL"]);
	});
};

