var flashvars = { path:'/uploadedfiles/en/_system/' }, params = { wmode:'opaque', menu: 'false' }, attributes = {  };
swfobject.embedSWF('/uploadedfiles/en/_system/swf/main.swf', 'flashcontent', '1003', '518', '10.0.0', '/uploadedfiles/en/_system/swf/expressInstall.swf', flashvars, params, attributes);

jQuery(function($) {
	$('.highlights ul.highlight-items').jcarousel({
		scroll: 1,
		visible: 3,
		buttonNextHTML: '<div class="next"><a href="#">Next</a></div>',
		buttonPrevHTML: '<div class="prev"><a href="#">Previous</a></div>',
		initCallback: function() {
			// Png fix for ie6 for higlight items image
			if ($.browser.msie && $.browser.version == 6) {
				if (!(typeof DD_belatedPNG === 'undefined')) {
					DD_belatedPNG.fix('.highlights .thumbnail img');
				}
			}
		},
		itemLastInCallback: {
			onBeforeAnimation: function(carousel, item, index, state) {
				if (state == 'next' || state == 'init') {
					$(item).addClass('no-bg');
				}
			},
			onAfterAnimation: function(carousel, item, index, state) {
				if (state == 'prev' || state == 'init') {
					$(item).addClass('no-bg');
				}
			}
		},
		itemLastOutCallback: {
			onBeforeAnimation: function(carousel, item, index, state) {
				if (state == 'next' || state == 'init') {
					$(item).removeClass('no-bg');
				}
			},
			onAfterAnimation: function(carousel, item, index, state) {
				if (state == 'prev' || state == 'init') {
					$(item).removeClass('no-bg');
				}
			}
		}
	});
	
	$('ul.highlight-items .content').each(function() {
		var content = $(this);
		var title = content.find('h2').text();
		var cta = content.find('span.more a').text();
		var links = content.find('a').click(function() {
			pageTracker._trackEvent('Homepage Banners Carousel', cta, title);
			return true;
		});
	});
});

var objects = [
	{
		"id": "Beach Station",
		"cms_id": 846,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=846",
		"name": "Beach Station/Carpark"
	},
	{
		"id": "The Merlion",
		"cms_id": 388,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=388",
		"name": "The Merlion"
	},
	{
		"id": "Sentosa 4D Magix",
		"cms_id": 379,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=379",
		"name": "Sentosa 4D Magix"
	},
	{
		"id": "Tiger Sky Tower",
		"cms_id": 389,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=389",
		"name": "Tiger Sky Tower"
	},	
	{
		"id": "Capella Singapore",
		"cms_id": 482,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=482",
		"name": "Capella Singapore"
	},
	{
		"id": "Fort Siloso",
		"cms_id": 392,
		"data_url": "/en/rpc/controller.aspx?&action=ajax&id=392",
		"name": "Fort Siloso Tours"
	}
];

jQuery(function($) {			
	
	$('#Map area').click(function() {
		var area = $(this);
		var cmsId = area.attr('href').replace('#','');
		var zone = area.attr('class');
		
		$.each(objects, function(index, value) {
			if (objects[index].cms_id == cmsId) {
				//trace(zone+' '+objects[index].data_url);
				showPopUp(zone, objects[index].data_url, '');
				return false;
			}
		});
		
		return false;
	});
	
	$('#area-the-merlion').hover(function(e) {
		
		$('#tooltip-the-merlion').show();
		
	}, function(e) {
		
		$('#tooltip-the-merlion').hide();
	});	
	
	$('#area-4d-magix').hover(function(e) {
		
		$('#tooltip-4d-magix').show();
		
	}, function(e) {
		
		$('#tooltip-4d-magix').hide();
	});
	
	$('#area-sky-tower').hover(function(e) {
		
		$('#tooltip-sky-tower').show();
		
	}, function(e) {
		
		$('#tooltip-sky-tower').hide();
	});	
});