// JavaScript Document

function fill_star(i) {
	var e = 1;
	while (e < 6) {
		if (i < e) {
			$('#star'+e).attr("src","/img/ico/empty_star.png");
		} else {
			$('#star'+e).attr("src","/img/ico/full_star.png");
		}
		e++;
	} 
}

function mail(name, host) {
	win = window.open('mailto:'+name+'@'+host,'emailWindow'); 
	win.close();
}

function set_star(i) {
	$('#stars').val(i);
	fill_star(i);
}

function filter_hotel(l) {
	window.location = l + '/' + $('#cat_id').val() + '?stars=' + $('#stars').val();
}

function get_month(month, year, site) {
	var div = document.getElementById('calendar');
	div.innerHTML = '<div style="text-align:center;"><img src="/img/ajax-loader.gif" alt="Loading.." height="16" width="16" hspace="75" vspace="60" /></div>';
	
		$.ajax({
			type: "GET",
			url: "/maia/maia_backend.php",
			data: "act=get_month&month="+month+"&year="+year+'&lang='+site,
			success: function(msg){
				$('#calendar').html(msg);
				$(".tip").tipsy({gravity: 's'});
			}
		});
}

function subscribe(lang, subs, clos) {
	$.ajax({
		type: "POST",
		url: "/maia/maia_backend.php",
		data: "act=subscribe&email=" + $('#s_email').val()+'&lang='+lang,
		success: function(msg){
			if (msg != '') {
				$.fancybox(
					'<h2>' + subs + '</h2><br /><div style="margin-right:5px;"><a href="#" onclick="$.fancybox.close();" class="but"><span><span><span>' + clos + '</span></span></span></a></div>',
					{
						'autoDimensions'	: false,
						'width'         		: 330,
						'height'        		: 80,
						'transitionIn'		: 'none',
						'transitionOut'		: 'none'
					}
				);
			}
		}
	});
}

function unsubscribe(subs, clos) {
	$.ajax({
		type: "POST",
		url: "/maia/maia_backend.php",
		data: "act=unsubscribe&email=" + $('#s_email').val(),
		success: function(msg){
			if (msg != '') {
				$.fancybox(
					'<h2 class="center">' + subs + '</h2><br /><div style="margin-right:5px;"><a href="#" onclick="$.fancybox.close();" class="but"><span><span><span>' + clos + '</span></span></span></a></div>',
					{
						'autoDimensions'	: false,
						'width'         		: 330,
						'height'        		: 80,
						'transitionIn'		: 'none',
						'transitionOut'		: 'none'
					}
				);
			}
		}
	});
}
