$(function(){ 
	$('input[title!=""]').hint();
	$('textarea[title!=""]').hint();
});
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};
	var tt=0;
	var vremeto;
	
function teaser()
	{
		if(tt) 
			{
			var old_pos=$("#hotnewschange > li").find('strong').text();
		    var new_pos1=parseInt(old_pos)+1;
			if(new_pos1>10) new_pos1=1;
			$("#hotnewschange > li:eq("+new_pos1+")").empty();
                $("#hotnewschange > li:eq("+new_pos1+")").append("<strong>"+new_pos1+"</strong>");
				$("#hotnewschange > li:eq("+old_pos+")").empty();
                $("#hotnewschange > li:eq("+old_pos+")").append("<a href=\"javascript:;\">"+old_pos+"</a>");
			
				$("#hothot .hothot").removeClass("visible");
				$("#hothot .hothot:eq("+(new_pos1-1)+")").addClass("visible");
			}
		vremeto=setTimeout('teaser()', 5000); 
	}	
	
	
	
	
	
$(document).ready(function(){
						   
	var animation_speed=1000;
	$("#hothot .hothot:first").addClass("visible");
	
	teaser();
	tt=1;
	$("#hotnewschange li").click(function(){
		if($(this).find('a').text())
		{
		var now_pos=$(this).text();
		var old_pos=parseInt($("#hotnewschange > li").find('strong').text());
	
			 if(now_pos>0&&now_pos<11)
			 {
				$("#hotnewschange > li:eq("+now_pos+")").empty();
                $("#hotnewschange > li:eq("+now_pos+")").append("<strong>"+now_pos+"</strong>");
				$("#hotnewschange > li:eq("+old_pos+")").empty();
                $("#hotnewschange > li:eq("+old_pos+")").append("<a href=\"javascript:;\">"+old_pos+"</a>");
		
				$("#hothot .hothot").removeClass("visible");
				$("#hothot .hothot:eq("+(now_pos-1)+")").addClass("visible");
			 }
			 else
			 {
				if(now_pos.replace(/^\s+|\s+$/g,"")=="назад"&&old_pos>0&&old_pos<11)
				 {
					var new_pos1=parseInt(old_pos)-1;
					if(new_pos1<1) new_pos1=10;
				 }
				 if(now_pos.replace(/^\s\s*/, '').replace(/\s\s*$/, '')=="напред"&&old_pos>0&&old_pos<11)
				{
				   var new_pos1=parseInt(old_pos)+1;
				   if(new_pos1>10) new_pos1=1;
					}
			 	
				$("#hotnewschange > li:eq("+new_pos1+")").empty();
                $("#hotnewschange > li:eq("+new_pos1+")").append("<strong>"+new_pos1+"</strong>");
				$("#hotnewschange > li:eq("+old_pos+")").empty();
                $("#hotnewschange > li:eq("+old_pos+")").append("<a href=\"javascript:;\">"+old_pos+"</a>");
				$("#hothot .hothot").removeClass("visible");
				$("#hothot .hothot:eq("+(new_pos1-1)+")").addClass("visible");
				 
			  }
		clearTimeout(vremeto);
		vremeto=setTimeout('teaser()', 5000);	
		}		
			 
		});
	
		
		
 
 
   if($("#forum_block").attr("id"))  $("#forum_block_container").load("/scripts/_script_homecomments.php",{});
    $("#forum_block ul  li").click(function(){
            var txt=$(this).text();
            var ch=$(this).find('a');
            if(ch.text())
             {
                $("#forum_block_container").html("<p align=\"center\"><img src=\"/html/im/load2.gif\" alt=\"\" /></p>");
                var old_str=$("#forum_block ul > li").find('em');
                var old_txt=old_str.text();
                var old_par=old_str.parent();
            
				$("#forum_block_container").load("/scripts/_script_homecomments.php",{"param":txt},function(){
                $("#forum_block_container").fadeIn(animation_speed);
                });
                old_par.empty();
                old_par.append("<a href=\"javascript:;\">"+old_txt+"</a>");
                $(this).empty();
                $(this).append("<em>"+txt+"</em>");
                }
            }); 


  
    if($("#gallery_block").attr("id"))  
		{  var old_str=$("#gallery_block ul > li").find('em');
		   var old_par=old_str.parent();
           var res=/id\_([0-9]*)/i.exec( old_par.attr("id") );
		   
			$("#g1").load("/scripts/_script_gallery.php",{"block":res[1]});
        }
	$("#gallery_block ul  li").click(function(){
            var txt=$(this).text();
            var ch=$(this).find('a');
            if(ch.text())
             {
                $("#g1").html("<p align=\"center\"><img src=\"/html/im/load2.gif\" alt=\"\" /></p>");
                var old_str=$("#gallery_block ul > li").find('em');
                var old_txt=old_str.text();
                var old_par=old_str.parent();
                var res=/id\_([0-9]*)/i.exec( $(this).attr("id") );
            
            	$("#g1").load("/scripts/_script_gallery.php",{"block":res[1]},function(){
                $("#g1").fadeIn(animation_speed);
                });
                old_par.empty();
                old_par.append("<a href=\"javascript:;\">"+old_txt+"</a>");
                $(this).empty();
                $(this).append("<em>"+txt+"</em>");
                }
            }); 
            
            
    $("#toptop_div_home").load("scripts/_script_toptop.php",{"design":1});
    $("#toptop ul > li").click(function(){
            var txt=$(this).text();
            var ch=$(this).find('a');
           if(ch.text())
             {
               
				$("#toptop_div_home").html("<p align=\"center\"><img src=\"/html/im/load2.gif\" alt=\"\" /></p>");
                var old_str=$("#toptop ul > li").find('em');
                var old_txt=old_str.text();
                var old_par=old_str.parent();
            
                
                $("#toptop_div_home").load("scripts/_script_toptop.php",{"toptop":txt,"design":1},function(){
                $("#toptop_div_home").fadeIn(animation_speed);
                });
                old_par.empty();
                old_par.append("<a href=\"javascript:;\">"+old_txt+"</a>");
                $(this).empty();
                $(this).append("<em>"+txt+"</em>");
                
                
                }
            });
	
	
	if($("#index_fanclubs").attr("id"))  $("#index_fanclubs_div").load("/scripts/_script_fanclub_new.php",{"block":3});
    $("#index_fanclubs ul  li").click(function(){
            var txt=$(this).text();
            var ch=$(this).find('a');
            if(ch.text())
             {
                $("#index_fanclubs_div").html("<p align=\"center\"><img src=\"/html/im/load2.gif\" alt=\"\" /></p>");
                var old_str=$("#index_fanclubs ul > li").find('em');
                var old_txt=old_str.text();
                var old_par=old_str.parent();
            
				$("#index_fanclubs_div").load("/scripts/_script_fanclub_new.php",{"toptop":txt,"block":3},function(){
                $("#index_fanclubs_div").fadeIn(animation_speed);
                });
                old_par.empty();
                old_par.append("<a href=\"javascript:;\">"+old_txt+"</a>");
                $(this).empty();
                $(this).append("<em>"+txt+"</em>");
                }
            }); 

	//---------bliasak reporteri
   if($("#index_reporters").attr("id"))  $("#index_reporters_div").load("/scripts/_script_gallery.php",{"block":3,"pics":110});
    $("#index_reporters ul  li").click(function(){
            var txt=$(this).text();
            var ch=$(this).find('a');
            if(ch.text())
             {
                $("#index_reporters_div").html("<p align=\"center\"><img src=\"/html/im/load2.gif\" alt=\"\" /></p>");
                var old_str=$("#index_reporters ul > li").find('em');
                var old_txt=old_str.text();
                var old_par=old_str.parent();
            
				$("#index_reporters_div").load("/scripts/_script_gallery.php",{"param":txt,"block":3,"pics":110},function(){
                $("#index_reporters_div").fadeIn(animation_speed);
                });
                old_par.empty();
                old_par.append("<a href=\"javascript:;\">"+old_txt+"</a>");
                $(this).empty();
                $(this).append("<em>"+txt+"</em>");
                }
            }); 
   
	
});

function QuizSwitch()
{
	var classtab1=$("#quiz-tab1").attr("class");
	var classtab2=$("#quiz-tab2").attr("class");	
	var ctab1=classtab1.split(" ");		
	if(ctab1[1]=='hidden')
	{
        $(".quiz_button").html("Резултати");
        $("#quiz-tab1").attr("class","boxi");
        $("#quiz-tab2").attr("class","boxi hidden"); 
    }
	else 
	{
        $(".quiz_button").html("Гласувай");
        $("#quiz-tab1").attr("class","boxi hidden");
        $("#quiz-tab2").attr("class","boxi"); 
	}	
}

function Quiz_vote(artid)
{
var vi=$("input[@name=voteit]:checked").val();
if(vi) $.post("/_scripts_qvote.php",{vote:vi,artid:artid},function(data) 
	{  res=data.split("|");
			
		alert(res[2]);
		
		if(parseInt(res[1])) 
		{
           
           $("#qid1").html(parseInt(res[3]));	
           var width=0;	  
		  for(var ii=1;ii<13;ii++) 
		  {
                var ki=3+ii;	
                if(parseInt(res[ki])>0)
                    kw=100*(parseInt(res[ki])/parseInt(res[3])); 
                else  kw=0;              
                vote_p=kw.toFixed(2);    
                width=parseInt(kw);            
                $("#aid"+ii).html(vote_p+"%");                                              
                $("#ans-status"+ii+" span").css("width",width+"%");                
		  }		  
          $(".quiz_button").remove();
		  
          $("#quiz-tab1").attr("class","boxi hidden");
          $("#quiz-tab2").attr("class","boxi");
		}
	});
else alert("Моля гласувайте");
}