/*try {
var _lang = 0;
var _url = document.location.href;
var _local = (_url.indexOf('intranet') != -1);
var _root = _local ? '/TMAWeb' : '/';
} catch(e) {
	alert(e);
}*/
var _lang = 0;


function writeToday() {
	// Array of day names
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
					"Thursday","Friday","Saturday");
	// Array of month Names
	var monthNames = new Array("January","February","March","April","May","June","July",
	"August","September","October","November","December");

	var frDayNames = new Array("Dimanche","Lundi","Mardi","Mercredi",
					"Jeudi","Vendredi","Samedi");
	var frMonthNames = new Array("Janvier", "F&eacute;vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "D&eacute;cembre");

	var now = new Date();
	var today;
	switch (_lang) {
		case 1:	// FRENCH
			today = now.getDate() + ' ' + frMonthNames[now.getMonth()] 
				+ ' ' + now.getFullYear();
			break;
		case 2:	// JAPANESE
			today = now.getFullYear() + '\u5e74' + (now.getMonth()+1)
				+ '\u6708' + now.getDate() + '\u65e5';
			break;
		default:
		today = monthNames[now.getMonth()] + " " + 
			now.getDate() + ", " + now.getFullYear();
	}
	var divToday = document.getElementById('today');
	if (divToday) {
		divToday.textContent = today;
		divToday.innerText = today;
	}
}

function openPopup(name,cat) {
	var url = '';
	var width = 600; var height = 400;
	var left = 200, top = 100;
	if (name.substr(0,3) == 'job') {
		url = 'careers/' + name + '.html';
	} else if (!cat) { 
		switch (name) {
			case 'direction': url = 'direction.html'; 
				width = 820; height = 820;
				break;
			case 'direction sub': url = '../direction.html'; 
				width = 820; height = 820;
				break;
			case 'labtour': url = 'labtour/index.html'; 
				width = 720; height = 640; left=30;
				break;
			case 'labtour sub': url = '../labtour/index.html'; 
				width = 720; height = 640; left=30;
				break;
			case 'workenv': url = 'workenv/index.html'; 
				width = 720; height = 640; left=30;
				break;
			case 'workenv sub': url = '../workenv/index.html'; 
				width = 720; height = 640; left=30;
				break;
			case 'tfv tmaintro': url = 'video/tmaintro.html'; 
				width = 550; height = 510; 
				break;
			case 'tfv tmacnn': url = 'video/tmacnn.html'; 
				width = 410; height = 350;
				break;
		}
	} else {
		switch (cat) {
			case 'tmdscreens':
				width = 220; height = 270;
				url = 'images/' + name + '.jpg';
				break;
		}
	}
	if (screen.width > width)
		left=Math.round((screen.width-width)/2);
	if (screen.height > height)
		top=Math.round((screen.height-height)/2);
	window.open(url,'_blank',"width=" + width + ", height=" + height 
				+ ", left=" + left + ", top=" + top
				+ ", status=no, titlebar=no, menubar=no, toolbar=no, scrollbars=yes");
	
}

function init() {
	var lang = document.getElementsByTagName('body')[0].getAttribute('lang');
	if (lang) {
		if (lang == 'fr') _lang = 1;
		else if (lang == 'ja') _lang = 2;
	}
	writeToday();
}

if (window.addEventListener)
	window.addEventListener("load", init, false);
else if (window.attachEvent)
	window.attachEvent("onload", init);

