function showViewer(){
	document.getElementById("bg").style.display = "block";
	document.getElementById("viewer").style.display = "block";
	document.getElementById("viewer").src = "/viewer/index.html";
	document.getElementById("viewer").style.width = "800px";
	document.getElementById("viewer").style.height = "600px";
}
function hideViewer(){
	document.getElementById("bg").style.display = "none";
	document.getElementById("viewer").style.display = "none";
	document.getElementById("viewer").src = "";
}
function showMoreNews(obj){
	document.getElementById("bg").style.display = "block";
	document.getElementById("viewer").style.display = "block";
	document.getElementById("viewer").src = obj.src;
	document.getElementById("viewer").style.width = obj.wid + "px";
	document.getElementById("viewer").style.height = obj.hei + "px";
}
function hideSkazka(){
	document.getElementById("bgSkazka").style.display = "none";
	document.getElementById("skazkaBlock").style.display = "none";
}
function parseXmlGallery(xml){
	$(xml).find("img").eq(0).each(function()
	{
		$("#bigPhoto").append("<img src='" + $(this).attr("src") + "' alt='" +  $(this).attr("num") + "' title='" +  $(this).attr("num") + "' />");
	});
	
	$(xml).find("img").each(function()
	{
		var alt = "";
		if($(this).attr("num")){
			alt = "alt='" +  $(this).attr("num") + "' title='" +  $(this).attr("num") + "'";
		}
		else if($(this).attr("alt")){
			alt = "alt='" +  $(this).attr("alt") + "' title='" +  $(this).attr("alt") + "'";
		}
		else{
			alt = "title='n/a'";	
		}
		$("#smallPhotos table tr").append("<td><img onclick='showBigGalleryPhoto(this)' src='" + $(this).attr("src") + "'" + alt +  " /></td> ");
		$("#smallPhotos img").simpletooltip();
	});
}

function showBigGalleryPhoto(img){
	$("#bigPhoto img").attr("src", img.src);
}
function sendXMLRequest(src){
	$(document).ready(function()
	{
	  $.ajax({
		type: "GET",
		url: src,
		dataType: "xml",
		success: parseXmlGallery
	  });
	});		
}
function parseXmlVideo(xml){
	$(xml).find("image").eq(0).each(function()
	{
		$("#flvPlayer").attr("href", $(this).attr("src"));
		flowplayer("flvPlayer", "/flowplayer-3.2.2.swf");
	});
	
	$(xml).find("image").each(function()
	{
		var alt = "";
		if($(this).attr("num")){
			alt = "alt='" +  $(this).attr("title") + "' title='" +  $(this).attr("title") + "'";
		}
		$("#smallPhotos table tr").append("<td><img onclick='showBigVideo(\"" + $(this).attr("src") + "\")' src='" + $(this).attr("icon") + "'" + alt +  " /></td> ");
	});
}
function showBigVideo(src){
	$("#flvPlayer").attr("href", src);
	flowplayer("flvPlayer", "/flowplayer-3.2.2.swf");
}
function showIssueGallery(path){
	$("#bigPhoto img").remove();
	$("#smallPhotos table tr td").remove();
	
	sendXMLRequest(path); 	
}
