function RedirectLink(lien_page)
{
	window.location = lien_page;
}

function ReloadPage()
{
	location.reload();
}

function createXhrObject()
{
    if (window.XMLHttpRequest)
        return new XMLHttpRequest();
 
    if (window.ActiveXObject)
    {
        var names = [
            "Msxml2.XMLHTTP.6.0",
            "Msxml2.XMLHTTP.3.0",
            "Msxml2.XMLHTTP",
            "Microsoft.XMLHTTP"
        ];
        for(var i in names)
        {
            try{ return new ActiveXObject(names[i]); }
            catch(e){}
        }
    }
    window.alert("Votre navigateur ne prend pas en charge l'objet XMLHTTPRequest.");
    return null; // non supporté
}

function AjaxRequest(url_traitement,param)
{
	var xhr=createXhrObject();
	xhr.open( "POST", url_traitement,  false); 
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xhr.send(param); 

	if(xhr.readyState  == 4)
	{
		if(xhr.status  == 200) 
		{
			response=xhr.responseText; 
			return response;
		}
		else
		{			  
			response=xhr.status;
			return response;
		}
	}
}

function ControlCase(id_box, id_box_verif, valeur_box, val_error,jquery_verif)
{
	if(document.getElementById(id_box_verif).value!=valeur_box || $('#'+id_box).val()=="")
	{
		document.getElementById(id_box).style.backgroundColor="#FFA0A0";
		document.getElementById(id_box).style.color="red";
		
		if($('#'+id_box).val()=="")
		{
			if(jquery_verif==false)
			{
				$('#'+id_box).hide();
				$('#'+id_box).fadeIn("slow");
				$('#'+id_box).val(val_error);
			}	
		}
	}
	else
	{	
		if(jquery_verif==true)
		{
			$('#'+id_box).hide();
			$('#'+id_box).fadeIn("slow");
			document.getElementById(id_box).style.backgroundColor="#D6ECA6";
			document.getElementById(id_box).style.color="#000000";
		}
		else
		{
			document.getElementById(id_box).style.backgroundColor="#FFFFFF";
			document.getElementById(id_box).style.color="#000000";
		}
	}
}

function VerifDataField(id_field,value_error,border)
{
	$('#'+id_field).hide();
	$('#'+id_field).fadeIn("slow");
	if(value_error==null)value_error='Veuillez remplir ce champ';
	if(document.getElementById(id_field)!=null)
	{
		if(document.getElementById(id_field).value=="")
		{	
			document.getElementById(id_field).style.backgroundColor="#FFA0A0";
			document.getElementById(id_field).style.color="red";
			document.getElementById(id_field).value=value_error;
		}
		else
		{
			document.getElementById(id_field).style.borderStyle=border;
			document.getElementById(id_field).style.backgroundColor="#FFFFFF";
			document.getElementById(id_field).style.color="#000000";
		}
	}
	else
	{
		alert('Field inconnu');
	}
}

function VerifDataFieldOnKey(id_field)
{	
	if(document.getElementById(id_field)!=null)
	{
		if(document.getElementById(id_field).value!="")
		{
			document.getElementById(id_field).style.backgroundColor="#D6ECA6";
			document.getElementById(id_field).style.color="#000000";
		}
		else
		{
			document.getElementById(id_field).style.backgroundColor="#FFA0A0";
		}
	}
}

function VerifDataFieldFocus(id_field)
{	
	if(document.getElementById(id_field)!=null)
	{
		//if(document.getElementById(id_field).value!="")
		//{
			document.getElementById(id_field).style.backgroundColor="#D6ECA6";
			document.getElementById(id_field).style.color="#000000";
		//}
	}
}

function recherche(path)
{
	//var mot = document.getElementById('Mot').value;
	//RedirectLink(path+"moteur_recherche/result.php?Mot="+mot);
	$('#form_recherche').submit();
}

function verif() {
	var recherche = document.getElementById('Mot').value;
	var mot = recherche.split(' ');
	if(mot.length == 4){
		recherche = recherche.substring(0, (recherche.length-1));
		document.getElementById('Mot').value = recherche;
		alert("3 mots maximum !");
	}
	//var nbstore = reponse[1]; // nbstore
}

function ChangeClass(id,classname)
{
	$('#'+id).toggleClass(classname);
}

function AddClass(id,classname)
{
	$('#'+id).addClass(classname);
}

function RemoveClass(id,classname)
{
	$('#'+id).removeClass(classname);
}

function RollOver(id,src_image)
{
	$('#'+id).attr("src",src_image);
}

function ChangeBorderColor(id,color)
{
	$('#'+id).css("borderColor",color);
}

function ShowInfo(id)
{
	$('#'+id).fadeIn("fast");
	//$('#'+id).css("display","block");
}

function HiddenInfo(id)
{
	$('#'+id).fadeOut("fast");
	//('#'+id).css("display","none");
}

function BtnClick(id)
{
	$('#'+id).css('border-style','inset');
}

function BtnUnClick(id)
{
	$('#'+id).css('border-style','outset');
}

function SplitNumber(number)
{
	unit_number=parseInt(number);
	decimal_number=Math.round(((parseFloat(number)*100)-(unit_number*100)));
	if(decimal_number=='')decimal_number="00";
	else if(decimal_number.length==1)decimal_number+"0";
	else if(decimal_number.length<10)"0"+decimal_number;
	//decimal_number=Math.round(decimal_number);
	return new Array(unit_number, decimal_number);
}
//document.onkeypress = detect_key; 
var konami_code='122|115|113|100';
var tab_konami=konami_code.split('|');	
var code_stroke='';
function detect_key(event)
{	
	var keycode;
	var valid=true;
	if (window.event) keycode = window.event.keyCode;
	else keycode = event.which;
	
	//alert(keycode);
	code_stroke=code_stroke+keycode+"|";
	
	tab_stroke=code_stroke.split('|');
	for(id in tab_konami)
	{
		if(tab_stroke[id])
		{
			if(tab_stroke[id] != tab_konami[id])
			{
				valid=false;
				code_stroke='';
				return false;
				break;
			}
		}
		else
		{
			valid=false;
		}
	}
	
	if(valid==true)easter_egg();
	
	/*if(keycode==122)move_vaisseaux('up');
	else if(keycode==115)move_vaisseaux('down');*/
	/*if(keycode==113)move_vaisseaux('left');
	else if(keycode==100)move_vaisseaux('right');
	else if(keycode==32) Shot();*/
}

function animBackColor(id, color, time)
{
	$("#"+ id).animate({ backgroundColor : color}, time );
}


function easter_egg()
{
	code_stroke='';
	var monCalque=document.createElement('div');
	//alert('Test');
	/*monCalque.setAttribute("class","maclasse");
	monCalque.setAttribute("className","maclasse");*/
	
	monCalque.innerHTML='HAHA essaye de me cliquer dessus';
	//body=document.getElementsByTagName("div").appendChild(monCalque);
	document.write('Tu a reussi le super test du konami code t\'est trop baleze')
	//alert(body);
	
}