$(document).ready(function(){

	$('area').each(function(i) {

		if (location.href.indexOf($(this).attr('href')) == -1) {

			$(this).attr('rel', '#overlay');
            $(this).attr('rev', $(this).attr('href'));
			$(this).attr('nohref', 'nohref');

		}

		else {
		    $(this).attr('rel', '#overlay');
		    $(this).attr('rev', $(this).attr('href'));
		    $(this).attr('href', 'javascript:void(0);');
		}

	});

	$('a.linklegenda').each(function(i) {

		if (location.href.indexOf($(this).attr('href')) == -1) {

			$(this).attr('rel', '#overlay');

			$(this).attr('rev', $(this).attr('href'));

			$(this).attr('href', 'javascript:void(0);');

		}

		else $(this).attr('href', 'javascript:void(0);');

	});

	$('area[rel]').overlay({

		expose: {

			color: '#000', 

			loadSpeed: 200, 

			opacity: 0.5 

		},

		onBeforeLoad: function() {

			var path = this.getTrigger().attr('rev');

			if (path.indexOf('/void/') > 0) {

				return false;

			}

			else if (path.indexOf('/images/') > 0) {

				$('#overlay .contentWrap').html('<img src="' + path + '" alt="details" />');

			}

			else if (path.indexOf('/dietenheim/') > 0) {

				$('#overlay .contentWrap').html('<img src="' + path + '" alt="details" />');

			}
			
			else if (path.indexOf('recordId=') > 0 && !($.browser.msie && $.browser.version < 7)) {

				$('#overlay .contentWrap').load('http://www.hotel.bz.it/' + path + ' .tdwrapattrazioni');

			}

			else {

				location.href = 'http://www.hotel.bz.it/' + path;

				return false;

			}

        } 

	});

	$('a[rel]').overlay({

		expose: {

			color: '#000', 

			loadSpeed: 200, 

			opacity: 0.5 

		},

		onBeforeLoad: function() {

			var path = this.getTrigger().attr('rev');

			if (path.indexOf('/images/') > 0) {

				$('#overlay .contentWrap').html('<img src="' + path + '" alt="details" />');

			}
			
			else if (path.indexOf('/dietenheim/') > 0) {

				$('#overlay .contentWrap').html('<img src="' + path + '" alt="details" />');

			}
			
			else if (path.indexOf('recordId=') > 0 && !($.browser.msie && $.browser.version < 7)) {

				$('#overlay .contentWrap').load('http://www.hotel.bz.it/' + path + ' .tdwrapattrazioni');

			}

			else {

				location.href = 'http://www.hotel.bz.it/' + path;

			}

        } 

	});

});

