var chemin_root="http://www.dix-heures.net/";
var extension_des_images=".png";
var what_replace = new Array();
var replace_by = new Array();
what_replace[0] = "%";
replace_by[0] = "%25";
what_replace[1] = " ";
replace_by[1] = "+";
what_replace[2] = "à";
replace_by[2] = "%E0";
what_replace[3] = "â";
replace_by[3] = "%E2";
what_replace[4] = "ä";
replace_by[4] = "%E4";
what_replace[5] = "é";
replace_by[5] = "%E9";
what_replace[6] = "è";
replace_by[6] = "%E8";
what_replace[7] = "ê";
replace_by[7] = "%EA";
what_replace[8] = "ë";
replace_by[8] = "%EB";
what_replace[9] = "ì";
replace_by[9] = "%EC";
what_replace[10] = "î";
replace_by[10] = "%EE";
what_replace[11] = "ï";
replace_by[11] = "%EF";
what_replace[12] = "ò";
replace_by[12] = "%F2";
what_replace[13] = "ô";
replace_by[13] = "%F4";
what_replace[14] = "ö";
replace_by[14] = "%F6";
what_replace[15] = "ù";
replace_by[15] = "%F9";
what_replace[16] = "û";
replace_by[16] = "%FB";
what_replace[17] = "ü";
replace_by[17] = "%FC";
what_replace[18] = "ÿ";
replace_by[18] = "%FF";
what_replace[19] = "ç";
replace_by[19] = "%E7";
what_replace[20] = "@";
replace_by[20] = "%40";
what_replace[21] = "\\&";
replace_by[21] = "%26";
what_replace[22] = "\\~";
replace_by[22] = "%7E";
what_replace[23] = "\\\"";
replace_by[23] = "%22";
what_replace[24] = "\\'";
replace_by[24] = "%27";
what_replace[25] = "#";
replace_by[25] = "%23";
what_replace[26] = "{";
replace_by[26] = "%7B";
what_replace[27] = "\\(";
replace_by[27] = "%28";
what_replace[28] = "\\[";
replace_by[28] = "%5B";
what_replace[29] = "\\|";
replace_by[29] = "%7C";
what_replace[30] = "\\`";
replace_by[30] = "%60";
what_replace[31] = "_";
replace_by[31] = "_";
what_replace[32] = "\\\\";
replace_by[32] = "%5C";
what_replace[33] = "\\^";
replace_by[33] = "%5E";
what_replace[34] = "°";
replace_by[34] = "%B0";
what_replace[35] = "\\)";
replace_by[35] = "%29";
what_replace[36] = "\\]";
replace_by[36] = "%5D";
what_replace[37] = "\\=";
replace_by[37] = "%3D";
what_replace[38] = "\\+";
replace_by[38] = "%2B";
what_replace[39] = "\\$";
replace_by[39] = "%24";
what_replace[40] = "£";
replace_by[40] = "%A3";
what_replace[41] = "\\*";
replace_by[41] = "%2A";
what_replace[42] = "µ";
replace_by[42] = "%B5";
what_replace[43] = "-";
replace_by[43] = "-";
what_replace[44] = ",";
replace_by[44] = "%2C";
what_replace[45] = "\\?";
replace_by[45] = "%3F";
what_replace[46] = ";";
replace_by[46] = "%3B";
what_replace[47] = "\\.";
replace_by[47] = ".";
what_replace[48] = ":";
replace_by[48] = "%3A";
what_replace[49] = "/";
replace_by[49] = "%2F";
what_replace[50] = "!";
replace_by[50] = "%21";
what_replace[51] = "§";
replace_by[51] = "%A7";
what_replace[52] = "²";
replace_by[52] = "%B2";
function urlencode(s)
{
	var text = s.toString();
	for(var c=0;c<what_replace.length;c++)
	{
		var maReg = new RegExp( what_replace[c], "gi") ;
		text = text.replace( maReg, replace_by[c] ) ;
	}
	
	//alert(text);
	return text;
}
var victor = {
	createDiv: function(that){
		//100%widthRequirement - use of min-width
		$('body').append('<div id="victor"></div>');
		$('#victor').css({
				'height': '505px', 
				'left': '0px',
				'position': 'absolute',
				'top': '100px',
				'width': '100%',
				'z-index': '100'
			});
		that.createFlashWrapper(that);
		
	},
	
	createFlashWrapper: function(that){
		$('#victor').append('<div id="victorFlashWrapper"></div>');
		$('#victorFlashWrapper').css({
				'height': '1px',
				'width': '1px'
		});
		that.injectFlash(that);
		
	},
	
	injectFlash: function(that){
		var pub = new SWFObject('http://www.justepourrire.fr/UserFiles/Flash/victor_pub.swf','victorFlash','100%','100%','8', "#FFFFFF");
		pub.addParam("menu", "false");
		pub.addParam("scale", "noscale");
		pub.addParam("wmode", "transparent");
		pub.addParam("salign", "t");
		pub.addVariable("_click_url", this._click_url);
		pub.addVariable("_click_url_2", this._click_url_2);
		pub.addVariable("_click_target", this._click_target);
		pub.addVariable("_file_src", this._file_src);
		pub.write('victorFlashWrapper');
		that.validateFlash();
	},
	
	validateFlash: function(that){
		//var el = document.getElementById('victorFlash'); //couldn't use [$] cause we can't extend an [embed] object
		
	},
	
	expandFlashWrapper: function(){
		//alert('expandFlashWrapper');
		$('#victorFlashWrapper').css({
			//'background-color': '#FF0000',
			'height': '100%',
			'width': '100%'
		});
	},
	
	contractFlashWrapper: function(){
		$('#victorFlashWrapper').css({
			'height': '1px',
			'width': '1px'
		});	
	},
	
	hide: function(){
		$('#victor').css('display', 'none');
	},
	
	show: function(){
		$('#victor').css('display', 'block');
	},
	
	onBeginAnim: function(){
		this.expandFlashWrapper();
	},
	
	onEndAnim: function(){
		this.contractFlashWrapper();
		this.hide();
		this.show = null;
	},
		
	defineMinWidth: function(){ //100%widthRequirement
		this._minWidth = $('body').width();
	},
	
	startUp: function(that){
		//this = that;
		//this.defineMinWidth(); //100%widthRequirement
		that.createDiv(that);
	},
	init: function(){
		// Define click through URL here
		this._click_url = "http://justepourrire.trium.fr/index.php/1/manifestation/196";
		this._click_url_2 = "http://justepourrire.trium.fr/index.php/1/manifestation/138";
		this._click_target = "_blank";
		this._file_src = "http://www.justepourrire.fr/UserFiles/Image/intersticiel_laclique.jpg";
		
		var delayMls = 3500;
		
		this.defineMinWidth();
		
		var that = this;
		setTimeout(function(){ that.startUp(that); },delayMls);
		//this.setTimeout(delayMls);
		//this.startUp.bind(this).delay(delayMls); //Use of [bind] because [delay] causes the lost of [this] reference
	}
};
$(function(){
		if($('#flashindex').length)
	{
		victor.init();
	}
		$(".titre_maincol_2").each(function(){
		var texte=$(this).html();
		var url = chemin_root+"traitement/grd-titre.php?gstr="+urlencode(texte);
		$(this).html($("<img>").attr("src",url).attr("alt",texte));
	});
	$(".titre_rightcol_2").each(function(){
		var texte=$(this).html();
		var url = chemin_root+"traitement/petit-titre.php?gstr="+urlencode(texte);
		$(this).html($("<img>").attr("src",url).attr("alt",texte));
	});
	$(".titre_maincol_fake").each(function(){
		var texte=$(this).html();
		var url = chemin_root+"traitement/fake-titre.php?gstr="+urlencode(texte);
		$(this).html($("<img>").attr("src",url).attr("alt",texte));
	});
	$(".titre_rightcol_2_v").each(function(){
		var texte=$(this).html();
		var url = chemin_root+"traitement/petit-titre-v.php?gstr="+urlencode(texte);
		$(this).html($("<img>").attr("src",url).attr("alt",texte));
	});
	$(".minih").each(function(){
		var texte=$(this).html();
		var url = chemin_root+"traitement/mini-titre.php?gstr="+urlencode(texte);
		$(this).html($("<img>").attr("src",url).attr("alt",texte));
	});
	$('.date-pick').each(function(){
		$(this).datePicker({createButton:true})
		$(this).dpSetPosition($.dpConst.POS_TOP, $.dpConst.POS_RIGHT)
		$(this).bind('click',
			function()
			{
				$(this).dpDisplay();
				this.blur();
				return false;
			}
		);
	});
});
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	var sfEls = document.getElementById("billtab").getElementsByTagName("TR");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);