var timeoutID;

/*
 * naptar funkcio, ajaxosan lapozza a honapokat, eveket
 *
 */
var Calendar = {};
Calendar.set = function() {
	$('.dateselect a').click(function(e) {
		e.preventDefault();

		var _url = $(this).attr('href');

		$('.naptar_content').fadeOut(200);

		$.ajax({
			url: _url,
			type: 'POST',
			data: {type:'ajax'},
			success: function(msg) {
				$('.naptar_content').html(msg);
				$('.naptar_content').fadeIn('slow');
			}
		});
	});
};

$(document).ready(function() {
	var url = $(location).attr('href');
	var main_url = url.split('/');
	var current_url = "/" + main_url[4];

	$('.left ul li a').each(function() {
		_link = $(this).attr("href");
		current_link = _link.split('/');
		if (current_url.indexOf(current_link[0]) > 0) {
			$(this).parent('li').addClass("current");
		}
	});

	$('.kiemelt-box').hover(
		function() {
			$('.image img', this).addClass('zoom_hover');
		},
		function() {
			$('.image img', this).removeClass('zoom_hover');
		}
	);
	$('.image-box').hover(
		function() {
			$('.right-image img', this).addClass('zoom_hover');
		},
		function() {
			$('.right-image img', this).removeClass('zoom_hover');
		}
	);
	$('.article').hover(
		function() {
			$('.image img', this).addClass('zoom_hover');
		},
		function() {
			$('.image img', this).removeClass('zoom_hover');
		}
	);
	$('.sharebar img').hover(
		function() {
			$(this).addClass('zoom_hover_simple');
		},
		function() {
			$(this).removeClass('zoom_hover_simple');
		}
	);
	$('.album').hover(
		function() {
			$('.image img', this).addClass('zoom_hover');
		},
		function() {
			$('.image img', this).removeClass('zoom_hover');
		}
	);
	$('.more_album').hover(
		function() {
			$('.image_prev img', this).addClass('zoom_hover');
		},
		function() {
			$('.image_prev img', this).removeClass('zoom_hover');
		}
	);
	/*
	$('li.parent_menu').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); }
			//function() { $(this).next('.almenu').css('display', 'block'); },
			//function() { $(this).next('.almenu').css('display', 'none'); }
	);*/
	$('.menu .fomenu').click(function(e) {
		if ($(this).hasClass("parent_menu") == false) {
			e.preventDefault();

			$(window.location).attr('href', $("base").attr("href") + $('a', this).attr('href'));
		}
	});
	$('.menu > li.parent_menu').click(function(e) {
		$('.menu > li.parent_menu > ul > li > a').click(function() {
			$(window.location).attr('href', $("base").attr("href") + $(this).attr('href'));
		});

		e.preventDefault();

		$('ul', this).css('display', 'block');
	});
	$('li.parent_menu').mouseleave(function() {
		$('ul', this).css('display', 'none');
	});
	$('.to_top a').click(function(e) {
		e.preventDefault();

		$('html, body').animate({scrollTop:0}, 'slow');
	});

	$('.main_box').click(function(e) {
		e.preventDefault();

		$(window.location).attr('href', $("base").attr("href") + $('.bovebben', this).attr('href'));
	});
	$('.article').click(function(e) {
		e.preventDefault();

		$(window.location).attr('href', $("base").attr("href") + $('h3 a', this).attr('href'));
	});
	$('.more_album').click(function(e) {
		e.preventDefault();

		$(window.location).attr('href', $("base").attr("href") + $('.image_prev a', this).attr('href'));
	});
	$("select#honnan").change(function() {
		if ($(this).val() == 6) {
			$('.egyeb').show();
		}
		else {
			$('.egyeb').hide();
		}
	});
	$('.image_prev img').hide();
	$('.image_prev img').load(function() {
		$(this).fadeIn();
	});
	$('.album .image img').hide();
	$('.album .image img').load(function() {
		$(this).fadeIn();
	});
	$('.show_options').click(function() {
		if ($('.csomagok').is(":visible") == false) {
			$('.csomagok').slideDown('slow');
		}
		else {
			$('.csomagok').slideUp('slow');
		}
	});

	Calendar.set();
	

	$("a.open_images").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'		:	'easeOutBack',
		'easingOut'		:	'easeInBack',
		'titlePosition'	:	'over',
		'titleFormat': function(title) {
			return "<span id='fancybox-title-over'>" + title + "<br /><iframe src='http://www.facebook.com/plugins/like.php?href=" + encodeURI($(this).attr('href')) + "&amp;layout=button_count&amp;show_faces=false&amp;width=80&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=22' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:120px; height:22px; margin-top: 5px;' allowTransparency='true'></iframe></span>";
		}
	});
	$("a.nagy").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'		:	'easeOutBack',
		'easingOut'		:	'easeInBack',
		'titlePosition'	:	'over'
	});
	$("a.pdf").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'		:	'easeOutBack',
		'easingOut'		:	'easeInBack',
		'titlePosition'	:	'over',
		'titleFormat': function(title) {
			return "<span id='fancybox-title-over'>" + title + "<br /><a href='http://www.mustanglovasclub.hu/kepletoltes/" + $(this).attr("href") + "' style='color: #ffffff; text-decoration: none; font-weight: bold;'>Letöltés PDF formátumban</a></span>";
		}
	});
	$('a.play').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'easingIn'		:	'easeOutBack',
		'easingOut'		:	'easeInBack'
	});
	$('.adatvedelem a').fancybox({
		'hideOnContentClick': true
	});
});

