var featuredMatrix = [];

function setFeaturedArray(index, value){
	
	featuredMatrix[index] = value;	
	
}

function initfeatured(){

	initAdreessFeatured(0);
	
}

function initAdreessFeatured(time){
	
	var vlr = $.address.value();
	value = vlr.split("/");
	
	if(value[2]!=undefined && value[2]!=""){
		
		if(featuredMatrix[value[2]]!=undefined){
		
			openSingleFeatured(featuredMatrix[value[2]], value[2], time);
			
		}else{
			
			closeSingleFeatured(time);
			
		}
		
	}else{
			
		closeSingleFeatured(time);
			
	}
	
}

function openSingleFeatured(id, title, time){
	
	var url = "featured_single.php?id=" + id + "&ln=" + lang;
	var tm = (time==0) ? 0 : 500;
	
	$("#featuredArea").stop(true, true).fadeOut(tm);
	
	window.setTimeout(function() {
				
		var cnt = document.getElementById("featuredArea");
		cnt.innerHTML = '';
				
		$("#featuredArea").load(url, function() {
					
			$("#featuredArea").stop(true, true).fadeIn(tm);
					 
		});
				
	}, tm);
	
	$.address.value("featured/" + title);

}

function closeSingleFeatured(time){
	
	var tm = (time==0) ? 0 : 500;
	
	$("#content").stop(true, true).fadeOut(tm);
	
	window.setTimeout(function() {
				
		var cnt = document.getElementById("content");
		cnt.innerHTML = '';
				
		$("#content").load("home.php?ln=" + lang, function() {
			
			$("#content").stop(true, true).fadeIn(tm);
					 
		});
				
	}, tm);
	
	$.address.value("home");
	
}
