
function rate_cat(cat,score) {

	$('rating_cat_'+cat).value = score;

	Element.setStyle($('rating_cat_'+cat+'_value'),{width: '0%'});

	Element.removeClassName($('rating_cat_'+cat+'_cross'),'cross_active');
	Element.addClassName($('rating_cat_'+cat+'_cross'),'cross_passive');

	Element.removeClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_active');
	Element.addClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_passive');

	if (score == -2) {
		Element.removeClassName($('rating_cat_'+cat+'_cross'),'cross_passive');
		Element.addClassName($('rating_cat_'+cat+'_cross'),'cross_active');
	} else if (score == -1) {
		Element.removeClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_passive');
		Element.addClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_active');
	} else {
		Element.setStyle($('rating_cat_'+cat+'_value'),{width: ((score/6)*100)+'%'});
	}

	return;

	var url = '/api/temphotelrating?cat='+cat+'&score='+score;

	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			var responsetext = transport.responseText;

			Element.update("rating_"+cat, responsetext);

			//new Effect.Shake("rating_"+cat,{});
		}
	});

}

function rate_cat_yesno(cat,score) {

	$('rating_cat_'+cat).value = score;

	Element.removeClassName($('rating_cat_'+cat+'_cross'),'cross_active');
	Element.addClassName($('rating_cat_'+cat+'_cross'),'cross_passive');

	Element.removeClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_active');
	Element.addClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_passive');

	Element.removeClassName($('rating_cat_'+cat+'_hook'),'hook_active');
	Element.addClassName($('rating_cat_'+cat+'_hook'),'hook_passive');

	if (score == 0) {
		Element.removeClassName($('rating_cat_'+cat+'_cross'),'cross_passive');
		Element.addClassName($('rating_cat_'+cat+'_cross'),'cross_active');
	} else if (score == -1) {
		Element.removeClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_passive');
		Element.addClassName($('rating_cat_'+cat+'_questionmark'),'questionmark_active');
	} else if (score == 1) {
		Element.removeClassName($('rating_cat_'+cat+'_hook'),'hook_passive');
		Element.addClassName($('rating_cat_'+cat+'_hook'),'hook_active');
	} else {
		Element.setStyle($('rating_cat_'+cat+'_value'),{width: ((score/6)*100)+'%'});
	}
}

function set_hotelstars(stars) {

	$('stars_value').value = stars;
	var width = (stars/5)*100;

	Element.setStyle($('current_stars'),{width: width+'%'});


}

function update_profilepoints() {

	var url = '/api/getprofilepoints';

	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			var responsetext = transport.responseText;

			Element.update("profile-points", responsetext);

			//new Effect.Shake("rating_"+cat,{});
		}
	});

}


function open_window(path,width,height) {

  wind = window.open(path, "Popup", "width="+width+",height="+height+",left=0,top=0,scrollbars=no");
  wind.focus();

}


// callback
var	do_confirm;

function cool_confirm(args)	{
	if (!args['id']) {
		if (!cool_confirm.initalized) {
			cool_confirm.initalized = true;
			cool_confirm.okLabel = document.getElementById('modal-window:ok_label').innerHTML;
			cool_confirm.cancelLabel = document.getElementById('modal-window:cancel_label').innerHTML;
		}
		else {
			document.getElementById('modal-window:title').innerHTML = '';
			document.getElementById('modal-window:text').innerHTML = '';
			document.getElementById('modal-window:ok_label').innerHTML = cool_confirm.okLabel;
			document.getElementById('modal-window:cancel_label').innerHTML = cool_confirm.cancelLabel;
			document.getElementById('modal-window:title').style.backgroundImage = 'url(/images/icn_help.gif)';
		}
	}
	var	id		= args['id'] ||	'modal-window';
	var	element	= args['element'];
	var	op		= args['op'];
	var	href		= args['href'];
	var	callback	= args['callback'];

	do_confirm = _do_confirm;

	var	modalWindow	= document.getElementById(id);
	modalWindow.className =	'modal-window';
	Element.setStyle(modalWindow, {	visibility:	'hidden', position:	'absolute',	left: '0', top:	'0', display: '' });
	if (modalWindow.parentNode != document.body) document.body.appendChild(modalWindow);

	if (args['icon']) {
		var	div	= document.getElementById(id + ':title');
		if (div) {
			div.style.backgroundImage =	'url(' + args['icon'] +	')';
		}
	}
	for	(var k in {	title: true, text: true, ok_label: true, cancel_label: true	}) {
		if (args[k]) {
			var	div	= document.getElementById(id + ':' + k);
			if (div) {
				div.innerHTML =	args[k];
			}
		}
	}

	Overlay.start({ dialog: modalWindow });
	Element.setStyle(modalWindow, {	visibility:	'' });

	var firstButton = modalWindow.getElementsByTagName('button')[0];
	if (firstButton) firstButton.focus();

	return false;

	function _do_confirm(returncode) {
		Element.hide(modalWindow);
		Overlay.stop();

		if (returncode)	{
			if (callback) {
				callback(returncode);
			}
			else if	(element) {
				if (element.tagName	== 'A')	{
					var	uriComponent;
					var	form = modalWindow.getElementsByTagName('form')[0];
					if (form) {
						uriComponent = Form.serialize(form);
					}
					else {
						uriComponent = '';
					}
					location.href = element.href + '&' + uriComponent;
				}
				else if	(element.tagName == 'BUTTON' || element.tagName == 'INPUT') {
					if (element.type == 'submit') {
						if (op)	element.form.op.value = op;
						element.form.submit();
					}
					else if	(element.type == 'button' && href) {
						location.href = href;
					}
				}
			}
		}
	}
}
