/****************************************************
** js 2008
*****************************************************/

/*********************************************************
* imgright onload 
*********************************************************/

/* window.onload = function(){
function DisplayImgUpRight(){ */
	document.getElementById('textdisplayonly').style.background = 'url("http://www.1hebergeur.com/images_2008/general/map_header.gif") top no-repeat';

/* }
*/

function changeback( NameSpf ){
	document.getElementById(''+NameSpf+'').style.background = '#eee';
}

function restoreback( NameSpf ){
	document.getElementById(''+NameSpf+'').style.background = '#fff';
}



function changeOp(){
	i=0;
		op=70;
		opM=5;

		A1 = (i * opM );
		B1 = A1 / 100;
		C1 = B1 + 0.7 + 0.05;

}

function restorOp(){
	document.getElementById("displg").style.opacity = 0.7;
}
//

function DisplIndF(ID,Act){
	if( Act == 'on' ){
		document.getElementById(''+ID+'').innerHTML ='<br /><br /><br /><br />en savoir plus ...&nbsp;';
	}
	else{
		document.getElementById(''+ID+'').innerHTML ='';
	}
}


// banniere and title display

bannerimg = new Array;
buttonimg = new Array;
banurl = new Array;
bantime = new Array;
bannerTitle = new Array;

bannerTitle[0] = '';
bannerimg[0] = "http://";
buttonimg[0] = "";
banurl[0] = "";
bantime[0] = "2";

bannerTitle[1] = '';
bannerimg[1] = "http://";
buttonimg[1] = "";
banurl[1] = "";
bantime[1] = "2";

bannerTitle[2] = '';
bantime[2] = "2";

bannerTitle[3] = '';
bantime[3] = "2";




	function AffichText(){
		document.getElementById('textdisplayonly').innerHTML = bannerTitle.length -1;
		numberImg = Math.round(Math.random()* bannerTitle.length-1) ; /* Math.round(Math.random()*(bannerTitle.length-1)); */
		while( bannerTitle[numberImg] == "" ) numberImg = Math.round(bannerTitle.length-1); /* Math.random()*(bannerTitle.length-1)); */

		document.getElementById('textdisplayonly').innerHTML += bannerTitle[numberImg];
		setTimeout("AffichText('textdisplayonly')",bantime[numberImg] * 1000 + 1000);


	}



function testext(){
	document.getElementById('textdisplayonly').innerHTML += "";

}

var LHC = document.getElementById('logcompleth');


function LangDisplayChoice( STATUS ){
	if( STATUS == 'on' )
	{
		document.getElementById('divlangprint').style.display = "block";
	}
	else{
		document.getElementById('divlangprint').style.display = "none";
	}
}

function LangUnavaible( STATUS2 ){
	if( STATUS2 == 'on' )
	{
		document.getElementById('unavaible').style.display = "block";
	}
	else{
		document.getElementById('unavaible').style.display = "none";
	}

}


/*************************************************
********** INFOS CONTROL ACCOUNT *****************
*************************************************/
function checkinfoacc(){
	
	var DomSub = document.getElementById('formacc2008').domaine.value;
	var PassDom = document.getElementById('formacc2008').password.value;

	/* error msg */
	var DomainInvalid = 'Domaine non valide';
	var PasswdInvalid = 'Mot de passe vide ou non valide';

	/* model search */
	/* var Model = '^(http://.*|www\..*|https://.*)'; */
	var ModelDom = /(^([a-z0-9]{1,}|[a-z0-9]{1,}-){1,}[a-z0-9]{1,}).[a-z]{1,3}$/g;
	var ModelPass = /^([a-zA-Z0-9]{2,})$/;

    if( DomSub != '' && PassDom != '' )
    {
	if( DomSub.search( ModelDom ) == -1  )
	{
		document.getElementById('returnmesserrormog').innerHTML = DomainInvalid ;
	}
	else if( PassDom.search( ModelPass ) == -1  )
	{
		document.getElementById('returnmesserrormog').innerHTML = PasswdInvalid ;
	}
	else{
		/* makeRequest('url'); */
		makeRequest('Login');
		//alert('print ok');
	}
    }
    else{
	document.getElementById('returnmesserrormog').innerHTML = DomainInvalid + ' / ' + PasswdInvalid;
   }	
}


function RestoreCssInput()
{
	document.getElementById( 'iddom' ).style.border = '1px solid black';
	document.getElementById( 'idpass' ).style.border = '1px solid black';
}
function Changeinputclick( IDP , IDOUT )
{
	if( IDP != '' )
	{
		document.getElementById( IDP ).style.border = '1px solid red';
		document.getElementById( IDOUT ).style.border = '1px solid black';
	}
}


/*************************************************************
********** AJAX LOGIN REQUEST ********************************
*************************************************************/
function makeRequest(Requrl) {

 	var httpRequest = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        }
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {}
            }
        }

        if (!httpRequest) {
            alert('Abandon :( Impossible de créer une instance XMLHTTP');
            return false;
        }

        httpRequest.onreadystatechange = function() {
                alertContents( httpRequest , Requrl );
        }

	if( Requrl == 'Login' )
	{
	        data = 'domaine='+document.getElementById('formacc2008').domaine.value+'&passwd='+document.getElementById('formacc2008').password.value+'&content=ajaxverifvalue';
	}
	else if( Requrl == 'Lostpass')
	{
		data = 'domaine='+document.getElementById('formrecpass').domain.value+'&content=ajaxsentpasswd&code_verif1='+document.getElementById('formrecpass').code_verif1.value ;
	}
        httpRequest.open("POST", "login2.php", true);
        httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        httpRequest.send(data);

} /* end make Request */

    function alertContents(httpRequest , Requrl ) {

        if (httpRequest.readyState == 1) {
                document.getElementById('returnmesserrormog').innerHTML = '(1) Traitement en cours ...';
        }
        else if( httpRequest.readyState == 2){
                document.getElementById('returnmesserrormog').innerHTML = '(2) Traitement en cours ..';
        }
        else if( httpRequest.readyState == 3){
                document.getElementById('returnmesserrormog').innerHTML = '(3) Traitement en cours ..';
        }
        else if (httpRequest.readyState == 4 ) {

            if (httpRequest.status == 200) {
                //document.getElementById('returnmesserrormog').innerHTML = httpRequest.responseText;
                var doc = httpRequest.responseXML;  //  Assigner le fichier XML à une variable
               // alert('res '+ doc.getElementsByTagName('status').length );
                var element = doc.getElementsByTagName('status').item(0);  //  Lire le premier élément avec DOM

		if( element.firstChild.data == 1 && Requrl == 'Login' )
                {
	                document.getElementById('formacc2008').submit();
        	}
        	else if( element.firstChild.data == 1 && Requrl == 'Lostpass' )
        	{
        		var stat2 = doc.getElementsByTagName('status').item(1).firstChild.data;
        		document.getElementById('returnmesserrormog').innerHTML = '';
        		document.getElementById('alertmesslost').innerHTML = 'Votre mot de passe vient d\'&ecirc;tre envoy&eacute; &agrave; l\'adresse email suivante:<br />';

        		var AddrM2 = stat2.replace('_at_',' @ ');
        		document.getElementById('alertmesslost').innerHTML += AddrM2 ;
			
			/* display input empty */
			document.getElementById('formrecpass').domain.value = '';
			document.getElementById('formrecpass').code_verif1.value = '';
			
        	}
		else if( element.firstChild.data == 3 && Requrl == 'Lostpass' )
		{
			var stat2 = doc.getElementsByTagName('status').item(1).firstChild.data;
			document.getElementById('alertmesslost').innerHTML = 'Code de vérification non valid <br />'+ stat2 ;
			
			
		}
        	else if( element.firstChild.data == 0 )
        	{
        		document.getElementById('returnmesserrormog').innerHTML = 'Informations non trouv&eacute;es';
			document.getElementById('alertmesslost').innerHTML = '';
        	}
        	else{
        		document.getElementById('returnmesserrormog').innerHTML = 'domaine ou mot de passe invalide';
			document.getElementById('alertmesslost').innerHTML = 44.
        	}

            } else {
                document.getElementById('returnmesserrormog').innerHTML = 'Erreur de vérification, veuillez contacter l\'administrateur';
		document.getElementById('alertmesslost').innerHTML = '';
            }
       }
} /* end alertContents */


/*******************************************************
*************  LOST PASSWORD ***************************
*******************************************************/

function VerifLostReq()
{
	var DomSub = document.getElementById('formrecpass').domain.value;
	var CodSub = document.getElementById('formrecpass').code_verif1.value;
	/* error msg */
	var DomainInvalid = 'Domaine vide ou non valide';
	var CodeInvalid = 'Code de vérification vide ou non valid';

	/* model search */
	var Model = '^(http://.*|www\..*|https://.*)';
	var ModelDom = /(^([a-z0-9]{1,}|[a-z0-9]{1,}-){1,}[a-z0-9]{1,}).[a-z]{1,3}$/g; //([a-z0-9]{1,})\.([a-z]{2,4}))/;   //'^(([a-z0-9]-){1,}[a-z0-9]{1,}).([a-z]{1,3})$';


	if( DomSub.search( ModelDom ) == -1  )
	{
		document.getElementById('alertmesslost').innerHTML = DomainInvalid ;
	}
	else if( CodSub == '' && CodSub.length == 0 )
	{
		document.getElementById('alertmesslost').innerHTML = CodeInvalid;
	}
	else{
		makeRequest('Lostpass');
	}
}



