var loadablePanes = {"#Philosophy":'office/philosophy.php',"#Services":'office/services.php',"#Kevin":'office/kevin-kennon.php', "#KKA":'office/kka.php', "#People":'office/people.php', "#Contact":'office/contact.php', "#Employment":'office/employment.php', 
"#News":'media/news.php', "#Awards":'media/awards.php', "#Publications":'media/publications.php', "#Exhibitions":'media/exhibitions.php', "#Press":'media/press.php', "#MediaInquiries":'media/media-inquiries.php',
"#Work":'work/work.php', 
"#MIXED":'work/mixed-use.php', "#WTC":'work/mixed-use/world-trade-center-competition.php', "#DOHA":'work/mixed-use/doha.php', "#AD":'work/mixed-use/ad-co-op-tower-hotel.php', "#17":'work/mixed-use/pier-17.php', "#BV":'work/mixed-use/bay-view-tower-hotel.php', "#TT":'work/mixed-use/tianjin-tower.php', "#GSH":'work/mixed-use/gold-street-hotel.php', "#TWT":'work/mixed-use/trump-world-tower-hotel.php', "#DP":'work/mixed-use/downtown-pines.php', "#DVCH":'work/mixed-use/devos-childrens-hospital.php',
"#CULTURAL":'work/cultural.php', "#RMDP":'work/cultural/rodin-museum.php', "#IP":'work/cultural/incubator-project.php', "#MLKJM":'work/cultural/martin-luther-king.php', "#WTCS":'work/cultural/world-trade-center-site.php', "#DTAP":'work/cultural/dubai-temporary-arts-pavilion.php',
 "#RETAIL":'work/retail.php', "#100":'work/retail/100william.php', "#BSM":'work/retail/bloomingdales-santa-monica.php', "#BCM":'work/retail/bloomingdales-costa-mesa.php', "#BCH":'work/retail/bloomingdales-chestnut-hill.php', "#BNY":'work/retail/bloomingdales-new-york.php', "#BOR":'work/retail/bloomingdales-orlando.php', "#BSF":'work/retail/bloomingdales-san-francisco.php', "#BM":'work/retail/bloomingdales-miami.php',
"#COMM":'work/commercial.php',"#OAP":'work/commercial/omniyat.php', "#LBH":'work/commercial/lehman.php', "#SOTH":'work/commercial/sotheby.php', "#INFO":'work/commercial/infosys.php', "#HS":'work/commercial/harborside.php', "#BDGA":'work/commercial/boeing.php', "#605":'work/commercial/605.php', "#ECB":'work/commercial/european.php',
"#EDU":'work/educational.php', "#CILC":'work/educational/columbus.php', "#CULVER":'work/educational/culver.php', "#RFLAC":'work/educational/robert-frost.php', "#UCSB":'work/educational/university-of-chicago.php', "#ROBSCH":'work/educational/robbins-school.php',
"#RES":'work/residential.php', "#111":'work/residential/111-leroy.php', "#CCA":'work/residential/cc-apartment.php', "#157":'work/residential/157-hudson.php', "#GOTR":'work/residential/gotbaum-residence.php', "#akar":'work/residential/akar-tower.php', "#SKETCH":'work/residential/sketchpad-project.php', "#350WB":'work/residential/350-west-broadway.php', 
"#MP":'work/master-plan.php', "#SANR":'work/master-plan/sanya-resort.php', "#HAIKV":'work/master-plan/haikou-villas.php', "#HAIKR":'work/master-plan/haikou-resort.php', "#CITYLC":'work/master-plan/city-lights-competition.php', "#CONED":'work/master-plan/con-edison-uncity.php'};

function autoloadpane() {
	var pane = new Array();
	var paneName;
	var paneString = window.location.hash;
	var end = paneString.indexOf('-');
	if (end > 0) paneName = paneString.substr(0,end);
	else paneName = paneString;
	if (loadablePanes[paneName]) {
		paneswitch(loadablePanes[paneName]); enableScrollables(); enableOverlay(); scrollPane();
	}
	if (paneName == '#News') {
		if (end > 0) {
			var id;
			var pair = paneString.substr(end);
			var equ = pair.indexOf('=');
			if (equ > 0) {
				id = pair.substr((equ+1));
				retrieve_and_load_page_with_news(id);
			};
		} else {
			// This loads the AddThis button when entering the URL directly
			// and no article is provided.
			var ts = new Date().getTime();
			var addthis_share = {
				url: 'http://'+location.hostname+location.pathname+'?time='+ts+window.location.hash
			};
			addthis.button('#addthis_button',{},addthis_share);
		}
	}
}

function paneswitch(url) {
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	document.getElementById('window').innerHTML=xmlhttp.responseText;
	if (url == 'media/news.php') {
		// This loads the AddThis button when navigating to the New page
		// The '#News' suffix is added because it's not there otherwise
		//(for some reason, probably related to the AJAX call returning).
		var ts = new Date().getTime();
		var addthis_share = {
			url: 'http://'+location.hostname+location.pathname+'?time='+ts+'#News'
		};
		addthis.button('#addthis_button',{},addthis_share);
		window.setTimeout('scrollPane()',1000);
	} else if (url == 'media/newsEditor.php') {
		newsEditorLoaded();
	}
}

function enableScrollables() {
	// enable circular scrollables with a click handler
	$(".scroll").scrollable({ circular: true }).click(function() {
		$(this).data("scrollable").next();    
	});
}

function enableScrollables() {

	// initialize scrollable
	$(".scrollable").scrollable({ vertical: true});

}

function enableOverlay() {
	$("img[rel]").overlay();
	$("span[rel]").overlay();
}

function homeSlide() {
	$('#slideshow').crossSlide({
	  sleep: 3,
	  fade: 1
	}, [
	  { src: 'images/wtc/wtc-01.jpg' },
      { src: 'images/rodin/rodin-01.jpg' },
      { src: 'images/bloomingdales/bloomcosta-01.jpg' },
      { src: 'images/sothebys/sothebys-01.jpg' },
      { src: 'images/incubator/incubator-01.jpg' }
	]);
}


function enableScrollables() {		
		
	// initialize scrollable with mousewheel support
	$(".scrollable").scrollable({ vertical: true, mousewheel: false });	
	
}


function scrollPane()
{
	$('.scroll-pane').jScrollPane();
}

function loadjsfile(filename){
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
  document.getElementsByTagName("head")[0].appendChild(fileref);
 }


