/* Container Javascript */

var facebook_like_button = "<iframe frameborder=\"0\" scrolling=\"no\" style=\"border: medium none; overflow: hidden; width: 150px; height: 22px;\" title=\"המלץ לחברים בפייסבוק\" src=\"http://www.facebook.com/plugins/like.php?action=recommend&font=arial&href=http%3A%2F%2Fwww.zmantov.com&layout=button_count&locale=en_US&node_type=link&send=false&show_faces=false&width=150\" allowtransparency=\"true\"></iframe>";            
var google_one_button = "<iframe width=\"100%\" scrolling=\"no\" frameborder=\"0\" title=\"המלץ על האתר בגוגל +1\" vspace=\"0\" tabindex=\"-1\" style=\"position: static; left: 0pt; top: 0pt; width: 106px; margin: 0px; border-style: none; height: 24px; visibility: visible;\" src=\"https://plusone.google.com/u/0/_/+1/fastbutton?url=http%3A%2F%2Fwww.zmantov.com%2F&amp;size=standard&amp;count=true&amp;annotation=&amp;hl=en-US&amp;jsh=r%3Bgc%2F24479126-6666cb8c#id=I1_1318889019605&amp;parent=http%3A%2F%2Fwww.zmantov.com&amp;rpctoken=93839635&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" allowtransparency=\"true\"></iframe>";

$(document).ready
(
  function()
  {
  
    $("#newsscroller_content").newsticker();
     
    $("#topsearch_keyword").click
    (
      function()
      {        
        if ($("#topsearch_keyword").val() == "הזן ביטוי לחיפוש...") { $("#topsearch_keyword").val(""); }
      }
    );
    
    $("#topsearch_keyword").blur
    (
      function()
      {     
        if ($("#topsearch_keyword").val() == "") { $("#topsearch_keyword").val("הזן ביטוי לחיפוש..."); }
      }
    );
        
    $("#app_news").click
    (
      function()
      {        
        BaseOpenGadget("http://www.apps."+"zmantov.com/topic-news.html"); return false;
      }
    );
    
    $("#app_chat").click
    (
      function()
      {        
        BaseOpenGadgetSpec("http://www.apps."+"zmantov.com/chat.html",610 ,450); return false;
      }
    );
    
    $("#app_gmail").click
    (
      function()
      {        
        BaseOpenNews("http://www.gmail"+".com/"); return false;
      }
    );
    
    $("#app_facebook").click
    (
      function()
      {        
        BaseOpenNews("http://www.facebook"+".com/"); return false;
      }
    );
    
    $("#listen_glglz").click
    (
      function()
      {        
        BaseOpenGadgetSmall("http://www.apps."+"zmantov.com/player.html?stream=1"); return false;
      }
    );
    
    $("#listen_radios").click
    (
      function()
      {        
        BaseOpenGadgetSmall("http://www.apps."+"zmantov.com/player.html?stream=2"); return false;
      }
    );
    
    $("#listen_reshetb").click
    (
      function()
      {        
        BaseOpenGadgetSmall("http://www.apps."+"zmantov.com/player.html?stream=3"); return false;
      }
    );
    
    $("#play_snake").click
    (
      function()
      {        
        BaseOpenGadgetMiddle("http://www.apps."+"zmantov.com/games.html?game=9"); return false;
      }
    );
    
    $("#play_tetris").click
    (
      function()
      {        
        BaseOpenGadgetMiddle("http://www.apps."+"zmantov.com/games.html?game=5"); return false;
      }
    );
    
    $("#play_chess").click
    (
      function()
      {        
        BaseOpenGadgetMiddle("http://www.apps."+"zmantov.com/games.html?game=8"); return false;
      }
    );
    
    var sekerCookieName = "ckSekerVoted_"+$("#seker_target").val();
    
    $("#frmSeker").submit
    (
      function()
      {
        
        BaseSetCookie(sekerCookieName, "0", 999);
      
        var frmSeker = document.getElementById("frmSeker");
        var voteRadio = frmSeker.vote;        
        
        for (i = 0 ; i < voteRadio.length; i++)
        {
          if (voteRadio[i].checked == true)
          {
            BaseSetCookie(sekerCookieName, (i+1).toString(), 999);            
          }
        }
        
        MakeAjaxCall("/seker.ajax", ConvertAjaxForm("frmSeker"), SekerVote, function(){alert("תקלה בשליחת הנתונים");})        
        return false;
      }
    );
    
    if (BaseGetCookie(sekerCookieName))
    {      
      if (BaseGetCookie(sekerCookieName) != "0")
      {        
        document.getElementById("vote"+BaseGetCookie(sekerCookieName)).checked = true;        
      }
      
      MakeAjaxCall("/seker.ajax", ConvertAjaxForm("frmSeker"), SekerVote, "");
    }       

        
    var promotionTimer = setTimeout("SetPromotionButtons();", 1000);
    
  }  
);

function SekerVote(ajaxResponse)
{  
  $("#seker").html(ajaxResponse);  
}

function SetPromotionButtons()
{
  $("#facebook_like").html(facebook_like_button);
  var promotionTimer1 = setTimeout("SetPromotionButtons1();", 500);
}
function SetPromotionButtons1() { $("#google_one").html(google_one_button); }

