$(document).ready(function() {

	$("a.fancy").fancybox({
		'padding'               : 2,                //Space between FancyBox wrapper and content
		'margin'                : 0,                //Space between viewport and FancyBox wrapper
		'autoScale'             : false,              //If true, FancyBox is scaled to fit in viewport
		'autoDimensions'        : false,              //For inline and ajax views, resizes the view to the element recieves. Make sure it has dimensions otherwise this will give unexpected results
		'overlayOpacity'        : 0.8,               //Opacity of the overlay (from 0 to 1; default - 0.3)
		'overlayColor'          : '#000',            //Color of the overlay
		'titlePosition'         : 'outside',            //The position of title. Can be set to 'outside', 'inside' or 'over'
		'transitionIn'          : 'fade',         //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'transitionOut'         : 'fade',         //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'speedIn'               : 200,               //Speed of the fade and elastic transitions, in milliseconds
		'speedOut'              : 200,               //Speed of the fade and elastic transitions, in milliseconds
		'changeSpeed'           : 200               //Speed of resizing when changing gallery items, in milliseconds
	});

	$(".fancy_map").fancybox({
		'padding'               : 5,                //Space between FancyBox wrapper and content
		'margin'                : 0,                //Space between viewport and FancyBox wrapper
		'centerOnScroll'        : false,             //When true, FancyBox is centered while scrolling page
		'overlayShow'           : true,              //Toggle overlay
		'overlayOpacity'        : 0.8,               //Opacity of the overlay (from 0 to 1; default - 0.3)
		'overlayColor'          : '#000',            //Color of the overlay
		'titleShow'             : true,              //Toggle title
		'titlePosition'         : 'over',            //The position of title. Can be set to 'outside', 'inside' or 'over'
		'titleFormat'           : null,              //Callback to customize title
		'transitionIn'          : 'fade',         //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'transitionOut'         : 'fade',         //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'speedIn'               : 200,               //Speed of the fade and elastic transitions, in milliseconds
		'speedOut'              : 200,               //Speed of the fade and elastic transitions, in milliseconds
		'changeSpeed'           : 200,               //Speed of resizing when changing gallery items, in milliseconds
		'showCloseButton'       : true,              //Toggle close button
		'showNavArrows'         : true,              //Toggle navigation arrows
		'enableEscapeButton'    : true              //Toggle if pressing Esc button closes FancyBox
	});

	//Apply CSS class to all A links that end in .pdf
	$("a[title$='.pdf']").addClass("pdf");

	//Apply CSS class to all A links that end in .doc
	$("a[title$='.doc']").addClass("doc");

	//Apply CSS class to all A links that end in .xls
	$("a[title$='.xls']").addClass("xls");

	//Apply CSS class to all A links that end in .ppt
	$("a[title$='.ppt']").addClass("ppt");

	//Apply CSS class to all A links that end in .jpg
	$("a[title$='.jpg']").addClass("image");

	//Apply CSS class to all A links that end in .gif
	$("a[title$='.gif']").addClass("image");

    $(".tip").tooltip({position: 'bottom center'});
	$(".tip2").tooltip({effect: 'toggle2', position: 'bottom left'});

	$.tools.tooltip.addEffect("toggle", 
	 
		function(done) {
			var conf = this.getConf(), tip = this.getTip(), o = conf.opacity;
			var leftP = parseInt(tip.css('left')) + 105  + 'px'

			if (o < 1) { tip.css({opacity: o}); }
			tip.css({top: '17px', left: leftP});

			tip.show();
			done.call();
		},

		function(done) {
			this.getTip().hide();
			done.call();
		}
	);

	$.tools.tooltip.addEffect("toggle2", 
	 
		function(done) {
			var conf = this.getConf(), tip = this.getTip(), o = conf.opacity;
			var leftP = parseInt(tip.css('left')) + 125  + 'px'

			if (o < 1) { tip.css({opacity: o}); }
			tip.css({top: '17px', left: leftP});

			tip.show();
			done.call();
		},

		function(done) {
			this.getTip().hide();
			done.call();
		}
	);

	// checkbox
	$("input:checkbox").each( function() {
		(this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
	});

	$(".fakecheck").click(function(){
		($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
		$(this.hash).trigger("click");
		return false;
	});

	// select
	$(".select").selectbox();

});

function checkSearchWord() {
	if ($('#keywords').val() == 'Keresőszó' || $('#keywords').val() == '') {
		alert('Keresőszó megadása kötelező'); 
		return false;
	} 
	else if ( $('#keywords').val().length < 3) {
		alert('Keresőszó minimális hossza 3 karakter'); 
		return false;
	}
	else {
		return true;
	}
}