$(document).ready(function() {
	
	/*$('a[rel*=lightbox], a.lightbox').lightBox();*/	
	$('a[rel*=lightbox], a.lightbox').attr('rel', 'gallery').fancybox({		
		'showCloseButton'	: true, 
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'titlePosition'	:  	'inside',
		'overlayShow': true,
		'hideOnContentClick': false
	});
	
	$("a[href$=.pdf]").attr('target','_blank');
	$("a[href$=.doc]").attr('target','_blank');
	$("a[href$=.docx]").attr('target','_blank');
	$("a[href$=.xls]").attr('target','_blank');
	$("a[href$=.xlsx]").attr('target','_blank');
	
	$('.kerek_fancy').fancybox({
		'frameWidth':940,		
		'frameHeight': 400,
		'overlayShow': true,
		'hideOnContentClick': false
	});
	
	$(".confirm").click(function() {
		return confirm("Biztosan ezt akarja?");
	});
	
	$(".datepicker").datepicker({ 
		dateFormat: 'yy-mm-dd',
		nextText: 'Következő',
		prevText: 'Előző',
		changeMonth: true,
		changeYear: true,
		currentText: 'Ma',
		firstDay: 1,
		dayNames: ['Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'],
		dayNamesShort: ['Vas','Hét', 'Kedd', 'Szer', 'Csüt', 'Pén', 'Szom'],
		dayNamesMin: ['Va', 'Hé', 'Ke', 'Sze', 'Cs', 'Pé', 'Szo' ],
		monthNames: ['Január','Február','Március','Április','Május','Június','Július','Augusztus','Szeptember','Október','November','December'],
		monthNamesShort: ['Január','Február','Március','Április','Május','Június','Július','Augusztus','Szeptember','Október','November','December']	
	}); 

	$('.potty').click(function() {
		$id=this.id.split('_');		
		$.ajax({
	  		url: '/egyiskolahire/'+$id[1],
	  		success: function(data) {
	    		$('#egyiskolahire').fadeOut('fast',function() {$('#egyiskolahire').html(data)});
	  			$('#egyiskolahire').fadeIn('slow');
	  		}
		});
		return false;
	});

	$('#cim_masol').click(function() {
		$('#cim_levelezesi_irsz').val($('#cim_allando_irsz').val());
		$('#cim_levelezesi_telepules').val($('#cim_allando_telepules').val());
		$('#cim_levelezesi_kozterulet_nev').val($('#cim_allando_kozterulet_nev').val());
		$('#cim_levelezesi_kozterulet_jelleg').val($('#cim_allando_kozterulet_jelleg').val());
		$('#cim_levelezesi_hazszam').val($('#cim_allando_hazszam').val());
	});

	$('#nev_masol').click(function() {
		$('#nev_sz_elotag').val($('#nev_v_elotag').val());
		$('#nev_sz_vezetek').val($('#nev_v_vezetek').val());
		$('#nev_sz_kereszt').val($('#nev_v_kereszt').val());		
	});
		
	$("#fomenusor a").hover(function(){$(this).parent().addClass("folotte");},function(){$(this).parent().removeClass("folotte");});

	if($("#felhnev").val()!='' || $("#jelszo").val()!=''){		
		$("#felhnev").siblings("label").hide();	
		$("#jelszo").siblings("label").hide();			
	}

	$("#felhnev, #jelszo").focus(function() {
		$("#felhnev").siblings("label").hide();	
		$("#jelszo").siblings("label").hide();
	});
	$("#felhnev, #jelszo").blur(function() {
		if ($("#felhnev").val()=="") {
			$("#felhnev").siblings("label").show();
		}else{
			$("#felhnev").siblings("label").hide();	
		}
		if ($("#jelszo").val()=="") {
			$("#jelszo").siblings("label").show();
		}else{
			$("#jelszo").siblings("label").hide();
		}
	});

	$("#kereses").focus(function() {
		$(this).siblings("label").hide();
	});
	$("#kereses").blur(function() {
		if ($(this).val()=="") {
			$(this).siblings("label").show();
		}
	});
	
	$('.menupont').click(function(){		
		$(".rejtett").slideUp('slow');		
		if($(this).siblings(".rejtett").css('display')=='none'){
			$(this).siblings(".rejtett").slideDown('slow');
			$.ajax({
				url: '/nyitott_menu/'+$(this).siblings(".rejtett").attr('id')				
			});
		}else{
			$.ajax({
				url: '/nyitott_menu/zart'				
			});
		}
		return false;
	});
	
	$('#lapoz_hatra').click(function(){
		hatra();
		return false;
	});
	
	$('#lapoz_elore').click(function(){
		elore();
		return false;
	});
	

	$('#jelenlegi').click(function(){
		if($('#jelenlegi').attr('checked')){
			$('#befejezodatum').val('');
			$('#befejezodatum').attr('disabled','disabled');
		}else{			
			$('#befejezodatum').attr('disabled','');
		}
	});
	
	$('#tanultbanhelyezkedettel_igen').change(function() {
		$('#div_tanultbanhelyezkedettel_nem').fadeOut();
	});
	
	$('#tanultbanhelyezkedettel_nem').change(function() {
		$('#div_tanultbanhelyezkedettel_nem').fadeIn();
	});
	
});

function hatra(){
	if(!$('#program_naptar_div').hasClass('disabled')){
		$.ajax({
			url: '/programnaptar/hatra/'+$('#aktualis_honap').html(),
			success: function(data) {
				$('#program_naptar_div').fadeOut('fast',function() {$('#program_naptar_div').html(data); $('#program_naptar_div').addClass('disabled');});
				$('#program_naptar_div').fadeIn('slow',function() {
					$('#lapoz_hatra').click(function(){
						hatra();
						return false;
					});
					$('#lapoz_elore').click(function(){
						elore();
						return false;
					});
					$('#program_naptar_div').removeClass('disabled');
				});
			}
		});
	}
}

function elore(){
	if(!$('#program_naptar_div').hasClass('disabled')){
		$.ajax({
			url: '/programnaptar/elore/'+$('#aktualis_honap').html(),
			success: function(data) {
				$('#program_naptar_div').fadeOut('fast',function() {$('#program_naptar_div').html(data); $('#program_naptar_div').addClass('disabled');});
				$('#program_naptar_div').fadeIn('slow',function() {
					$('#lapoz_hatra').click(function(){
						hatra();					
						return false;
					});
					$('#lapoz_elore').click(function(){
						elore();					
						return false;
					});
					$('#program_naptar_div').removeClass('disabled');
				});
			}
		});
	}
}
