
function simple_activ(target_items,name){
 $(target_items).each(function(i){
 
 $(this).mouseover(function(){$(this).addClass(name);});
 $(this).mouseout(function(){$(this).removeClass(name);});
 });
 
}


function getNameBrouser() {
 var ua = navigator.userAgent.toLowerCase();
 // Определим Internet Explorer
 if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
   return "msie"
 }
 // Opera
 if (ua.indexOf("opera") != -1) {
   return "opera"
 }
 // Gecko = Mozilla + Firefox + Netscape
 if (ua.indexOf("gecko") != -1) {
   return "gecko";
 }
 // Safari, используется в MAC OS
 if (ua.indexOf("safari") != -1) {
   return "safari";
 }
 // Konqueror, используется в UNIX-системах
 if (ua.indexOf("konqueror") != -1) {
   return "konqueror";
 }
 return "unknown";
} 



function simple_tooltip(target_items, name){
 $(target_items).each(function(i){
 id=$(this).attr('id');
 id="."+id;
 text=$(id).html();
 $(id).remove();
 $("body").append("<div class='"+name+"' id='"+name+i+"'><div class='inner_tip'>"+text+"</div></div>");
 var my_tooltip = $("#"+name+i);

 $(this).removeAttr("title").mouseover(function(){
 my_tooltip.css({opacity:0.8, display:"none"}).fadeIn(400);
 }).mousemove(function(kmouse){
 my_tooltip.css({left:kmouse.pageX-215, top:kmouse.pageY-185});
 }).mouseout(function(){
 my_tooltip.fadeOut(0);
 });
 });
}




function get_rezol()
{

width=(screen.width/screen.height);
var src="";

if (width>1.4) 
    {
     $('.nwide').remove();
     $('.wide').attr('ID',"BG_IMAGE_FILE");
   
    }
    else
     {
       $('.wide').remove();
       $('.nwide').attr('ID',"BG_IMAGE_FILE");
     }


//     alert(src);
     
}

function open_p_windows(file)
 {


 var winw=document.body.clientWidth;
 var winh=document.body.clientHeight;
 var width=540;
 var height=420;
 

 $("#PAGE_COUNT").hide();
 $("#fon").css("width",winw);
 $("#fon").css("height",winh); 
 $("#fon").show();
 
 
   
  $("#fon").parent().prepend("<div id='ajax_box'><div class='top'><a alt='Закрыть' title='Закрыть' onclick='close_p_windows()' class='close' href='javascript:void(0)'></a></div><div class='inner'></div><div class='bottom'></div></div>");
 
  $("#ajax_box").hide();

                   $("#ajax_box").css("width",width);
                   $("#ajax_box").css("height",height+72);
                   
                   $("#ajax_box .inner").css("width",width);
                   $("#ajax_box .inner").css("height",height);                  
               
  if ((winw-width)<0) width=0; else width=(winw-width)/2;
  if ((winh-height)<0) height=0; else height=(winh-(height+72))/2; 
                 //центрируем форму
                   $("#ajax_box").css("left",width);
                   $("#ajax_box").css("top",height);
    
  $("#fon").fadeTo(1000,0.7,function(){  
  			$("#ajax_box").show();
  			$("#ajax_box").fadeTo(1000,1); });

 

 $("#ajax_box .inner").load("/js/player.php?ID="+file);
 
 //$("#ajax_box .inner").load(file);
  //alert("wqe");
 }


function open_a_windows(alb,from)
 {
 $("#PAGE_COUNT").hide();
 var winw=document.body.clientWidth;
 var winh=document.body.clientHeight;
 var width=630;
 var height=330;
 
 $("#fon").css("width",winw);
 $("#fon").css("height",winh); 
 $("#fon").show();
 
 

  $("#fon").parent().prepend("<div id='ajax_box'><div class='top'><a alt='Закрыть' title='Закрыть' onclick='close_p_windows()' class='close' href='javascript:void(0)'></a></div><div class='inner'></div><div class='bottom'></div></div>");
  
  $("#ajax_box").hide();

                   $("#ajax_box").css("width",width);
                   $("#ajax_box").css("height",height+72);
                   
                   $("#ajax_box .inner").css("width",width);
                   $("#ajax_box .inner").css("height",height);                  
                   
  if ((winw-width)<0) width=0; else width=(winw-width)/2;
  if ((winh-height)<0) height=0; else height=(winh-(height+72))/2; 
                 //центрируем форму
                   $("#ajax_box").css("left",width);
                   $("#ajax_box").css("top",height);
  
  $("#fon").fadeTo(1000,0.7,function(){  
  			$("#ajax_box").show();
  			$("#ajax_box").fadeTo(1000,1);    });
         
 $("#ajax_box .inner").load("/js/player_a.php?PL="+alb+"&ST="+from);

 }



function  show_podp()
 {
$("#PAGE_COUNT").hide();
 var winw=document.body.clientWidth;
 var winh=document.body.clientHeight;
 var width=300;
 var height=170;
 
 $("#fon").css("width",winw);
 $("#fon").css("height",winh); 
 $("#fon").show();
 
 

  $("#fon").parent().prepend("<div id='ajax_box'><div class='top'><a alt='Закрыть' title='Закрыть' onclick='close_p_windows()' class='close' href='javascript:void(0)'></a></div><div class='inner'></div><div class='bottom'></div></div>");
  
  $("#ajax_box").hide();

                   $("#ajax_box").css("width",width);
                   $("#ajax_box").css("height",height+72);
                   
                   $("#ajax_box .inner").css("width",width);
                   $("#ajax_box .inner").css("height",height);                  
                   
  if ((winw-width)<0) width=0; else width=(winw-width)/2;
  if ((winh-height)<0) height=0; else height=(winh-(height+72))/2; 
                 //центрируем форму
                   $("#ajax_box").css("left",width);
                   $("#ajax_box").css("top",height);
  
  $("#fon").fadeTo(1000,0.7,function(){  
  			$("#ajax_box").show();
  			$("#ajax_box").fadeTo(1000,1);    });
         
 $("#ajax_box .inner").load("/js/podp.php");

 }



function close_p_windows()
{ $("#ajax_box").remove();
$("#PAGE_COUNT").show();
  $("#fon").fadeTo(1000,0.0,function(){$("#fon").hide();});
  
}

var index_last=0;

function show_bayan(index)
{
if (index_last==index)
 {$(".active").toggleClass("active");
   div="#BAYAN_"+index;
   $(".text").hide(300);
   index_last=0;
   return;
 }

index_last=index;
$(".active").toggleClass("active");
h3="#H3_"+index;
//alert(h3);
$(h3).toggleClass("active");
div="#BAYAN_"+index;
  $(".text").hide(300);
$(div).show(300);

}




function active_link()
{
 $(".main a").each(function(i){
 link=parseInt($(this).attr('link'));
 var href=$(this).attr('href');
 if (link!=1) 
  	  $(this).click(function(){
  	  

	   $(".main").fadeTo(700,0//,function(){ $(".body_bg").fadeTo(1000,0} 
	   );
	   href="document.location.href='"+href+"'";
	   window.setTimeout(href, 1000);
	   return false;
	 });
 
 });



}

function showcontent()
{
  $("#loading").fadeTo(500,0, function(){
  
	 $("#loading").remove();
	 
	 $(".body_bg").show(); 
	 $(".body_bg img").fadeTo(0,0.9);
	 $(".body_bg").fadeTo(0,0);
	 
	  $(".body_bg").fadeTo(200,1,function(){
 
				$(".main").css("visibility","visible"); 
				//$(".outer").fadeTo(0,0);
                                //  $(".outer").css("visibility","visible"); 
				// $(".outer").fadeTo(1000,1);
				 
				 $(".outer").fadeTo(0,0.85);
				 $(".sidebar").fadeTo(0,0.85);
				 
			 
				// $(".content").fadeTo(1000,1);
				 //$(".sidebar").fadeTo(1000,1);	
				 
				
				 
				 
	                      });
	 

   
  
  
  }
  );


}


$(document).ready(function(){
 
 br=getNameBrouser();
 if (br=="gecko")
    {
      $(".main").css("overflow-x","visible");
    }

  get_rezol();
 active_link();
  $("#fon").fadeTo(0,0);
 simple_activ(".main_men","hover"); 
 
  

 


 
});

 

