$(document).ready(function(){start();
		

});
function start(){
	$(".neolink").click(function(){ 
	window.location.href = $(this).attr('title');
	}); 
	$(".galerija a").lightBox({fixedNavigation:true});
	$(".galerijameniu a,.meniu a,.other a").click(function(){
	if (this.pathname){addTask('open',insertPage(str_replace('/','',this.pathname+".html"),".text","html"));return false;}});	 
}
function str_replace(search, replace, subject){return subject.split(search).join(replace);}
function killTask(killID){if(process[killID]){delete process[killID];process=clearArray(process);viewObject(process);}}
function killTasks(){process=Array();x=0;$(".text").html('&nbsp;');}
function addTask(nameto,todo){if(nameto && todo){process[x]=Array(nameto,todo);viewObject(process);x++;}}

var req = 1;
function insertPage(meurl,name,type) { 
	if (req == 1) {req++
		 $.ajax({
			type: "GET",
			url: 'pages/'+meurl,
			cache: false,
			success: function(msg){
				if (type == 'insert') 	{
					if (msg){$(name).after(msg).fadeIn("slow");}}if (type == 'html'){ 
						$(name).html(msg);
						

					}
				if (type == 'return'){
				if (req){req=(req-1);}
				if (msg){if(msg == 'ok'){$(name).addClass("enable");$(name+"error").html("&nbsp;").fadeIn("slow");return true;}else{$(name).removeClass("enable");$(name).addClass("disable");$(name+"error").html(msg).fadeIn("slow");stop();return false;}}else{$(name).removeClass("enable");$(name).addClass("disable");$(name+"error").html("ERROR: The URL is not reachable!").fadeIn("slow");return false;}
			}
			if (req){req=(req-1);}
			start();

		}
		 });

	}

}


