
//global variables  
// catalogs

//var nlsCat =  new Object(eval((new XMLHttpLoader()).getSync("./data/content/exhibitions/exhibitions_nls_data.json")));
var nlsCatGeneral =  new Object(eval((new XMLHttpLoader()).getSync("./data/content/common_stuff/general_nls_content.json")));
var titleCycleDelay = 5000;	


//end global variables

	

dojo.addOnLoad(function(){

dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("dojox.image.SlideShow");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.Tooltip");
dojo.require("dijit.Dialog");
dojo.require("dojox.layout.ContentPane");


		
		var buildUI = function(){



	    	var filestore = new dojo.data.ItemFileReadStore({
 			 	url: "../../../data/context/exhibitions.json"
 			 });




			var slideshow = new dojox.image.SlideShow({
				slideShowInterval: 10,
				loop: true,
				autoLoad: true,
				id: 'defaultslideshow',
				autoStart: false,
				noLink: true,
				dynamicScale: true
				}).placeAt(dojo.body());
		
			
			dojo.style(dijit.byId("defaultslideshow").domNode, {
				"position": "absolute",
				"left": "0px",
				"top": "0px",
				"width": "100%",
				"height": "100%",
				"text-align": "left",
				"margin": "0px",
				"padding": "0px",
				"z-index": "0",
				"border": "none"
				});
        	
    	
				
		slideshow.setDataStore(
    	  filestore,
      		{ query: {}, count:1 },
     		{
        imageThumbAttr: "thumb",
        imageLargeAttr: "large"
      		}
    	);
				
		
			
		
			// the main BC
			var outer = new dijit.layout.BorderContainer({
				gutters: false,
				id: 'outer'
			}).placeAt(dojo.body());
			


			
			dojo.style(dijit.byId("outer").domNode, {
				"height": "100%",
            	"width": "100%"
        	});

			
			// top region:
			var topregion = new dojox.layout.ContentPane({
				region:"top",
				style:"height:52px",
				href:"../../../pages/exhibitions/header.html",
				splitter:false,
				id:'header_container'
			}).placeAt(outer);
			
			
			var leftregion = new dojox.layout.ContentPane({
				region:"left",	
				style:"width:52px",
				href: '../../../pages/exhibitions/left_region.html',
				splitter:false,
				id:'left_region'
			}).placeAt(outer);


			
			
			var rightregion = new dojox.layout.ContentPane({
				region:"right",
				style:"width:52px",
				href: '../../../pages/exhibitions/right_region.html',
				splitter:false,
				id:'right_region'
			}).placeAt(outer);
			
			
			var bottomregion = new dojox.layout.ContentPane({
				region:"bottom",
				style:"height:52px;",
				href: "../../../pages/exhibitions/footer_content.html",
				splitter:false,
				id: "bottom_region"
			}).placeAt(outer);
			
			
			var core = new dijit.layout.BorderContainer({ 
				region:"center", 
				style:"overflow: hidden;", 
				design: "sidebar", 
				gutters: false,
				id: 'core'
			}).placeAt(outer);


		var hiddentitle = new dojox.layout.ContentPane({
				region:"top",
				style:"height:99px;",
				id:'the_content_title',
				href:'../../../pages/exhibitions/title.html'
			}).placeAt(core);
			


		var core_contentpane = new dojox.layout.ContentPane({
				region:"center",
				style:"margin: auto;",
				href:"../../../pages/exhibitions/content.html",
				id:'the_content'
			}).placeAt(core);
			










var statuscheck = function(){	

		var titlescript = function(){
		
		//detect layouting fail and correct the problem  
		if (outer._contentBox.h === 0) { location.reload();};
//		hidden_content = dojo.byId("work_title_hidden");

	};

		


var titlescript_trigger = function(){return (dijit.byId("the_content_title").isLoaded === true) ? titlescript : dojo.connect(dijit.byId("the_content_title"),"onLoad", titlescript);};



titlescript_trigger();


	var footerscript = function(){
	//detect layouting fail and correct the problem  
	if (outer._contentBox.h === 0) { location.reload();}

	//internationalize footer content
	nls.regCatId("i18n_newsletter_tooltip", nlsCatGeneral.i18n_newsletter_tooltip);
				

        connectNewsLetterTooltip();


};


var footerscript_trigger = function(){return (dijit.byId("bottom_region").isLoaded === true) ? footerscript : dojo.connect(dijit.byId("bottom_region"),"onLoad", footerscript);};

footerscript_trigger();


var contentscript = function(){
	
	//detect layouting fail and correct the problem  
	if (outer._contentBox.h === 0) { location.reload();}
	
	// catalogs
//	nls.regCatId("i18n_subtitle_1_transdisciplinary", nlsCat.subtitle_1_transdisciplinary);

  

	};


var contentscript_trigger = function(){return (dijit.byId("the_content").isLoaded === true) ? contentscript : dojo.connect(dijit.byId("the_content"),"onLoad", contentscript);};

contentscript_trigger();



var headerscript = function(){
		
		//detect layouting fail and correct the problem  
		if (outer._contentBox.h === 0) { location.reload();}
		
	
		//internationalize stuff
		// animations
		//static texts
		nls.regCatId("i18n_about", nlsCatGeneral.about);
		nls.regCatId("i18n_exhibitions", nlsCatGeneral.exhibitions);
		nls.regCatId("i18n_artists", nlsCatGeneral.artists);
		nls.regCatId("i18n_collaborations", nlsCatGeneral.collaborations);
		nls.regCatId("i18n_profile", nlsCatGeneral.profile);
		nls.regCatId("i18n_manifesto", nlsCatGeneral.manifesto);		
		//tooltips
		nls.regCatId("i18n_homebutton_tooltip", nlsCatGeneral.homeButtonTooltip);
		
	};


var headerscript_trigger = function(){return (dijit.byId("header_container").isLoaded === true) ? headerscript : dojo.connect(dijit.byId("header_container"),"onLoad", headerscript);};

headerscript_trigger();


		
	};


			
			// do all the layout etc
			outer.startup();

dojo.connect(outer, "onLoad",  statuscheck());



		};
		
		dojo.addOnLoad(buildUI);
		


  });
	


