$(function()
{    function getCookie(c_name)
    {
        if (document.cookie.length>0)
        {
            c_start=document.cookie.indexOf(c_name + "=");
            if (c_start!=-1)
            {
                c_start=c_start + c_name.length+1;
                c_end=document.cookie.indexOf(";",c_start);
                if (c_end==-1) c_end=document.cookie.length;
                return unescape(document.cookie.substring(c_start,c_end));
            }
        }
        return "";
    }

    $("a[target=_blank]").each(function()
    {
         var ref = new String($(this).attr("href"));
         if( (ref.indexOf(".jpg") != -1) || ((ref.indexOf(".png") != -1)) )
         {
          $(this).colorbox(
          {height:"98%"}
          );
         }
    });

  $("a[rel='gal']").each(function()
  {
    $(this).colorbox({transition:"fade",height:"98%"});
  });

  $("a.colorbox").colorbox({transition:"fade",height:"98%",
    current:"{current}. k?p / {total}",
    previous:"&laquo;&nbsp;el?z?",
    next:"következő &raquo;",
    close:"Bezárás",
    speed:350,
    slideshowStop:"Diavetítés leállítása",
    slideshowStart:"Diavetítés"
  });


    function szavazos(html){
        if(html==""){return;}
        $("div.szavazas").html(html);
        $(".szaz").hide();
        $(".polls").each(function()
        {
            var w = new String( $(this).next("div.szaz").html() );
            var s = w;
            var obj = {width:s};
            $(this).animate({width:"0px"},"slow","linear",function()
            {
                $(this).animate(obj,"slow","linear",function(){
                    $(".szaz").show();

                });
            });
        });

//       $(".left").height($(".right").height());
    }

    $(".poll").live("click",function()
    {
        $.get("index.php","mod=poll&"+$("#poll").serialize(),szavazos,"html")
        return false;
    });

    $.get("index.php","mod=poll",szavazos,"html");

    $("#hiba").hide();

    $("#submit").bind("click",function(){
        var ok = ( ( $("#nev").val()!="" ) && ( $("#email").val()!="" ) && ( $("#uzenet").val()!="" ) )

        if(!ok)
        {
            $("#hiba").hide();
            $("#hiba").html("<div class='hiba'>Kérem adjon meg minden szükséges adatot</div>");
            $("#hiba").fadeIn();
        }
        return ok;
    });

    $(".footer").before("<div class='rss'><div class='cs'>&nbsp;</div></div>");
    $("div.rss").addClass("wait");
    $.get("index.php","mod=rss",function(html){
        //$(".footer").before("<div class='rss'><div class='cs'>"+html+"</div></div>");
        $("div.cs").html(html);
        $("div.rss").removeClass("wait");
        $.get("index.php","mod=banner",function(html){$(".footer").before(html);},"html");
    },"html");


    $("a[href^=http]").live("click",function(){window.open( $(this).attr("href")); return false;});


    if ($(".left").height()<$(".right").height())
    {
        $(".left").css("min-height",$(".right").height()+"px");
        $(".left").css("_height",$(".right").height()+"px");
    }



});



