$(function()
{

if($("body").width()<1200 )
{
  $(window).resize(function(){
  var p = $(".main").position();
  var x = p.left-80;
  $("body").css("background-position",x+"px top");
//  $(".body").css("margin-left","185px");
    $(".body").css("position","relative");
    $(".body").css("left","225px");
  });
  var p = $(".main").position();
  var x = p.left-180;
  $(".body").css("width","1350px!important");
  $("body").css("background-position",x+"px top");
  $(".body").css("position","relative");
  $(".body").css("left","225px");
  $(".flash div").css("left","172px");
  $(".flash div").css("top","-9px");

}
else
{
  $("body").css("background-position","center top");
  $(".menu a:first-child").css("margin-left","-3px");
}

  var p = $(".sdoc").position();
//  $(".padder").css("left",(p.left+62)+"px");

  $(".body").width( $("body").width()+50 );
  //$(".body").width($("body").width());

 $("a[href$='.jpg']").colorbox({maxHeight:"98%"});
 $("a[href$='.png']").colorbox({maxHeight:"98%"});

 $("a[href$='.JPG']").colorbox({maxHeight:"98%"});
 $("a[href$='.PNG']").colorbox({maxHeight:"98%"});

 $(".hk:last-child").hide();

 $("a[rel=nofollow]").click(
 function(){
    window.open($(this).attr("href"),"_");
    return false;
 }
 );

 $(".hir a").click(
 function()
 {
    /*
    $(".hir").show();
    $(".hir2").hide();
    $.get($(this).attr("href")+"&ajax=1","",function(html)
    {
        $(".hir2").html(html);
        $(".hir2").fadeIn();
    },"html" );
    $(this).parents(".hir").hide();
    return false;*/
 });

  $(".menu a").each(function(){
    if(document.location.toString().indexOf( $(this).attr("href") ) > -1 )
    {
        var s = $(this).children("img").attr("src").toString().split("/");
        var i = s[1].charAt(1);
        $(this).children("img").attr("src","images/a"+i+".jpg");
    }
  }
  );

  $("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"
  });


$(".vk").hide();
$("#uu").click(function()
{
    $(".vk").slideToggle("slow",function()
    {
        $(".padder").height($(".content2").height()-700);
    } );
    return false;
});
/*
$(".madar").draggable();
*/
var ok=true;

function x()
{
    var l=parseInt($(".madar").css("left") );
    var t = parseInt($(".madar").css("top"));
    $(".madar").css("left",l+1);
    if(Math.random()>0.5)
    {
        $(".madar").css("top",t+1)
    }
    else
    {
        $(".madar").css("top",t-1)
    }
if(ok){
//    setTimeout(x,1);
}
}

function y()
{
    var t = parseInt($(".madar").css("top"));
    $(".madar").css("top",t+30)
    setTimeout(y,1);

}

$(".menu2 a").each(
function()
{
    $(this).removeClass("axxx");
    var hr = $(this).attr("href");
    if( document.location.toString().indexOf(hr) > -1 )
    {
        $(this).addClass("axxx");
    }
}
);

$(".menu2 a:odd").addClass("odda");

$(".vk button").click(function()
{
 $("form").attr("action","index.php?mod=vk");
});

//$(".madar").live("click",function(){
//    ok=!ok;
//    setTimeout(x,1);
//});

//$(".content2").draggable();
//$(".content2").draggable("option", "disabled");
$(".content2").css("position","relative");

$(".padder").height($(".content2").height()-700);

if($(".padder").height()<200)
{
    $(".padder").height(200);
}
//setTimeout(x,1000);
//$(".madar").clone().appendTo(".flash");
$(".padder").draggable();
//$(".t").draggable();



var last = 0;
   $(".t").each(
   function(){
    var id = $(this).html();
    $(this).colorbox({close:"Bezárás",inline:false, href:"adatlap.php?id="+id, onComplete:function(){
        last = id;
    }});

   });

if(document.location.toString().indexOf("terkep")>-1 )
   $('.terkep a[title].t').qtip({
      content: {
         text: false
      },
      show: { effect: 'fade',length:"500" },
      style: {
          border: {
             width: 2,
             radius: 5
          },
          padding: 5,
          textAlign: 'center',
          tip: 'topLeft',
          name: 'light'
        }
    });
    $(".vp td").live("mouseover",function(){
        $(this).parent("tr").toggleClass("x");
    });

    $(".vp td").live("mouseout",function(){
        $(this).parent("tr").toggleClass("x");
    });

    $(".vp td").live("click",function()
    {
        var ids = $(this).parent("tr").attr("id");
        var idk = ids.split("_");
        var id = idk[1];
        $(this).colorbox({close:"Bezárás",inline:false,href:"adatlap.php?gid="+id, open:true
//        ,onClosed:function(){
//            setTimeout(function(){
//            $(this).colorbox({inline:false, href:"adatlap.php?id="+last,onClosed:false,open:true});
//            },2000);
            //$(".a"+last).click()},2000);
//        }
//        {
//          $(this).colorbox({inline:false, href:"adatlap.php?id="+last,onClosed:false,open:true});
//        }
        });
    });

});