﻿function log(s) {	return; }
function tostr(o) { return ; }

jQuery.fx.interval = 16.67;

// listener functions
myListener = {
	onInit: function(){
		this.position = 0;
		$("#mp3Player")[0].SetVariable("method:setUrl", "ressources/medias/BABY_I_M_YOURS.mp3");
	},
	onUpdate: function(){
		if (this.isPlaying === "true") { $("#playerplay").hide(); $("#playerpause").show(); }
		else { $("#playerplay").show(); $("#playerpause").hide(); }
	}
};
stateTracker = function(obj){
	switch (obj.newstate.toLowerCase()) {
		case "completed": HN.MS.Wave4.hidePopupVideo(); break;
		default:
	}
};
playerReady = function(){
	var playero = $("#popup-video *[name='player1']")[0];
  if (HN.MS.Wave4.cm.read("videoPlayed") >= "1") {
    HN.MS.Wave4.hidePopupVideo();
  }
  else {
    playero.sendEvent("load","HD2-DEF42.mp4");
  }
	playero.addModelListener("state","stateTracker");
	if (HN.MS.Wave4.popupVideoHidden)
		playero.sendEvent("stop");
};

if (!window.HN) HN = window.HN = {};
HN.CookieManager = function(){};
HN.CookieManager.prototype = {
	read: function(name) {
		var arg = name + "=";
		var i = 0;
		while (i < document.cookie.length) {
			var offset = i + arg.length;
			if (document.cookie.substring(i, offset) == arg) {
				var endstr = document.cookie.indexOf (";", offset);
				if (endstr == -1) endstr = document.cookie.length;
				return unescape(document.cookie.substring(offset, endstr));
			}
			i = document.cookie.indexOf(" ",i) + 1;
			if (i == 0) break;
		}
		return null;
	},
	write: function(name, value) {
		var argv = this.write.arguments;
		var argc = this.write.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
		var path = (argc > 3) ? argv[3] : null;
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;
		document.cookie = name + "=" + escape(value) +
			((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
			((path == null) ? "" : ("; path=" + path)) +
			((domain == null) ? "" : ("; domain=" + domain)) +
			((secure == true) ? "; secure" : "");	
	},
	del: function(name) {
		var date = new Date(0);
		this.write(name, null, date);
	}
};
HN.MS = {};
HN.userAgent = navigator.userAgent.toLowerCase();
HN.browser = {
	version: (HN.userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
	safari: /applewebkit/.test( HN.userAgent ) && /safari/.test( HN.userAgent ) && !/chrome/.test( HN.userAgent ),
	chrome: /applewebkit/.test( HN.userAgent ) && /safari/.test( HN.userAgent ) && /chrome/.test( HN.userAgent ),
	opera: /opera/.test( HN.userAgent ),
	msie: /msie/.test( HN.userAgent ) && !/opera/.test( HN.userAgent ),
 	mozilla: /mozilla/.test( HN.userAgent ) && !/(compatible|webkit)/.test( HN.userAgent ),
	firefox: /firefox/.test( HN.userAgent ),
	firefoxVer: (HN.userAgent.match( /.+firefox\/([\d.]+)/ ) || [])[1],
	windows: /windows/.test( HN.userAgent ),
	macintosh: /macintosh/.test( HN.userAgent ),
	windows_xp: /windows nt 5.1/.test( HN.userAgent ),
	windows_vista: /windows nt 6.0/.test( HN.userAgent ),
	windows_seven: /windows nt 6.1/.test( HN.userAgent )
};

// helper for tracking
function MMAT() {
	return HN.MS.Wave4.slides.current().desc;
}

$(function(){ HN.MS.Wave4.init(); });

HN.MS.Wave4 = {
	base_url: "http://www.windowslive.fr/messenger/",
	tips: [],
	slides: null,
	curSlide: 0,
	featureZoneOpened: false,
	animating: false,
	autoSlideTO: null,
	featZoneOpeningTO: null,
	popupVideoHidden: false,
	
	MSN_consentCompleted: false,
	MSN_SignedIn: false,
	
	
	init: function(){
		var me = this;
		var nt6 = HN.browser.windows_vista || HN.browser.windows_seven;
		
		// replace png for gif if ie6
		if (HN.browser.msie && HN.browser.version < 7)
			$("img.has-gif").each(function(){ $(this).attr("src", $(this).attr("src").replace(/\/([^\/]+)\.png$/i,"/gif/$1.gif")); });
		
    if (HN.browser.firefox) $("#sbs-firefox").show();
		else if (HN.browser.chrome) $("#sbs-chrome").show();
		else if (HN.browser.opera) $("#sbs-opera").show();
		else if (HN.browser.safari) $("#sbs-safari").show();
		else $("#sbs-iexplorer").show();
    
		/* Facebook
		***********************************************************************************************************************/
		window.fbAsyncInit = function() {
			FB.init({
				appId : '131487966875768',
				status : true, // check login status
				cookie : true, // enable cookies to allow the server to access the session
				xfbml : false
			});
		};
		var fbScript = document.createElement("script");
		fbScript.src = document.location.protocol+"//connect.facebook.net/fr_FR/all.js";
		fbScript.async = true;
		document.getElementById("fb-root").appendChild(fbScript);
		
		// slides init
		me.slides = new me.slideCollection({
			node: $("#slides")[0],
			transitionSpeed: 2000,
			childDftSettings: {
				"class": "slide",
				"imgClass": "bg-img",
				onShow: function(){
					var speed = 2000;
					if (arguments.length > arguments.callee.length && typeof arguments[0].speed === "number")
						speed = arguments[0].speed;
					var _this = this;
					$(this.node).find("div.hours").fadeIn(speed);
				},
				onAfterShow: function(){
					$(this.node).find("div.hours").appendTo("#feat-zone");
					this.tips.show();
				},
				onBeforeHide: function(){
					var speed = 2000;
					if (arguments.length > arguments.callee.length && typeof arguments[0].speed === "number")
						speed = arguments[0].speed;
					$(this.node).find("img.cross-sell").before($("#feat-zone").find("div.hours"));
					$(this.node).find("div.hours").animate({ opacity: 0.0 }, speed, function(){ $(this).css({ opacity: '', display: "none" }); }); // fadeout bug out, so doing it manually
					this.tips.hide();
				}
			}
		});
		var $slideNodes = $("#slides div.slide");
		me.slides.addSlides([
			{ name: "abdos_fessiers", desc: "Messenger sur Mobile", node: $slideNodes[0], baseWidth: 1417, baseHeight: 920 },
			{ name: "travaux_de_groupe", desc: "Conversation par Onglet", node: $slideNodes[1], baseWidth: 1417, baseHeight: 945 },
			{ name: "diner_bio", desc: "Actu Facebook dans Messenger", node: $slideNodes[2], baseWidth: 1417, baseHeight: 945 },
			{ name: "petit_verre_entre_amis", desc: "Conversation Video HD", node: $slideNodes[3], baseWidth: 1417, baseHeight: 945 },
			{ name: "bureau_flashback", desc: "Diaporama Photos", node: $slideNodes[4], baseWidth: 1417, baseHeight: 945 },
			{ name: "rires_apnee", desc: "Partage de Videos Youtube", node: $slideNodes[5], baseWidth: 1417, baseHeight: 945 }
		]);
		
		// tips init
		var tip_mouseenter = function(s, tipNode, tipTextNode){
			if (s.bgAnim) {
				this.reset();
				var rotation = s.text["class"].indexOf("top") != -1 ? 0.25 : -0.25;
				this.animate(rotation, function(){
					$(tipTextNode).show(500);
				});
			}
			else
				$(tipTextNode).show(500);
		};
		var tip_mouseleave = function(s, tipNode, tipTextNode){
			if (s.bgAnim) {
				var _this = this;
				$(tipTextNode).hide(500, function(){
					_this.reset();
					var rotation = s.text["class"].indexOf("top") != -1 ? -0.25 : 0.25;
					_this.animate(rotation, function(){
						_this.startRandBgAnim();
					});
				});
			}
			else
				$(tipTextNode).hide(500);
		};
		var tip_dft_settings = {
			childDftSettings: {
				"class": "tip-square",
				mouseenter: tip_mouseenter,
				mouseleave: tip_mouseleave,
				text: { "class": "tip-text-bottom", height: "40px" }
			}
		}
		if (HN.browser.msie && HN.browser.version < 7)
			tip_dft_settings.childDftSettings.bgAnim = null;
		me.slides[0].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[0].node } },tip_dft_settings))).addTips([
			{ left: "50%", top: "24%", text: { width: "188px", "class": "tip-text-top", content: "Le saviez-vous ? Nous sommes déjà 22 millions à utiliser Messenger en France. Bienvenue dans notre petit groupe !" } },
			{ left: "38%", top: "45%", text: { width: "180px", "class": "tip-text-top", content: "Le saviez-vous ? En moyenne dans le monde, un utilisateur de Messenger a 60 contacts. Et vous :) ?" } },
			{ left: "65%", top: "70%", text: { width: "185px", content: "Le saviez-vous ? Messenger a vu le jour en juillet 1999. Déjà onze ans que Messenger vous mène à tout !" } }
		]);
		me.slides[1].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[1].node } },tip_dft_settings))).addTips([
			{ left: "74%", top:  "1%", text: { width: "208px", "class": "tip-text-top", content: "Le saviez-vous ? Vous êtes plutôt bavards : en moyenne 9.4 milliards de messages sont échangés chaque jour sur Messenger !" } },
			{ left: "65%", top: "68%", text: { width: "165px", content: "Le saviez-vous ? Amis polyglottes, réjouissez-vous : Messenger est disponible en 48 langues." } },
			{ left: "97%", top: "73%", text: { width: "208px", content: "Le saviez-vous ? Vous pouvez personnali-<br/>ser le son entendu lorsqu’on vous envoie un message instantané." } }
		]);
		me.slides[2].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[2].node } },tip_dft_settings))).addTips([
			{ left: "50%", top: "24%", text: { width: "188px", "class": "tip-text-top", content: "Le saviez-vous ? Nous sommes déjà 22 millions à utiliser Messenger en France. Bienvenue dans notre petit groupe !" } },
			{ left: "38%", top: "45%", text: { width: "180px", "class": "tip-text-top", content: "Le saviez-vous ? En moyenne dans le monde, un utilisateur de Messenger a 60 contacts. Et vous :) ?" } },
			{ left: "65%", top: "70%", text: { width: "185px", content: "Le saviez-vous ? Messenger a vu le jour en juillet 1999. Déjà onze ans que Messenger vous mène à tout !" } }
		]);
		me.slides[3].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[3].node } },tip_dft_settings))).addTips([
			{ left: "74%", top:  "1%", text: { width: "208px", "class": "tip-text-top", content: "Le saviez-vous ? Vous êtes plutôt bavards : en moyenne 9.4 milliards de messages sont échangés chaque jour sur Messenger !" } },
			{ left: "65%", top: "68%", text: { width: "165px", content: "Le saviez-vous ? Amis polyglottes, réjouissez-vous : Messenger est disponible en 48 langues." } },
			{ left: "97%", top: "73%", text: { width: "208px", content: "Le saviez-vous ? Vous pouvez personnali-<br/>ser le son entendu lorsqu’on vous envoie un message instantané." } }
		]);
		me.slides[4].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[4].node } },tip_dft_settings))).addTips([
			{ left: "50%", top: "24%", text: { width: "188px", "class": "tip-text-top", content: "Le saviez-vous ? Nous sommes déjà 22 millions à utiliser Messenger en France. Bienvenue dans notre petit groupe !" } },
			{ left: "38%", top: "45%", text: { width: "180px", "class": "tip-text-top", content: "Le saviez-vous ? En moyenne dans le monde, un utilisateur de Messenger a 60 contacts. Et vous :) ?" } },
			{ left: "65%", top: "70%", text: { width: "185px", content: "Le saviez-vous ? Messenger a vu le jour en juillet 1999. Déjà onze ans que Messenger vous mène à tout !" } }
		]);
		me.slides[5].tips = (new me.tipCollection($.extend(true, { childDftSettings: { parentNode: me.slides[5].node } },tip_dft_settings))).addTips([
			{ left: "74%", top:  "1%", text: { width: "208px", "class": "tip-text-top", content: "Le saviez-vous ? Vous êtes plutôt bavards : en moyenne 9.4 milliards de messages sont échangés chaque jour sur Messenger !" } },
			{ left: "65%", top: "68%", text: { width: "165px", content: "Le saviez-vous ? Amis polyglottes, réjouissez-vous : Messenger est disponible en 48 langues." } },
			{ left: "97%", top: "73%", text: { width: "208px", content: "Le saviez-vous ? Vous pouvez personnali-<br/>ser le son entendu lorsqu’on vous envoie un message instantané." } }
		]);
		
		// feature zone
		$("#feat-zone").find("div.content").mouseenter(function(){ me.openFeatureZone(); }).click(function(){ me.closeFeatureZone(); });
		// open/close feature zone
		$slideNodes.find("div.hour, div.arrow, div.cross")
			.click(function(){ if (!me.featureZoneOpened) me.openFeatureZone(); else me.closeFeatureZone(); })
			.mouseenter(function(){ me.openFeatureZone(); })
		$("#btn-show-friends-news-video").click(function(){
			$("#popup-video2").show();
			(new Image()).src = "http://g.msn.fr/FR1003/2364";
			(new Image()).src = "http://g.msn.fr/FR1003/2367";
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body Link:Voir Demo Actu Facebook';
			s.tl(true,'o','Voir Demo Actu Facebook');
			setTimeout(function(){
				var $playero2 = $("#popup-video2 *[name='player2']");
				if ($playero2.length && $playero2[0].sendEvent)
					$playero2[0].sendEvent("play");
			}, 500);
		});
		
		// next/prev slide
		$("#btn-slide-prev").click(function(){
			clearTimeout(me.featZoneOpeningTO);
			if (me.featureZoneOpened) me.closeFeatureZone(function(){ me.slides.prev(function(){ me.openFeatureZone(); }); });
			else me.slides.prev(function(){
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Navigation:Fleches';
				s.tl(true,'o','Fleches');
				me.showFeatZoneGlimpse();
			});
		});
		$("#btn-slide-next").click(function(){
			clearTimeout(me.featZoneOpeningTO);
			if (me.featureZoneOpened) me.closeFeatureZone(function(){ me.slides.next(function(){ me.openFeatureZone(); }); });
			else me.slides.next(function(){
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Navigation:Fleches';
				s.tl(true,'o','Fleches');
				me.showFeatZoneGlimpse();
			});
		});
		
		// cta init
		if (HN.browser.macintosh) {
			$("#cta-msn-mac7").show().click(function(){
				window.open("http://view.atdmt.com/action/frmmgm_hpgomessengermac_1","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2327";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Sent to Messenger for Mac';
				s.tl(true,'o','Sent to Messenger for Mac');
			});
			$("#cta-new-wlm").hide().click(function(){ // happens only via script, case go=telecharger
				document.location.href = "http://view.atdmt.com/action/frmmgm_hpgomessengermac_1";
				(new Image()).src="http://g.msn.fr/FR1003/2327";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Sent to Messenger for Mac';
				s.tl(true,'o','Sent to Messenger for Mac');
      });
			$("#cta-msn-mobile").click(function(){
				window.open("http://www.messengersurvotremobile.com/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2330";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Sent to Messenger sur votre Mobile';
				s.tl(true,'o','Sent to Messenger sur votre Mobile');
			});
		}
		else if (HN.browser.windows_xp) {
			$("#cta-caption-discover").show();
			$("#cta-caption-dl").hide();
			$("#cta-new-wlm").click(function(){
				$("#popup1, #footer-links-share").show();
				$("#footer-present-text").hide();
				$iframe = $("<iframe src=\"http://view.atdmt.com/action/frmmgm_comparatiftelechargezwave3_1\" width=\"1\" height=\"1\"></iframe>").appendTo("body");
				setTimeout(function(){ $iframe.remove(); }, 5000);
				(new Image()).src="http://view.atdmt.com/action/frmmgm_hpgocomparatif_1";
				(new Image()).src="http://g.msn.fr/FR1003/2328";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Discover Wave 4';
				s.tl(true,'o','Discover Wave 4');
			});
			$("#cta-msn-mobile").click(function(){
				window.open("http://www.messengersurvotremobile.com/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2331";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Sent to Messenger sur votre Mobile';
				s.tl(true,'o','Sent to Messenger sur votre Mobile');
			});
		}
		else {
			$("#cta-new-wlm").click(function(){
				$("#popup-how-to-dl-wlm").show();
				$iframe = $("<iframe src=\"http://clk.atdmt.com/FRM/go/249688759/direct/01/\" width=\"1\" height=\"1\"></iframe>").appendTo("body");
				setTimeout(function(){ $iframe.remove(); }, 5000);
				//document.location.href = "http://clk.atdmt.com/FRM/go/249688759/direct/01/";
				(new Image()).src="http://g.msn.fr/FR1003/2326";
				s.linkTrackVars='events,eVar8,prop8,channel,prop33,prop3,eVar3,eVar33';
				s.linkTrackEvents='event3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA: Download Now (Installer Wave 4)';
				s.events='event3';
				s.tl(true,'e','Download Now (Installer)');
				(new Image()).src="http://g.msn.fr/FR1003/2359";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Step by step:Step by step';
				s.tl(true,'o','Step by step');
			});
			$("#cta-msn-mobile").click(function(){
				window.open("http://www.messengersurvotremobile.com/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2329";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body CTA:Sent to Messenger sur votre Mobile';
				s.tl(true,'o','Sent to Messenger sur votre Mobile');
			});
		}
		if (!HN.browser.msie) {
			$("#cta-light-glow-1, #cta-light-glow-2").fadeIn(5000,function(){ $(this).fadeOut(5000); });
			setInterval(function(){ $("#cta-light-glow-1, #cta-light-glow-2").fadeIn(5000,function(){ $(this).fadeOut(5000); }); }, 11000);
		}
		
    // cross sell
		$slideNodes.find("img.cross-sell").each(function(i){
      switch(i) {
        case 0:
          $(this).click(function(){
            window.open("http://itunes.apple.com/us/app/windows-live-messenger/id376196406?mt=8","_blank");
            if (HN.browser.macintosh) {
				(new Image()).src="http://g.msn.fr/FR1003/2334";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Messenger sur votre Mobile iPhone';
				s.tl(true,'o','Sent to Messenger sur votre Mobile iPhone');
			}
            else if (HN.browser.windows_xp) {
				(new Image()).src="http://g.msn.fr/FR1003/2336";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Messenger sur votre Mobile iPhone';
				s.tl(true,'o','Sent to Messenger sur votre Mobile iPhone');
			}
            else {
				(new Image()).src="http://g.msn.fr/FR1003/2332";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Messenger sur votre Mobile iPhone';
				s.tl(true,'o','Sent to Messenger sur votre Mobile iPhone');
			}
          });
          break;
        case 1:
          if (HN.browser.windows_xp) {
            $(this).attr("src", "ressources/images/cross-sell-actu-out.png").click(function(){
              $("#popup-video3").show();
              setTimeout(function(){
                var $playero3 = $("#popup-video3 *[name='player3']");
                if ($playero3.length && $playero3[0].sendEvent)
                  $playero3[0].sendEvent("play");
              }, 500);
            });
            break;
          }
        case 2:
        case 3:
        case 5:
          $(this).click(function(){
            window.open("http://www.facebook.com/messenger?ref=ts","_blank");
            if (HN.browser.macintosh) {
				(new Image()).src="http://g.msn.fr/FR1003/2335";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Facebook Messenger';
				s.tl(true,'o','Sent to Facebook Messenger');
			}
            else if (HN.browser.windows_xp) {
				(new Image()).src="http://g.msn.fr/FR1003/2337";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Facebook Messenger';
				s.tl(true,'o','Sent to Facebook Messenger');
			}
            else {
				(new Image()).src="http://g.msn.fr/FR1003/2333";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Facebook Messenger';
				s.tl(true,'o','Sent to Facebook Messenger');
			}
          });
          break;
        case 4:
          $(this).click(function(){
            if (HN.browser.macintosh) window.open("http://g.msn.fr/FR1003/2378","_blank");
            else if (HN.browser.windows_xp) window.open("http://g.msn.fr/FR1003/2380","_blank");
            else window.open("http://g.msn.fr/FR1003/2378","_blank");
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Cross-sell CTA:Sent to Live Radio';
			s.tl(true,'o','Sent to Live Radio');
          });
          break;
      }
		});
		
		// footer
		$("#footer-link-popup2").click(function(){
			if (HN.browser.macintosh) {
				(new Image()).src="http://g.msn.fr/FR1003/2339";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Footer Link:Nouveautes';
				s.tl(true,'o','Nouveautes');
			}
			else if (HN.browser.windows_xp) {
				(new Image()).src="http://g.msn.fr/FR1003/2340";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Footer Link:Nouveautes';
				s.tl(true,'o','Nouveautes');
			}
			else {
				(new Image()).src="http://g.msn.fr/FR1003/2338";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Footer Link:Nouveautes';
				s.tl(true,'o','Nouveautes');
			}
			$("#popup2, #footer-links-share").show();
			$("#footer-present-text").hide();
			return false;
		});
		$("#footer-links-share a:first").click(function(){ me.FB_streamPublish("Téléchargez en avant-première la nouvelle version de Windows Live Messenger ! + de réseaux sociaux, + de mobile, + de partage : découvrez plus de 30 nouveautés", function(){ log("stream published !"); }); return false; }); // facebook
		$("#footer-links-share a:last").click(function(){
			if ($.browser.msie) window.open("http://www.messengerpartenlive.com/wlm2011/msn-signin-ie.aspx","wlm_signin_ie","width=170,height=52");
			window.frames["MSN-picker"].location.href = "http://www.messengerpartenlive.com/wlm2011/msn-picker.aspx";
			$("#popup1, #popup2").hide();
			$("#popup-taf").show();
			return false;
		});
		$("map[name='tag-line-map'] area:first").click(function(){ $("#popup-credits").show(); return false; });
		var flasho = $("#mp3Player")[0];
		$("#playerplay").click(function(){
			if (myListener.position == 0 || !myListener.position)
				flasho.SetVariable("method:setUrl", "ressources/medias/BABY_I_M_YOURS.mp3");
			flasho.SetVariable("method:play", "");
			flasho.SetVariable("enabled", "true");
			$("#playerplay").hide();
			$("#playerpause").show();
		});
		$("#playerpause").click(function(){
			flasho.SetVariable("method:pause", "");
			$("#playerplay").show();
			$("#playerpause").hide();
		});
		$("#playerstop").click(function(){
			flasho.SetVariable("method:stop", "");
			$("#playerplay").show();
			$("#playerpause").hide();
		});
		var playero = $("#popup-video *[name='player1']")[0];
		$("#btn-hd-off").click(function(){
			playero.sendEvent("load","HD2-DEF42.mp4");
			$("#btn-hd-on").show();
			$("#btn-hd-off").hide();
			(new Image()).src="http://g.msn.fr/FR1003/2366";
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body Link:Video HD';
			s.tl(true,'o','Video HD');
		});
		$("#btn-hd-on").click(function(){
			playero.sendEvent("load","HD2-DEF43.mp4");
			$("#btn-hd-on").hide();
			$("#btn-hd-off").show();
			(new Image()).src="http://g.msn.fr/FR1003/2365";
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body Link:Video SD';
			s.tl(true,'o','Video SD');
		});
		$("#btn-replay").click(function(){
			me.cm.del("videoPlayed");
			document.location.href="http://www.windowslive.fr/messenger/";
		});
		
		// popup
		$("#popup1")
			.find("a:first").attr("href","http://view.atdmt.com/action/frmmgm_comparatiftelechargezwave3_1").click(function(){
				(new Image()).src="http://g.msn.fr/FR1003/2347";
				s.linkTrackVars='events,eVar8,prop8,channel,prop33,prop3,eVar3,eVar33';
				s.linkTrackEvents='event3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Comparatif Link: Download Now (Installer Wave 3)';
				s.events='event3';
				s.tl(true,'e','Download Now (Installer)');
			}).end()
			.find("a:last").attr("href","http://www.microsoft.com/france/windows/windows-7/").click(function(){
				(new Image()).src="http://g.msn.fr/FR1003/2348";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Comparatif Link:Sent to Windows 7';
				s.tl(true,'o','Sent to Windows 7');
			}).end()
			.find("img.close").click(function(){ $("#popup1, #footer-links-share").hide(); $("#footer-present-text").show(); });
		if (HN.browser.macintosh) {
			$("#popup2 a:first").click(function(){
				window.open("http://view.atdmt.com/action/frmmgm_nouveautesgomessengermac_1","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2343";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link:Sent to Messenger for Mac';
				s.tl(true,'o','Sent to Messenger for Mac');
				return false;
			});
			$("#popup2 a:last").click(function(){
				window.open("http://www.microsoft.com/france/windows/windows-7/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2344";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link:Sent to Windows 7';
				s.tl(true,'o','Sent to Windows 7');
				return false;
			});
		}
		else if (HN.browser.windows_xp) {
			$("#popup2 a:first").click(function(){
				window.open("http://view.atdmt.com/action/frmmgm_nouveautestelechargezwave3_1","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2345";
				s.linkTrackVars='events,eVar8,prop8,channel,prop33,prop3,eVar3,eVar33';
				s.linkTrackEvents='event3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link: Download Now (Installer Wave 3)';
				s.events='event3';
				s.tl(true,'e','Download Now (Installer)');
				return false;
			});
			$("#popup2 a:last").click(function(){
				window.open("http://www.microsoft.com/france/windows/windows-7/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2346";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link:Sent to Windows 7';
				s.tl(true,'o','Sent to Windows 7');
				return false;
			});
		}
		else {
			$("#popup2 a:first").click(function(){
				window.open("http://clk.atdmt.com/FRM/go/249688760/direct/01/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2341";
				s.linkTrackVars='events,eVar8,prop8,channel,prop33,prop3,eVar3,eVar33';
				s.linkTrackEvents='event3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link: Download Now (Installer Wave 4)';
				s.events='event3';
				s.tl(true,'e','Download Now (Installer)');
				return false;
			});
			$("#popup2 a:last").click(function(){
				window.open("http://www.microsoft.com/france/windows/windows-7/","_blank");
				(new Image()).src="http://g.msn.fr/FR1003/2342";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Nouveautes Link:Sent to Windows 7';
				s.tl(true,'o','Sent to Windows 7');
				return false;
			});
		}
		$("#popup2 img.close").click(function(){ $("#popup2, #footer-links-share").hide(); $("#footer-present-text").show(); });
		if (nt6) $("#popup2 p:lt(2)").html("");
		$("#popup-confirmation")
			.find("img.close").click(function(){
				$("#popup-confirmation").hide();
				(new Image()).src = "http://g.msn.fr/FR1003/2372";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Fermeture';
				s.tl(true,'o','Fermeture');
			}).end()
			.find("a:eq(0), a:eq(1)").click(function(){
				(new Image()).src = "http://g.msn.fr/FR1003/2369";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Partage Facebook';
				s.tl(true,'o','Partage Facebook');
				me.FB_streamPublish("Je viens de télécharger la nouvelle version de Windows Live Messenger, il y a plein de nouveautés ! Découvrez-les sur www.messenger.fr !", function(){ log("stream published !"); });
				return false;
			}).end()
			.find("a:eq(2), a:eq(3)").click(function(){
				if ($.browser.msie) window.open("http://www.messengerpartenlive.com/wlm2011/msn-signin-ie.aspx","wlm_signin_ie","width=170,height=52");
				window.frames["MSN-picker"].location.href = "http://www.messengerpartenlive.com/wlm2011/msn-picker.aspx";
				$("#popup-confirmation").hide();
				$("#popup-taf").show();
				(new Image()).src = "http://g.msn.fr/FR1003/2370";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Partage Messenger';
				s.tl(true,'o','Partage Messenger');
				return false;
			}).end()
			.find("a:eq(4)").click(function(){
				(new Image()).src = "http://g.msn.fr/FR1003/2371";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Changer Statut Messenger';
				s.tl(true,'o','Changer Statut Messenger');
			}).end()
			.find("td.block area")
				.eq(0).click(function(){
					window.open(this.href, "_blank");
					s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
					s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Creez';
					s.tl(true,'o','Creez');
					return false;
				}).end()
				.eq(1).click(function(){
					window.open(this.href, "_blank");
					s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
					s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Decouvrez';
					s.tl(true,'o','Decouvrez');
					return false;
				}).end()
				.eq(2).click(function(){
					window.open(this.href, "_blank");
					s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
					s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Telechargez';
					s.tl(true,'o','Telechargez');
					return false;
				});
		$("#popup-taf img.close").click(function(){ $("#popup1, #popup2, #popup-taf, #footer-links-share").hide(); $("#footer-present-text").show(); });
		$("#popup-how-to-dl-wlm img.close").click(function(){ $("#popup-how-to-dl-wlm").hide(); });
		$("#popup-credits img.close").click(function(){ $("#popup-credits").hide(); });
		$("#popup-video div.skip-video").click(function(){
			me.hidePopupVideo();
			(new Image()).src = "http://g.msn.fr/FR1003/2362";
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body Link:Video Skip';
			s.tl(true,'o','Video Skip');
		});
		$("#popup-video2 img.close").click(function(){
			var $playero2 = $("#popup-video2 *[name='player2']");
			if ($playero2.length && $playero2[0].sendEvent)
				$playero2[0].sendEvent("stop");
			$("#popup-video2").hide();
		});
		$("#popup-video3 img.close").click(function(){
			var $playero3 = $("#popup-video3 *[name='player3']");
			if ($playero3.length && $playero3[0].sendEvent)
				$playero3[0].sendEvent("stop");
			$("#popup-video3").hide();
		});
		$("#popup-video-bing").find("a").each(function(i){
			var $playerObing = $("#popup-video-bing *[name='player_bing']");
			$(this).click(function(){ $playerObing[0].sendEvent("ITEM", i); return false; });
		}).end().find("img.close").click(function(){
			var $playerObing = $("#popup-video-bing *[name='player_bing']");
			if ($playerObing.length && $playerObing[0].sendEvent)
				$playerObing[0].sendEvent("stop");
			$("#popup-video-bing").hide();
		});
		
		// disable selection
		$("#wrapper").mousedown(function(){ return false; });
		
		// window resize handler
		$(window).resize(function(){
			var win_width = $(window).width();
			var win_height = $(window).height();
			me.slides.each(function(){ this.resize(win_width, win_height); });
			$("#slides").width(win_width).height(win_height);
			$("#popup1").width(win_width-52).height(win_height-258);
			$("#popup1 div.what-changed").height(win_height-380);
			$("#popup2").width(win_width-52).height(win_height-128);
			$("#popup2 div.whatsnew").height(win_height-(nt6?205:265));
			//$("#popup-confirmation").width(win_width-52).height(win_height-128);
		}).resize();
		
		// init slide
		var goto_slide = 0;
		var queryUrl = window.location.search.substr(1, window.location.search.length);
		var params = {};
		var msgParts = queryUrl.split("&");
		for (var i=0; i < msgParts.length; i++) {
			var param = msgParts[i].split("=");
			params[param[0]] = param[1];
		}
		if (params.go) {
			if (params.go == "xp") {
				$("#footer-present-text").hide();
				$("#popup1, #footer-links-share").show();
			}
			else if (params.go == "new") {
				$("#footer-present-text").hide();
				$("#popup2, #footer-links-share").show();
			}
			else if (params.go == "confirmation") {
				(new Image()).src = "http://view.atdmt.com/jaction/frmmgm_confinstallationwave4_1";
				(new Image()).src = "http://g.msn.fr/FR1003/2368";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Confirmation:Ouverture';
				s.tl(true,'o','Ouverture');
				$("#footer-present-text").hide();
				$("#popup-confirmation, #footer-links-share").show();
			}
			else if (params.go == "bing") {
				(new Image()).src = "http://go.microsoft.com/fwlink/?LinkID=206968&clcid=0x80c";
				s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
				s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Popup Bing Panel:Ouverture';
				s.tl(true,'o','Ouverture');
				$("#popup-video-bing").show();
			}
      else if (params.go == "telecharger") {
        if ($("#sbs-iexplorer").css("display") != "none") { // if ie popup will be shown, change it
          $("#sbs-iexplorer").hide();
          $("#sbs-iexplorer-auto").show();
        }
        setTimeout(function(){ $("#cta-new-wlm").click(); }, 1000);
      }
			else {
				params.go = parseInt(params.go);
				if (!isNaN(params.go) && params.go >= 1 && params.go <= 6)
				goto_slide = params.go-1;
			}
			me.hidePopupVideo();
		}
		
		if (!me.popupVideoHidden) {
			(new Image()).src="http://g.msn.fr/FR1003/2365";
			s.linkTrackVars='eVar8,prop8,channel,prop33,prop3';
			s.prop8=s.eVar8='WL:fr-fr:Windowslive:Messenger:Messenger Mene a Tout:'+MMAT()+':'+'Body Link:Video SD';
			s.tl(true,'o','Video SD');
		}
		
		me.slides.current().show({ speed: 0 }).afterShow({ speed: 0 });
		if (goto_slide)
			me.slides.goto(goto_slide,1);
		
		// rollover init (slow, so done at the very end)
		$(".ro-h").each(function(){ me.initURO(this, "over"); });
		$(".ro-d").each(function(){ me.initURO(this, "down"); });
		
	},
	
	openFeatureZone: function(){
		var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
		var me = this;
		if (!me.featureZoneOpened && !me.animating) {
			me.animating = true;
			me.featureZoneOpened = true;
			$("#slides, #feat-zone").find("div.arrow").fadeOut(750,function(){ $(this).hide(); }).end().find("div.bg-black").fadeIn(750).end().find("div.hours").animate({ left: 345 }, 750);
			$("#feat-zone").find("div.content").animate({ left: 0 }, 750, function(){ for (var k=0;k<cb.length;k++) cb[k].apply(this, p); });
			$("#feat-zone-slide-"+me.slides.pos()).show().animate({ left: 0 }, 750);
			setTimeout(function(){ $("#slides, #feat-zone").find("div.cross").fadeIn(600, function(){ me.animating = false; }); }, 150);
		}
	},
	closeFeatureZone: function(){
		var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
		var me = this;
		if (me.featureZoneOpened && !me.animating) {
			me.animating = true;
			me.featureZoneOpened = false;
			$("#slides, #feat-zone").find("div.cross").fadeOut(750,function(){ $(this).hide(); }).end().find("div.bg-black").fadeOut(750, function(){ $(this).hide(); }).end().find("div.hours").animate({ left: 23 }, 750);
			$("#feat-zone").find("div.content").animate({ left: -322 }, 750, function(){ for (var k=0;k<cb.length;k++) cb[k].apply(this, p); });
			$("#feat-zone-slide-"+me.slides.pos()).animate({ left: -100 }, 750, function(){ $(this).hide() });;
			setTimeout(function(){ $("#slides, #feat-zone").find("div.arrow").fadeIn(600, function(){ me.animating = false; }); }, 150);
		}
	},
	hidePopupVideo: function(){
		var me = this;
		me.popupVideoHidden = true;
		var $playero = $("#popup-video *[name='player1']");
		if ($playero.length && $playero[0].sendEvent)
			$playero[0].sendEvent("stop");
		$("#popup-video").hide();
		$("#hd").hide();
		$("#mp3").show();
		me.cm.write("videoPlayed", "1", new Date(~(1<<31)*1000));
		// auto open feature zone at start
		me.showFeatZoneGlimpse();
		// document click/mousemove handler
		$(document).mousemove(function(){ me.startAutoSlide(); }).click(function(){ me.startAutoSlide(); });
		// auto slide if no activity for xx s
		me.startAutoSlide();

	},
	showFeatZoneGlimpse: function(){
		var me = this;
		clearTimeout(me.featZoneOpeningTO);
		me.featZoneOpeningTO = setTimeout(function(){
			me.openFeatureZone(function(){
				setTimeout(function(){ me.closeFeatureZone(); },250);
			});
		}, 3000);
	},
	startAutoSlide: function(){
		var me = this;
		clearInterval(me.autoSlideTO);
		me.autoSlideTO = setInterval(function(){{ $("#btn-slide-next").click(); }}, 18000);
	},
	
	// universal rollover init
	initURO: function (elem) {
		var $elem = $(elem);
		var outUrl;
		if (!$elem.data("state")) {
			if ($elem.is("img")) {
				outUrl = $elem.attr("src");
				$elem.data("showState", function(state){
					if ($elem.data("state-"+state)) {
						$elem.data("state", state);
						$elem.attr("src", $elem.data("state-"+state));
					}
					else {
						$elem.data("state", "out");
						$elem.attr("src", $elem.data("state-out"));
					}
				});
			}
			else {
				outUrl = $elem.css("backgroundImage");
				$elem.data("showState", function(state){
					if ($elem.data("state-"+state)) {
						$elem.data("state", state);
						$elem.css("backgroundImage", $elem.data("state-"+state));
					}
					else {
						$elem.data("state", "out");
						$elem.css("backgroundImage", $elem.data("state-out"));
					}
				});
			}
			$elem.data("state-out", outUrl);
			$elem.data("state", "out");
		}
		else {
			outUrl = $elem.data("state-out");
		}
		
		if (arguments.length > arguments.callee.length) {
			var state = arguments[arguments.callee.length];
			var stateUrl = outUrl.replace(/\-out\.([^\.]*)$/i,"-"+state+".$1");
			if ($elem.is("img")) // preload img
				(new Image()).src = stateUrl;
			else
				(new Image()).src = stateUrl.replace(/^url\("?([^"]+)"?\)$/,"$1");
			$elem.data("state-"+state, stateUrl);
			switch(state){
				case "over": $elem.mouseenter(function(){ $elem.data("showState")("over"); }).mouseleave(function(){ $elem.data("showState")("out"); }); break;
				case "down": $elem.mousedown(function(){ $elem.data("showState")("down"); }).mouseup(function(){ $elem.data("showState")("over"); }); break;
			}
		}
	},
	
	// objects
	slideCollection: function(_settings){
		var _this = this;
		// dft settings
		this.node = null;
		this.transition = "slide";
		this.transitionSpeed = 1000;
		this.easing = "linear";
		this.childDftSettings = {};
		$.extend(true, this, _settings); // get settings
		
		// no dom node = stop
		if (!this.node || this.node.nodeType != 1) return false;
		// dft parentNode of children = current collection node
		if (!this.childDftSettings.parentNode || this.childDftSettings.parentNode != 1) this.childDftSettings.parentNode = this.node;
		
		// private vars
		var curPos = 0;
		
		//public vars
		this.length = 0;
		this.animating = false;
		
		//public functions
		this.addSlides = function(slides){
			if ($.isArray(slides)) for(var k=0,km=slides.length; k<km; k++) this.addSlide(slides[k]);
			else this.addSlide(slides);
			return this;
		};
		this.addSlide = function(slide){
			if (typeof slide == "object") {
				if ($.isPlainObject(slide)) slide = new HN.MS.Wave4.slide($.extend(true, {}, this.childDftSettings, slide));
				this[this.length++] = slide;
			}
			return this;
		};
		this.current = function(){
			return this[curPos];
		};
		this.pos = function(){
			return curPos;
		};
		this.goto = function(pos){
			log("goto");
			if (!this.animating) {
				var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
				var prevPos = curPos;
				curPos = pos % this.length; // always >=0 & <len
				var speed = (p[0] && !isNaN(p[0]=parseInt(p[0]))) ? p[0] : this.transitionSpeed;
				if (prevPos != curPos) {
					this[curPos].beforeShow({ speed: speed });
					$(this[curPos].node).css({ left: "-100%" }).appendTo(this.node);
					this[curPos].show({ speed: speed });
					this[prevPos].beforeHide({ speed: speed });
					this.animating = true;
					$(this[curPos].node).animate({ left: "0%" }, speed, function(){
						_this.animating = false;
						_this[curPos].afterShow({ speed: speed });
						_this[prevPos].hide({ speed: speed });
						_this[prevPos].afterHide({ speed: speed });
						for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
					});
				}
				return this[curPos];
			}
			else
				return false;
		};
		this.next = function(){
			if (!this.animating) {
				var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
				var prevPos = curPos;
				curPos = (curPos+1) % this.length; // always >=0 & <len
				var speed = (p[0] && !isNaN(p[0]=parseInt(p[0]))) ? p[0] : this.transitionSpeed;
				this[curPos].beforeShow({ speed: speed });
				$(this[curPos].node).css({ left: "-100%" }).appendTo(this.node);
				this[curPos].show({ speed: speed });
				this[prevPos].beforeHide({ speed: speed });
				this.animating = true;
				$(this[curPos].node).animate({ left: "0%" }, speed, function(){
					_this.animating = false;
					_this[curPos].afterShow({ speed: speed });
					_this[prevPos].hide({ speed: speed });
					_this[prevPos].afterHide({ speed: speed });
					for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
				});
				return this[curPos];
			}
			else
				return false;
		};
		this.prev = function(){
			if (!this.animating) {
				var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
				var prevPos = curPos;
				curPos = (curPos-1+this.length) % this.length; // always >=0 & <len
				//if (curPos > prevPos) // we have to slide between the first and the last slide
				//	this.node.insertBefore(this[curPos].node, this[prevPos].node); // making some node swapping to achieve this
				var speed = (p[0] && !isNaN(p[0]=parseInt(p[0]))) ? p[0] : this.transitionSpeed;
				this[curPos].beforeShow({ speed: speed });
				$(this[curPos].node).css({ left: "-100%" }).appendTo(this.node);
				this[curPos].show({ speed: speed });
				this[prevPos].beforeHide({ speed: speed });
				this.animating = true;
				$(this[curPos].node).animate({ left: "0%" }, speed, function(){
					_this.animating = false;
					_this[curPos].afterShow({ speed: speed });
					_this[prevPos].hide({ speed: speed });
					_this[prevPos].afterHide({ speed: speed });
					for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
				});
				return this[curPos];
			}
			else
				return false;
		};
		this.each = function(func){
			if (!$.isFunction(func)) return false;
			for (var k=0,km=this.length; k<km; k++)
				func.call(this[k],k);
		};
	},
	slide: function(_settings){
		var _this = this;
		// dft settings
		this.node = null;
		this.parentNode = null;
		this.imgNode = null;
		this.name = "";
		this.baseWidth = 1417;
		this.baseHeight = 945;
		this.minZoom = 1;
		this.maxZoom = 2;
		this.onShow = this.onHide = null;
		this.tips = null;
		
		$.extend(true, this, _settings); // get settings
		
		// create dom node if not specified
		if (!this.node || this.node.nodeType != 1) { // no dom node
			if (!this.parentNode || this.parentNode.nodeType != 1) return false; // no parent either -> can't create
			this.node = document.createElement("div");
			this.node.className = this["class"] || "";
			this.parentNode.appendChild(this.node);
		}
		
		// create img node if not specified
		if (!this.imgNode || this.imgNode.nodeType != 1 || this.imgNode.nodeName.toUpperCase() != "IMG") {
			this.imgNode = document.createElement("img");
			this.imgNode.className = this["imgClass"] || "";
			this.imgNode.alt = this.name;
			$(this.node).prepend(this.imgNode);
		}
		
		// public vars
		this.baseRatio = this.baseWidth/this.baseHeight;
		this.width = this.baseWidth;
		this.height = this.baseHeight;
		this.ratio = this.baseWidth / this.baseHeight;
		this.minWidth = this.width*this.minZoom;
		this.minHeight = this.height*this.minZoom;
		this.maxWidth = this.width*this.maxZoom;
		this.maxHeight = this.height*this.maxZoom;
		this.imgUrl = HN.MS.Wave4.base_url+"ressources/images/bg/"+this.name+".jpg";
		this.imgNode.src = "";
		this.imgNode.src = this.imgUrl;
		this.visible = false;
		
		// event functions
		//$(this.imgNode).load(function(){ onImgLoad(); });
		
		// public functions
		this.resize = function(width, height){
			this.ratio = width/height;
			if (this.ratio >= this.baseRatio) {
				this.width = width < this.minWidth ? this.minWidth : width > this.maxWidth ? this.maxWidth : width;
				this.height = this.width/this.baseRatio;
			}
			else {
				this.height = height < this.minHeight ? this.minHeight : height > this.maxHeight ?this.maxHeight : height;
				this.width = this.height*this.baseRatio;
			}
			if (this.visible) this.redraw();
			return this;
		};
		this.redraw = function(){
			$(this.imgNode).width(this.width).height(this.height);
			return this;
		};
		
		this.beforeShow = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//log(_this.name+" onBeforeShow");
			if ($.isFunction(this.onBeforeShow)) this.onBeforeShow.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
		this.show = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//if (!this.beforeShowDone) this.beforeShow();
			//log(this.name+" show start");
			$(this.node).show();
			this.redraw();
			this.visible = true;
			if ($.isFunction(this.onShow)) this.onShow.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
		this.afterShow = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//log(_this.name+" onAfterShow");
			if ($.isFunction(this.onAfterShow)) this.onAfterShow.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
		
		this.beforeHide = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//log(_this.name+" onBeforeHide");
			if ($.isFunction(this.onBeforeHide)) this.onBeforeHide.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
		this.hide = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//log(this.name+" hide start");
			$(this.node).hide();
			this.visible = false;
			if ($.isFunction(this.onHide)) this.onHide.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
		this.afterHide = function(){
			var cb=[],p=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);else p.push(a_[k]);
			//log(_this.name+" onAfterHide");
			if ($.isFunction(this.onAfterHide)) this.onAfterHide.apply(this, p);
			for (var k=0;k<cb.length;k++) cb[k].apply(this, p);
			return this;
		};
	},
	tipCollection: function(_settings){
		var _this = this;
		this.childDftSettings = {};
		$.extend(true, this, _settings); // get settings
		
		var current = 0;
		this.length = 0;
		this.addTips = function(tips){
			if ($.isArray(tips)) for(var k=0,km=tips.length; k<km; k++) this.addTip(tips[k]);
			else this.addTip(tips);
			return this;
		};
		this.addTip = function(tip){
			if (typeof tip == "object") {
				if ($.isPlainObject(tip)) tip = new HN.MS.Wave4.tip($.extend(true, {}, this.childDftSettings, tip));
				this[this.length++] = tip;
			}
			return this;
		};
		this.current = function(){
			return this[current];
		};
		this.next = function(){
			return current < this.length-1 ? this[++current] : false;
		};
		this.prev = function(){
			return current ? this[--current] : false;
		};
		this.show = function(){ log("show tips"); };
		this.hide = function(){ log("hide tips"); };
	},
	tip: function(_settings){
		// private vars
		var _this = this;
		var intervalTimeout;
		var bgAnimInterval;
		var randBgAnimStopped = false;
		var s = {
			parentNode: null,
			"class": "tip",
			width: 19,
			height: 19,
			left: 0,
			top: 0,
			text: {
				content: "",
				"class": "",
				width: "",
				height: ""
			},
			mouseenter: null,
			mouseleave: null,
			bgAnim: {
				steps: 40, // number of different steps in the image used
				lineSteps: 10, // number of steps per line in the image
				minE: 3, // minimum execution count per interval
				maxE: 5, // max,
				onlyComplete: true, // only execute complete animation (no partial)
				way: "random", // shift image forward/backward/random
				minI: 3000, // minimum interval between 2 set of animations
				maxI: 6000, // max
				frameInterval: 17,
				stepPerFrame: 1
			}
		};
		$.extend(true, s, _settings);
		
		// tip node
		var tipNode;
		if (s.node && s.node.nodeType == 1)
			tipNode = s.node;
		else { // no dom node -> create one
			if (!s.parentNode || s.parentNode.nodeType != 1) return false; // no parent -> can't create
			tipNode = document.createElement("div");
			tipNode.className = s["class"];
			s.parentNode.appendChild(tipNode);
		}
		tipNode.style.left = s.left;
		tipNode.style.top = s.top;
		
		// tip text node
		var tipTextNode = document.createElement("div");
		tipTextNode.innerHTML = s.text.content;
		tipTextNode.className = s.text["class"];
		tipTextNode.style.width = s.text.width;
		tipTextNode.style.height = s.text.height;
		tipNode.appendChild(tipTextNode);
		
		// public vars
		this.curStep = 0;
		
		// event functions
		//$(tipNode).mousedown(function(){ return false; }); // disable selection
		if (s.mouseenter) $(tipNode).mouseenter(function(){ s.mouseenter.apply(_this, [s, tipNode, tipTextNode]); })
		if (s.mouseleave) $(tipNode).mouseleave(function(){ s.mouseleave.apply(_this, [s, tipNode, tipTextNode]); })
		
		// private functions
		this.animate = function(count){
			var cb=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);
			var steps = Math.round(Math.abs(count*s.bgAnim.steps));
			var frameInterval = s.bgAnim.frameRate ? Math.round(1000/s.bgAnim.frameRate) : s.bgAnim.frameInterval;
			var stepOffset = s.bgAnim.stepPerFrame * (count > 0 ? 1 : -1);
			//log("animate "+count+" times / steps="+steps+" / frameInterval="+frameInterval);
			
			bgAnimInterval = setInterval(function(){
				_this.curStep = (_this.curStep + stepOffset + s.bgAnim.steps) % s.bgAnim.steps; // curStep is always >= 0
				var posX = - (_this.curStep % s.bgAnim.lineSteps) * s.width;
				var posY = - Math.floor(_this.curStep / s.bgAnim.lineSteps) * s.height;
				//log("step="+steps+" "+posX+"px "+posY+"px");
				tipNode.style.backgroundPosition = posX+"px "+posY+"px";
				steps--;
				if (!steps) {
					//log("bg animation complete !");
					clearInterval(bgAnimInterval);
					for (var k=0;k<cb.length;k++) cb[k]();
				}
			}, frameInterval);
		};
		
		// public functions
		this.queueRandBgAnim = function(){
			//log("queue random bg animation");
			if (!randBgAnimStopped) {
				intervalTimeout = setTimeout(function(){
					var bgAnimCount = s.bgAnim.minE + Math.random() * (s.bgAnim.maxE - s.bgAnim.minE);
					switch (s.bgAnim.way) {
						case "random": bgAnimCount *= (Math.random()>0.5?1:-1); break;
						case "backward": bgAnimCount *= -1; break;
						case "forward":
						default: bgAnimCount *= 1;
					}
					if (s.bgAnim.onlyComplete)
						bgAnimCount = Math.round(bgAnimCount);
					_this.animate(bgAnimCount, function(){ _this.queueRandBgAnim(); });
				}, s.bgAnim.minI + Math.random() * (s.bgAnim.maxI - s.bgAnim.minI));
			}
		};
		this.startRandBgAnim = function(){
			//log("start random bg animation");
			randBgAnimStopped = false;
			this.queueRandBgAnim();
		};
		this.stopRandBgAnim = function(stopCurAnim){
			//log("stop random bg animation");
			clearTimeout(intervalTimeout);
			randBgAnimStopped = true;
			if (stopCurAnim)
				clearInterval(bgAnimInterval);
		};
		this.reset = function(){
			tipNode.style.left = s.left;
			tipNode.style.top = s.top;
			this.curStep = 0;
			this.stopRandBgAnim(true);
			//if (s.bgAnim)
			//	this.startRandBgAnim();
		};
		
		// init
		if (s.bgAnim) this.startRandBgAnim();
		
	},
	
	// Facebook functions
	FB_getLoginStatus: function(){
		var cb=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);
		var me = this;
		FB.getLoginStatus(function(response) {
			if (response.session) {
				log("logged in");
				for (var k=0;k<cb.length;k++) cb[k]();
			} else {
				log("not logged in");
				FB.login(function(response) {
					if (response.session) {
						log("user successfully logged in");
						for (var k=0;k<cb.length;k++) cb[k]();
					} else {
						log("user cancelled login");
					}
				});
			}
		});
	},
	FB_streamPublish: function(msg){
		var cb=[],a_=arguments;for(var k=a_.callee.length;k<a_.length;k++)if(typeof(a_[k])=="function")cb.push(a_[k]);
		var me = this;
		
		log("checking if user is logged on FB...");
		me.FB_getLoginStatus(function(){
			log("publishing stream...");
			FB.ui({
					method: "stream.publish",
					message: msg
					/*attachment: {
						name: "Wave 4 name",
						caption: "Wave 4 caption",
						href: ""
					}*/
				},
				function(response) {
					if (response && response.post_id) {
						log("Post was published.");
						for (var k=0;k<cb.length;k++) cb[k]();
					} else {
						log("Post was not published.");
					}
				}
			);
		});
	}
}

HN.MS.Wave4.cm = new HN.CookieManager(); // cookie manager, loaded here to be directly operational 

