var query = ''

function getScreen( url, size )
{
  if(url === null){ return ""; }

  size = (size === null) ? "big" : size;
  var vid;
  var results;

  results = url.match("[\\?&]v=([^&#]*)");

  vid = ( results === null ) ? url : results[1];

  if(size == "small"){
    return "http://img.youtube.com/vi/"+vid+"/2.jpg";
  }else {
    return "http://img.youtube.com/vi/"+vid+"/0.jpg";
  }
}

$(document).ready(function() {
  $(function() {
    
    $(".youtube .img").each(function() {
      $(this).find("img").attr({src: getScreen( $(this).find("a").attr("rel"), "small" )});
    })

    $('input#query').focus(function() {
      query = $(this).val();
      $(this).val('');
    })

    $('input#query').blur(function() {
      if ($(this).val() == '')
        $(this).val(query);
    })

    
    var generatstyle = $('link[href="style/style.css"]');
    
    var anchorage = self.document.location.hash.substring(1);

    if(anchorage == 'print') {  
        $(generatstyle).attr({href : "style/print.css"});       
           $("#topdiv").css({"background" : "none","width" : "0px"});
           $("#topdiv2").css({"width" : "0px"});
           setTimeout(function(){window.print()}, 200);
           $("#print_dialog").show();                  
  
           
           $("div#print_dialog a.back").click(function() {
             window.close();
             return false;
             $("#print_dialog").hide();  
              $("#topdiv").css({"background" : "url(images/l---l.gif)","width" : "960px"});
              $("#topdiv2").css({"width" : "920px"});
             $(generatstyle).attr({href : "style/style.css"});
              return false;
           })
  
           $("div#print_dialog a.cancel").click(function() {
             $("#print_dialog").hide();
             return false;
           })         
    }


    
  })
  
  $('div.more a.cat_view, div.more a.cat_overview').click(function(){
    if ($(this).hasClass('cat_open')) {
       $(this).removeClass('cat_open');
       $(this).addClass('cat_close');
       $(this).parent().find('ul.hidden_links').attr('class', 'hidden_links_show');    
    
    }else {

       $(this).removeClass('cat_close');
       $(this).addClass('cat_open');
       $(this).parent().find('ul.hidden_links_show').attr('class', 'hidden_links');              
    
    }
    
    return false;
  
  });
});


            

