 var $curr;
 
 $(document).ready(function(){
   // Your code here
  
  
  $("#rating_up").click(function(e){
				//alert("Мы учтем! ;)");
				arg = $("#big_photo").attr("src");
				 $.post("http://"+location.host+"/includes/vote_photo.php", {string: arg}, function(xml){
					if($("res",xml).text()=="NO"){alert("Не получилось! Попробуйте еще раз");}
					if($("res",xml).text()=="LIMIT"){alert("С Вашего IP-адреса голосовали сегодня трижды! Продолжить можно завтра :)");}
				 	if($("res",xml).text()=="YES"){alert("Мы учли! ;)");}
				});
				return false;
			});
  $("#photo_prev").click(function(e){
							$curr.prev().click();
							return false;
						});
  $("#photo_next").click(function(e){
							$curr.next().click();
							return false;
						});
  
  $(".photo_viewer").click(function(e){
							$curr = $(this);
							$("#big_photo").attr("src",$(this).attr("title"));
							//alert($curr.find(".rating").html());
							$("#alldatab").html($curr.find(".alldata").html());
							$("#authorb").html($curr.find(".author").html());
							$("#ratingb").html($curr.find(".rating").html());
							//$("#photo_view").width($("#big_photo").width()+4);
							$("#photo_view").animate({height: "show"}, 300);
							
							return false;
						})
					.mouseover(function(){
 									this.style.cursor="pointer";  
									// $(this).css({color: "#F00" });
								  });
					
	$("#close_photo").click(function(e){
									$("#photo_view").animate({height: "hide"}, 300);
									return false;
									});					
  
  
  $(".song")
  			.mouseover(function(){
 									this.style.cursor="pointer";  
									// $(this).css({color: "#F00" });
			})
  			.click(function(e){
									
									this.style.cursor="wait";  
									var arg = this;
									var myObj = $("#track_text").get(0);
									leftPos = $(this).get(0).offsetLeft;
									topPos = $(this).get(0).offsetTop;
									
									var coors = findPos($(this).get(0));
									var y =	coors[1]-20;								
									myObj.style.top=y + 'px';
									//myObj.style.left=coors[0] + 'px';
									
									arg_string = $(this).html();

									$.post("http://"+location.host+"/includes/get_liriks.php", {string: arg_string}, function(xml) {
														if($("txt",xml).text()!="NO"){
															$("#name_h3").html($("name",xml).text());
															$("#text_p").html($("txt",xml).text());
															$("#data_p").html($("author",xml).text());
															}
														else{
															$("#name_h3").html("");
															$("#text_p").html("Текст не найден");
															$("#data_p").html("");
															}	
														
														
														//$("#track_text").show();
														$("#track_text").animate({height: "show"}, 300,retcursor(arg));

											});

									return false;
									});

  
  $(".text_name")
  			.mouseover(function(){
 									this.style.cursor="pointer";  
									// $(this).css({color: "#F00" });
			})
  			.click(function(e){
									
									this.style.cursor="wait";  
									var arg = this;
									var myObj = $("#track_text").get(0);
									leftPos = $(this).get(0).offsetLeft;
									topPos = $(this).get(0).offsetTop;
									
									var coors = findPos($(this).get(0));
									var y =	coors[1]-20;								
									myObj.style.top=y + 'px';
									//myObj.style.left=coors[0] + 'px';
									
									arg_string = $(this).html();
									
									$.post("http://"+location.host+"/includes/get_liriks.php", {string: arg_string}, function(xml) {
														if($("txt",xml).text()!="NO"){
															$("#name_h3").html($("name",xml).text());
															$("#text_p").html($("txt",xml).text());
															$("#data_p").html($("author",xml).text());
															}
														else{
															$("#name_h3").html("");
															$("#text_p").html("Текст не найден");
															$("#data_p").html("");
															}
														
														$("#track_text").animate({height: "show"}, 300,retcursor(arg));

											});
									
									
									
									//
									//this.style.cursor="default"; 
									return false;
									});
   $("#close").click(function(e){
							  		 
									$("#track_text").animate({height: "hide"}, 300);
						
									return false;
									});
 });
 
 
 function retcursor(arg){
	 arg.style.cursor="default"; 
	 }
 
 function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}	
