function popWindow(wName){
var a_int_windowWidth = '580';
var a_int_windowHeight = '215';
var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
var int_windowTop = (screen.height - a_int_windowHeight) / 2;
features = 'width=' + a_int_windowWidth + ',height=' + a_int_windowHeight + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no';
pop = window.open('',wName,features);
if(pop.focus){ pop.focus(); }
return true;
}
$(function(){

$.get("index.php","addstat=1",null,"html");

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 "";
}

  $("#lgform").submit(function(){
    $.get("index.php?mod=login","user="+$("#partner").val()+"&passw="+$("#pass").val(),
      function(html){
       if(html!="OK")
       {
         $("#dialog").html(html);
         $("#dialog").dialog("open");
      }else{
          document.location=document.location;
      }
    },"html");
    return false;
  });

  $("#odavissza").click(function()
  {
    $(".hidden").each(function(){$(this).toggle();});
  });
  $("div.menu").bind("click",
  function()
  {
    document.location="/";
  }
  );
	 $("input.datum").each(function(){
	   var min = new Date();
	   min.setDate( min.getDate()+2 );
		  $(this).datepicker({
  			changeMonth: true,
  			changeYear: true,
  			minDate:min,
        onSelect:function(){
          var date = $(this).datepicker( 'getDate' );
          var cd = new Date();
          if( cd.getUTCHours()>17 )
          {
            cd.setDate(cd.getDate()+1);
            if ( (cd.getDate()==date.getDate() ) && (cd.getMonth==date.getMonth) )
            {
              alert("Honlapra már nem tudunk online foglalást elfogadni, kérem jelezze igényét telefonon!");
              $(this).val("");
            }
          }
          $("#rdatum1").html(
          ($("#inddatum").val())
          );
          $("#rdatum2").html(
          ($("#erkdatum").val())
          );
        }

  		});
    	$(this).datepicker('option', $.extend({showMonthAfterYear: false}, $.datepicker.regional["<?=$lang?>"]));
    	$(this).datepicker('option','dateFormat',"yy. MM dd. (DD)");
  	}
    );


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

  $("a.login").bind("click",function(){
    $.get("index.php?mod=login","user="+$("#partner").val()+"&passw="+$("#pass").val(),
      function(html){
       if(html!="OK")
       {
         $("#dialog").html(html);
         $("#dialog").dialog("open");
      }else{
          document.location=document.location;
      }
    },"html");
    return false;
  });

  if(getCookie("loggedin")!="")
  {
    $("div.login").html("<div class='book'><a href='index.php?mod=orders'>Foglalásaim / my bookings</a></div><div class='lout'><a href='#'>Kilépés</a></div>");
    $("div.lout a").bind("click",function()
    {
      $.get("index.php?mod=login","logout=1",function(){
      document.location=document.location;
      },"html");
      return false;
    });
  }

  $("body").append("<div title='Bejelentkezési hiba' id='dialog'></div>");
  $("#dialog").dialog({
      autoOpen:false,
			bgiframe: true,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
  });
  $(".hidden").each(function(){$(this).hide();});
  
  //vendégkönyv
  $(".vk").hide();
 $("#uu").click(function(){
    $(".vk").slideToggle("slow",function()
    {
        $(".padder").height($(".content2").height()-700);
    } );
    return false;
});

  $(".vk button").click(function()
{
    $(".kell").css("border","1px solid silver");
    var ok = true;
    $(".vk .kell").each(function(){
        if($(this).val()=='')
        {
            $(this).css("border","1px dashed red");
            ok=false;
        }
    }
    );
    //$("form").attr("action","index.php?mod=vk");
    if(ok){alert("Hozzászólását rögzítettük. Köszönjük!");}
    return ok;
});

 $(".kats a").click(function(){
    if($(this).next("ul").is("ul"))
    {
        $(this).next("ul").slideToggle();
        return false;
    }
 });
 
});
