var shown = 0;
var news_shown = 0;
var deleting = 0;
function file(fichier)
 {
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
 };
function afficher_menu(boite)
{
	/* On regarde si un autre menu est ouvert */
	 if(boite != "ulaccueil")
		document.getElementById("ulaccueil").style.visibility = "hidden";
	 
	 if(boite != "ulpol")
		document.getElementById("ulpol").style.visibility = "hidden";
	 
	 if(boite != "ulforums")
		document.getElementById("ulforums").style.visibility = "hidden";
	 
	 if(boite != "ulmembres")
		document.getElementById("ulmembres").style.visibility = "hidden";
	 
	 /* On remet tout en noir */
	 document.getElementById("ulaccueil_link").style.color = "#CCFFFF";
	 document.getElementById("ulpol_link").style.color = "#CCFFFF";
	 document.getElementById("ulforums_link").style.color = "#CCFFFF";
	 document.getElementById("ulmembres_link").style.color = "#CCFFFF";
	 
	 /* On ouvre ou ferme le menu */
	 if(document.getElementById(boite).style.visibility == "visible")
	 {
		document.getElementById(boite+"_link").style.color = "#CCFFFF";
		document.getElementById(boite).style.visibility = "hidden";
	 }
	 else
	 {
		document.getElementById(boite+"_link").style.color = "#FFFFFF";
		document.getElementById(boite).style.visibility = "visible";
	 }
	 //menuul li:hover ul
}

function loadimage()
{
	image = document.createElement("img")
	image.setAttribute("src","http://www.playonlinux.com/test/pol.php")
	document.body.appendChild(image)
}
function show_privmessage(id, sent)
{
	if(deleting == 0)
	{
		adresse = url+"/messages/see_mess_ajax.php?mess="+id;
		//location.href = adresse;
		//texte = "Afficher le message "+id;
		if(document.getElementById("message_"+id).style.display == "block")
		{
			$("div#message_"+id).hide(300);
			shown = id;
			//$("div#message_"+shown).html("");
		}
		if(shown != id)
		{
			if(sent == false)
			{
				$("img#pmessage_image_"+id).attr("src",url+"/images/forums/vert.png"); 
				file(adresse);
			}
			$("div#message_"+id).show(300);
			shown = id;
		}
		else
		{
			shown = 0;
		}
	}
	deleting = 0;
}
function show_download(div, fichier)
{
	$("div#content").load(fichier);
}
function delete_pmessage(id)
{
	if(confirm("Are you sure you want to delete this message ?"))
	{
		file(prefixe+"/delete_private_message_confirm-"+id+"-0.html");
		$("div#message_title_"+id).hide(300);
		$("div#message_"+id).hide(300);
	}
	deleting = 1;
}
function delete_pmessage_s(id)
{
	if(confirm("Are you sure you want to delete this message ?"))
	{
		file(prefixe+"/delete_private_message_confirm-"+id+"-1.html");
		$("div#message_title_"+id).hide(300);
		$("div#message_"+id).hide(300);
	}
	deleting = 1;
}
function delete_page(id)
{
	if(confirm("Are you sure you want to delete this page ?"))
	{
		file(url+"/admin/pages/delete_ajax.php?id="+escape(id));
		$("div#reponse_"+id).hide(300);
		$("div#page_"+id).hide(300);
	}
	deleting = 1;
}
function faq_show(id)
{
		if(shown != 0)
		{
			$("div#reponse_"+shown).hide(300);
			//$("div#message_"+shown).html("");
		}
		if(shown != id)
		{
			//$("img#pmessage_image_"+id).attr("src",url+"/images/forums/vert.png");
			//file(adresse);
			$("div#reponse_"+id).show(300);
			shown = id;
		}
		else
		{
			shown = 0;
		}
}
function pres_show(id)
{
		if(news_shown != 0)
		{
			$("div#pres_item"+news_shown).slideUp(300);
			//$("div#message_"+shown).html("");
			if(news_shown == 5)
			{
				$("div#presentation5").addClass("no_bottom");
			}
		}
		if(news_shown != id)
		{
			//$("img#pmessage_image_"+id).attr("src",url+"/images/forums/vert.png");
			//file(adresse);
			$("div#pres_item"+id).slideDown(300);
			news_shown = id;
			if(id == 5)
			{
				$("div#presentation5").removeClass("no_bottom");
			}
		}
		else
		{
			news_shown = 0;
		}
}
function set_name(valeur)
{
	document.getElementById("pseudo_box").value = valeur;
	$("div#pseudobox_content").hide(300);
}
function look_for(texte)
{
	if(texte == "")
	{
		$("div#pseudobox_content").hide(300);
	}
	else
	{
		$("div#pseudobox_content").load(url+"/js/ajax/membre_ajax.php?membre="+escape(texte)).show(300);
	}
}


function ajax_apercu(message,auteur)
{
	$("div#apercu").hide(0);
	if(auteur != '')
		$("div#apercu").load(url+'/forums/previsualisation.php?message='+escape(message)+'&auteur='+escape(auteur)).show(300);
}

function secret(div2)
{
	
	var divs = div2.getElementsByTagName('div');
	var div3 = divs[0];
	div3.setAttribute("id","temp_id");
	
	if (div3.style.display == "block")
		$("div#temp_id").slideUp(200)
	else
		$("div#temp_id").slideDown(200)
		
	div3.removeAttribute("id");
}
// JavaScript Document
//script chopé sur http://actuel.fr.selfhtml.org/articles/javascript/bbcode/index.htm
// merci :D

function insertion(repdeb, repfin) {
  var input = document.forms['formulaire'].elements['message'];
  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined') {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}
function replace_select(id_liste)
{
		document.getElementById(id_liste).options[0].selected = true;
}
function insert_code(code, title)
{
	if(title == '')
		$("p#code_album").html("<b>BB Code :</b> [box][URL]/images/uploads/"+code+".jpg[/box]");
	else
		$("p#code_album").html("<b>BB Code :</b> [box title="+title+"][URL]/images/uploads/"+code+".jpg[/box]");
}
function search_box(valuebox)
{
	if(valuebox == "")
		$("input#search_button").fadeOut(500).get(0).disabled = true;
	else
		$("input#search_button").fadeIn(500).get(0).disabled = false;
	
}

function envahir(i)
{
	var x = Math.random();
	var y = Math.random();
	x = Math.ceil(x * (screen.width - 200));
	y = Math.ceil(y * (screen.height - 300));
	delais = Math.ceil(Math.random() * 200)
	//alert(x);
	$("body").append("<img src='http://www.playonlinux.com/images/tux.png' alt='' style='position:absolute;left:"+x+"px;top:"+y+"px'>");

	
	if(i < 100)
	{
		setTimeout("envahir("+(i + 1)+");",delais);
	}
}
if ( window.addEventListener ) {  
   var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";  
   window.addEventListener("keydown", function(e){  
       kkeys.push( e.keyCode );  
       if ( kkeys.toString().indexOf( konami ) >= 0 )  
          envahir(0)
   }, true);  
}  
function hide_all()
{			
if( document.getElementById("champ42"))
{
	document.getElementById("champ42").setAttribute('class','mail');
	document.getElementById("field1").setAttribute('class','mail');
	document.getElementById("champ4").setAttribute('style','display:none');
}	
}
window.onload = hide_all;
