Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;

function highlightThis(el){
	el.style.background = "#04265c";
	el.style.color = "#ffffff";
	pointThis(el);
}
function lowlightThis(el){
	el.style.background = "#04265c";
	el.style.color = "#939598";	
	unpointThis(el);
}
function pointThis(el){
	el.style.cursor = "pointer";
}
function unpointThis(el){
	el.style.cursor = "normal";
}
function showMenu(menuid, myLeft, myTop){
	//if(myTop == 'auto') myTop = '-20px';
	if($(menuid))
	{
		document.getElementById(menuid).style.top=myTop;
		document.getElementById(menuid).style.left=myLeft;
	}
}
function hideMenu(menuid){
	if($(menuid))
	{
		document.getElementById(menuid).style.left="-999em";
	}
}
var j = 0;
var geocoder;
var map = false;
var markers = false;
var infoBoxes;

function showMap() {
	if($('google'))
	{

		geocoder = new google.maps.Geocoder();
		var latLong = new google.maps.LatLng(48.861948,2.342062);
		var zoomLevel = 12;

		markers = [];
		var mapOptions = {
			zoom: zoomLevel,
			center: latLong,
			mapTypeId: google.maps.MapTypeId.ROADMAP, // 2D map
		//	disableDefaultUI: false, // limit the user's ability to adjust the map
			navigationControl: true, // zoom/pan
			mapTypeControl: false, // no you can't change it to satellite
			scaleControl: true, // :(
			draggable: true, // more :(
			other_params: "sensor=false" // v3 API needs this
		};



		map = new google.maps.Map($('google'), mapOptions);

		address.each(function(a,i) {
			geocoder.geocode( { 'address': a[0]}, function(results, status) {
			  if (status == google.maps.GeocoderStatus.OK) {
				var marker = new google.maps.Marker({
					map: map,
					position: results[0].geometry.location,
					icon: 'assets/images/icon_google_marker.png'
				});
				var contentString = '<div style="color: #000000;">'+a[1]+'</div>';
				var infowindow = new google.maps.InfoWindow({
					content: contentString
				});
				google.maps.event.addListener(marker, 'click', function() {
				  infowindow.open(map,marker);
				});

			  }
			});
		});
	}
}

// START GOOGLE MAPS API

function viewmap(open_copy,close_copy) 
{	 
	/* Fix for ie6 for english and french*/ 
	if(Prototype.Browser.IE6)
	{
		cntMarginTop = $('location').getStyle('marginTop');
		if(cntMarginTop != "-15px" && cntMarginTop != "15px")
		{
			$('location').style.marginTop = "40px"; 	
		}
		else if(cntMarginTop=="15px" || cntMarginTop == "-15px") 
		{
			$('location').style.marginTop = "15px"; 	
		}
	}
	
	if($('map_container').style.display=='none' || $('map_container').style.visibility=='hidden')
	{
		$('image_container').style.display='none';
		$('map_container').style.visibility='visible';
		$('map_container').style.display='block';
		showMap();
		$('location_copy').update(close_copy);
	} 
	else if($('map_container').style.display=='block')
	{
		$('map_container').style.visibility='hidden';
		$('map_container').style.display='none';
		$('image_container').style.display='block';
		$('location_copy').update(open_copy);
	}
}
	//Associates Bar
	var associates = Array();

	document.observe('dom:loaded', function(){
			// Default coordinates and zoom
		// Puts the position between the three hotels
	
	
	// plot
	showMap();

	$$('#associatesBar .asc_details').each(function(e){
		associates.push(e);
	});
	
	associates.pointer = 0;
	
	associates.current = function() {
		return associates[associates.pointer];
	};
	
	associates.next = function() { 
		if (associates.length > 0)
		{
			associates.pointer += 1;  
			if (associates.pointer >= associates.length)
			{
				associates.pointer = 0;
			}
			return associates.current();
		} else {
			return false;
		}
	};
	
	associates.prev = function() {
		if (associates.length > 0)
		{
			associates.pointer -= 1;  
			if (associates.pointer < 0)
			{
				associates.pointer = associates.length - 1;
			}
			return associates.current();
		} else {
			return false;
		}
	};
	
	associates.goto = function(i) {
		if (associates.length > 0)
		{
			associates.pointer = i;  
			if (associates.pointer < 0)
			{
				associates.pointer = 0;
			} else if (associates.pointer >= associates.length) {
				associates.pointer = associates.length - 1;
			}
			return associates.current();
		} else {
			return false;
		}
	}
	
	if ($('asc_next'))
	{
		$('asc_next').clickFX = function(){
			if (associates.length > 1)
			{
				var c = associates.current();
				
				new Effect.Opacity(c.identify(), {
					from: 1,
					to: 0,
					duration: 0.5,
					beforeSetup: function(){
						$('asc_next').stopObserving('click', $('asc_next').clickFX);
						$('asc_prev').stopObserving('click', $('asc_prev').clickFX);
						
						var n = associates.next();
						n.show();
						
						new Effect.Opacity(n.identify(), {
							from: 0,
							to: 1,
							duration: 0.5,
							afterFinish: function(){
								c.hide();
								$('asc_next').observe('click', $('asc_next').clickFX);
								$('asc_prev').observe('click', $('asc_prev').clickFX);
							}
						});
					}
				});
			}
		};
		$('asc_next').observe('click', $('asc_next').clickFX);
	}
	
	if ($('asc_prev'))
	{
		$('asc_prev').clickFX = function(){
			if (associates.length > 1)
			{
				var c = associates.current();
				
				new Effect.Opacity(c.identify(), {
					from: 1,
					to: 0,
					duration: 0.5,
					beforeSetup: function(){
						$('asc_next').stopObserving('click', $('asc_next').clickFX);
						$('asc_prev').stopObserving('click', $('asc_prev').clickFX);
						
						var p = associates.prev();
						p.show();
						
						new Effect.Opacity(p.identify(), {
							from: 0,
							to: 1,
							duration: 0.5,
							afterFinish: function(){
								c.hide();
								$('asc_next').observe('click', $('asc_next').clickFX);
								$('asc_prev').observe('click', $('asc_prev').clickFX);
							}
						});
					}
				});
			}
		};
		$('asc_prev').observe('click', $('asc_prev').clickFX);
	}

});


function photoPopup(el) {
	var href = el.readAttribute("href");
	window.open(href,'photo_window','width=683, height=393');
	//return false;
}

function toggle_property(tag_id,id)
	{
		var trigger_icon = document.getElementById('propbox_arrow_'+id);
		var expandable = document.getElementById(tag_id+id);
		if (expandable.style.display != 'none')
		{
			trigger_icon.src='assets/light_down_arrow.gif';
			expandable.style.display = 'none';
		} else {
			trigger_icon.src='assets/light_up_arrow.gif';
			expandable.style.display = 'block';
		}
	}

var soc_offers = Array();

document.observe('dom:loaded', function(){
	$$('#specialOfferCallout .soc_offer').each(function(e){
		soc_offers.push(e);
	});
	
	soc_offers.pointer = 0;
	
	soc_offers.current = function() {
		return soc_offers[soc_offers.pointer];
	};
	
	soc_offers.next = function() { 
		if (soc_offers.length > 0)
		{
			soc_offers.pointer += 1;  
			if (soc_offers.pointer >= soc_offers.length)
			{
				soc_offers.pointer = 0;
			}
			return soc_offers.current();
		} else {
			return false;
		}
	};
	
	soc_offers.prev = function() {
		if (soc_offers.length > 0)
		{
			soc_offers.pointer -= 1;  
			if (soc_offers.pointer < 0)
			{
				soc_offers.pointer = soc_offers.length - 1;
			}
			return soc_offers.current();
		} else {
			return false;
		}
	};
	
	soc_offers.goto = function(i) {
		if (soc_offers.length > 0)
		{
			soc_offers.pointer = i;  
			if (soc_offers.pointer < 0)
			{
				soc_offers.pointer = 0;
			} else if (soc_offers.pointer >= soc_offers.length) {
				soc_offers.pointer = soc_offers.length - 1;
			}
			return soc_offers.current();
		} else {
			return false;
		}
	}
	
	if($('soc_next'))
	{
		$('soc_next').clickFX = function(){
			if (soc_offers.length > 1)
			{
				var c = soc_offers.current();
				
				new Effect.Opacity(c.identify(), {
					from: 1,
					to: 0,
					duration: 0.5,
					beforeSetup: function(){
						$('soc_next').stopObserving('click', $('soc_next').clickFX);
						$('soc_prev').stopObserving('click', $('soc_prev').clickFX);
						
						var n = soc_offers.next();
						n.show();
						
						new Effect.Opacity(n.identify(), {
							from: 0,
							to: 1,
							duration: 0.5,
							afterFinish: function(){
								c.hide();
								$('soc_next').observe('click', $('soc_next').clickFX);
								$('soc_prev').observe('click', $('soc_prev').clickFX);
							}
						});
					}
				});
			}
		};
		$('soc_next').observe('click', $('soc_next').clickFX);
	}
	if($('soc_prev')) 
	{
		$('soc_prev').clickFX = function(){
			if (soc_offers.length > 1)
			{
				var c = soc_offers.current();
				
				new Effect.Opacity(c.identify(), {
					from: 1,
					to: 0,
					duration: 0.5,
					beforeSetup: function(){
						$('soc_next').stopObserving('click', $('soc_next').clickFX);
						$('soc_prev').stopObserving('click', $('soc_prev').clickFX);
						
						var p = soc_offers.prev();
						p.show();
						
						new Effect.Opacity(p.identify(), {
							from: 0,
							to: 1,
							duration: 0.5,
							afterFinish: function(){
								c.hide();
								$('soc_next').observe('click', $('soc_next').clickFX);
								$('soc_prev').observe('click', $('soc_prev').clickFX);
							}
						});
					}
				});
			}
		};
		$('soc_prev').observe('click', $('soc_prev').clickFX);
	}
});
function showMeetingContactForm(id)
{
	new Ajax.Request('templates/ajax/contact_form.php', {
		method: 'post',
		parameters: {
			'lang':'212',
			'id':id
		},
		onSuccess: function(transport){
			$('lb_content').update(transport.responseText);
			showLightBox();
						}
	});
}
//PNG Fix
function fixPNG(img) {
	if (navigator.userAgent.indexOf("MSIE") > -1 && parseInt(navigator.appVersion) <= 6) {
      var pSrc = img.src;
      img.onload = null;
      img.src = "assets/images/blank.gif";
      img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='" + pSrc + "')";
    }
}
