var DEBUG = false;

function isCss3Nav () {
	// CSS3 Browser are Chrome & Safari (Webkit), Opera & Firefox 4+
	return Prototype.Browser.WebKit || Prototype.Browser.Opera || /firefox\/[4-9]+/gi.test(navigator.userAgent);
}

var css3 = isCss3Nav();

function init () {
	$$('img.Zoom').each(function (img) {
		// Makes all images with "Zoom" Class clickable => Frame View
		img.observe('click', imgFrame.curry(img));
	});
	// IE Hacks
	if (Prototype.Browser.IE) {
		var main = $('Main');
		if ($('BizLeft') && !main.hasClassName('Home'))
			$('BizLeft').show();
		// Quotes
		var quotes = $('BizQuotes');
		if (quotes) {
			$('BizQuotes').select('blockquote').each(function (q) {
				q.insert({top: '<img src="'+Mx.urls.ie+'/quote1.gif"/><img class="End" src="'+Mx.urls.ie+'/quote2.gif"/>'});
			});
		}

		// Demo link Triangles
		if ($('DemoLink'))
			$('DemoLink').insert({top: '<span id="DemoLinkDesign"></span>'});
	}

}

// CSS3 Compliance
var html = {homeTxt: 'HomeBigText', bizTxt: 'BizLeft'};

// Shows or hides an animation step image with CSS3
function toggleCSS3 (elt, hide) {
	(!!hide ? Element.removeClassName : Element.addClassName)(elt, 'Visible');
}
// Shows or hides an animation step image with Scriptaculous JS framework
function toggleJS (elt, hide) {
	(!!hide ? Effect.Fade : Effect.Appear)(elt, {duration: Mx.params.animTime});
}

var toggleStep = css3 ? toggleCSS3 : toggleJS;

var BizAnim = Class.create({
	initialize: function (biz, settings) {
		this.biz = biz;
		this.steps = $$('.'+Mx.css.stepClass+'_'+biz);
		this.nbsteps = this.steps.length;
		this.timer = 0;
		// Initialize series of steps
		this.init();
	},

//	toggleStep: css3 ? toggleCSS3 : toggleJS,
// Integrer toggle dans la classe
// Integrer les constantes (html, duration...
// Faire classe générique et étendre...

	init: function () {
		this.current = 0;
		this.pause = true;
		// Init steps (hide steps so that last will not stay for next anim)
		this.steps.each(function (step, index) {
			toggleStep(step, true);
		});
		// Init end/finish
		this.txtBox = $(html.homeTxt) || $(html.bizTxt);
		toggleStep(this.txtBox, true);
	},

	getCurrent: function () {
		return this.steps[this.current];
	},

	next: function (handler) {
		if (!this.pause)
		{
			// showing next step if not last
			if (this.current < this.nbsteps - 1) {
				toggleStep(this.getCurrent(), true);
				this.current++;
				mxlog('Next => '+this.getCurrent().id);
				toggleStep(this.getCurrent());
			}
			// If last, showing finish & stoping Animation
			if (this.current >= this.nbsteps - 1)
			{
				mxlog('Last => '+this.getCurrent().id);
				this.stop();
				this.finish();
			}
			this.timer = this.next.bind(this).delay(Mx.params.animTime);
//			console.log(this.timer);
		}
	},

	finish: function () {
		if ($(html.homeTxt))
			$('Title_'+this.biz).show().siblings().invoke('hide');
		toggleStep(this.txtBox);
		mxwarn('--- End Anim ---');
//		console.groupEnd();
		this.txtBox.fire('Anim:ended', {biz: this.biz});
	},

	start: function () {
		if (this.pause)
		{
//			console.group('Anim ['+this.biz+']');
			mxwarn('START ('+this.getCurrent().id+')');
			this.pause = false;
			toggleStep(this.getCurrent());
			this.timer = this.next.bind(this).delay(Mx.params.animTime);
		}
	},

	stop: function () {
		window.clearTimeout(this.timer);
//		console.warn(this.getCurrent().timer);
		this.pause = true;
		mxwarn('--- PAUSED ---');
	}
});

var HomeAnim = Class.create({
	initialize: function (bizs) {
		this.current = 0;
		this.anims = [];
		bizs.each(function (biz) {
			this.anims.push(new BizAnim(biz));
			$('MenuLink_'+biz).observe('mouseenter', this.menuHover.bind(this, biz));
			$('MenuLink_'+biz).observe('mouseleave', this.menuOut.bind(this));
		}, this);
		this.pause = true;
		document.observe("Anim:ended", this.animWatcher.bind(this));
	},

	getCurrent: function () {
		return this.anims[this.current];
	},

	start: function () {
		this.pause = false;
		this.getCurrent().start();
	},

	next: function () {
		this.getCurrent().init();
		this.current = (this.current + 1) % this.anims.length;

		// Changing background !
		$('Main').setStyle({background: 'url('+animImgs[this.getCurrent().biz].background.src+') left top no-repeat'});
		// Changing Tripod's top
		$('TripodTop').src = animImgs[this.getCurrent().biz].tripodTop.src;

		this.getCurrent().start();
	},

	animWatcher: function (event) {
//		event.stop();
		mxwarn('--- AnimFinish triggered ---');
		this.timer = this.next.bind(this).delay(5);
//		console.log(this.timer);
	},

	menuHover: function (biz) {
		this.stop();
		toggleStep($('HomeBigText'));
	//	homeleft.select('.Title').invoke('hide');
		$('BizText_'+biz).show().siblings().invoke('hide');;
	},

	menuOut: function () {
//		toggleStep($('HomeBigText'), true);
		this.start();
	},

	stop: function () {
		this.getCurrent().stop();
		window.clearTimeout(this.timer);
//		console.warn(this.timer);
		this.pause = true;
	}
});



/*
// Anim controls
Event.observe(window, 'load', function () {
	$('Main').insert({after:	'<a href="javascript:;" onclick="home.init();">Init</a>' +
										'<a href="javascript:;" onclick="home.start();">Start</a>' +
										'<a href="javascript:;" onclick="home.stop();">Stop</a>'
	});
})
*/









function newTab (link) {
	window.open(link.href);
	return false;
}

function setMessage (elt, type, msg) {
	var types = ['Error', 'Warning', 'Message'];
	types.each( function (c) {
		if (elt.hasClassName(c))
			elt.removeClassName(c);
	});
	elt.addClassName(type).update(msg).show();
}

// links and tabs must be in the same order from their parents !
function switchTab (tabs, link) {
	if (Object.isString(link))
		link = $(link);
	if (Object.isString(tabs))
		tabs = $(tabs);

	var index = link.up().childElements().indexOf(link);
	// Shows tab and hides others
	tabs.childElements()[index].show().siblings().invoke('hide');
	// Makes the clicked link the "Current" one (allowing css styling)
	link.addClassName('Current').adjacent('.Current').invoke('removeClassName', 'Current');
	return false;
}
/*
//Gestion du dimensionnement automatique des images de la prévisualisation en fct de la taille de la fenetre (script.php5 / preview.tpl)
var imgResize = function (img) {
	var win = document.viewport.getDimensions();
	var ratioWin = win.width / win.height;
	// Redimensionnement si la fenêtre fait une taille minimum
	if (win.height > minHeight + 2*Config.previewMargin)
	{
		if (ratioImg >= ratioWin)
		{
			// L'image n'est pas agrandi si la fenêtre est + grande
			var newWidth = win.width > image.width ? image.width : win.width - 2 * Config.previewMargin;
			img.setStyle({width:newWidth+'px', height:''});
		}
		else
		{
			// L'image n'est pas agrandie si la fenêtre est + grande
			var newHeight = win.height > image.height ? image.height : win.height - 2 * Config.previewMargin;
			img.setStyle({width:'', height:newHeight+'px'});
		}
	}
};
*/

// Using Box for centered images
function imgFrame (img) {

	var imgContent;
	// if url (not an existing image in page
	if (Object.isString(img))
	{
		imgContent = new Image();
		imgContent.src = img;
	}
	// If img is an Element
	else
	{
		imgContent = $(img).clone().removeClassName('Zoom');
		var win = document.viewport.getDimensions();
		// max-height is Viewport Height - 75px (2*15px[box padding] + (25+10)px[title height] + 2*5px[top/bottom space left])
		var spaceTaken = 2*15 + 25+10 + 2*5;
		imgContent.setStyle({display: 'block', maxHeight: (win.height-spaceTaken)+'px', margin: '0 auto'}).stopObserving();
	}
	return showBox(imgContent, img.alt);
}

function contentFrame (html, title) {
	return showBox(html, title);
}

// Using Box for web page
function frame (url, title, settings) {
	settings = Object.isUndefined(settings) ? '' : settings;
	var win = document.viewport.getDimensions();
	var spaceTaken = 2*15 + 25+10 + 2*5 + 5;
	style = Object.isUndefined(settings.style) ? '' : settings.style;
	var content = '<iframe frameborder="0" marginheight="0" marginwidth="0" src="'+url+'" style="height:'+(win.height-spaceTaken)+'px;'+style+'"></iframe>';
	return showBox(content, title);
}

function switchBox (content, title, settings) {
	closeBox();
	return frame(content, title, settings);
}

var animImgs = [];
var home;
function homeAnim (bizs) {
//	if (DEBUG) console.profile();

	// Preloading next animation
	var elt = $('HomeLeft');
	bizs.each(function (biz, index) {
		animImgs[biz] = { background: new Image(), tripodTop: new Image(), steps: [] };
		// Preloading background
		animImgs[biz].background.src = Mx.urls.img + '/background-' + biz + '.jpg';
		// Preloading tripod head
		animImgs[biz].tripodTop.src = Mx.urls.img + '/tripod-top-' + biz + '.png';
		$R(1,3).each(function(step) {
			// Preloading each step...
			var img = new Image();
			img.src = Mx.urls.img + '/anim/anim-'+biz+'-'+step+'.png';
			animImgs[biz].steps.push(img);
			// ...and inserting them in the page
			var imgID = 'AnimStep_'+biz+'_'+step;
			if (!$(imgID))
			{
				// Anim Images are style with opacity:0.
				// Images are "display:none" in IE bacause it doesn't handle opacity
				var html = '<img src="'+img.src+'" id="'+imgID+'" class="AnimStep AnimStep_'+biz+' AnimStep'+step+' '+(css3?'Hidden':'')+'"'+(css3 ? '' : ' style="display:none;"')+'/>';
				if (!Prototype.Browser.IE)
					elt.show();
				elt.insert({before: html});
			}
			else
				elt.show();
		});
	});


	home = new HomeAnim(bizs);
	home.start();
//	if (DEBUG) console.profileEnd();
}


// Business Home Animation (shows & hides each steps of the animation one after the other
var anim;
function bizHomeAnim (biz) {
	anim = new BizAnim(biz);
	anim.start();
}





// DEMO
var videos = [{
	// tableau des vidéos
		title		: 'Relev\351 d\'une pi\350ce',
		url		: 'http://www.youtube.com/embed/k5YmN3EEKRo',
		img		: 'http://i4.ytimg.com/vi/k5YmN3EEKRo/default.jpg'
	},{
		title		: 'Relev\351 d\'un poteau',
		url		: 'http://www.youtube.com/embed/OhCsUUB-Zjo',
		img		: 'http://i4.ytimg.com/vi/OhCsUUB-Zjo/default.jpg'
	},{
		title		: 'Relev\351 d\'une ouverture',
		url		: 'http://www.youtube.com/embed/5J_Yy9eDwto',
		img		: 'http://i2.ytimg.com/vi/5J_Yy9eDwto/default.jpg'
	},{
		title		: 'Relev\351 d\'une surface < 1m80',
		url		: 'http://www.youtube.com/embed/7YSZABDf2PA',
		img		: 'http://i4.ytimg.com/vi/7YSZABDf2PA/default.jpg'
	},{
		title		: 'Relev\351 d\'un plafond 2 pentes',
		url		: 'http://www.youtube.com/embed/ovHNXVl3k-o',
		img		: 'http://i4.ytimg.com/vi/ovHNXVl3k-o/default.jpg'
	},{
		title		: 'Relev\351 de charpente',
		url		: 'http://www.youtube.com/embed/kXkjTgVHvMs',
		img		: 'http://i4.ytimg.com/vi/kXkjTgVHvMs/default.jpg'
	// },{
		// title		: 'Relev\351 d\'un bâtiment',
		// url		: 'http://www.youtube.com/embed/JVE-ByiAXQQ',
		// img		: 'http://i3.ytimg.com/vi/JVE-ByiAXQQ/default.jpg'
	},{
		title		: 'Relev\351 d\'une poutre',
		url		: 'http://www.youtube.com/embed/GQRPLLS5QV8',
		img		: 'http://i4.ytimg.com/vi/GQRPLLS5QV8/default.jpg'
}];
var fullDemo = {
		title		: 'D\351monstration TRIPOD Measurix',
		url		: 'http://www.youtube.com/p/8E3F9F03524D89CE',//'http://www.youtube.com/watch?v=k5YmN3EEKRo&feature=PlayList&p=8E3F9F03524D89CE&index=0&playnext=1',//
		img		: 'resources/img/logo-small.jpg'
};
var vidLink = '<a id="VideoLink_#{index}" class="VideoLink" href="javascript:;" title="#{title}" onclick="return setVideo(#{index});">' +
						'<div style="background-image:url(#{img});"></div>#{title}' +
					'</a>';
var getVideoLink = function (index) {
	return videos[index-1] ? vidLink.interpolate({
											index:index,
											title:index + '. ' + videos[index-1].title,
											img:videos[index-1].img,
											url:videos[index-1].url
									}) : '';
};

var setVideo = function (index) {
	// Full Demo
	$$('a.VideoLink').invoke('removeClassName', 'CurrentVideo');
	if (!videos[index-1])
	{
		// IE Object Patch !
		if ($('IEPL'))
			$('IEPL').remove();
		// Set video title
		$('VideoTitle').innerHTML = fullDemo.title;
		// IE Object Patch !
		if (Prototype.Browser.IE)
		{
			var pl = '<div id="IEPL"><object width="640" height="385"><param name="movie" value="http://www.youtube.com/p/8E3F9F03524D89CE?hl=en_US&fs=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/p/8E3F9F03524D89CE?hl=en_US&fs=1&autoplay=1" type="application/x-shockwave-flash" width="640" height="385" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>';
			$('YoutubeDemoVideo').hide();
			$('EmbeddedVideo').insert({top:pl});
		}
		else
		{
			// Remove IE Object Patch !
			if ($('IEPL'))
				$('IEPL').remove();
			$('YoutubeDemoVideo').show();
			// End Patch
			$('YoutubeDemoVideo').src = fullDemo.url+'?rel=0&autoplay=1&fs=1';
		}
		$('VideoLink_'+index).addClassName('CurrentVideo');
		// set next & prev links
		$('PreviousVideo').innerHTML = $('NextVideo').innerHTML = '';
	}
	// tests de l'ID
	else if ($('YoutubeDemoVideo'))
	{
		// IE Object Patch !
		if ($('IEPL'))
			$('IEPL').remove();
		$('YoutubeDemoVideo').show();
			// End Patch
		// Set video title
		$('VideoTitle').innerHTML = index + '. ' + videos[index-1].title;
		// set Video
		$('YoutubeDemoVideo').src = videos[index-1].url+'?rel=0&autoplay=1&version=3';
		$('VideoLink_'+index).addClassName('CurrentVideo');
		// set next & prev links
		$('PreviousVideo').innerHTML = getVideoLink(index-1);
		$('NextVideo').innerHTML = getVideoLink(index+1);
		$('Demo').scrollTo();
	}
	return false;
};

function initDemo () {
	$('EmbeddedVideo').show();
	var html = '';
		html += vidLink.interpolate({index:0, title:fullDemo.title, img:fullDemo.img, url:fullDemo.url}) + '<br/>';
	videos.each(function(v,k){
		html += vidLink.interpolate({index:k+1, title:(k+1)+'. '+v.title, img:v.img, url:v.url}) + '<br/>';
	});
	$('DemoMenu').innerHTML = html;
	setVideo(1);
	window.scrollTo(0, 0);
	return false;
};


// Partners Info Frame
function viewPartner (link) {
	var logo = link.down();
	var content = '<div><img src="'+logo.src+'" style="display:block;margin:0 auto;"/>' +
							'<div>' +
								link.next().innerHTML +
								'<a href="'+link.href+'" onclick="return newTab(this);">'+link.href+'</a>' +
							'</div>' +
						'</div>';
	return contentFrame(content, logo.alt);
}

// Tour de France signup frame
function signup (url) {
	return frame(url, null, {style: 'width:680px;'});
}





// QUOTES
var current;
function loopQuotes () {
	current = $('BizQuotes').firstDescendant();
	current.show();
	new PeriodicalExecuter(switchQuote, Mx.params.quoteTime);
}

function switchQuote () {
//	var width = $('BizQuotes').getWidth();
//	current.setStyle({width:width+'px'});
//	current.setStyle({position: 'absolute'});
	current.fade();
	current = current.next();
	if (Object.isUndefined(current))
		current = $('BizQuotes').firstDescendant();
//	current.setStyle({position: 'absolute', top: 0});
	current.appear();
//	current.setStyle({position: 'relative'});

//	new Effect.Move(current, { x: -200, y: 0 });
	//new Effect.Move(next, { x: -100, y: 0 });
//	current = next;
/*	new Effect.Parallel([
		current
	], { 
		duration: 1.0,
		delay: 0
	});*/
}

function openAccount () {
	frame('http://client.measurix.com/client/', 'Espace Client', {style: 'width:700px;'});
}

function setContactForm (requiredFields) {
// DEBUG !!
// if (DEBUG) $('ContactForm').select('input[type=text]').each(function(f){f.value=f.previous().innerHTML;});
	// Marking required fields with a red *
	requiredFields.each(function (f) {
		var label = $(f).previous();
		if (label)
		label.insert({bottom: ' <span class="Red">*</span>'});
	});
	// Dynamically changing regions when country is changed
	$('country').observe('change', function () {
		MxAjax.request('/do/getRegions/', {
			parameters:	'country='+$F(this),
			onSuccess: function (res) {
				res = res.responseJSON;
				if (!MxAjax.checkResponse(res))
					alert(Mx.html.error);
				else if (!res.ack)
					$('ContactError').update(res.msg).show();
				else if (res.data.length == 0)
					$('region').update('').up().hide();//.previous().hide().next(1).hide();
				else
					$('region').update(res.data).up().show();//.previous().show().next(1).show();
			}
		});
	});
}

/*************** VERIFICATION FORMULAIRE CONTACT ***************/
function checkContact () {
	$('ContactError').hide();
	var form = $('ContactForm');
	MxAjax.request(form.action, {
		parameters:	form.serialize(),
		onSuccess: function (res) {
			res = res.responseJSON;
			if (!MxAjax.checkResponse(res))
				alert(Mx.html.error);
			else if (!res.ack)
			{
				window.scrollTo(0,0);
				$('ContactError').update(res.msg).show();
				form.select('input[type=text]').each( function (field) {
					field.previous().setStyle({color:'black', fontWeight: '500'});
				});
				res.data.each( function(field) {
					$(field).previous().setStyle({color:'red', fontWeight: '900'});
				});
			}
			else
			{
				window.scrollTo(0,0);
				form.reset();
				$('ContactMessage').update(res.msg).show();
			}
				
		}
	});
	return false;
}

/*************** VERIFICATION FORMULAIRE INSCRIPTIONS ***************/
function checkSignup () {
	$('SignupError').hide();
	var form = $('SignupForm');
	MxAjax.request(form.action, {
		parameters:	form.serialize(),
		onSuccess: function (res) {
			res = res.responseJSON;
			if (!MxAjax.checkResponse(res))
				alert(Mx.html.error);
			else if (!res.ack)
			{
				window.scrollTo(0,0);
				$('SignupError').update(res.msg).show();
				form.select('input[type=text]').each( function (field) {
					field.previous().setStyle({color:'black', fontWeight: '500'});
				});
				res.data.each( function(field) {
					$(field).previous().setStyle({color:'red', fontWeight: '900'});
				});
			}
			else
			{
				window.scrollTo(0,0);
				//form.reset();
				// $('SignupForm').select('input').invoke(function(field){field.value='';})
				$('Field_company').value='';
				$('Field_job').value='';
				$('Field_name').value='';
				$('Field_mail').value='';
				$('Field_gsm').value='';
				$('SignupMessage').update(res.msg).show();
			}
				
		}
	});
	return false;
}

/**************** VERIFICATION FORMULAIRE LOGIN ****************/
function checkLogin () {
	// Hiding error msg block
	$('LoginError').update('').hide();
	var form = $('LoginForm');
	// if both fields are filled
	if (form.login.value.length > 0 && form.pass.value.length > 0)
		MxAjax.request('/do/login/', {
			parameters:	form.serialize(),
			onSuccess: function (res) {
				res = res.responseJSON;
				if (!MxAjax.checkResponse(res))
					alert(Mx.html.error);
				else if (!res.ack)
					setMessage($('LoginError'), Mx.css.errorClass, res.msg);//$('LoginError').update(res.msg).show();
				else
					openAccount();
			}
		});
	return false;
};

function initPasswd () {
	// Hiding error msg block
	$('NewPassError').update('').hide();
	var mail = $F('mail');
	// if mail is filled
	if (mail.length > 0)
		MxAjax.request('/do/initPasswd/', {
			parameters:	'mail='+mail,
			onSuccess: function (res) {
				res = res.responseJSON;
				if (!MxAjax.checkResponse(res))
					alert(Mx.html.error);
				else if (!res.ack)
					setMessage($('NewPassError'), Mx.css.errorClass, res.msg);
				else
					setMessage($('NewPassError'), Mx.css.msgClass, res.msg);
			}
		});
	return false;
};

function checkNewPass () {
	// Hiding error msg block
	$('NewPassFormError').update('').hide();
	var form = $('NewPassForm');
	if ($F('pass2').length > 0 && $F('pass3').length > 0)
		MxAjax.request('/do/initPasswd/', {
			parameters:	form.serialize(),
			onSuccess: function (res) {
				res = res.responseJSON;
				if (!MxAjax.checkResponse(res))
					alert(Mx.html.error);
				else if (!res.ack)
					setMessage($('NewPassFormError'), Mx.css.errorClass, res.msg);
				else
				{
					setMessage($('LoginError'), Mx.css.msgClass, res.msg);
					form.hide().reset();
					$('LoginForm').show();
				}
			}
		});
	return false;
}
/***************************************************************/


// NEWS POPUP !!!
function pub () {
	var html = '<table id="NewsAd" cellpadding="0" cellspacing="0" style="position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;z-index:999;"><tr>' +
'	<td id="Mx_Ad" style="position: relative;height:100%;">' +
'		<div style="overflow:auto;position: relative;width:800px;min-height:500px;max-height:90%;margin:0 auto;padding:25px;border-radius:8px;*zoom:1;background:rgba(0, 0, 0, 0.7);filter: progid:DXImageTransform.Microsoft.gradient (startColorstr = \'#99000000\', endColorstr = \'#99000000\');*behavior: url(/resources/IE/PIE.htc);">' +
'			<img style="position:absolute; right: 0; margin: -18px 7px 0 0; cursor: pointer;" onclick="$(\'NewsAd\').remove();" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAADAFBMVEX+/v62AAD87fGYAAD6y9L3c3y4EAwnAAD89PPpQkzoO0X1Q0v2pqhuLEICAADmHSLaFBfjDhDTIR/2hYv4U1yljJA3AAL1DhDHAADWAgHzLDKYiYllAACoAACniYnzNDrpY2vEi4vhfpDkd4X6AQD74N7lAgDpkI7GEQvJJSjzYmzxkY7XEgz0O0S/IRvQMS7mFhfdHiMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABghghghggAN7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ0bPOAAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAJdJREFUeNptT1sOwiAQ3BGr0vr4aXRR8YlYrc/7H8kzmLhA61cnhMlMZneAqAtI1FOJ+1k2aHgYeKRzXYgz1lrnE0lPIRMAviGEj9zzBbOJZ7lKS9bGCoDZpm1R2+Ds9v/agwqGVa0+SjzCNhrMXDpmIL7wJAW+PFdOanARwxrjrzXRzRlzf4RIFTWRd8UzLXnVif276+c/y8IMeYcYrDYAAAAASUVORK5CYII=" />' +
'			<h1 style="margin:0 auto;">Tour de France 2011 et Concours TRIPOD</h1>' +
'			<h3>Inscrivez-vous pour le Tour de France 2011 et gagnez un TRIPOD !</h3>' +
'			<a href="/inscriptions/?event=11092010" onclick="return signup(this.href);">' +
'				Inscription G\351om\350tres<br/>' +
'				<img src="/resources/img/com/TDF-2011-ge.jpg" style="width:200px;margin-top:5px;" />' +
'			</a>' +
'			<a href="/inscriptions/?event=11092030" onclick="return signup(this.href);">' +
'				Inscription Architectes<br/>' +
'				<img src="/resources/img/com/TDF-2011-archi.jpg" style="width:200px;margin-top:5px;" />' +
'			</a>' +
'			<a href="/inscriptions/?event=11092050" onclick="return signup(this.href);">' +
'				Inscription Diagnostiqueurs<br/>' +
'				<img src="/resources/img/com/TDF-2011-diag.jpg" style="width:200px;margin-top:5px;" />' +
'			</a>' +
'			<h1 style="">Actualit\351 Measurix !</h1>' +
'			<div class="ActuNews" style="width:750px;margin:5px auto 15px auto;padding:10px;color:white;font-weight:900;">' +
'				<h2 style="margin:0 auto;color:white;text-align:left;padding-left:30px;">Un G\351om\350tre heureux !</h2>' +
'				<p style="padding:0 15px;text-align:left;">' +
'					\253 Je tenais \340 vous remercier pour cette journ\351e extraordinaire au circuit de SPA.' +
'					Vous m\'avez donn\351 une grosse envie d\'essayer le pilotage. \273<br/>' +
'				</p>' +
'				<p style="text-align:center;">' +
'					<span style="display: inline-block;width:200px;">' +
'						<img src="/resources/img/news/circuit-1.jpg" onclick="return imgFrame(this);" style="width:100%;cursor:pointer;" />' +
'					</span>' +
'					<span style="display: inline-block;width:200px;">' +
'						<img src="/resources/img/news/circuit-2.jpg" onclick="return imgFrame(this);" style="width:100%;cursor:pointer;" />' +
'					</span>' +
'				</p>' +
'			</div>' +
'		</div>' +
'	</td>' +
'</tr></table>';
	$(document.body).insert({top: html});
}

function splashOld () {
	// margin/padding
	var space = 15;
	// Viewport height
	var vph = document.viewport.getHeight();
	// Inner div height (auto/max=containerH)
	var containerH = parseInt(vph - 2*space);
	var contentH = containerH - 2*space;
	var ieh1 = 'width:780px;';
	var html =
'<table id="NewsAd" cellpadding="0" cellspacing="0" style="position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;z-index:999;"><tr>' +
'	<td id="Mx_Ad" style="width:100%;height:100%;margin:0;padding:0;text-align:center;vertical-align:middle;">' +
'		<span style="display:inline-block;width:auto;max-width:800px;height:auto;max-height:'+containerH+'px;margin:0 '+space+'px;padding:'+space+'px;border-radius:8px;*display:inline;*width:800px;*zoom:1;background:rgba(0, 0, 0, 0.7);filter: progid:DXImageTransform.Microsoft.gradient (startColorstr = \'#99000000\', endColorstr = \'#99000000\');">' +
'			<div style="position:relative;overflow:auto;height:auto;max-height:'+contentH+'px;">' +
'				<img style="position:absolute;right: 0;margin:5px 5px 0 0;padding:2px;background-color:white;cursor:pointer;" onclick="$(\'NewsAd\').remove();" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAADAFBMVEX+/v62AAD87fGYAAD6y9L3c3y4EAwnAAD89PPpQkzoO0X1Q0v2pqhuLEICAADmHSLaFBfjDhDTIR/2hYv4U1yljJA3AAL1DhDHAADWAgHzLDKYiYllAACoAACniYnzNDrpY2vEi4vhfpDkd4X6AQD74N7lAgDpkI7GEQvJJSjzYmzxkY7XEgz0O0S/IRvQMS7mFhfdHiMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABghghghggAN7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ0bPOAAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAJdJREFUeNptT1sOwiAQ3BGr0vr4aXRR8YlYrc/7H8kzmLhA61cnhMlMZneAqAtI1FOJ+1k2aHgYeKRzXYgz1lrnE0lPIRMAviGEj9zzBbOJZ7lKS9bGCoDZpm1R2+Ds9v/agwqGVa0+SjzCNhrMXDpmIL7wJAW+PFdOanARwxrjrzXRzRlzf4RIFTWRd8UzLXnVif276+c/y8IMeYcYrDYAAAAASUVORK5CYII=" />' +

'				<h1 style="'+(Prototype.Browser.IE ? ieh1 : '')+'font-size:130%;margin:0 auto;">Actualit\351 Measurix !</h1>' +
'				<div class="ActuNews" style="margin:15px 0 0 0;padding:0 10px;color:white;font-weight:900;">' +

'					<h2 style="margin:0 auto;color:white;text-align:left;padding-left:10px;">Tour de France Circuit</h2>' +
'					<p style="padding:5px 0 10px 15px;text-align:center;">' +
'						<span style="display:inline-block;width:200px;margin:0 2px;">' +
'							<img src="/resources/img/news/circuit-1.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
'						</span>' +
'						<span style="display:inline-block;width:200px;margin:0 3px;">' +
'							<img src="/resources/img/news/circuit-2.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
'						</span>' +
'						<br/><u>SPA le 6 Octobre :</u>\253 Je tenais \340 vous remercier pour cette journ\351e extraordinaire au circuit de SPA. Vous m\'avez donn\351 une grosse envie d\'essayer le pilotage. \273' +
'					</p>' +
'					<p style="padding:5px 0 10px 15px;text-align:center;">' +
'						<span style="display:inline-block;width:200px;margin:0 3px;">' +
'							<img src="/resources/img/news/circuit-3.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
'						</span>' +
'						<span style="display:inline-block;width:200px;margin:0 3px;">' +
'							<img src="/resources/img/news/circuit-4.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
'						</span>' +
'						<br/><u>Le Mans le 15 Octobre 2011 :</u> un grand moment sur un circuit mythique' +
'					</p>' +
'					<p style="padding:5px 0 10px 15px;text-align:center;">' +
'						<span style="display:inline-block;width:200px;margin:0 3px;">' +
'							<img src="/resources/img/news/circuit-5.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
'						</span>' +
'						<br/><u>Nogaro le 30 Octobre 2011 :</u> pr\351paration du bolide' +
'					</p>' +

'				</div>' +

'			</div>' +
'		</span>' +
'	</td>' +
'</tr></table>';
	$(document.body).insert({top: html});
}

function splash () {
	// margin/padding
	var space = 15;
	// Viewport height
	var vph = document.viewport.getHeight();
	// Inner div height (auto/max=containerH)
	var containerH = parseInt(vph - 2*space);
	var contentH = containerH - 2*space;
	var html =
'<table id="NewsAd" cellpadding="0" cellspacing="0" style="position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;z-index:999;"><tr>' +
	'<td id="Mx_Ad" style="width:100%;height:100%;margin:0;padding:0;text-align:center;vertical-align:middle;">' +
		'<span style="display:inline-block;width:auto;max-width:800px;height:auto;max-height:'+containerH+'px;margin:0 '+space+'px;padding:'+space+'px;border-radius:8px;*display:inline;*width:800px;*zoom:1;background:rgba(0, 0, 0, 0.7);filter: progid:DXImageTransform.Microsoft.gradient (startColorstr = \'#99000000\', endColorstr = \'#99000000\');">' +
			'<div style="position:relative;overflow:auto;height:auto;max-height:'+contentH+'px;">' +

				'<h1 style="font-size:130%;margin:0 auto;padding:5px;">' +
				'<img style="float:right;display:block;margin:0px 0px 0 0;padding:2px;background-color:white;cursor:pointer;" onclick="$(\'NewsAd\').remove();" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAADAFBMVEX+/v62AAD87fGYAAD6y9L3c3y4EAwnAAD89PPpQkzoO0X1Q0v2pqhuLEICAADmHSLaFBfjDhDTIR/2hYv4U1yljJA3AAL1DhDHAADWAgHzLDKYiYllAACoAACniYnzNDrpY2vEi4vhfpDkd4X6AQD74N7lAgDpkI7GEQvJJSjzYmzxkY7XEgz0O0S/IRvQMS7mFhfdHiMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABghghghggAN7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ0bPOAAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAJdJREFUeNptT1sOwiAQ3BGr0vr4aXRR8YlYrc/7H8kzmLhA61cnhMlMZneAqAtI1FOJ+1k2aHgYeKRzXYgz1lrnE0lPIRMAviGEj9zzBbOJZ7lKS9bGCoDZpm1R2+Ds9v/agwqGVa0+SjzCNhrMXDpmIL7wJAW+PFdOanARwxrjrzXRzRlzf4RIFTWRd8UzLXnVif276+c/y8IMeYcYrDYAAAAASUVORK5CYII=" />' +
					'Actualit\351 Measurix !' +
				'</h1>' +
				'<div class="ActuNews" style="margin:15px 0 0 0;padding:0 10px;color:white;font-weight:900;">' +

					'<h2 style="margin:0 auto;color:white;text-align:left;padding-left:10px;">Measurix France pr\351sent au salon BATIMAT 2011</h2>' +
					'<p style="padding:5px 15px 10px 15px;text-align:justify;">' +
						'Measurix France sera pr\351sent au ' +
						'<a onclick="return newTab(this);" href="http://www.batimat.com/">Salon International de la Construction BATIMAT 2011</a> ' +
						'qui se d\351roulera \340 Paris, Porte de Versailles, du 7 au 12 novembre 2011 (Hall 5.1, all\351e B, n\272 27) ' +
						'<a onclick="return newTab(this);" href="http://www.batimat.com/site/FR/Preparer_sa_visite/Plan_du_salon,C2194,I2194.htm">(voir le plan).</a> ' +
						'Vous pouvez obtenir un badge \340 un tarif pr\351f\351rentiel de 25 euros en remplissant ' +
						'<a onclick="return newTab(this);" href="http://www.batimat.com/index.php?Lang=FR&argRedirect=FR|Badge&CodeMkg=PXR001#xtor=AL-12">ce formulaire</a>' +
						'<p style="text-align:center;"><img alt="" src="/resources/img/news/batimat-2011.gif"></p>' +
					'</p>' +

					'<h2 style="margin:0 auto;color:white;text-align:left;padding-left:10px;">Tour de France Circuit</h2>' +
					'<p style="padding:5px 0 10px 15px;text-align:center;">' +
						'<span style="display:inline-block;width:200px;margin:0 2px;">' +
							'<img src="/resources/img/news/circuit-1.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						'</span>' +
						'<span style="display:inline-block;width:200px;margin:0 3px;">' +
							'<img src="/resources/img/news/circuit-2.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						'</span>' +
						'<br/><u>SPA le 6 Octobre :</u>\253 Je tenais \340 vous remercier pour cette journ\351e extraordinaire au circuit de SPA. Vous m\'avez donn\351 une grosse envie d\'essayer le pilotage. \273' +
					'</p>' +
					'<p style="padding:5px 0 10px 15px;text-align:center;">' +
						'<span style="display:inline-block;width:200px;margin:0 3px;">' +
							'<img src="/resources/img/news/circuit-3.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						'</span>' +
						'<span style="display:inline-block;width:200px;margin:0 3px;">' +
							'<img src="/resources/img/news/circuit-4.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						'</span>' +
						'<br/><u>Le Mans le 15 Octobre 2011 :</u> un grand moment sur un circuit mythique' +
					'</p>' +
					'<p style="padding:5px 0 10px 15px;text-align:center;">' +
						'<span style="display:inline-block;width:200px;margin:0 3px;">' +
							'<img src="/resources/img/news/circuit-5.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						'</span>' +
						'<br/><u>Nogaro le 30 Octobre 2011 :</u> pr\351paration du bolide' +
					'</p>' +

				'</div>' +

			'</div>' +
		'</span>' +
	'</td>' +
'</tr></table>';
	$(document.body).insert({top: html});
}
/*
function splash2 () {
	if ($('NewsAd'))
		$('NewsAd').remove();
	var css = {
		table:		'position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;',
		td:			'width:100%;height:100%;margin:0;padding:0;text-align:center;',
		span:			'display:inline-block;width:auto;max-width:800px;height:auto;margin:15px;padding:15px;border:solid red 1px;*width:800px;',
		h1:			'position:relative;height:24px;line-height:24px;margin:0;padding:0;font-size:130%;background-color:red;',
		icon:			'position:absolute;top:0;right:0;margin:1px;padding:3px;background-color:white;cursor:pointer;',
		scroll:		'height:500px;overflow:auto;margin:0;padding:0 15px;border:solid orange 1px;',
		// Elements
		titleH2:		'margin:0 auto;color:white;text-align:left;padding-left:10px;',
		p:				'padding:5px 0 10px 15px;text-align:center;',
		imgSpan:		'display:inline-block;width:200px;margin:0 2px;',
		img:			'display:block;width:100%;cursor:pointer;',
		foo:''
	};

	var tpl = {
		img:	'<span style="'+css.imgSpan+'"><img src="/resources/img/news/#{src}" onclick="return imgFrame(this);" style="'+css.img+'" /></span>',
		news:	'<h2 style="'+css.titleH2+'">#{title}</h2><p style="'+css.p+'">#{data}</p>'
	};
	var news = [
		{	title:	'Tour de France Circuit',
			data:		[
				[{src: 'circuit-1.jpg'}, {src: 'circuit-2.jpg'}].map( function (item) { return tpl.img.interpolate(item); }).join('') +
					'<br/><u>SPA le 6 Octobre :</u>\253 Je tenais \340 vous remercier pour cette journ\351e extraordinaire au circuit de SPA. Vous m\'avez donn\351 une grosse envie d\'essayer le pilotage. \273',
				[{src: 'circuit-3.jpg'}, {src: 'circuit-4.jpg'}].map( function (item) { return tpl.img.interpolate(item); }).join('') +
					'<br/><u>Le Mans le 15 Octobre 2011 :</u> un grand moment sur un circuit mythique',
				tpl.img.interpolate({src: 'circuit-3.jpg'})
			]
		}
	];
	var newsHTML = news.map( function (n) {
		return tpl.news.interpolate({n});
	}).join('');
	var html =
	'<table id="Container" cellpadding="0" cellspacing="0" style="'+css.table+'">' +
		'<tr><td style="'+css.td+'">' +
			'<span id="Centered" style="'+css.span+'">' +
				'<h1 style="'+css.h1+'">' +
					'<img style="'+css.icon+'" onclick="$(\'NewsAd\').remove();" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAADAFBMVEX+/v62AAD87fGYAAD6y9L3c3y4EAwnAAD89PPpQkzoO0X1Q0v2pqhuLEICAADmHSLaFBfjDhDTIR/2hYv4U1yljJA3AAL1DhDHAADWAgHzLDKYiYllAACoAACniYnzNDrpY2vEi4vhfpDkd4X6AQD74N7lAgDpkI7GEQvJJSjzYmzxkY7XEgz0O0S/IRvQMS7mFhfdHiMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABghghghggAN7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ0bPOAAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAJdJREFUeNptT1sOwiAQ3BGr0vr4aXRR8YlYrc/7H8kzmLhA61cnhMlMZneAqAtI1FOJ+1k2aHgYeKRzXYgz1lrnE0lPIRMAviGEj9zzBbOJZ7lKS9bGCoDZpm1R2+Ds9v/agwqGVa0+SjzCNhrMXDpmIL7wJAW+PFdOanARwxrjrzXRzRlzf4RIFTWRd8UzLXnVif276+c/y8IMeYcYrDYAAAAASUVORK5CYII=" />' +
					'Actualité Measurix !' +
				'</h1>' +
				'<div style="'+css.scroll+'">' + newsHTML +
// '					<h2 style="'+css.titleH2+'">Tour de France Circuit</h2>' +
// '					<p style="'+css.p+'">' +
// '						<span style="display:inline-block;width:200px;margin:0 2px;">' +
// '							<img src="/resources/img/news/circuit-1.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
// '						</span>' +
// '						<span style="display:inline-block;width:200px;margin:0 3px;">' +
// '							<img src="/resources/img/news/circuit-2.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
// '						</span>' +
// '						<br/><u>SPA le 6 Octobre :</u>\253 Je tenais \340 vous remercier pour cette journ\351e extraordinaire au circuit de SPA. Vous m\'avez donn\351 une grosse envie d\'essayer le pilotage. \273' +
// '					</p>' +
// '					<p style="padding:5px 0 10px 15px;text-align:center;">' +
// '						<span style="display:inline-block;width:200px;margin:0 3px;">' +
// '							<img src="/resources/img/news/circuit-3.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
// '						</span>' +
// '						<br/><u>Nogaro le 30 Octobre 2011 :</u> pr\351paration du bolide' +
// '					</p>' +
// '					<p style="padding:5px 0 10px 15px;text-align:center;">' +
// '						<span style="display:inline-block;width:200px;margin:0 3px;">' +
// '							<img src="/resources/img/news/circuit-4.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
// '						</span>' +
// '						<span style="display:inline-block;width:200px;margin:0 3px;">' +
// '							<img src="/resources/img/news/circuit-5.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
// '						</span>' +
// '						<br/><u>Le Mans le 15 Octobre 2011 :</u> un grand moment sur un circuit mythique' +
// '					</p>' +

					// '<h2 style="margin:0 auto;color:white;text-align:left;padding-left:10px;">Tour de France Circuit</h2>' +
					// '<p style="padding:5px 0 10px 15px;text-align:center;">' +
						// '<span style="display:inline-block;width:200px;margin:0 2px;">' +
							// '<img src="/resources/img/news/circuit-1.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						// '</span>' +
						// '<span style="display:inline-block;width:200px;margin:0 3px;">' +
							// '<img src="/resources/img/news/circuit-2.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						// '</span>' +
						// '<br/><u>SPA le 6 Octobre :</u>\253 Je tenais à vous remercier pour cette journée extraordinaire au circuit de SPA. Vous m\'avez donné une grosse envie d\'essayer le pilotage. \273' +
					// '</p>' +
					// '<p style="padding:5px 0 10px 15px;text-align:center;">' +
						// '<span style="display:inline-block;width:200px;margin:0 3px;">' +
							// '<img src="/resources/img/news/circuit-3.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						// '</span>' +
						// '<br/><u>Nogaro le 30 Octobre 2011 :</u> préparation du bolide' +
					// '</p>' +
					// '<p style="padding:5px 0 10px 15px;text-align:center;">' +
						// '<span style="display:inline-block;width:200px;margin:0 3px;">' +
							// '<img src="/resources/img/news/circuit-4.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						// '</span>' +
						// '<span style="display:inline-block;width:200px;margin:0 3px;">' +
							// '<img src="/resources/img/news/circuit-5.jpg" onclick="return imgFrame(this);" style="display:block;width:100%;cursor:pointer;" />' +
						// '</span>' +
						// '<br/><u>Le Mans le 15 Octobre 2011 :</u> un grand moment sur un circuit mythique' +
					// '</p>' +
				'</div>' +
			'</span>' +
		'</td></tr>' +
	'</table>';
	$(document.body).insert({top: html});
}
*/
// AJAX TOOLS

var MxAjax = {
	checkResponse: function (res) {
		error = false;
		// response need at least a "ack" field (whether or not result is ok)
		return res instanceof Object && !Object.isUndefined(res.ack);
	},

	request: function (url, settings) {
		settings.method = Object.isUndefined(settings.method) ? 'post' : settings.method;// =  settings.method || 'post' ???????
		if (!Object.isFunction(settings.onSuccess))
			settings.onSuccess = null;
		if (!Object.isFunction(settings.onFailure))
			settings.onFailure = function () {
					alert('Une erreur inconnue est survenue.\n'+
									'Votre session a peut-être expiré.');
			};
		new Ajax.Request(url, settings);
		return false;
	}
};


// Tools

function goTo (url) {
	window.location = url;
}

function log (txt) {
	$('Debug').insert({bottom: getTime()+'. ' + txt + '<br/>'});
}
function getTime () {
	var d = new Date();
	return d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
}

function mxlog (log) {
	if (!Prototype.Browser.IE)
	if (DEBUG) console.log(log);
}
function mxwarn (log) {
	if (!Prototype.Browser.IE)
	if (DEBUG) console.warn(log);
}

