$(document).ready(function() {
	//Új oldalon megnyíló hivatkozások
	$('.external').click(function() {
		window.open($(this).attr('href'), "").focus();
		return false;
	});
	
	$('#banner_switcher a').click(function() {
		if($('#banner_wrapper').is(":hidden")) {
			var banner_state = 'true';
		} else {
			var banner_state = 'false';
		}
		$(this).toggleClass('closed');
		$('#banner_wrapper').slideToggle('slow');
		$.ajax({
					url: base_url + "ajax/banner_state/" + banner_state,
					global: false,
					dataType: "html",
					type: "POST"
				});
		return false;
	});
	
	//SLOTOK AZONOS MAGASSÁGA
	$('.slots').each(function() {
		var max_height = 0;
		$(this).find('.slot_body').each(function() {
			if(max_height < $(this).height()) max_height = $(this).height();
		});
		$(this).find('.slot_body').height(max_height);
	});
	
	//Keresés gomb cseréje
	$('.search_submit').replaceWith('<img class="search_submit" src="'+base_url+'assets/front/img/search_button.png">');
	$('img.search_submit').click(function(){
		$('form#search').submit();
		return false;
	});


	/*$("#top_contacts_button").click(function(){
		if ($(this).is(".open")) {
			$(this).removeClass("open");
		} else {
			$(this).addClass("open");
		}
	  
		if ($("#top_contacts_content").is(":hidden")) {
			$("#top_contacts_content").slideDown(300);
		} else {
			$("#top_contacts_content").slideUp(300);		
		}
		return false;
	});*/
});

function check_comment(user_nickname, user_email, comment) {
	if (user_nickname == "") {
		alert('A név mező üresen maradt!');
		return false;
	} else if (user_email !== '') {
		if( (user_email.indexOf("@") < 1) || (user_email.indexOf(".") < 1) ) {
			alert('A megadott e-mail cím nem tűnik érvényesnek. Nem kötelező e-mail címet megadni, amennyiben mégis megadja, kérjük érvényes e-mail címet adjon meg!');
			return false;
		}
	} else if(comment == "") {
		alert('A hozzászólás mező üresen maradt!');
		return false;
	} else {
		return true;
	}	
}


/*
FLASH BANNERS
*/

var flashvars = {};
var params = {
menu: "false",
allowfullscreen: "false",
wmode: "false"
};
var attributes = {};
swfobject.embedSWF("http://www.pecsibolcsesz.hu/public/upload/flash/banners/sziget_2010.swf", "flash_holder", "728", "90", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
