function getLangInUrl() {
  tmpLoc = self.location.href;
  if (tmpLoc.indexOf(".com/en") > -1) {
    return 'en';
  }
  else return 'fr';
}

function showmap(lt,lg) {
  mapwindow = window.open('/gmap.php?lt='+lt+'&lg='+lg, 'mapwindow','status=0,scrollbars=0,width=515,height=310');
  mapwindow.moveTo(0,0);
}

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

function loadMovie(theFile, activeId) {
  player.sendEvent('LOAD',{file:theFile});
  player.sendEvent('PLAY');
  
  $("#videos img").removeClass('active');
  $("#"+activeId).addClass('active');
}

function createPlayer(playlist) {
	var flashvars = {
		skin:"/templates/allegro/player/nacht.swf",
		autostart:"false",
		stretching:"uniform",
		plugins:"googlytics-1",
		file:playlist,
		repeat:"list"
	}
	var params = {
		allowfullscreen:"true", 
		allowscriptaccess:"always"
	}
	var attributes = {
		id:"theplayer",  
		name:"theplayer"
	}

	swfobject.embedSWF("/templates/allegro/player/player.swf", "placeholder", "230", "197", "9.0.0", false, flashvars, params, attributes);
}

function updateResidences(region, lang) {
	region = jQuery.trim(region);
		
	$.ajax({
		url: '/_residences.php?region='+region+'&lang='+lang,
		success: function(data) {
			$('#s_residences').html(data);
			$('#s_residences').css('display', 'block');
		}
	});
}

function assembleEmail(email) {
  if (email) {
		email = email.split('__');
		email = email[1]+'@'+email[0];
		return email;
	}
	else {
		return '';
	}
}

function slideSwitch() {
	var $active = $('#banner img.active');
	
	if ($active.length == 0) {
		$active = $('#slideshow img:last');
	}
	
	var $next = $active.next().length ? $active.next() : $('#banner img:first');
	
	$active.addClass('last-active');

  $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
	});
}
