// <![CDATA[
var debug = true;
var tempSub;
var screenH;
var screenW;
var contentH;
var overlayW;
var overlayH;
var galleryOn=false;
var newsOpen = true;
var contentOpen = true;
var overlayOpen = true;
var menuClosed = true;
var overlayPresent = false;
var newsPresent = false;
var contentPresent = false;
var videoPresent = false;
var openMenuSubNav;
var activeMenuSubNav1;
var activeMenuSubNav2;
var activeMenuSubNav3;
var reloadBackground = true;
var newsAreaDiv;
var contentAreaDiv;
var bigContentAreaDiv;
//page variables subNav1ID, subNav2ID, 
var pageType;
var activeMenuItem;
var activeMenuItemImg;
var subNav1ID;
var subNav2ID;
var subNav3ID;
var contentID;
var backgroundID;
var menuID;
var menuSubID;
var clickedFromSub=0;
var pressLogin=false;
var iE_browser= false;
var iE_version;
var is_iphone;
var is_ipad;

var initializePage = function(){
	//set page type
	pageType = arguments[0];
	//set page title
	document.title = "[pilobolus:  " + pageType +"]";
	//process content
	switch(pageType){
		
		case "home":
			contentPresent=false;
			newsPresent=true;
			setupContent();
			setupScrollBars();
			$("#newsContent").show();
			$("#newsBG").fadeIn(500);
			$('#newsContentReveal').fadeIn(500);
		break;
		
		default:
			contentPresent=true;
			newsPresent=false;							
			$('div#pageContent').css({
					'top' : 0
			});
			$("#pageContent").show();

			setupContent();
			setupScrollBars();	
			rescale(screenW, screenH);

			var tempPos = screenH - ($('div#pageContent').height() + 20);
			$('div#pageContent').css({
					'top' : tempPos
			});
			$("#pageContent").fadeIn(500);
		break;	
	}
	if($('a.menuBG').is(":visible")){
		$('a.menuBTN').click();
	}
}
var setupBackground = function(bgData){
		
	//compare data
	$("#galleria").hide();	
	$(".galleria-image").each(function(n){
		$(this).remove();
	});
	if(videoPresent){
		//console.log();log('video present');
		if(!iE_browser){
			//swfobject.removeSWF("videoReplace");
			jwplayer("videoArea").remove();
			$("#videoSection").children().remove();
			videoPresent = false;
		}else{
			swfobject.removeSWF("videoReplace");
			$("#videoSection").children().remove();
			videoPresent = false;
		}
	}
	$(".galleria-images").append(bgData);
	if($('.galleria-image').length > 1){
		galleryOn=true;
		$('#galleria').galleria({
            image_crop: true,
            frame: false,
			thumbnails: false
		});
		videoPresent = false;
		$("#galleria").show("slow");
	}else{
		galleryOn=false;
		
	}
	
	
	if(!galleryOn){
		if($('#videoReplace').length > 0){
			//console.log('video replace present');
			var tempH = Math.round((screenH - 500)/2);
			var tempW = Math.round((screenW - 426)/2);
			$('#videoSection').css({
				'top' : tempH,
				'left' : tempW
			});
			videoPresent = true;
			$('#videoReplace').appendTo("#videoSection");
		
		
			
			//var tempSrc = $('#videoArea').find('source').attr('src');
			$('#videoReplace').show();
			
			if(!iE_browser){
				
				//console.log('video present :' + $('#videoArea').attr('src'));
				var tempSrc = $('#videoArea').attr('src');
				// var flashvars = { file:tempSrc, autostart:'true'};
				// 						  	var params = { allowfullscreen:'true', allowscriptaccess:'always' };
				// 						  	var attributes = { id:'player1', name:'player1' };
				// 
				// 		  	swfobject.embedSWF('jwplayer/player.swf','videoReplace','426','320','9.0.115','false',flashvars, params, attributes);
				jwplayer("videoArea").setup({
												file: tempSrc,
												height:320 ,width:426, 
												players: [{ type: "flash", src: "/jwplayer/player.swf" },{ type: "html5" }],
												autostart: true
												});
			}else{
				var tempSrc = $("#videoReplace").attr("rel");
					
				var flashvars = { file:tempSrc,autostart:'true' };
			  	var params = { allowfullscreen:'true', allowscriptaccess:'always' };
			  	var attributes = { id:'player1', name:'player1' };

			  	swfobject.embedSWF('jwplayer/player.swf','videoReplace','426','320','9.0.115','false',flashvars, params, attributes);
			}					
			rescale(screenW,screenH);
		}else{
			videoPresent = false;
			$("#galleria").show("slow");
		}
	}
}
var setActiveMenuItem = function(str){
	$("a.menuItem").each(function(i){
		var tempStr = $(this).html();
		var tempPar = $(this).parent();
		
		tempStr = tempStr.toLowerCase();
		str = str.toLowerCase();
		if(pageType){
			if(pageType != str){
				if(tempStr == str){
					$(activeMenuItem).removeClass('active');
					$(activeMenuItemImg).remove();
					//add image
					$('<img class="activeBar" src="common/images/activeNavBar.gif" width="25" height="42" alt="ActiveNavBar" border="0" />').prependTo(tempPar);
					activeMenuItemImg = $(tempPar).find('.activeBar');
					$(this).addClass('active');
					activeMenuItem = $(this);
				}else{
					var tempImg = $(tempPar).find(".activeBar");
					$(this).removeClass('active');
					$(tempImg).remove();
				}
			}
		}else{
			if(tempStr == str){
				$('<img class="activeBar" src="common/images/activeNavBar.gif" width="25" height="42" alt="ActiveNavBar" border="0" />').prependTo(tempPar);
				activeMenuItemImg = $(tempPar).find('.activeBar');
				activeMenuItem = $(this);
			}else{
					var tempImg = $(tempPar).find(".activeBar");
					$(this).removeClass('active');
					$(tempImg).remove();
			}
		}
	});
	
}
var configurePageOverlay = function(){
	$("#overlay").hide();
	$("#contentOverlay").hide();
	//remove old overlay content
	$("#overlayArea").children().remove();
	//add new content
	if(!overlayOpen){
		toggleOverlay(true);
	}
	$("#overlayArea").append(arguments[1]);
	//format it 
	setupContentOverlay();
	//show it
	$("#overlay").show();
	$("#contentOverlay").show();
	resetOverlay();
}
var configurePageContent = function(){
	//set page type
	pageType = arguments[0];
	if(pageType=="pilobolus"){
			document.title = "[pilobolus:  what is " + pageType +"? ]";
	}else{
			document.title = "[pilobolus:  " + pageType +"]";
	}
	//hide all content areas
	$("#pageContent").hide();	
	$("#newsBG").hide();
	$("#newsContent").hide();
	$('#newsContentReveal').hide();
	
	//process content
	switch(arguments[0]){
		case "home":
			setupContentHidingButtons();
			contentPresent=false;
			newsPresent=true;
			$("#newsContent").remove();
			$("#newsbar").append(arguments[1]);
			setupContent();
			setupContentHidingButtons();
			setupScrollBars();	
			rescale(screenW, screenH);
			if(!menuClosed){
				toggleMenu(menuClosed);
			}
			newsOpen = true;
			resetNews();
		break;
		
		default:
			contentPresent=true;
			newsPresent=false;
			$("#contentArea").remove();
			$("#pageContent").show();
			$("#pageContent").append(arguments[1]);
			setupContent();
			setupContentHidingButtons();
			setupScrollBars();
			rescale(screenW, screenH);
			if(!menuClosed){
				toggleMenu(menuClosed);
			}
			resetContent();
		break;	
	}	
}
var configureSub3Content = function(){
	//load from clicking menu with subNav1 present

	//remove content after subNav1
	var tempJScrollArea1 = $("#subNav1").parent();
	var tempJScrollArea2 = $("#subNav2").parent();
	var tempJScrollArea3 = $("#subNav3").parent();	
	$("#contentArea").children().not(tempJScrollArea1).not(tempJScrollArea2).not(tempJScrollArea3).remove();
	//put data in ContentArea after subNav1
	$(arguments[1]).appendTo("#contentArea");
	setupContent();
	setupContentHidingButtons();
	setupScrollBars();
	rescale(screenW, screenH);
}
var configureSub2Content = function(){
	//load from clicking menu with subNav1 present

	//remove content after subNav1
	var tempJScrollArea1 = $("#subNav1").parent();
	var tempJScrollArea2 = $("#subNav2").parent();
	$("#contentArea").children().not(tempJScrollArea1).not(tempJScrollArea2).remove();
	//put data in ContentArea after subNav1
	$(arguments[1]).appendTo("#contentArea");
	setupContent();
	setupContentHidingButtons();
	setupScrollBars();
	rescale(screenW, screenH);
}
var configureSub1Content = function(){
	//load from clicking menu with subNav1 present

	//remove content after subNav1
	var tempJScrollArea = $("#subNav1").parent();
	$("#contentArea").children().not(tempJScrollArea).remove();
	//put data in ContentArea after subNav1
	$(arguments[1]).appendTo("#contentArea");
	setupContent();
	setupContentHidingButtons();
	setupScrollBars();
	rescale(screenW, screenH);
}
var loadMenu = function(h,w){
	
	if(is_ipad || is_iphone){
		$("div#menuBG").css( {
			'height': h - 35,
			'width': w - 40,
			'top' : 20, 
			'left' : 20,
			'opacity' : .75
		});
		$("div#menu").css( {
			'height': h - 35,
			'width': w - 40,
			'top' : 20, 
			'left' : 20
		});
	}else{
		$("div#menuBG").css( {
			'height': h - 30,
			'width': w - 40,
			'top' : 20, 
			'left' : 20,
			'opacity' : .75
		});
		$("div#menu").css( {
			'height': h - 30,
			'width': w - 40,
			'top' : 20, 
			'left' : 20
		});
	}
	
	$("div#menuItems").css( {
		'width': 242,
		'left': ($("#menu").width() - 242)/2	
	});
	
	$('a.menuBTN').click(function(){
		checkOpenWindows(menuClosed);
		return false;
	});
	
	$("a.menuItem").click(function(){
		var tempSubMenu = $(this).parent().find('div.menuSubItems');
		var tempMenu = $(tempSub).parent().find('div.menuSubItems');
		//if no sub, check sub is true
		if(checkSub(tempMenu, tempSubMenu, this)){
				return false;
		}else{
			if(iE_browser && iE_version == 6){
				return true;
			}else{
				if($(this).hasClass('ext')){
					return true;
				}else{
					clickedFromSub=0;
					var hashString = $(this).attr("rel");
					reloadBackground=true;
					//check hash for 0 in background, 0 in subNav1, 2, 3
					window.location.hash =  hashString;
					return false;
				}
			}
		}
	});
	$("a.menuSubItem").click(function(){
		
		if(iE_browser && iE_version == 6){
			return true;
		}else{
			if($(this).hasClass('ext')){
				return true;
			}else{
				clickedFromSub=0;
				reloadBackground=true;
				var hashString = $(this).attr("rel");
				window.location.hash =  hashString;
				return false;
			}
		}
	});
	
	$("a.footerLink").click(function(){
		if(iE_browser && iE_version == 6){
			return true;
		}else{
			if($(this).hasClass('ext')){
				return true;
			}else{
				clickedFromSub=0;
				reloadBackground=true;
				var hashString = $(this).attr("rel");
				window.location.hash =  hashString;
				return false;
			}
		}
	});
	
	$('a.hash-link').click(function(){
		if(iE_browser && iE_version == 6){
			return true;
		}else{
			if($(this).hasClass('ext')){
				return true;
			}else{
				if($(this).attr('id') == "home-link"){
					//check if current page is home
					//console.log(pageType);
					if(pageType != "home"){
						clickedFromSub=0;
						reloadBackground=true;
						var hashString = $(this).attr("rel");
						window.location.hash =  hashString;					
					}
				}else{
					clickedFromSub=0;
					reloadBackground=true;
					var hashString = $(this).attr("rel");
					window.location.hash =  hashString;
				}
				return false;
			}
		}
	});
	$("div#menuBG").hide();
	$("div#menu").hide();
};
var checkSub = function(tempMenu, tempSubMenu, that){
	var bool = true;
	if($(that).data('open')){
		$(openMenuSubNav).hide('fast');
		$(that).removeData("open");	
		openMenuSubNav = null;
	}else{
		if($(tempSub).data('open')){
			$(openMenuSubNav).hide('fast');
			$(tempSub).removeData("open");	
			openMenuSubNav = null;
			tempSub = null;
		}
		if(tempSubMenu.length > 0){
			$(that).data('open', true);
			openMenuSubNav = $(tempSubMenu);
			$(openMenuSubNav).show('fast');
			tempSub = $(that);
		}else{
			bool = false;
		}
	}
	return bool;
}

var rescaleIDevice = function(ipad, iphone){
	
	var h;
	var w;
	
	if(window.orientation == 0 || window.orientation == 180){
		h = 900;
		w =	1024;
	}else{
		h = 660;
		w = 1024;
	}
	
	window.height = h;
	window.width = w;
	
	$("#galleria").css({
		'width' : w, 
		'height' : h, 
		'overflow' : 'hidden'
	});

	$("#contentArea").width(w);
	
	
	//check minimum
	var newH = h;
	var newW = w;

	$("div#menuBG").css( {
		'height': newH - 35,
		'width': newW - 40
	});
	$("div#menu").css( {
		'height': newH - 35,
		'width': newW - 40
	});
	$("div#menuItems").css( {
		'width': 242,
		'left': (newW - 242)/2	
	});
	
	$('div#overlay').css({
		'height' : newH, 
		'width' : newW
	});
	screenH = newH;
	screenW = newW;
	positionIDeviceContent(newH, newW);
}


var rescale = function(w,h){
	
	if(is_ipad || is_iphone){
		rescaleIDevice(is_ipad,is_iphone);
	}else{
		//check minimum
		var newH;
		var newW;
		if(h < $("div#menuItems").height() + 40){
			newH = $("div#menuItems").height() + 40;
			$('body').css({
				'height' : newH
			});
		}else{
			newH = h;
		}
		if(w <= 900){
			newW = 900;
			$('body').css({
				'width' : newW
			});
		}else{
			newW = w;
		}
		$("div#menuBG").css( {
			'height': newH - 55,
			'width': newW - 40
		});
		$("div#menu").css( {
			'height': newH - 55,
			'width': newW - 40
		});
		$("div#menuItems").css( {
			'width': 242,
			'left': (newW - 242)/2	
		});
	
		$('div#overlay').css({
			'height' : newH, 
			'width' : newW
		});
		screenH = newH;
		screenW = newW;
		positionContent(newH, newW);
	}
}
var positionIDeviceContent = function(h,w){
	
	//check size of contentbody
	var tempFooterPosX = 800;
	
	$("#footerArea").css({
		'top' : h-15,
		'width' : 1200
	});
	var tempfooterPos = (1024-tempFooterPosX)/2;
	$("#footer-bar").css({
		'left': tempfooterPos
	});
	$("#footer-bar").show();
	
	var tempPos = h - (contentH+30);
	if(contentPresent){
		$('div#pageContent').css({
			'top' : tempPos
		});
	}else{
		$('div#pageContent').css({
			'top' : h-10
		});
	}
	var newsPos = 680;
	if(w > 900){
		if(newsPresent){
			$('div#newsContent').css({
				'left' : w-(newsPos)
			});
		}
	}
	if(overlayPresent){
		var tempOverPosY = ((h - overlayH)/2) - 100;
		var tempOverPosX = (w - overlayW)/2;

		if(tempOverPosY < 20){
			tempOverPosY = 20;
		}
		if(tempOverPosX < 200){
			tempOverPosX = 200;
		}
		if(!overlayOpen){
			$('div#contentOverlay').css({
				'left' : w , 
 				'top' : tempOverPosY
			});
		}else{
			$('div#contentOverlay').css({
				'left' : tempOverPosX,
				'top' : tempOverPosY
			});
		}
	}
	if(!galleryOn){
		//scale image or video
		
		var tempH = Math.round((screenH- 500) /2);
		var tempW = Math.round((screenW - 426)/2);

		$('#videoSection').css({
			'top' : tempH,
			'left' : tempW
		});
		
	}	
}
var positionContent = function(h,w){
	
	//check size of contentbody
	var tempFooterPosX = 800;

	$("#footerArea").css({
		'top': (h-35),
		'width' : w
	});
	var tempfooterPos = (w-tempFooterPosX)/2;
	$("#footer-bar").css({
		'left': tempfooterPos
	});
	
	$("#footer-bar").show();
	
	
	var tempPos = h - (contentH + 50);

	if(contentPresent){
		$('div#pageContent').css({
			'top' : tempPos
		});
	}else{
		$('div#pageContent').css({
			'top' : h - 50
		});
	}
	
	var newsPos = 680;
	if(w > 900){
		if(newsPresent){
			$('div#newsContent').css({
				'left' : w-(newsPos)
			});
		}
	}	
	
	if(overlayPresent){
		var tempOverPosY = ((h - overlayH)/2) - 100;
		var tempOverPosX = (w - overlayW)/2;

		if(tempOverPosY < 20){
			tempOverPosY = 20;
		}
		if(tempOverPosX < 200){
			tempOverPosX = 200;
		}
		if(!overlayOpen){
			$('div#contentOverlay').css({
				'left' : w , 
 				'top' : tempOverPosY
			});
		}else{
			$('div#contentOverlay').css({
				'left' : tempOverPosX,
				'top' : tempOverPosY
			});
		}
	}
	if(!galleryOn){
		//scale image or video
		
		var tempH = Math.round((screenH- 500) /2);
		var tempW = Math.round((screenW - 426)/2);

		$('#videoSection').css({
			'top' : tempH,
			'left' : tempW
		});
		
	}	
}
var setupContentHidingButtons = function(){
	if(!$("#newsContentReveal").data("mydata")){
		$("#newsContentReveal").click(function(){
			if(menuClosed){
				toggleNews(!newsOpen);
			}
		});
		var myNewsData = [ { loaded: false} ];
		$("#newsContentReveal").data("mydata", myNewsData);
	}
	if(!$("#pageOverlayReveal").data("mydata")){
		$("#pageOverlayReveal").click(function(){
			if(menuClosed){
				toggleOverlay(!overlayOpen);
			}
		});
		var myOverlayData = [ { loaded: false} ];
		$("#pageOverlayReveal").data("mydata", myOverlayData);	
	}
	if(!$("#pageContentReveal").data("mydata")){
		$("#pageContentReveal").click(function(){
			if(menuClosed){
				toggleContent(!contentOpen);	
			}
		});
		var myContentData = [ { loaded: false} ];
		$("#pageContentReveal").data("mydata", myContentData);
	}
	
}
var setupContent = function(){
	
	//console.log("setup content");
	$('.scroll-pane tr td').css({
	background: '#000000',
	opacity: '0.7'
	});
	$('#newsBG').css({
			opacity : .5
	});
	
	$("#newsContent .newstab a.hash-link").each(function(){
		$(this).click(function(){
			var hashString = $(this).attr("rel");
			window.location.hash =  hashString;
			return false;	
		});	
	});
	
	$('.navItemRow').each(function(n){
		$(this).css({
			opacity : .8
		});
		var tempA = $(this).find('a');
		var that = $(this);
		if($(tempA).data("mydata") == null){
			var tempPar = $(this).parent();
			var tempSubNum = String($(tempPar).attr('id'));
			tempSubNum = parseInt(tempSubNum.substr(tempSubNum.length-1));
			var myRowData = [true, tempSubNum];
			
			if($(tempA).hasClass('active')){
				switch(tempSubNum){
					case 1:
					activeMenuSubNav1 = $(tempA);
					if($(tempA).attr("id") == "subNavIDNum1"){
						subNav1ID = 1;
					}
					if($(tempA).attr("id") == "subNavIDNum2"){
						subNav1ID = 2;
					}
					break;
					case 2:
					activeMenuSubNav2 = $(tempA);
					break;
					case 3:
					activeMenuSubNav3 = $(tempA);
					break;
				}
			}
			$(tempA).data("mydata",  myRowData);
			$(tempA).not(".ext").click(function(){
				var tempParPar = $(this).parent().parent();
				var tempPar = $(this).parent();
				var tempNum = String($(tempParPar).attr('id'));	
				tempNum = tempNum.substr(tempNum.length-1);	
				clickedFromSub = tempNum;
				//change 
				
				
				
				if(!$(this).hasClass('active')){
			
					if(iE_browser && iE_version == 6){
						return true;
					}else{	
				
						switch($(this).data('mydata')[1]){
							case 1:
							var tempSubPar1 = $(activeMenuSubNav1).parent();
							$(tempSubPar1).css({
								'background-color' : '#000'
							});
							$(activeMenuSubNav1).removeClass('active');
							activeMenuSubNav1 = $(this);
							break;
							case 2:
							var tempSubPar2 = $(activeMenuSubNav2).parent();
							$(tempSubPar2).css({
								'background-color' : '#000'
							});
							$(activeMenuSubNav2).removeClass('active');
							activeMenuSubNav2 = $(this);
							break;
							case 3:
							var tempSubPar3 = $(activeMenuSubNav3).parent();
							$(tempSubPar3).css({
								'background-color' : '#000'
							});
							$(activeMenuSubNav3).removeClass('active');
							activeMenuSubNav3 = $(this);
							break;
						}
						$(this).addClass('active');
						$(tempPar).css({
							'background-color' : '#ff8d00'
						});
				
						//get new hash string to load
						var hashString = $(this).attr("rel");
						var currentHashArray = new Array();
						currentHashArray = hashString.split("/");
						//check hash for backgroundID
						switch(currentHashArray[0]){
							case 'people':
						
							if(currentHashArray[1]==-1 || currentHashArray[1]==0){
								currentHashArray[1]=-1;
								if(currentHashArray[1] == backgroundID){
									reloadBackground=false;
								}else{
									reloadBackground=true;
								}
							}else{
								reloadBackground=true;
							}
							
								console.log(reloadBackground);
							break;
							case 'works':
							if($(this).attr("id") == "subNavIDNum1"){
								subNav1ID = 1;
							}
							if($(this).attr("id") == "subNavIDNum2"){
								subNav1ID = 2;
							}
							if(currentHashArray[1]==-1){
								if(currentHashArray[1] == backgroundID){
									reloadBackground=false;
								}else{
									reloadBackground=true;
								}
							}else{
								reloadBackground=true;
							}
							break;
							case 'pilobolus':
							if(currentHashArray[4]==1 && currentHashArray[3]==7){
								currentHashArray[1]=-1;
								if(currentHashArray[1] == backgroundID){
									reloadBackground=false;
								}else{
									reloadBackground=true;
								}
							}else{
								if(currentHashArray[1] != backgroundID){
									reloadBackground=true;
								}else{
									reloadBackground=false;
								}
							}
							break;
					
							default:
							if(currentHashArray[1]==0){
								reloadBackground=false;
								currentHashArray[1] = backgroundID;
							}else{
								reloadBackground=true;
							}
							break;
						}
						var tempHashString = "";
						for(var i=0;i<currentHashArray.length;i++){
							if(i == 0){
								tempHashString += currentHashArray[i];
							}else{
								tempHashString += ("/" + currentHashArray[i]);
							}
						}
						window.location.hash =  tempHashString;
						
						
					}
				}
				return false;
			});	
		}
		$(tempA).mouseover(function(){
			if(!$(tempA).hasClass('active')){
				$(that).css({
					opacity : 1,
					'background-color' : '#ff8d00'
				});
			}
		}).mouseout(function(){
			if(!$(tempA).hasClass('active')){
				$(that).css({
					opacity : .8,
					'background-color' : '#000'
				});
			}
		});
		
		if($(tempA).hasClass('active')){
			$(this).css({
				'background-color' : '#ff8d00'
			});
		}
		if($(tempA).is('.active')){
			$(that).css({
				opacity: 1
			});
		}
		var tempH;
		if($(tempA).height() > 16){
			$(this).css({
				'height' : $(tempA).height() + 9
			})
		}	
	});
	if(is_ipad || is_iphone){
		$("#contentArea").width(screenW);
		var tempBodyW = screenW - (($('.navScroll').length * 235));
	}else{
		var tempBodyW = screenW - (($('.navScroll').length * 235) + 70);
	}
	$('.bodyScroll').css({
		opacity : .8,
		width : tempBodyW
	});
	$("#pageContentReveal_holder").css({
		'width' : $("#contentArea").width()
	});
	
	contentH = $('div#pageContent').height();
	
}
var setupContentOverlay = function(){
	
	$('div#overlay').css({
		opacity : .4,
		'height' : screenH, 
		'width' : screenW
	});
	
	//$('div#overlay').hide();
	if($('#contentOverlay')){
		overlayW = $('div#contentOverlay').width();
		overlayH = $('div#contentOverlay').height();
	}
	$('div#contentOverlay').css({
		'top' : ((screenH - $('div#contentOverlay').height())/2) - 100,
		'left': (screenW - $('div#contentOverlay').width())/2
	});
	$('#pageOverlayReveal').css({
		'top' : $('div#contentOverlay').height()/2
	});
	
	$("#contentMiddle .scroll-pane").jScrollPane({showArrows:true, arrowSize:16, scrollbarWidth:19, scrollbarMargin:19, animateTo:true});

}
var checkHeight = function(arr){
	var tempH = 19;
	for(var i=0; i<arr.length; i++){
		if(arr[i] > tempH){
			tempH = arr[i];
		}
	}
	return tempH;
}
var setupScrollBars = function(){
	$('.itemRow').each(function(n){
		var tempArr = new Array();
		var temp1 = $(this).find('div.eventDate').height();
		if(temp1 != null){
			tempArr.push(temp1);
		}
		var temp2 = $(this).find('div.contactName').height();
		if(temp2 != null){
			tempArr.push(temp2);
		}
		var temp3 =$(this).find('div.contactTitle').height();
		if(temp3 != null){
			tempArr.push(temp3);
		}
		var temp4 =$(this).find('div.contactNum').height();
		if(temp4 != null){
			tempArr.push(temp4);
		}
		var temp5 =$(this).find('div.linkTitle').height();
		if(temp5 != null){
			tempArr.push(temp5);
		}
		
		var tempHeight = checkHeight(tempArr);
		
		if(tempHeight > 24){
			$(this).css({
				'height' : tempHeight +  10 + 'px',
				'opacity' : '.8'
			});
			
		}else{
				$(this).css({
					'height' : '24px',
					'opacity' : '.8'
				});
		}
	});
	
	$('.scroll-pane').each(function(n){
		if($(this).data("loaded") == null){
			$(this).jScrollPane({showArrows:true, arrowSize:16, scrollbarWidth:19, scrollbarMargin:19, animateTo:true});
			var scrollLoaded = [true]
			$(this).data("loaded",  scrollLoaded);
		}
	});
}

var checkOpenWindows = function(bool){
	//bool is opening menu true (hide every else), false is closing (open what needs to be open)
	//three sections and all backgrounds and buttons
	var delaytime = 0;
	//news
	if(newsPresent){
		if(bool){
			if(newsOpen){
				toggleNews(false);
				delaytime = 500;
			
			}
		}else{
			if(!newsOpen){
				toggleNews(true);
			}
		}
	}
	//overlay
	if(overlayPresent){
		if(bool){
			if(overlayOpen){
				delaytime = 500;
				toggleOverlay(false);
			}
		}else{
			if(!overlayOpen){
				toggleOverlay(true);
			}
		}
	}
	//page content
	if(contentPresent){
		if(bool){
			if(contentOpen){
				toggleContent(false);
				delaytime = 500;
			}
		}else{
			if(!contentOpen){
				toggleContent(true);
			}
		}
	}
	toggleMenu(bool,delaytime);
}
var resetOverlay = function(){
		var tempPos = (screenW - overlayW)/2;
		$("div#overlayArea").animate({
			opacity : 1
		},500);
		$('#contentOverlay').animate({
			left : tempPos
		}, 500, function(){
			$('#pageContentReveal').css({
				'background-position': '0px -16px'
			});
			overlayOpen = true;
		});			
}
var resetContent = function(){
	$('#pageContentReveal').animate({
			top : -16
		}, 500, function(){
					$('#pageContentReveal').css({
						'background-position': '0px -16px'
					});
					contentOpen = true;
		}
	);		
}
var resetNews = function(){
	$("#newsContent").show();
	$("#newsBG").fadeIn(500);
	$('#newsContentReveal').fadeIn(500);
	$('#newsContentReveal').animate({
		top : 131
	},500, function(){
			$('#newsContentReveal').css({
			 	'background-position': '0px 0px'
			});	
		});
}
var toggleNews = function(bool){
	//bool true=open, false=close
	if(bool){
		//move arrow, reveal bg/text
		// ? slide toggle ? 
		$('#newsContentReveal').animate({
			top :131
		},500, function(){
				$('#newsContentReveal').css({
				 	'background-position': '0px 0px'
				});	
			});
		$("#newsBG").slideToggle(500, function(){
			$("#newsContent").show();
			newsOpen = true;
		});
	}else{
		//hide bg/text, move arrow
		$("#newsContent").hide();
		$("#newsBG").slideToggle(500);
		$('#newsContentReveal').animate({
			top : 0
		},500, function(){
			$('#newsContentReveal').css({
			 	'background-position': '0px -16px'
			});
		} );
		newsOpen = false;
	}	
}
var toggleContent = function(bool){
	if(bool){
		//open
		$('#pageContentReveal').animate({
				top : -16
			}, 500, function(){
					$("#contentArea").slideToggle(500);	
					$('#pageContentReveal').css({
						'background-position': '0px -16px'
					});
					contentOpen = true;
				}
		);
	}else{
		$("#contentArea").slideToggle(500,function(){
				$('#pageContentReveal').animate({
						top : contentH
					}, 500, function(){
							$('#pageContentReveal').css({
								'background-position': '0px 0px'
							});
							contentOpen = false;
						}
				);
			}
		);
	}
}
var toggleOverlay = function(bool){
	if(bool){
		//move arrow, reveal bg/text
		// ? slide toggle ? 
			var tempPos = (screenW - overlayW)/2;
			$("div#overlayArea").show();		
			$("div#overlayArea").animate({
				opacity : 1
			}, 200, function(){
				$('#pageOverlayReveal').css({
					'background-position': '-16px 0px'
				});
			
				overlayOpen = true;
			});
	

			$("#contentOverlay").animate({
				 left : tempPos
				}, 500
			);
		
	}else{
		//hide bg/text, move arrow
		
			$("div#overlayArea").animate({
				opacity : 0
			}, 500, function(){
				$('#pageOverlayReveal').css({
					'background-position': '0px 0px'
				});
				$("div#overlayArea").hide();
				overlayOpen = false;
			});
		
			$("#contentOverlay").animate({
								 	left: screenW	
									}, 500
								);
	}
}
var toggleMenu = function(bool,delaytime){
	menuClosed = !bool;
	$('div#menuBG').delay(delaytime).slideToggle();
	$('div#menu').delay(delaytime).slideToggle();
}
var checkOverlay = function(){
	var bool = false;
	var pageOverayURL="false";
	switch(arguments[0][0]){
		case 'pilobolus':
			if(arguments[0][4] == 2 && arguments[0][2] == 7){
				bool = true;
			}
		break;
	}
	if(bool){
		pageOverayURL = "page.jsp?page=" + arguments[0][0] + "&ajax=true&subNav2ID=" + arguments[0][4] + "&overlay=true";
	}
	return pageOverayURL;		
}
var stageSetup = function(){
	$(window).bind('orientationchange',function(event){

		if(is_ipad || is_iphone){
			rescaleIDevice(is_ipad,is_iphone);
		}else{
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {
			    //Non-IE
			    myWidth = window.innerWidth;
			    myHeight = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			    //IE 6+ in 'standards compliant mode'
			    myWidth = document.documentElement.clientWidth;
			    myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			    //IE 4 compatible
			    myWidth = document.body.clientWidth;
			    myHeight = document.body.clientHeight;
			}
			if(myHeight < 600){
				myHeight = 600;
			}
			if(myWidth < 900){
				myWidth = 900;
			}
        	rescale(myWidth,myHeight);
		}
	});
	
	
	if(is_ipad || is_iphone){
		rescaleIDevice(is_ipad,is_iphone);	
	}else{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		    myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		}
		if(myHeight < 600){
			myHeight = 600;
		}
		if(myWidth < 900){
			myWidth = 900;
		}
		screenH =  myHeight;
		screenW =  myWidth;
		$(window).bind('resize', function() {
				var myWidth = 0, myHeight = 0;
				if( typeof( window.innerWidth ) == 'number' ) {
				    //Non-IE
				    myWidth = window.innerWidth;
				    myHeight = window.innerHeight;
				} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				    //IE 6+ in 'standards compliant mode'
				    myWidth = document.documentElement.clientWidth;
				    myHeight = document.documentElement.clientHeight;
				} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				    //IE 4 compatible
				    myWidth = document.body.clientWidth;
				    myHeight = document.body.clientHeight;
				}
				if(myHeight < 600){
					myHeight = 600;
				}
				if(myWidth < 900){
					myWidth = 900;
				}
				if(is_ipad || is_iphone){
					rescaleIDevice(is_ipad,is_iphone);
				}else{
	            	rescale(myWidth,myHeight);
				}
	        });
	}
	
	loadMenu(screenH, screenW);
	
	
	
	
	 
	
}
var ajaxHashSetup = function(){

	// Bind an event to window.onhashchange that, when the history state changes,
	// iterates over all .bbq widgets, getting their appropriate url from the
	// current state. If that .bbq widget's url has changed, display either our
	// cached content or fetch new content to be displayed.
	
	$(window).bind( 'hashchange', function(event) {
		

		$(window).data()
		// Iterate over all .bbq widgets.
		var hash = location.hash;
		var currentHashArray = new Array();
		hash = hash.replace(/^#/, '');
		currentHashArray = hash.split("/");
		
		//console.log(currentHashArray);
		var pageURL;
		var pageOverayURL = "false";
		var loadOverlay = false;

		
		if(currentHashArray.length != 0){
			if(currentHashArray.length != 1){
				
				if(iE_browser && iE_version == 6){

					alert('figure out what to do with IE6 for loading from hash');
					//take hash and create a page redirect -- to the appropriate page.jsp 
					if(currentHashArray[0] == "home"){
						contentURLStr = "home.jsp";
					}else{
						switch(currentHashArray.length){
							case 3:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&contentID=" + currentHashArray[2]+ "&backgroundID=" + currentHashArray[1];
							break;
							case 4:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&contentID=" + currentHashArray[2] + "&subNav1ID=" + currentHashArray[3] + "&backgroundID=" + currentHashArray[1];
							break;
							case 5:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&contentID=" + currentHashArray[2] + "&subNav1ID=" + currentHashArray[3] + "&subNav2ID=" + currentHashArray[4] + "&backgroundID=" + currentHashArray[1];;
							break;
							case 6:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&contentID=" + currentHashArray[2]+ "&subNav1ID=" + currentHashArray[3] + "&subNav2ID=" + currentHashArray[4] + "&subNav3ID=" + currentHashArray[5] + "&backgroundID=" + currentHashArray[1];
							break;
						}
					}
					window.location = contentURLStr;
				}else{
					var contentURLStr;
					// if contains subNav1 - check to see if the 
					if(currentHashArray[0] == "home"){
						contentURLStr = "home.jsp?ajax=true";
					}else{
						pageOverayURL = checkOverlay(currentHashArray);
						switch(currentHashArray.length){
							case 3:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&contentID=" + currentHashArray[2]+ "&excluded=" + clickedFromSub;
							break;
							case 4:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&contentID=" + currentHashArray[2] + "&subNav1ID=" + currentHashArray[3] + "&excluded=" + clickedFromSub;
							break;
							case 5:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&contentID=" + currentHashArray[2] + "&subNav1ID=" + currentHashArray[3] + "&subNav2ID=" + currentHashArray[4] + "&excluded=" + clickedFromSub;
							break;
							case 6:
							contentURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&contentID=" + currentHashArray[2]+ "&subNav1ID=" + currentHashArray[3] + "&subNav2ID=" + currentHashArray[4] + "&subNav3ID=" + currentHashArray[5] + "&excluded=" + clickedFromSub;
							break;
						}
					}		
					//var navID = currentHashArray[3];
					//find the menuItems  - class="menuItem" add or move the active Image to the current active menu Item
					//add class="active" the menuItem
					var LoadBackground = true;
					var backgroundURLStr;

					if(reloadBackground){
						if(currentHashArray[1] != 0){
							//check against page type
							if(currentHashArray[0] == 'people' || currentHashArray[0] == 'works'){
								// for people, works, 
								
								
								
								if(currentHashArray[1]==-1){
									//set for default
									backgroundID = currentHashArray[1];
									backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];
								}else{
									
									var tempProcessBGURL;
									LoadBackground = false;
									if(currentHashArray[0] == 'people'){
										tempProcessBGURL = 'process.jsp?action=people_media_check&people_id=' + currentHashArray[1]
									}
									if(currentHashArray[0] == 'works'){
										//check for subNav1ID
										if(subNav1ID == 1 || currentHashArray[3] == 1){
											tempProcessBGURL = 'process.jsp?action=works_media_check&works_id=' + currentHashArray[1]
										}else{
											if(backgroundID != -1){
												LoadBackground = true;
												backgroundID = -1;
												backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&subNav1ID=" + currentHashArray[3] + "&backgroundID=-1";
											}
										}

									}
									
									//check against peopleID, worksID to see if there are backgrounds
									if(tempProcessBGURL != undefined){
										$.get(tempProcessBGURL, 		
											function(data){
												var tempStr = data;
												var tempStrNum = tempStr.indexOf('true');
												var LoadBackgroundAfter = true;

												if(tempStrNum != -1){
													backgroundID = currentHashArray[1];
													if(currentHashArray[0] == "works"){
													 	backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&subNav1ID=" + currentHashArray[3] + "&backgroundID=" + currentHashArray[1];
													}else{
														backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];
													}
													backgroundID = currentHashArray[1];
												}else{

													if(backgroundID == undefined){
														if(currentHashArray[0] == "works"){
															backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&subNav1ID=" + currentHashArray[3] + "&backgroundID=" + backgroundID;
															backgroundID = -1;
														}else{
															backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];
															backgroundID = -1;
														}
													}else{
															
															if(currentHashArray[0] == "people" && backgroundID != -1){
																backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=-1";
																backgroundID = -1;
																LoadBackgroundAfter = true;
															}else{
																backgroundID = -1;
																LoadBackgroundAfter = false;	
															}
															
															
														
													}
												}
											
												if(LoadBackgroundAfter){
													$.get(backgroundURLStr, function(data){
														console.log(data);
														setupBackground(data);
													});
												}
											}
										);
									}
								}
								
							
								
							}else{
								//check for pilobolus for reel
								if(currentHashArray[0] == 'pilobolus'){

									if(currentHashArray[4] == 1 && currentHashArray[3] == 7){
										backgroundID = currentHashArray[1];
										backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&reels=true&ajax=true&backgroundID=" + currentHashArray[1] + "&subNav2ID=1";	
									}else{
										backgroundID = currentHashArray[1];
										backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];	
									}

								}else{
									backgroundID = currentHashArray[1];
									backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];
								}

							}
						}else{
							if(currentHashArray[0] == 'people' || currentHashArray[0] == 'works'){
								if(currentHashArray[1]==0){
									currentHashArray[1]=-1;
									backgroundID = currentHashArray[1];
									backgroundURLStr = "page.jsp?page=" + currentHashArray[0] + "&ajax=true&backgroundID=" + currentHashArray[1];
								}else{
									LoadBackground = false;	
								}
							}else{
								LoadBackground = false;	
							}
						}
					}else{
						LoadBackground = false;	
					}

					if(LoadBackground){
						$.get(backgroundURLStr, function(data){
							setupBackground(data);
						});
					}
					if(pageOverayURL != "false"){
						overlayPresent=true;
						$.get(pageOverayURL, function(data) {
							configurePageOverlay(currentHashArray[0],data);
						});
					}else{
						if(overlayPresent){
							$("#overlay").hide();
							$("#contentOverlay").hide();
							$("#overlayArea").children().remove();
						}
						overlayPresent=false;
					}

					$.get(contentURLStr, function(data) {
						//run a method to re-establish content divs and position
						setActiveMenuItem(currentHashArray[0]);
						switch(parseInt(clickedFromSub)){

							case 0:
							configurePageContent(currentHashArray[0],data);
							break;

							case 1:
							configureSub1Content(currentHashArray[0],data);
							break;

							case 2:
							configureSub2Content(currentHashArray[0],data);
							break;

							case 3:
							configureSub3Content(currentHashArray[0],data);
							break;
						}		
					});
				}
			}else{
				if(currentHashArray[0] == ''){
					
					// if(iE_browser && iE_version == 6){

						// alert('figure out what to do with IE6');
						// 				if($('.galleria-image').length > 1){
						// 					galleryOn=true;
						// 					$('#galleria').galleria({
						// 			            image_crop: true,
						// 			            frame: false,
						// 						thumbnails: false
						// 					});
						// 					$("#galleria").show("slow");
						// 				}else{
						// 					galleryOn=false;
						// 					$("#galleria").show("slow");		
						// 				}
						// 				setActiveMenuItem();
						// 				initializePage(path, tempNav1, tempNav2, tempNav3, contentID);
						// 				rescale(screenW, screenH);
						// 				setupContentHidingButtons();
						// 				setupContent();
						// 				setupScrollBars();

					//}else{
					
					
						var tempQueryStringPageType = getQuerystring('page');
						var tempNav1 = getQuerystring('subNav1ID');
						var tempNav2 = getQuerystring('subNav2ID');
						var tempNav3 = getQuerystring('subNav3ID');
						var contentID = getQuerystring('contentID');
						backgroundID = getQuerystring('backgroundID');
						var path;

						currentHashArray[0] = tempQueryStringPageType;
						currentHashArray[1] = backgroundID;
						currentHashArray[2] = contentID;
						currentHashArray[3] = tempNav1;
						currentHashArray[4] = tempNav2;
						currentHashArray[5] = tempNav3;

						pageOverayURL = checkOverlay(currentHashArray);

						if(pageOverayURL != "false"){
							overlayPresent=true;
							$.get(pageOverayURL, function(data) {
								configurePageOverlay(currentHashArray[0],data);
							});
						}else{
							if(overlayPresent){
								$("#overlay").hide();
								$("#contentOverlay").hide();
								$("#overlayArea").children().remove();
							}
							overlayPresent=false;
						}
						if(tempQueryStringPageType != -1){
							path = tempQueryStringPageType;
						}else{
							path = location.pathname;
							path = path.substring(1,path.length-4);	
						}
						
						if($('.galleria-image').length > 1){
							galleryOn=true;
							$('#galleria').galleria({
					            image_crop: true,
					            frame: false,
								thumbnails: false
							});
							$("#galleria").show("slow");
						}else{
							galleryOn=false;
							$("#galleria").show("slow");		
						}
						
						initializePage(path, tempNav1, tempNav2, tempNav3, contentID);
						setActiveMenuItem(path);
						setupContentHidingButtons();
						rescale(screenW, screenH);
						
						if(iE_browser && iE_version == 6){
						
						}else{
								
						}
					//}
				}
			}
		}
	});
	//trigger a hash check on initial page load
	$(window).trigger( 'hashchange' );	

}

var getQuerystring = function(key)
{
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return -1;
  else
    return qs[1];
}
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

$(document).ready(function(){
	
	BrowserDetect.init();
	if(BrowserDetect.browser == "Explorer"){
		iE_browser = true;
		iE_version = BrowserDetect.version;
	}
	
	var agent=navigator.userAgent.toLowerCase();
	is_iphone = ((agent.indexOf('iphone') != -1));
	is_ipad = ((agent.indexOf('ipad') != -1));
	
	
	$("#galleria").hide();
	stageSetup();
 	$("#overlay").hide();
	$("#contentOverlay").hide();
	$("#pageContent").hide();
	$("#newsBG").hide();
	$("#newsContent").hide();
	$('#newsContentReveal').hide();	
	//setup gallery theme
	Galleria.loadTheme('common/js/galleria.full_plus_move.js');
	//setup ajax hash-change, and trigger hash-change
	ajaxHashSetup();	
});

