Date.prototype.Add = function(strInterval, intIncrement) {
	if (strInterval != "M" && strInterval != "D" && strInterval != "Y" && strInterval != "h" && strInterval != "m" && strInterval != "uM" && strInterval != "uD" && strInterval != "uY" && strInterval != "uh" && strInterval != "um" && strInterval != "us") {
		throw("DateAdd: Second parameter must be M, D, Y, h, m, uM, uD, uY, uh, um or us");
	}
	if(typeof(intIncrement) != "number") {
		throw("DateAdd: Third parameter must be a number");
	}
	switch(strInterval) {
		case "M":
		this.setMonth(parseInt(this.getMonth()) + parseInt(intIncrement));
		break;

		case "D":
		this.setDate(parseInt(this.getDate()) + parseInt(intIncrement));
		break;

		case "Y":
		this.setYear(parseInt(this.getYear()) + parseInt(intIncrement));
		break;

		case "h":
		this.setHours(parseInt(this.getHours()) + parseInt(intIncrement));
		break;

		case "m":
		this.setMinutes(parseInt(this.getMinutes()) + parseInt(intIncrement));
		break;

		case "s":
		this.setSeconds(parseInt(this.getSeconds()) + parseInt(intIncrement));
		break;

		case "uM":
		this.setUTCMonth(parseInt(this.getUTCMonth()) + parseInt(intIncrement));
		break;

		case "uD":
		this.setUTCDate(parseInt(this.getUTCDate()) + parseInt(intIncrement));
		break;

		case "uY":
		this.setUTCFullYear(parseInt(this.getUTCFullYear()) + parseInt(intIncrement));
		break;

		case "uh":
		this.setUTCHours(parseInt(this.getUTCHours()) + parseInt(intIncrement));
		break;

		case "um":
		this.setUTCMinutes(parseInt(this.getUTCMinutes()) + parseInt(intIncrement));
		break;

		case "us":
		this.setUTCSeconds(parseInt(this.getUTCSeconds()) + parseInt(intIncrement));
		break;
	}
	return this;
}

$(function(){
	
	// BOOK: ROME
	$("a[class*='cat_19']").click(function(){
		hhotelSearchGroup('ITTHHTLRoma', '', '', '', '');
		return false;
	});
	// PRIVACY: ROME
	$("[class*='NOTUSED_cat_22']").click(function(){
		window.open("/themes/hotel_touristhouse/static/privacy.php","popup","scrollbars=no,width=724,height=453,top=50,left=23").focus
		return false;
	});	
	// PRIVACY: FIRENZE
	$("[class*='NOTUSED_cat_30']").click(function(){
		window.open("/themes/hotel_touristhouse/static/privacy.php","popup","scrollbars=no,width=724,height=453,top=50,left=23").focus
		return false;
	});	
	// BOOK: FIRENZE
	$("a[class*='cat_26']").click(function(){
		hhotelSearchGroup('ITTHHTLFlorence', '', '', '', '');
		return false;
	});

	$('#logo').ifixpng(); 

	$('body#group #where-we-are li a').each(function() {
		var location 	= $(this).parent('li').attr('id');
		$(this).hover(function() {
			$('body#group #where-we-are #pop-' + location).fadeIn(500);
		}, function() {
			$('body#group #where-we-are #pop-' + location).fadeOut(100);
		});
	});
	
	$('form#booking-form').each(function() {
		var td_date = new Date();
		var bf_date	= td_date.Add("D", 6);
		var that = this;

		$(this).attr('target', 'dispoprice');

		$(this).find('#fromday').val(bf_date.getDate());
		$(this).find('#frommonth').val(bf_date.getMonth() + 1);
		$(this).find('#fromyear').val(bf_date.getYear() + 1900);

		$(this).find('#book-now-submit').click(function() {
			hhotelDispoprice(that);
			return false;
		});

		$(this).find('#bf-cancel').click(function() {
			var cluster_name = $(this).attr('rel');
			hhotelcancel(cluster_name,'');
			return false;
		});

		$(this).find('#bf-option').click(function() {
			var cluster_name = $(this).attr('rel');
			hhotelSearch(cluster_name, "", "", "", "", "", "&amp;FSTBKNGTrackLink=");
			return false;
		});
		
		$(this).find('#HotelList').change(function() {
		 	hhotelFormUpdateHotelnames(that);
		})
	})
});