$(document).ready(function() {
	$(document).pngFix();
	$("#tabs").idTabs();

	// linkkattintasok
	$('a.redirect').click(function(e) {
		$.ajax({
			type: "POST",
			url: document.URL,
			data: { ajaxFile: 'ajax.php', ajaxFunction: 'atiranyitas', link: this.href }
		});

	});

	// ertekelesek
	if ( $('#ertekles1').attr('id') ) {
		$.reviews_id = 1;
		$('#ertekles1').show();
		$('#reviews_back').click(function() {
			var i = $.reviews_id-1;
			var j = $.reviews_id;
			
			if ( $('#ertekles'+i).attr('id') ) {
				$('#ertekles'+j).queue(function () {
				    $(this).fadeOut('fast');
			        $(this).dequeue();
				});
				$('#ertekles'+j).queue(function () {
					$.reviews_id--;
		    		$('#ertekles'+i).fadeIn('fast');
				    $(this).dequeue();
				});
			}
		});

		$('#reviews_next').click(function() {
			var i = $.reviews_id+1;
			var j = $.reviews_id;
			
			if ( $('#ertekles'+i).attr('id') ) {
				$('#ertekles'+j).queue(function () {
				    $(this).fadeOut('fast');
			        $(this).dequeue();
				});
				$('#ertekles'+j).queue(function () {
					$.reviews_id++;
		    		$('#ertekles'+i).fadeIn('fast');
				    $(this).dequeue();
				});
			}
		});
	}
	
	
	// szamos ertekeles
	if ( $('input#hotel_rating').attr('id') ) {
		$("input#hotel_rating").bind('keypress', function (e) {
			if ( e.which == 13 ) { return checkHotelRating(); }
	    });
	}
});


function checkHotelRating() {
	var hotel_rating = $('#hotel_rating').val();
	
	if ( hotel_rating!='' && ( hotel_rating<1 || hotel_rating>10) ) {
		bmAlert('Kérem 1-10 közötti számot adjon meg!', 'error');
		return false;
	}
	return true;
}
