// JavaScript Document
$(document).ready(function(){						   
	getAutors();
});

//console.log("load");
var creator_small_pic=new Array();
var creator_big_pic=new Array();
var name=new Array();
var name_description=new Array();
var info=new Array();
var animation=1;
var countAutors=0;
function getAutors() {
			 $.ajax({
                 type: "GET",
				 error: function(){alert("bad")},
                 url: "creators/creators.xml",
                 dataType: "xml",
                 success: function(xml) {
						//console.log("ld");
                     $(xml).find('root page').each(function(i){					 
						countAutors=i;
						 $(this).find('creator_small_pic').each(function(){
									creator_small_pic[i]=$(this).text();							
						 });
						 $(this).find('creator_big_pic').each(function(){
									creator_big_pic[i]=$(this).text();							
						 });
						 $(this).find('name_description').each(function(){
									name_description[i]=$(this).text();							
						 });
						 $(this).find('info').each(function(){
									info[i]=$(this).text();							
						 });
						 $(this).find('name').each(function(){
									name[i]=$(this).text();							
						 });
						
                     });
					 showAutorsList();
					 
                 }
             }); 
}

function showAutorsList(){
		var autorsStr='';
		for (i=0;i<=countAutors;i++){		
		autorsStr+="<div class=\"creator\" onmouseover=\"showName('"+i+"')\"  onclick=\"showInfo('"+i+"')\"  onmouseout=\"clearName()\" ><div class=\"mask\"><a href=\"javascript:showAutor('"+i+"')\" title=\""+name[i]+"\"><img src=\"images/creatorsMaska.png\" width=\"104\" height=\"73\" alt=\""+name[i]+"\"  title=\""+name[i]+"\" /></a></div><div class=\"fase\"><img src=\""+creator_small_pic[i]+"\" width=\"94\" height=\"54\" title=\""+name[i]+"\" alt=\""+name[i]+"\"  /></div></div>";
			
			
						//console.log(newsStr);			
		}
	$(".creatorsLesnocarelMouve").html(autorsStr);
		
	
	$(".newsList").live("click", function(){
			var Dlocation="news_more.php?news="+$(this).attr("item");
			document.location=Dlocation;
		});

	
	
}

function showName(id) {
	$(".showName").html(name[id]);
}
function showInfo(id) {
	//alert(id);
	$(".sozdatName").html(name_description[id]);
	$(".sozdatPhoto img").attr("src", creator_big_pic[id]);
	$(".sozdatPhoto img").attr("alt", name[id]);
	$(".sozdatPhoto img").attr("title", name[id]);
	$(".sozdatInfo").html(info[id]);
	$(".sozdatPopup").show();
}
function clearName() {
	$(".showName").html("");
}
function topM() {
	var top=$(".creatorsLesnocarelMouve").css("top");
	top=top.substring(0,top.length-2)*1;
	var totalH=(countAutors+1)*73;
	if((totalH+top)>449 && animation==1 ){
		animation=0;
		$(".creatorsLesnocarelMouve").animate( { top: "-=73px" } , 500, 0 , function(){ animation=1 });	
	}
}
function botM() {
	var top=$(".creatorsLesnocarelMouve").css("top");
	top=top.substring(0,top.length-2)*1;
	if (top<0  && animation==1 ) {
		animation=0;
		$(".creatorsLesnocarelMouve").animate( { top: "+=73px" } , 500, function(){ animation=1 } );
	}	

}

function closePopup() {
	$(".sozdatPopup").hide();
	$(".sozdatName").html("");
	$(".sozdatInfo").html("");
	$(".sozdatPhoto img").attr("src", "images/pixel.gif");
	$(".sozdatPhoto img").attr("alt", "");
	$(".sozdatPhoto img").attr("title", "");
}

