
$().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);
			
			$('#infoContain .menu a').removeClass("sel");
			$('#infoContain .infoPanel').removeClass("sel");
			
			$('#infoContain #m'+id).addClass("sel");
			$('#infoContain #i'+id).addClass("sel");
			
			if (id != "news") {
				$('#i'+id+" img").each(
					function(){
						this.src = this.name;
					});
			}
		}
	}
}

function setupImgs(){
	$('#iphotos img, #ivideos img').each(
		function(){
			this.name = this.src;
			this.src = "";
		});
	$("#iphotos a").lightBox();
	$("#newsContent a.imgG").lightBox();
	
	
	$('#iphotos.sel img, #ivideos.sel img').each(
		function(){
			this.src = this.name;
		});
}



function loadNewsItem(wId){
	var query = "id=" + wId;
	
	$("#newsList .loading").show();
	$.get("/asia/common_gl/inc_news_item.php", query, function(data){
		$("#newsList .loading").hide();
		$("#newsList .nLnk").removeClass('sel');
		$("#newsList #nL"+wId).addClass('sel');
		
		$("#newsContent").html(data);
		$("#newsContent a.imgG").lightBox();
	});
}
