Search = {
  sw_cookie_name    : 'sw_c',
  sw_cookie_option  : { path: '/', expires: 10 },
  set_cookie_name   : 'jop_c',
  set_cookie_option : { path: '/', expires: 90 },
  Settings          : {},     
  RowNum      : 20,
  Date        : "",
  Order       : "",
  init        : function()
                {
                  this.Settings['jop'] = $.cookie(Search.set_cookie_name);
                },
  showDetails : function(slow_or_fast)
                {                  
                   $("#search_details").html('');
                   $("#search_details").html('<table><tr><td class="left"><div class="title">Dátum</div><div class="elements">Csak az elmúlt <select name="d"><option value="">Nincs</option><option value="d">24 órában</option><option value="w">1 hétben</option><option value="m">1 hónapban</option></select>.</div><div class="title">Beállítások</div><div class="elements"><select name="r"><option value="10">10</option><option value="20" selected="selected">20</option><option value="50">50</option></select> sor / oldal. Rendezve <select name="o"><option value="">relevancia</option><option value="d">dátum</option></select> szerint.</div></td><td><div class="close"> <a href="javascript:/*/ Mégsem /*/;" onclick="Search.hideDetails();">Mégsem</a></div></td></tr></table>');
                   $("#search_details").show(slow_or_fast);                   
                   this.loadDetails();                                     
                },
  hideDetails : function()
                {
                   $("#search_details").hide("slow");
                   setTimeout('$("#search_details").html(\'\')', 400);                                    
                },
  loadDetails : function()
                {                          
                  if(this.RowNum != 20) $("#search_details select[name=r]").val(this.RowNum);
                  if((this.Date == "d") | (this.Date == "w") | (this.Date == "m")) $("#search_details select[name=d]").val(this.Date);
                  if(this.Order == "d") $("#search_details select[name=o]").val(this.Order); 
                },
  showFullDesc : function(a)
                {
                  $(a).parent().find('.dh').show();
                  $(a).remove();
                },
  switchView : function(m)
                {
                  $.cookie(Search.sw_cookie_name, m, Search.sw_cookie_option);
                  pageTracker._trackPageview ('/button/'+ m);
                  if($.browser.msie){ location.reload(); return; }
                  var mosaic = '/css/mosaic.css';
                  if(m=='mosaic'){
                    if($('head link[type=\'text/css\'][href=\''+mosaic+'\']').length==0){
                      $('head').append('<link rel="stylesheet" href="'+mosaic+'" type="text/css" />');
                      $('#funcs .w_v_sw').html('Mozaik nézet aktív - ');                                             
                    }
                  }else{
                    $('head link[type=\'text/css\'][href=\''+mosaic+'\']').remove();
                    $('#funcs .w_v_sw').html('');
                  }                  
                },
  justOnePlayer : function()
                  {
                    if(this.Settings['jop']!=null){
                      $.cookie(Search.set_cookie_name, null);
                      $('#funcs .w_v_job').html('');
                    }else{
                      $.cookie(Search.set_cookie_name, true, Search.set_cookie_option); //törlés
                      $('#funcs .w_v_job').html('Egy betekintő csak - ');
                    }
                    this.init(); //újra init
                  }
}

VideoEmbed = {
  Embed : function(place, source, id){
            if((place.length>0) & (source.length>0) & (id!="")){
              if(Search.Settings['jop']!=null) {
                $("#results .item div[id^=v]").each(function(){
                  $(this).remove();
                });
              }
              var vBox_id = "v"+place;
              $("#"+vBox_id).remove();
              $iBox = $("#i"+String(place));
              var domain = $iBox.find(".i img").attr('title');
              var href = $iBox.find(".d .l a").attr('href');              
              $iBox.find(".d .m").prepend('<div id="'+vBox_id+'" class="vbox"><div class="video"></div><div class="info"> <a href="'+href+'">Videó megtekintése a forrásoldalon: <b>'+domain+'</b></a><br /><small>[ <a href="javascript:/*/ Bezár /*/;" onclick="VideoEmbed.Close(\''+place+'\')">bezár</a> ]</small></div></div>');              
              var $vBox = $("#"+vBox_id);
              $vBox.parent().find('img').hide('slow');                             
              $vBox.find('.video').flash( VideoEmbed.Pattern[source](id), { version: 8 } );
              $vBox.find('.info').css({width:$vBox.find('.video').width()});
              //feedback for me
              $.post("/ajax.assesment.php", {method:"embed",id:place,target:'video'},function(){}, "json");              
            }
          },
  Close : function(place){
            $vBox = $("#v"+place);
            $vBox.parent().find('img').show();
            $vBox.remove();            
          },
  Pattern : {
             'indavideo.hu' : function(id){
                    return { 
                      src: 'http://files.indavideo.hu/player/gup.swf?b=1009',
                      width : 460, height : 384,
                      allowScriptAccess : "always",
                      allowFullScreen : true,
                      flashvars : { 
                        autostart : false,
                        vID : id
                      },
                      name : "guPlayer-fa7651b6c2",
                      bgcolor : "#666666",
                      wmode :  'transparent'
                    }
             },   
             'videa.hu'  : function(id){                              
                    return {
                      src : 'http://videa.hu/flvplayer.swf?v=' + id,
                      width : 434, height : 357,
                      movie : 'http://videa.hu/flvplayer.swf?v=' + id,
                      allowScriptAccess : 'sameDomain',
                      wmode :  'transparent'
                    }
             },
             'videoplayer.hu': function(id){                                
                    return {
                      src : 'http://www.videoplayer.hu/videos/embed/'+String(id),
                      width : 425, height : 350,
                      movie : 'http://www.videoplayer.hu/videos/embed/'+String(id),
                      wmode :  'transparent'                                  
                    }
             },
             'freevlog.hu': function(id){                                 
                    return {
                      id : 'vidixplayer',
                      src : 'http://www.freevlog.hu/player/vplayer.swf?v=@@'+id+'&autoplay=0&host=www.freevlog.hu',
                      width : 400, height : 345,
                      movie : 'http://www.freevlog.hu/player/vplayer.swf?v=@@'+id+'&autoplay=0&host=www.freevlog.hu',                                  
                      menu : false,
                      allowScriptAccess : 'sameDomain',
                      bgcolor : '#000000',
                      wmode :  'transparent'
                    }
             },
             'ende.hu' : function(id){
                    return {
                      src : "http://www.ende.hu/player_embed.swf",
                      width : 400, height : 329,
                      loop : false,
                      scale : 'exactfit',
                      flashvars : {
                          vid : id,
                          langid : 0
                      },
                      wmode :  'transparent'
                    }
             },
             'keptelenseg.hu' : function(id){
                    return {
                      src : 'http://static.keptelenseg.hu/k/'+id,
                      width : 400, height : 340,
                      movie : 'http://static.keptelenseg.hu/k/'+id,
                      allowFullScreen : true,
                      bgcolor : '#ffffff',
                      wmode :  'transparent'
                    }
             },
             'youtube.com' : function(id){
                    return {                                    
                      src : "http://www.youtube.com/v/"+String(id)+"&hl=hu",                                                                        
                      width :  425, height : 344,
                      movie : "http://www.youtube.com/v/"+String(id)+"&hl=hu",
                      allowFullScreen : true,
                      allowScriptAccess : 'always',
                      wmode :  'transparent'
                    }
             },
             'pixter.hu' : function(id){
                    return {                                    
                      src : "http://static.pixter.hu/video_player/pixter_player_embed.swf",
                      width : 425, height: 355,
                      flashvars : {
                        file : "http://static.pixter.hu/playlist2_"+String(id)+".xml"
                      },
                      loop : false,
                      scale : 'exactfit',
                      wmode :  'transparent'
                    }
             },
             'kukker.ro' : function(id){
                    return {                                          
                      src : "http://kukker.ro/new/player/flvplayer_elite.swf",
                      width : 425, height: 345,
                      flashvars : {
                        config : "http://kukker.ro/new/player/configXMLemb.php?id="+String(id)
                      },
                      name : 'flvplayer',
                      allowScriptAccess : true,
                      allowFullScreen : true,
                      bgcolor: '#000000',
                      wmode :  'transparent'
                    }
             }                                                                         
            }
}

$(document).ready(function(){
  Search.init();  
  Assesment.init('video'); // Értékelések    
});