function addListeners () {
	$('#Email').focus(function () {
		$(this).val(
			($(this).val() != (lang == 'en' ? 'Sign up here' : 'Votre email') ? $(this).val() : '')
		);
		
	});
	
	$('#Email').blur(function () {
		$(this).val(
			($(this).val() != '' ? $(this).val() : (lang == 'en' ? 'Sign up here' : 'Votre email'))
		);
		
	});
	
	$('#EmailSubmit').click(function () {
		alert('Run AJAX');
		
	});
	
	$('.dates').focus(function () {
		$(this).datePicker({ clickInput: true });
	})
}

function sortDates () {
	var date = new Date();
	var suf = (date.getHours() > 12 ? 'PM' : 'AM');
	var h = (date.getHours() > 12 ? date.getHours() - 12 : date.getHours());
	
	//$('#headerTime').text(h + ':' + date.getMinutes() + ' ' + suf);
	$('#footerYear').text(date.getFullYear());
	
}

function toggleLang (l) {
	$('.' + l).show();
	$('.' + (l == 'en' ? 'fr' : 'en')).hide();
	
	$('#Email').val((l == 'en' ? 'Sign up here' : 'Votre email'));
	
	$('#languages').toggle();
	
	switch (l)
	{
		case 'en':
		window.document.title = 'The Westin Paris | Discover the new d\351cor of The Westin Paris | Paris Hotel';
		$('#formLang').val('en_US');
		$('#formEM').val('THENEWWESTINPARIS_SEARCH_EN_WI_1729_PAR_NWE');
		
		break;
		
		case 'fr':
		window.document.title = 'The Westin Paris | D\351couvrez le nouveau d\351cor du Westin Paris | H\364tel Paris';
		$('#formLang').val('fr_US');
		$('#formEM').val('THENEWWESTINPARIS_SEARCH_FR_WI_1729_PAR_NWE');
		
		break;
	}
	
	lang = l;
	
	document.location.hash = '#' + l;
	
}

function checkIE () {
	if (navigator.userAgent.indexOf('MSIE') != -1) {
		$('body').addClass('ie');
		
	}
	
}

function loader () {
	var params = { 'wmode': 'transparent', 'menu': 'false' };
	var attributes = { };

	swfobject.embedSWF('flash/loader.swf','bgFlashEnInner','790','450','8.0.0','js/expressInstall.swf',{ 'fileToLoad': 'westin_en.swf' },params,attributes);
	swfobject.embedSWF('flash/loader.swf','bgFlashFrInner','790','450','8.0.0','js/expressInstall.swf',{ 'fileToLoad': 'westin_fr.swf' },params,attributes);

	if (document.location.hash == '#fr') {
		toggleLang('fr');

	} else {
		toggleLang('en');

	}

	$('#languages').hide();
	
	addListeners();
	sortDates();
	checkIE();	
}

var lang = 'en';
