$(window).load(function() {
  $(".video").fancybox({
    'titleShow': false,
    'width'		: 460,
    'height'		: 340,
    'type'		: 'iframe'
  });
					
  $('#slider').nivoSlider({
    pauseTime:10000, // How long each slide will show
    directionNav:true, // Next & Prev navigation
    controlNav:true,
    effect:'random'
  });
});
				
$(document).ready(function() {
  
  $("a#example2").fancybox({
    'titleShow'     : false,
    'transitionIn'	: 'elastic',
    'transitionOut'	: 'elastic'
  });
	
		
  $("a[rel=example_group]").fancybox({
    'transitionIn'	: 'none',
    'transitionOut'	: 'none',
    'titlePosition' 	: 'over',
    'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
      return '<span id="fancybox-title-over">Kép: ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
    }
  });
  
  $( "#datepicker" ).datepicker({
    dateFormat: 'yy.mm.dd.'
  });
});

function doLogin(url)
{
  email = document.getElementById('login_email').value;
  password = document.getElementById('login_password').value;
  $.post("/ajax/dologin", {
    email: email,
    password: password
  }, function(data) {
    if (data != "")
    {
      //alert(data);
      //            popupErrorMessage(_('login'), data);
      popupErrorMessage('Bejelentkezés', data);
    }
    else
    {
      //            		alert('Sikeres bejelentkezés');
      if (url)
        window.location = url;
      else
        window.location = '/';
    }
  });
}

function overlayclickclose()
{
  if (closedialog) {
  //          $('#error_message').dialog('close');
  }
  //set to one because click on dialog box sets to zero
  closedialog = 1;
}

function popupErrorMessage(title, message)
{
  $('#error_message').attr('title', title);
  $('#error_message').html(message);
  $('#error_message').dialog({
    'modal': true,
    //'show': 'fade',
    'resizable': false,
    open: function(){
      closedialog = 1;
      $(document).bind('click', overlayclickclose);
    },
    focus: function(){
      closedialog = 0;
    },
    close: function(){
      $(document).unbind('click')
    }
  });
}

function AjaxLoad(val, dom){
  $.post("/ajax/getguide", {
    day: val
  }, function(data) {
    $('#tabvanilla').html(data);
    $('#tabvanilla > ul').tabs({
      fx: {
        height: 'toggle', 
        opacity: 'toggle'
      },
      selected: dom
    });
  $('#featuredvid > ul').tabs();
  });  
}
