function resize(id, t, w, h, c, s, hide) {
	var reg = new RegExp("[ ,;]+", "g");
	var div = hide.split(reg);
	if ( document.getElementById ) {
		img = document.getElementById(id);
		}
	else if ( document.all ) {
		img = document.all[id];
		}
	else if ( document.layers ) {
		img = document.layers[id];
		}
	iw = img.style.width;
	iw = eval(iw.substr(0, iw.length-2));
	ih = img.style.height;
	ih = eval(ih.substr(0, ih.length-2));
	if ( s == 0 ) {
		if ( iw<w ) {
			nw = iw+iw*c/100;
			nh = ih+ih*c/100;
			if ( t == 0 ) view2('zoomin');
			if ( t == 0 && hide != 0 ) {
				for ( var i = 0; i<div.length; i++) {
					view2(div[i]);
					}
				}
			img.style.width = Math.round(nw)+"px";
			img.style.height = Math.round(nh)+"px";
			fresize = window.setTimeout("resize('"+id+"', 1, "+w+", "+h+", "+c+", "+s+", '"+hide+"')", 10);
			}
		else {
			view('zoomout');
			img.style.width = w+"px";
			img.style.height = h+"px";
			window.clearTimeout(fresize);
			}
		}
	else {
		if ( iw>w ) {
			nw = iw-iw*c/100;
			nh = ih-ih*c/100;
			if ( t == 0 ) view('zoomout');
			img.style.width = Math.round(nw)+"px";
			img.style.height = Math.round(nh)+"px";
			fresize = window.setTimeout("resize('"+id+"', 1, "+w+", "+h+", "+c+", "+s+", '"+hide+"')", 20);
			}
		else {
			view('zoomin');
			img.style.width = w+"px";
			img.style.height = h+"px";
			if ( hide != 0 ) {
				for ( var i = 0; i<div.length; i++) {
					view(div[i]);
					}
				}
			window.clearTimeout(fresize);
			}
		}
	}

function getid(id) {
	if ( document.getElementById ) {
		value = document.getElementById(id);
		}
	else if ( document.all ) {
		value = document.all[id];
		}
	else if ( document.layers ) {
		value = document.layers[id];
		}
	return value;
	}

function view(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = ( document.getElementById(id).style.display == "block" ) ? "none" : "block";
		}
	else if ( document.all ) {
		document.all[id].style.display = ( document.all[id].style.display == "block" ) ? "none" : "block";
		}
	else if ( document.layers ) {
		document.layers[id].display = ( document.layers[id].display == "block" ) ? "none" : "block";
		}
	}

function onlyview(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "block";
		}
	else if ( document.all ) {
		document.all[id].style.display = "block";
		}
	else if ( document.layers ) {
		document.layers[id].display = "block";
		}
	}

function onlyhide(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "none";
		}
	else if ( document.all ) {
		document.all[id].style.display = "none";
		}
	else if ( document.layers ) {
		document.layers[id].display = "none";
		}
	}

function view2(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = ( document.getElementById(id).style.display == "block" || document.getElementById(id).style.display != "none" ) ? "none" : "block";
		}
	else if ( document.all ) {
		document.all[id].style.display = ( document.all[id].style.display == "block" || document.all[id].style.display != "none" ) ? "none" : "block";
		}
	else if ( document.layers ) {
		document.layers[id].display = ( document.layers[id].display == "block" || document.layers[id].display != "none" ) ? "none" : "block";
		}
	}

function changeimage(id, value) {
	var div = getid(id);
	div.src = value;
	}

function getvalue(id) {
	var div = getid(id);
	return div.value;
	}

function changevalue(id, value) {
	var div = getid(id);
	div.value = value;
	}

function changevalue2(idvalue) {
	var val = idvalue.split("||");
	var id = val[0];
	var value = val[1];
	var div = getid(id);
	div.value = value;
	}

function checkinput(id, c, v) {
	var i2 = getid(id);
	var v2 = getvalue(id);
	if ( v2 == v ) {
		changevalue(id, '');
		i2.style.color = '#'+c;
		}
	}

function getinnerhtml(id) {
	var div = getid(id);
	return div.innerHTML;
	}

function changeinnerhtml(id, value) {
	var div = getid(id);
	div.innerHTML = value;
	}

function connexion() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		return true;
		}
	xhr_object.open("POST", "/connexion.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	form = getinnerhtml("textlogin");
	formlogin = getvalue("formlogin");
	formpassword = getvalue("formpassword");
	var vars = "ajax=ajax&login="+formlogin+"&password="+formpassword;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				window.location.replace(window.location);
				}
			else {
				changeinnerhtml("textlogin", xhr_object.responseText);
				window.setTimeout("changeinnerhtml('textlogin', form)", 2000);
				}
			}
		}
	return false;
	}

function connexion2() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		return true;
		}
	xhr_object.open("POST", "/connexion.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	form = getinnerhtml("textlogin2");
	formlogin = getvalue("formlogin2");
	formpassword = getvalue("formpassword2");
	var vars = "ajax=ajax2&login="+formlogin+"&password="+formpassword;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				window.location.replace(window.location);
				}
			else {
				changeinnerhtml("textlogin2", xhr_object.responseText);
				window.setTimeout("changeinnerhtml('textlogin2', form)", 2000);
				}
			}
		}
	return false;
	}

function submithis(form) {
	var str = form.q.value;
	if (str != "") {
		if ( form.w.value == "google" ) {
			str = "google-"+str;
			}
		var str = str.toLowerCase();
		var str = cleanString(str);
		newLocation = "/recherche/"+str+".html";
		document.location = newLocation;
		}
	return false;
	}

function replaceAll(str, search, repl) {
	while ( str.indexOf(search) != -1 ) {
		str = str.replace(search, repl);
		}
	return str;
	}

function vote(id) {
	for ( i=1; i<6; i++ ) {
		changeimage("vote"+i, "img/vote-off.gif");
		}
	for ( i=1; i<id+1; i++ ) {
		changeimage("vote"+i, "img/vote-on.gif");
		}
	}

function sendvote(note, page, id) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", "/"+page, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "note="+note;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(id, xhr_object.responseText);
			}
		}
	}

function getchrono(concours, user) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", "/concours/"+concours+"/validation.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "getchrono=1&user="+user;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml("concours_validation", xhr_object.responseText);
			}
		}
	}

function setchrono(concours, user, valide) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	var voiture = getvalue('voiture');
	var message = getvalue('message');
	var time_minutes = getvalue('minutes');
	var time_secondes = getvalue('secondes');
	var time_centiemes = getvalue('centiemes');
	xhr_object.open("POST", "/concours/"+concours+"/validation.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = ( valide == 1 ) ? "setchrono=1&user="+user+"&voiture="+voiture+"&minutes="+time_minutes+"&secondes="+time_secondes+"&centiemes="+time_centiemes : "setchrono=1&user="+user+"&message="+message+"&delete=1";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml("concours_validation", "");
			updatepage("/concours/"+concours+"/validation.html", "scroll_classement_content");
			getchrono(concours, xhr_object.responseText);
			initScrollLayers(1);
			}
		}
	}

function updatepage(url, div) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", url, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "update=1";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(div, xhr_object.responseText);
			}
		}
	}

function sendallopass(id, site, doc, code, page) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec cette option...");
		return;
		}
	changeinnerhtml(id, "<p class=\"confirm\">Envoi des données...</p>");
	xhr_object.open("POST", page, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "SITE_ID="+site+"&DOC_ID="+doc+"&RECALL=1&CODE0="+code;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(id, xhr_object.responseText);
			}
		}
	}

function showchat() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=show";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				onlyview("chat");
				view2("showchat");
				view2("hidechat");
				getid("chat_connexion").style.left = "562px";
				getid("chat_connexion").style.width = "413px";
				updatechat();
				}
			else {
				onlyview("chat_error");
				}
			}
		}
	}

function hidechat() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=hide";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			view("chat");
			view2("showchat");
			view2("hidechat");
			getid("chat_connexion").style.left = "819px";
			getid("chat_connexion").style.width = "156px";
			}
		}
	}

function updatechat() {
	var time = 1000;
	var div = "chat_content";
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=update&div="+div;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText != 0 ) {
				if ( changeinnerhtml ) {
					changeinnerhtml(div, xhr_object.responseText);
					getid("chat_content").style.top = 135-getid("chat_content").offsetHeight+"px";
					}
				window.setTimeout("updatechat()", time);
				}
			}
		}
	}

function addchat() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var add = getvalue("chat_add");
	if ( add != "<Votre message ici>" && add != '' ) {
		changevalue("chat_add", "");
		var vars = "chat=add&message="+add;
		xhr_object.send(vars);
		xhr_object.onreadystatechange = function() {
			if ( xhr_object.readyState == 4 ) {
				if ( xhr_object.responseText == 1 ) {
					updatechat();
					getid("chat_add").focus();
					getid("chat_content").style.top = 135-getid("chat_content").offsetHeight+"px";
					}
				}
			}
		}
	else {
		getid("chat_add").focus();
		}
	}

function cleanString(sStr) {
	var out = "";
	var spec = new Array("é", "è", "ê", "ë", "à", "â", "ä", "ù", "û", "ü", "ì", "î", "ï", "ò", "ô", "ö");
	var norm = new Array("e", "e", "e", "e", "a", "a", "a", "u", "u", "u", "i", "i", "i", "o", "o", "o");
	for ( var i=0; i<spec.length; i++ ) {
		sStr = replaceAll(sStr, spec[i], norm[i]);
		}
	for ( i=0; i<sStr.length; i++ ) {
		out += ( charcheck(sStr.charAt(i)) ) ? sStr.charAt(i) : "-";
		}
	out = escape(out);
	return out;
	}

function charcheck(keychar) {
	ret = ( ("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1 ) ? true : false;
	return ret;
	}

function updatecheck(id, num, hide, value) {
	if ( num == 1 ) {
		document.getElementById(id+"1").style["background"] = "url('img/selected-on.gif') no-repeat 3px 1px";
		document.getElementById(id+"2").style["background"] = "url('img/selected-off.gif') no-repeat 3px 1px";
		}
	else {
		document.getElementById(id+"1").style["background"] = "url('img/selected-off.gif') no-repeat 3px 1px";
		document.getElementById(id+"2").style["background"] = "url('img/selected-on.gif') no-repeat 3px 1px";
		}
	changevalue(hide, value);
	}

function screenshot(img, titre) {
	w = open("", "image", "width=400, height=400, toolbar=no, scrollbars=no, resizable=no");
	w.document.write("<html><head><title>"+titre+"</title>");
	w.document.write("<sc"+"ript type='text/javas"+"cript'>");
	w.document.write("	function checksize() {");
	w.document.write("		if ( document.images['img'].complete ) {");
	w.document.write("			var height = document.images[0].height+35;");
	w.document.write("			var width = document.images[0].width+5;");
	w.document.write("			if ( height>screen.height ) {");
	w.document.write("				var width = (width*(screen.height-35))/height;");
	w.document.write("				var height = screen.height-35;");
	w.document.write("				document.images[0].height = height;");
	w.document.write("				}");
	w.document.write("			if ( width>screen.width-5 ) {");
	w.document.write("				var height = (height*(screen.width-5))/width;");
	w.document.write("				var width = screen.width-5;");
	w.document.write("				document.images[0].width = width;");
	w.document.write("				}");
	w.document.write("			var top = (screen.height-height)/2;");
	w.document.write("			var left = (screen.width-width)/2;");
	w.document.write("			window.moveTo(left, top);");
	w.document.write("			window.resizeTo(width, height);");
	w.document.write("			window.focus();");
	w.document.write("			}");
	w.document.write("		else {");
	w.document.write("			setTimeout('checksize()', 250)");
	w.document.write("			}");
	w.document.write("		}");
	w.document.write("	</"+"script>");
	w.document.write("</head>");
	w.document.write("<body onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 bgcolor='#111111'>");
	w.document.write("<a href='javascript:self.close()'><img src='/"+img+"' border=0 name='img' alt='"+titre+"' title='"+titre+"' /></a>");
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
	}

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='img/login-browse.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for ( var i=0;i<x.length;i++ ) {
		if ( x[i].type == 'file' ) {
			if ( x[i].parentNode.className != 'fileinputs' ) continue;
			x[i].className = 'file';
			var clone = fakeFileUpload.cloneNode(true);
			x[i].parentNode.appendChild(clone);
			x[i].relatedElement = clone.getElementsByTagName('input')[0];
			x[i].relatedElement.className = 'double';
			x[i].onchange = x[i].onmouseout = function () {
				this.relatedElement.value = this.value;
				}
			}
		}
	}

function controlplayer2() {
	var main_path = ""+parent.frames['main'].location+"";
	var main_url = main_path.split("/");
	var main_var1 = main_url[3];
	var main_var2 = main_url[4];
	var player_path = ""+parent.frames['player'].location+"";
	var player_url = player_path.split("/");
	var player_var1 = player_url[3];
	var player_var2 = player_url[4];
	if ( main_var1 == "" || main_var1 == "homepage.html" || main_var1 == "videos" ) {
		if ( player_var1 != "player.html" ) {
			parent.frames['player'].location = "player.html";
			}
		}
	else {
		if ( player_var1 == "player.html" ) {
			parent.frames['player'].location = "player/play.html";
			parent.frames['player'].document.swfplayer.TGotoFrame("_level0/main/player/controles/js", 2);
			}
		}
	}

function controlplayer(play) {
	if ( parent.frames['player'].document.swfplayer ) {
		var play = ( play == 1 ) ? 1 : 0;
		var path = ""+parent.frames['main'].location+"";
		var url = path.split("/");
		var var1 = url[3];
		var var2 = url[4];
		if ( var1 == "" || var1 == "homepage.html" || var1 == "videos" ) {
			if ( play == 1 ) {
				parent.frames['player'].document.swfplayer.TGotoFrame("_level0/main/player/controles/js", 2);
				var play = 0;
				}
			}
		else {
			if ( play == 0 ) {
				parent.frames['player'].document.swfplayer.TGotoFrame("_level0/main/player/controles/js", 1);
				var play = 1;
				}
			}
		}
	window.setTimeout("controlplayer("+play+")", 2000);
	}

function playergoto(frame) {
	if ( parent.frames['player'].document.swfplayer ) {
		parent.frames['player'].document.swfplayer.TGotoFrame("_level0/main/player/controles/list", frame);
		}
	}