
$().ready(function(){
	setupImgs();
	setInterval("checkAnchor()", 300);
});

var currentAnchor = null;

function checkAnchor(){
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		
		if (!currentAnchor || currentAnchor == "" || currentAnchor == "#") {
			$('#infoContain .menu a').removeClass("sel");
			$('#infoContain .infoPanel').removeClass("sel");
			
			$('#infoContain .menu a:first').addClass("sel");
			$('#infoContain .infoPanel:first').addClass("sel");
		} else {
			var id = currentAnchor.substring(1);
			
			if (id.indexOf("initiatives") > -1) {
				if (id.indexOf("_") > -1) {
					itemId = id.substring(id.indexOf("_")+1);
					loadIniItem(itemId);
					$("#iinitiatives .headList ul").show();
					id = id.substring(0, id.indexOf("_"));
				} else {
					loadIniItem("0");
					$("#iinitiatives .headList ul").hide();
				}
			}
			
			$('#infoContain .menu a').removeClass("sel");
			$('#infoContain .infoPanel').removeClass("sel");
			
			$('#infoContain #m'+id).addClass("sel");
			$('#infoContain #i'+id).addClass("sel");
		}
	}
}

function setupImgs(){
	$("#inisContent a.imgG").lightBox();
}


var currItemId = '0';

function loadIniItem(wId){
	if (currItemId != wId) {
		$("#inisContent").html("<br><br>");
	
		currItemId = wId;
	
		var query = "id=" + wId;
		
		$("#iinitiatives .loading").show();
		$.get("/common_gl/inc_ini_item.php", query, function(data){
			$("#iinitiatives .loading").hide();
			$("#iinitiatives .iLnk").removeClass('sel');
			$("#iinitiatives #iL"+wId).addClass('sel');
			
			$("#inisContent").html(data);
			$("#inisContent a.imgG").lightBox();
			
			updateBackground();
		});
	}
}