 
  var cur_wide;
  var old_wide;
  var min_bs = 100;
  var max_bs = 110;
  
  var timer;
  var i =0;
  
  function artist(name) {

    jQuery.getFeed({
        url: root+'/proxy.php?url='+name,
        success: function(feed) {

           
            html = '';
            for(var i = 0; i < feed.items.length && i < 5; i++) {

                var item = feed.items[i];
                
                html += ''
                + '<a href="'
                + item.link
                + '"  style="font-size: 12px;">'
                + item.title
                + '</a>'
                + '<br>';
                
                
                html += '<div style="font-size: 11px;">'
                + item.description
                + '</div>';
            }

            $('#results').append(html);
        }    
    });
}

  
  function vmousOverImage(name,id,nr){

	if(name)
		imname = name;
	//make border orange
	//imname.style.border = 	'1px solid #A0A1CD';

	imname.style.backgroundImage = "url(http://img.youtube.com/vi/"+id+"/"+nr+".jpg)";
	nr++;
	if(nr > 3)
		nr = 1;
		
	var im = new Image();
	im.src = "http://img.youtube.com/vi/"+id+"/"+nr+".jpg";
  	
	timer =  setTimeout("vmousOverImage(false,'"+id+"',"+nr+");",1000);

  }


  function vmouseOutImage(name){

	if(name)
		imname = name;
	//make border back to greyish
	//name.style.border = 	'1px solid #FAF8FF';
	if(timer)
		clearTimeout(timer)
  nr = 1;
  }
  
  
  function show_alert(text, button_caption, button_onclick) 
  {
    var bc = button_caption || 'Закрыть';
    var bo = button_onclick || 'hide_alert();';

    $('#reg_form').hide(); 
    $('#login_form').hide(); 
    $('#alert').html('<div onclick=\"hide_alert();\" class=\"close_button\">X</div>'+
                     '<center><br>'+text+'<br>'+'<div style=\'position: absolute; left: 10px; text-align: center; width: 300px; bottom: 10px;\'><input type=button value=\''+bc+'\' onclick=\''+bo+'\'></div>'); 
    var w = document.getElementById('all_waiting');
    var r = document.getElementById('alert');
    set_fullscreen(w);               
    set_element_top_middle(r);    
  } 
  
  function hide_alert()
  {
                                                         
   var w = document.getElementById('all_waiting');
   var r = document.getElementById('alert');
   w.style.display = 'none';
   r.style.display = 'none';
 
  }
  
  function start_waiting()
  {
  if (document.getElementById('waiting')) 
   return;
   var e = document.createElement('div');
   var b = document.body;
   b.appendChild(e);

   try {e.style.opacity = 0.8;} catch(e) {}
   try {e.style.MozOpacity = 0.8;} catch(e) {}
   try {e.style.filter = 'alpha(opacity='+Math.round(0.8 * 100)+')';} catch(e) {}
   try {e.style.KhtmlOpacity = 0.8;} catch(e) {}
                e.id = 'waiting';    
                e.style.backgroundColor = '#fcc';
                set_fullscreen(e);
                set_element_top_middle(document.getElementById('ds'));
  }
  
  function stop_waiting()
  {
   if (document.getElementById('waiting'))
    document.body.removeChild(document.getElementById('waiting'));
  }
  
  function set_fullscreen(elem)
  {
   var b = document.body;   
      elem.style.position = 'absolute';  
                var left = b.offsetLeft, 
                    top = b.offsetTop,
                    width = b.offsetWidth,
                    height = b.offsetHeight,
                    l = b._loading;
                elem.style.left = left+'px';
                elem.style.top = top+'px';
                elem.style.width = width+'px';
                elem.style.height = height+'px';
                elem.style.display = 'inline';                        
  }
  
  function set_element_top_middle(elem)
  {
    height = document.body.offsetHeight;  
    sY = 0;
    if( typeof( scrollY ) == 'number' ) sY = scrollY;
    if( typeof( document.documentElement.scrollTop ) == 'number' ) sY = document.documentElement.scrollTop;     
 
    sX = 0;
    if( typeof( scrollX ) == 'number' ) sX = scrollX;
    if( typeof( document.documentElement.scrollLeft ) == 'number' ) sX = document.documentElement.scrollLeft;  
    
    
      var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    }  
    //alert(sX);
    elem.style.position = 'absolute';
    elem.style.display = 'inline';     
    elem.style.top = (sY+Math.round(myHeight/2)-Math.round(elem.offsetHeight/2))+'px';
    elem.style.left = (sX+Math.round(myWidth/2)-Math.round(elem.offsetWidth/2))+'px';
    
  }
  
  
  
  function vote_make_plus(id)
  {
   if (!loged_in)
   {
    show_alert('Чтобы проголосовать за ссылку, необходимо войти в систему','Войти','hide_alert(); show_login_form();');
    return false;
   }
                          
   if (!id) 
    {
    show_alert('Вы уже проголосовали за эту ссылку','Ну и ладно','hide_alert();'); 
    return false;
    }
   up_el = document.getElementById('j_votes_'+id); 
   dn_el = document.getElementById('j_votes_'+id);   
    
   $.post(root+"/ajax_processor.php", { action: "vote_make_plus", id: id }, 
                                   function (data) { 
                                    //up_el = document.getElementById('j_votes_'+id);  
                                    if (data == "1") show_alert("Вы уже проголосовали за эту ссылку.");
                                    if (data == "0") up_el.innerHTML = (parseInt(up_el.innerHTML)+1);
                                     
                                   } );
   
   //up_el.className = 'inf_vup_n';
   //dn_el.className = 'inf_vdown_n'; 
   
   $(document.getElementById('j_votes_u_'+id)).one("click");
   $(document.getElementById('j_votes_u_'+id)).unbind("click");     
   
   $(document.getElementById('j_votes_d_'+id)).one("click");
   $(document.getElementById('j_votes_d_'+id)).unbind("click");     
  }
  
  function vote_make_minus(id)
  {
   if (!loged_in)
   {
    show_alert('Чтобы проголосовать против ссылки, необходимо войти в систему','Войти','hide_alert(); show_login_form();');
    return false;
   }  
  
   if (!id) 
    {
    show_alert('Вы уже проголосовали за эту ссылку','Ну и ладно','hide_alert();');
    return false;
    }

   up_el = document.getElementById('j_votes_'+id); 
   dn_el = document.getElementById('j_votes_'+id);   
    
   $.post(root+"/ajax_processor.php", { action: "vote_make_minus", id: id }, 
                                   function (data) { 
                                    //up_el = document.getElementById('j_votes_'+id);  
                                    if (data == "1") show_alert("Вы уже проголосовали против этой ссылки.");
                                    if (data == "0") up_el.innerHTML = (parseInt(up_el.innerHTML)-1);
                                     
                                   } );
                                   
   //up_el.className = 'inf_vup_n';
   //dn_el.className = 'inf_vdown_n'; 
   
   $(document.getElementById('j_votes_u_'+id)).one("click");
   $(document.getElementById('j_votes_u_'+id)).unbind("click");     
   
   $(document.getElementById('j_votes_d_'+id)).one("click");
   $(document.getElementById('j_votes_d_'+id)).unbind("click");         
  }  
  














  function vvote_make_plus(id)
  {
   if (!loged_in)
   {
    show_alert('Чтобы проголосовать за клип, необходимо войти в систему','Войти','hide_alert(); show_login_form();');
    return false;
   }
                          
   if (!id) 
    {
    show_alert('Вы уже проголосовали за этот клип','Ну и ладно','hide_alert();'); 
    return false;
    }
   up_el = document.getElementById('vj_votes_'+id); 
   dn_el = document.getElementById('vj_votes_'+id);   
    
   $.post(root+"/ajax_processor.php", { action: "vvote_make_plus", id: id }, 
                                   function (data) { 
                                    //up_el = document.getElementById('j_votes_'+id);  
                                    if (data == "1") show_alert("Вы уже проголосовали за этот клип.");
                                    if (data == "0") up_el.innerHTML = (parseInt(up_el.innerHTML)+1);
                                     
                                   } );
   
   //up_el.className = 'inf_vup_n';
   //dn_el.className = 'inf_vdown_n'; 
   
   $(document.getElementById('vj_votes_u_'+id)).one("click");
   $(document.getElementById('vj_votes_u_'+id)).unbind("click");     
   
   $(document.getElementById('vj_votes_d_'+id)).one("click");
   $(document.getElementById('vj_votes_d_'+id)).unbind("click");     
  }
  
  function vvote_make_minus(id)
  {
   if (!loged_in)
   {
    show_alert('Чтобы проголосовать против клипа, необходимо войти в систему','Войти','hide_alert(); show_login_form();');
    return false;
   }  
  
   if (!id) 
    {
    show_alert('Вы уже проголосовали за этот клип','Ну и ладно','hide_alert();');
    return false;
    }

   up_el = document.getElementById('vj_votes_'+id); 
   dn_el = document.getElementById('vj_votes_'+id);   
    
   $.post(root+"/ajax_processor.php", { action: "vvote_make_minus", id: id }, 
                                   function (data) { 
                                    //up_el = document.getElementById('j_votes_'+id);  
                                    if (data == "1") show_alert("Вы уже проголосовали против этого клипа.");
                                    if (data == "0") up_el.innerHTML = (parseInt(up_el.innerHTML)-1);
                                     
                                   } );
                                   
   //up_el.className = 'inf_vup_n';
   //dn_el.className = 'inf_vdown_n'; 
   
   $(document.getElementById('vj_votes_u_'+id)).one("click");
   $(document.getElementById('vj_votes_u_'+id)).unbind("click");     
   
   $(document.getElementById('vj_votes_d_'+id)).one("click");
   $(document.getElementById('vj_votes_d_'+id)).unbind("click");         
  }  




  
  
  
