document.observe("dom:loaded", function() {
	  // initially hide all containers for tab content
	 mustLaunch = 0;
	 mustLaunchFlash = 0;
	 var mustLaunchVideo = 0;
	  
	 theDate =new Date();
	 var iDate =  parseInt(theDate.getFullYear() * 10000 + ((theDate.getMonth()+1)*100) + theDate.getDate()) ;
	 //Crack the Code 08/06/2009
	  if (theDate.getDay() == '8'
		  && (theDate.getDate()+1) == '6'
		  && theDate.getFullYear() == '2009' 
		  && (document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
		 ) {
		  backgrounColor = '#000000';
		  habillageImageUrl = '/design/virginradio/images/habillage/crack/crack_the_code-2.jpg';
		  habillageUrl = 'http://www.virginradio.fr/radio/crack-the-code';
		  habillageTitle = 'Crack the code';
		  mustLaunch = 1;
	  }
	  
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate > 20090701 && iDate < 20090703)
	  ) {
		  backgrounColor = '#000000';
		  habillageImageUrl = 'http://video.premiere.fr/musique/pub/moby/moby_hp.jpg';
		  habillageUrl = 'http://www.virginradio.fr/antenne/Emissions/MOBY';
		  habillageTitle = 'Moby';
		  mustLaunch = 1;
	  }	
	  
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate == 20090703)
	  ) {
		  backgrounColor = '#FFFFFF';
		  habillageImageUrl = 'http://video.premiere.fr/musique/pub/wilkinson/fond_site_3.jpg';
		  FlashLeftUrl = 'http://video.premiere.fr/musique/pub/wilkinson/left_0307.swf';
		  FlashTopUrl = 'http://video.premiere.fr/musique/pub/wilkinson/top_0307.swf';
		  FlashRightUrl = 'http://video.premiere.fr/musique/pub/wilkinson/right_0307.swf';
		  habillageTitle = 'Wilkinson';
		  mustLaunchFlash = 1;
	  }	
	  
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate > 20090703 && iDate < 20090708)
	  ) {
		  backgrounColor = '#000000';
		  habillageImageUrl = 'http://video.premiere.fr/musique/pub/mainsquare/main_square_vradio.jpg';
		  habillageUrl = 'http://www.virginradio.fr/festival/main-square-festival';
		  habillageTitle = 'Main Square Festival';
		  mustLaunch = 1;
	  }	
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate === 20090709)
	  ) {
		  backgrounColor = '#FFFFFF';
		  habillageImageUrl = 'http://video.premiere.fr/musique/pub/wilkinson/fond_site_3.jpg';
		  FlashLeftUrl = 'http://video.premiere.fr/musique/pub/wilkinson/left_0907.swf';
		  FlashTopUrl = 'http://video.premiere.fr/musique/pub/wilkinson/top_0907.swf';
		  FlashRightUrl = 'http://video.premiere.fr/musique/pub/wilkinson/right_0907.swf';
		  habillageTitle = 'Wilkinson';
		  mustLaunchFlash = 1;
	  }	
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate == 20090922)
	  ) {
		  backgrounColor = '#990000';
		  habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/popjob/VRadio/fond.jpg';
		  FlashLeftUrl = 'http://video.premiere.fr/premiere/publicite/habillage/popjob/VRadio/habillage_G_100x700.swf';
		  FlashTopUrl = 'http://video.premiere.fr/premiere/publicite/habillage/popjob/VRadio/habillage_centre_1017x130.swf';
		  FlashRightUrl = 'http://video.premiere.fr/premiere/publicite/habillage/popjob/VRadio/habillage_D_100x700.swf';
		  habillageTitle = 'PopJob';
		  mustLaunchFlash = 1;
	  }
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate == 20090914 || iDate == 20090917 || iDate == 20090921 || iDate == 20090925 || iDate == 20090928)
	  ) {
		  backgrounColor = '#000000';
		  habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/op%20U2_guillon/hab_virginradio_guillon.jpg';
		  habillageUrl = 'http://www.virginradio.fr/evenements/Agenda/Evenements/Dossiers-speciaux/Partez-a-la-rencontre-de-U2-!';
		  habillageTitle = 'Partez à la rencontre de U2 !';
		  mustLaunch = 1;
	  }
	  
	  
	  if ((document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				&& (iDate === 20090918)
	  ) {
		  backgrounColor = '#000000';
		  habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/Next/hab_VRadio/fond.jpg';
		  FlashLeftUrl = 'http://video.premiere.fr/premiere/publicite/habillage/Next/hab_VRadio/habillage_G_100x700.swf';
		  FlashTopUrl = 'http://video.premiere.fr/premiere/publicite/habillage/Next/hab_VRadio/habillage_centre_1017x130.swf';
		  FlashRightUrl = 'http://video.premiere.fr/premiere/publicite/habillage/Next/hab_VRadio/habillage_D_100x700.swf';
		  habillageTitle = 'Next Made in France';
		  mustLaunchFlash = 1;
	  }
	  
	  
	  if (
			 (document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
			  && (iDate == 20100114 )
	  ) {
		  var backgrounColor = '#A29A86';
		  //habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/V17_ChanteSiTuPeux/fd_chantesitupeux.jpg';
		  

			  

		  var habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/muse/fond_muse.jpg';
		  var FlashUrl = 'http://video.premiere.fr/premiere/publicite/habillage/muse/muse_resistance.swf';
		  var RedirUrl = 'http://www.virginradio.fr/musique/videos/Resistance-integralite';
		  
		  var ForceParams = new Array();
		  ForceParams['width'] = 290;
		  ForceParams['height'] = 217;
		  ForceParams['top'] = -204;
		  ForceParams['left'] = 710;
		  
		  var habillageTitle = 'Le dernier clip de Muse en EXCLU sur virginradio.fr';
		  mustLaunchVideo = 1;
	  }
	  
	  if (
				 (document.location.href=='http://dev.virginradio.fr/' || document.location.href=='http://www.virginradio.fr/' || document.location.href=='http://test.virginradio.fr/')
				  && (iDate == 20100127 || iDate == 20100128 )
		  ) {
			  var backgrounColor = '#000000';

			  var habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/habillage/V17_24h_chrono/VRadio/fond_24h.jpg';
			  var FlashUrl = 'http://video.premiere.fr/premiere/publicite/habillage/V17_24h_chrono/VRadio/24H_994x245.swf';
			  var RedirUrl = 'http://www.virgin17.fr/Programmes/Emissions-Series/Serie-24h';
			  
			  var ForceParams = new Array();
			  ForceParams['width'] = '994';
			  ForceParams['height'] = '245';
			  ForceParams['top'] = '-213';
			  ForceParams['left'] = '0';
			  
			  var bHref = false;
			  
			  var habillageTitle = '24H Chrono sur Virgin 17';
			  mustLaunchVideo = 1;
		  }
	  
	  
	  if (mustLaunch == 1) {
		  launchHabillage( backgrounColor, habillageImageUrl, habillageUrl, habillageTitle);
	  }
	  
	  if (mustLaunchFlash == 1) {
		  launchHabillageFlash( backgrounColor, habillageImageUrl, FlashLeftUrl, FlashTopUrl, FlashRightUrl, habillageTitle);
	  }
	  
	  if (mustLaunchVideo == 1) {
		  launchHabillageVideo(  backgrounColor, habillageImageUrl, FlashUrl, habillageTitle, RedirUrl, ForceParams, bHref);
	  }
	  
	});


/*
backgrounColor = '#8DD3F1';'
habillageImageUrl = 'http://video.premiere.fr/premiere/publicite/virginradio/hab_virginradio_essilor_v2.jpg\';
habillageUrl = 'http://fr.a2dfp.net/c?i2as_s=4675&i2as_ad=16923&i2as_rd=2046198558';
habillageTitle = '';
alert('avant launch');
launchHabillage( backgrounColor, habillageImageUrl, habillageUrl, habillageTitle);
alert('laprès aunch');
*/

function launchHabillage( backgrounColor, habillageImageUrl, habillageUrl, habillageTitle) {
	
//	stylePub = document.createElement('style');
//	stylePub.appendChild(document.createTextNode('body{background: ' + backgrounColor + ' url(' + habillageImageUrl + ') no-repeat top center; margin: 149px 0 0 0;}'));
	  
	document.body.style.background=backgrounColor + ' url(' + habillageImageUrl + ') no-repeat top center';
	document.body.style.margin = '149px 0 0 0';
	
//	document.getElementsByTagName('head')[0].appendChild(stylePub);
	  
	  divPub = document.createElement('div');
	  //divPub.setAttribute('style', 'position: absolute;	width: 998px; height: 209px; top: -175px; left: -10px;');
	  divPub.style.position = 'absolute';
	  divPub.style.width = '998px';
	  divPub.style.height = '209px';
	  divPub.style.top = '-175px';
	  divPub.style.left = '-10px';
	  aPub = document.createElement('a');
	  aPub.setAttribute('href', habillageUrl);
	  aPub.setAttribute('title', habillageTitle);
	  aPub.setAttribute('target', '_blank');
	  
	  imgPub = document.createElement('img');
	  imgPub.setAttribute('src', '/design/virginradio/images/pixtrans.gif');
	  imgPub.setAttribute('width', '998');
	  imgPub.setAttribute('height', '209');
	  
	  aPub.appendChild(imgPub);
	  divPub.appendChild(aPub);
	  //div.style = 'position: absolute;	width: 998px; height: 209px; top: -175px; left: -10px;';
	  document.getElementById('global').insertBefore(divPub, document.getElementById('global').firstChild);
	  
}


function launchHabillageFlash( backgrounColor, habillageImageUrl, flashLeftUrl, flashTopUrl, flashRightUrl, habillageTitle) {
	
//	stylePub = document.createElement('style');
//	stylePub.appendChild(document.createTextNode('body{background: ' + backgrounColor + ' url(' + habillageImageUrl + ') no-repeat top center; margin: 149px 0 0 0;}'));
	  
	document.body.style.background=backgrounColor + ' url(' + habillageImageUrl + ') no-repeat top center';
	document.body.style.margin = '80px 0 0 0';
	
	
	
//	document.getElementsByTagName('head')[0].appendChild(stylePub);
	  
	  
	  divPubTop = document.createElement('div');
	  //divPub.setAttribute('style', 'position: absolute;	width: 998px; height: 209px; top: -175px; left: -10px;');
	  divPubTop.id = 'flashPubTop';
	  divPubTop.name = 'flashPubTop';
	  divPubTop.style.position = 'absolute';
	  divPubTop.style.width = '1017px';
	  divPubTop.style.height = '133px';
	  divPubTop.style.top = '-110px';
	  divPubTop.style.left = '-10px';
	  //divPubTop.style.backgroundColor = 'red';
	  
	  document.getElementById('global').insertBefore(divPubTop, document.getElementById('global').firstChild);
	  
	  
	  divPubLeft = document.createElement('div');
	  //divPub.setAttribute('style', 'position: absolute;	width: 998px; height: 209px; top: -175px; left: -10px;');
	  divPubLeft.id = 'flashPubLeft';
	  divPubLeft.name = 'flashPubLeft';
	  divPubLeft.style.position = 'absolute';
	  divPubLeft.style.width = '100px';
	  divPubLeft.style.height = '700px';
	  divPubLeft.style.top = '-110px';
	  divPubLeft.style.left = '-110px';
	 // divPubLeft.style.backgroundColor = 'green';
	  
	  document.getElementById('global').insertBefore(divPubLeft, document.getElementById('global').firstChild);
	  
	  
	  divPubRight = document.createElement('div');
	  divPubRight.id = 'flashPubRight';
	  divPubRight.name = 'flashPubRight';
	  divPubRight.style.position = 'absolute';
	  divPubRight.style.width = '100px';
	  divPubRight.style.height = '700px';
	  divPubRight.style.top = '-110px';
	  divPubRight.style.left = '1007px';
	 // divPubRight.style.backgroundColor = 'green';
	  
	  document.getElementById('global').insertBefore(divPubRight, document.getElementById('global').firstChild);
	  
	  
	  var so = new SWFObject(flashTopUrl, "flashPubLeft", "1017", "133", "8", "");
	  so.addParam("wmode", "transparent");
	  so.write("flashPubTop");
	   
	  var so = new SWFObject(flashLeftUrl, "flashPubLeft", "100", "700", "8", "");
	  so.addParam("wmode", "transparent");
	   so.write("flashPubLeft");
	   
	   var so = new SWFObject(flashRightUrl, "flashPubRight", "100", "700", "8", "");
	   so.addParam("wmode", "transparent");
	   so.write("flashPubRight");
}

function launchHabillageVideo(  backgrounColor, habillageImageUrl, FlashUrl, habillageTitle, RedirUrl, ForceParams, bHref) {
	document.body.style.background=backgrounColor + ' url(' + habillageImageUrl + ') no-repeat top center';
	document.body.style.margin = '180px 0 0 0';
	
	 divPubTop = document.createElement('div');
	  divPubTop.id = 'flashPubTop';
	  divPubTop.name = 'flashPubTop';
	  divPubTop.style.position = 'absolute';
	  if(typeof ForceParams['width'] != 'undefined'){
		  divPubTop.style.width = ''+ForceParams['width']+'px';
	  }else{
		  divPubTop.style.width = '320px';
	  }
	  if(typeof ForceParams['height'] != 'undefined'){
		  divPubTop.style.height = ''+ForceParams['height']+'px';
	  }else{
		  divPubTop.style.height = '240px';
	  }
	  if(typeof ForceParams['top'] != 'undefined'){
		  divPubTop.style.top = ''+ForceParams['top']+'px';
	  }else{
		  divPubTop.style.top = '-150px';
	  }
	  if(typeof ForceParams['left'] != 'undefined'){
		  divPubTop.style.left = ''+ForceParams['left']+'px';
	  }else{
		  divPubTop.style.left = '672px';
	  }
	  
	  document.getElementById('global').insertBefore(divPubTop, document.getElementById('global').firstChild);
	  if(bHref == true){
		  aPub = document.createElement('a');
		  aPub.setAttribute('href', RedirUrl);
		  aPub.setAttribute('title', habillageTitle);
		  aPub.style.height = '237px';
		  aPub.style.width = '700px';
		  aPub.style.top = '-220px';
		  aPub.style.position = 'absolute';
		  aPub.style.zIndex = '5000';
		  document.getElementById('global').insertBefore(aPub, document.getElementById('global').firstChild);
	  }
	  
	  
	  var flashWidth = "320";
	  var flashHeight = "240";
	  if(typeof ForceParams['width'] != 'undefined'){
		  flashWidth = ''+ForceParams['width']+'';
	  }
	  if(typeof ForceParams['height'] != 'undefined'){
		  flashHeight = ''+ForceParams['height']+'';
	  }
	  
	  var so = new SWFObject(FlashUrl, "flashPubVideo", flashWidth, flashHeight, "8", "");
	  so.addParam("wmode", "transparent");
	  so.addVariable("clickTag", RedirUrl);
	  so.write("flashPubTop");
	  document.getElementById("flashPubTop").style.zIndex = '6000';
}
