/**
 * @lanewsletterdelacreation.com Administrateur
*/

function loading(){
	var left = $('content').firstChild;
		if(left.data) left = left.nextSibling;
		
	var right = left.nextSibling;
		if(right.data) right = right.nextSibling;
	
	if( left.offsetHeight >  right.offsetHeight){
		Element.setStyle(right,{height:(left.offsetHeight-2)+'px'});
	}else{
		Element.setStyle(left,{height:(right.offsetHeight-2)+'px'});
	}
}

function jeMinscris(){
	Element.setStyle($('jeMinscris'),{display:'block'});
	$('inscrisBtn').className = 'btnActif';
	$('dejaBtn').className = 'btn';
	//---------------------------
	Element.setStyle($('dejaMembre'),{display:'none'});
	
	//---------------------------
	loading();
}
function dejaMembre(){
	Element.setStyle($('dejaMembre'),{display:'block'});
	$('dejaBtn').className = 'btnActif';
	$('inscrisBtn').className = 'btn';
	//---------------------------
	Element.setStyle($('jeMinscris'),{display:'none'});
	
	//---------------------------
	loading();
}

function jeMinscrisRed(){
	Element.setStyle($('jeMinscrisRed'),{display:'block'});
	$('inscrisBtnRed').className = 'btnActif';
	$('dejaBtnRed').className = 'btnRed';
	//---------------------------
	Element.setStyle($('dejaMembreRed'),{display:'none'});
	
	//---------------------------
	loading();
}
function dejaMembreRed(){
	Element.setStyle($('dejaMembreRed'),{display:'block'});
	$('dejaBtnRed').className = 'btnActif';
	$('inscrisBtnRed').className = 'btnRed';
	//---------------------------
	Element.setStyle($('jeMinscrisRed'),{display:'none'});
	
	//---------------------------
	loading();
}

function checkMail(mail){
	if (!mail.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) {
		return false;
	}else{
		return true;
    }
}

function checkSimple(value){
	if( value && value!='' ) return true;
		else return false;
}

function checkPass(value){
	if( value && value!='' && value.length>=5 ) return true;
		else return false;
}

function verifPassInscription(){
	if( $('pass1').value == $('pass2').value && $('pass2').value!='' ) return true;
		else return false;
}

function verifIdent(){
	if( $('identifiant').value == '' || $('identifiant').value.length<5 ) return false;
	var param = 'login='+$('identifiant').value;
		var ajaxRequest = new Ajax.Request(
					'checkIdent.ajax.php',
					{
						"method": 'post',
						"postBody": param,
						"asynchronous":false
					}
							);
			var reponseText = ajaxRequest.transport.responseText; 
			if( reponseText != '0' ) return false;
				else return true;
			
}

function verifEmail(email){
	var param = 'email='+email;
		var ajaxRequest = new Ajax.Request(
					'lecteurs/checkEmail.ajax.php',
					{
						"method": 'post',
						"postBody": param,
						"asynchronous":false
					}
							);
			var reponseText = ajaxRequest.transport.responseText; 
			if( reponseText != '0' ) $('mailIndispo').style.visibility='visible';
				else $('mailIndispo').style.visibility='hidden';	
}

function testLogin(){
	var email = $('email2').value;
	var password = $('password').value;
	var param = 'email='+email+'&password='+password;
	//alert(param);
		var ajaxRequest = new Ajax.Request(
					'lecteurs/identification.ajax.php',
					{
						"method": 'post',
						"postBody": param,
						"asynchronous":false
					}
							);
			var reponseText = ajaxRequest.transport.responseText; 
			if( reponseText != '1' ) $('errLogin').style.visibility='visible';
				else{
					$('errLogin').style.visibility='hidden';
					document.location.href = 'lecteurs/mon-compte.php';
				}

	return false;
}

function valideForm(element,update){
	var test=0;
	
	if( checkSimple($('organisme').value) ){
		$('organisme').parentNode.previousSibling.className="true"; test++;
	}else{
		$('organisme').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('civilite').value) ){
		$('civilite').parentNode.previousSibling.className="true"; test++;
	}else{
		$('civilite').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('adresse').value) ){
		$('adresse').parentNode.previousSibling.className="true"; test++;
	}else{
		$('adresse').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('prenom').value) ){
		$('prenom').parentNode.previousSibling.className="true"; test++;
	}else{
		$('prenom').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('cp').value) ){
		$('cp').parentNode.previousSibling.className="true"; test++;
	}else{
		$('cp').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('nom').value) ){
		$('nom').parentNode.previousSibling.className="true"; test++;
	}else{
		$('nom').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('ville').value) ){
		$('ville').parentNode.previousSibling.className="true"; test++;
	}else{
		$('ville').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('fonction').value) ){
		$('fonction').parentNode.previousSibling.className="true"; test++;
	}else{
		$('fonction').parentNode.previousSibling.className="neutre";
	}
	if( checkSimple($('tel').value) ){
		$('tel').parentNode.previousSibling.className="true"; test++;
	}else{
		$('tel').parentNode.previousSibling.className="neutre";
	}

	//-- Cas de l'email
	if( checkMail($('email').value) ){
			$('email').parentNode.previousSibling.className = "true";
			$('errMail').style.visibility = 'hidden';
			test++;
	}else if( checkSimple($('email').value) ){
			$('email').parentNode.previousSibling.className = "false";
			if(element.id=='email') $('errMail').style.visibility='visible';
	}else{
		$('email').parentNode.previousSibling.className = "neutre";
	}
	
	
	if(!update){
		//-- Cas de l'identifiant
		if( verifIdent() ){
			$('identifiant').parentNode.previousSibling.className="true"; test++;
			$('errIdent').style.visibility = 'hidden';
			$('errIdent2').style.visibility='hidden';
		}else if( checkSimple($('identifiant').value) ){
			$('identifiant').parentNode.previousSibling.className="false";
			if(element.id=='identifiant' && $('identifiant').value!='' && $('identifiant').value.length>=5 ){
				$('errIdent').style.visibility='visible';
				$('errIdent2').style.visibility='hidden';
			}
			if( element.id=='identifiant' && $('identifiant').value.length<5 ){
				$('errIdent2').style.visibility='visible';
			}
		}else{
			$('identifiant').parentNode.previousSibling.className="neutre";
		}
		
		//-- Cas de la conf du pass
		if( checkPass($('pass1').value) ){
			$('pass1').parentNode.previousSibling.className="true"; test++;
			$('errPass').style.visibility='hidden;'
		}else if( checkSimple($('pass1').value) ){
			$('pass1').parentNode.previousSibling.className="false";
			if(element.id=='pass1') $('errPass').innerHTML ='(le mot de passe doit faire 5 caract&egrave;res minimum)';
			if(element.id=='pass1') $('errPass').style.visibility='visible';
		}else{
			$('pass1').parentNode.previousSibling.className="neutre";
		}
		
		if( checkSimple($('pass1').value) && checkSimple($('pass2').value) ){
			if( verifPassInscription() ){
				$('pass2').parentNode.previousSibling.className="true"; test++;
				$('errPass').style.visibility='hidden';
			}else{
				$('pass2').parentNode.previousSibling.className="false";
				if(element.id=='pass2') $('errPass').innerHTML ='(les mots de passe ne sont pas identiques)';
				if(element.id=='passs2') $('errPass').style.visibility='visible';
			}
		}else{
			$('pass2').parentNode.previousSibling.className="neutre";
		}
	}
	if(test==13 || ( test==10 && update )) $('valid').style.visibility='visible';
		else $('valid').style.visibility='hidden';
}

function updatePass(element){
	var test = 0;
	if( checkPass($('pass1').value) ){
		$('pass1').parentNode.previousSibling.className="true"; test++;
		$('errPass').style.visibility='hidden;'
	}else{
		$('pass1').parentNode.previousSibling.className="false";
		if(element.id=='pass1') $('errPass').innerHTML ='(le mot de passe doit faire 5 caract&egrave;res minimum)';
		if(element.id=='pass1') $('errPass').style.visibility='visible';
	}
	
	if( verifPassInscription() ){
		$('pass2').parentNode.previousSibling.className="true"; test++;
		$('errPass').style.visibility='hidden';
	}else{
		$('pass2').parentNode.previousSibling.className="false";
		if(element.id=='pass2') $('errPass').innerHTML ='(les mots de passe ne sont pas identiques)';
		if(element.id=='passs2') $('errPass').style.visibility='visible';
	}
	if(test==2) $('valid2').style.visibility='visible';
		else $('valid2').style.visibility='hidden';
}

//-------------- Liste Departements ------------

function color(element){
	element.style.backgroundColor="#CFEDFF";
}

function colorAll(element){
	element.style.backgroundColor="#CFEDFF";
	if( element.tagName=='DT' ) element.parentNode.style.backgroundColor="#CFEDFF";
	else{
		if( element.nextSibling.data ) element.nextSibling.nextSibling.style.backgroundColor="#CFEDFF";
		else element.nextSibling.style.backgroundColor="#CFEDFF";
	}
}
				
function decolor(element){
	element.style.backgroundColor="transparent";
}

function decolorAll(element){
	element.style.backgroundColor="transparent";
	if( element.tagName=='DT' ) element.parentNode.style.backgroundColor="transparent";
	else{
		if( element.nextSibling.data ) element.nextSibling.nextSibling.style.backgroundColor="transparent";
		else element.nextSibling.style.backgroundColor="transparent";
	}
}

/*
 * 
 * function checkDl(id){
 * 	if( $('d'+id) ){
 * 		return $('d'+id);
 * 	}else{
 * 		var newDl = $(id).cloneNode(false);
 * 			newDl.setAttribute('id','d'+id);
 * 			
 * 			
 * 			if( $(id).firstChild.data )
 *  				var dt = $(id).firstChild.nextSibling;
 * 			else
 * 				var dt = $(id).firstChild;
 *  			var	newDt = dt.cloneNode(true);
 * 				
 * 				newDl.appendChild(newDt);
 * 				$('listeD').insertBefore(newDl,$('listeD').firstChild);
 * 			return newDl;
 * 	}
 * }
 * 
 */

function selectDep(dep){
	var idRegion = dep.parentNode.id.substr(1,dep.parentNode.id.length);
	var myDl = $('insertIci');

	var tempon = dep.id.substr(4,dep.id.length);	
	if( !$('depD'+tempon) ){
		var newDd = $('dep'+tempon).cloneNode(true);
			newDd.setAttribute('id','depD'+tempon);
			
			myDl.insertBefore(newDd,myDl.firstChild);
			$('departements').value += tempon+';';
	}
}


function selectAll(region){
	var infosRegion = $('r'+region).childNodes;
	for( i=0;i<infosRegion.length;i++ ){
		if( infosRegion[i].tagName=='DT' || infosRegion[i].data ) continue;
			else{
				var tempon = infosRegion[i].id.substr(3,infosRegion[i].id.length);
					selectDep( $('depL'+tempon) );
			}
	}
}

function selectFrance(){
	for( i=95;i>=10;i-- ){
		selectDep($('depL'+i));
	}
	for( i=9;i>=1;i-- ){
		selectDep($('depL0'+i));
	}
}

function deSelect(dep){
	dep.parentNode.removeChild(dep);
	var tempon = dep.id.substr(4,dep.id.length)+';';
	var liste = $('departements').value;
	var newListe = liste.gsub(tempon,"");
		$("departements").value=newListe;
}


function deSelectFrance(){
	$('insertIci').innerHTML = '<br/>';
	$('departements').value = '';
}


//---------- 


function submitFormInsertInfo(){
	
	$('dateDiff').value=$('dojoDate').firstChild.value;

	var test=0;
	
	//-------------------------------------------------------------------------
	if( checkSimple($('sujet').value) ){
		$('sujet').parentNode.previousSibling.className="true"; test++;
	}else{
		$('sujet').parentNode.previousSibling.className="false";
	}
	//-------------------------------------------------------------------------
	if( checkSimple($('info').value) ){
		var tr = $('info').parentNode.parentNode.previousSibling;
		if( tr.data ) tr = tr.previousSibling;
		var td = tr.firstChild;
		if(td.data)td=td.nextSibling;
		td.className="true"; test++;
	}else{
		var tr = $('info').parentNode.parentNode.previousSibling;
		if( tr.data ) tr = tr.previousSibling;
		var td = tr.firstChild;
		if(td.data)td=td.nextSibling;
		td.className="false";
	}
	//-------------------------------------------------------------------------
	if( checkSimple($('diffuseur').value) ){
		$('diffuseur').parentNode.previousSibling.className="true"; test++;
	}else{
		$('diffuseur').parentNode.previousSibling.className="false";
	}
	if( checkSimple($('idCategorie').value) ){
		if($('idCategorie').parentNode.previousSibling.data) var elt = $('idCategorie').parentNode.previousSibling.previousSibling;
			else var elt = $('idCategorie').parentNode.previousSibling;
		elt.className="true"; test++;
	}else{
		if($('idCategorie').parentNode.previousSibling.data) var elt = $('idCategorie').parentNode.previousSibling.previousSibling;
			else var elt = $('idCategorie').parentNode.previousSibling;
		elt.className="false";
	}
	if( checkSimple($('dateDiff').value) ){
		var dateJour = new Date();
		
		var annee =$('dateDiff').value.substr(0,4);
		
		var mois = $('dateDiff').value.substr(5,2);
		
		var jour = $('dateDiff').value.substr(8,2);
		
		var dateChoisie = new Date(annee, mois-1, jour);
		
		
		if( dateJour >= dateChoisie ){
			$('dateDiff').parentNode.className="false";
			//-- affichage message
			$('badDateDiff').style.visibility='visible';
		}else{
			$('dateDiff').parentNode.className="true";
			test++;
			$('badDateDiff').style.visibility='hidden';
		}
		
	}else{
		$('badDateDiff').style.visibility='hidden';
		$('dateDiff').parentNode.className="false";
	}
	if( checkSimple($('departements').value) ){
		var tr = $('departements').parentNode.parentNode.previousSibling;
		if( tr.data ) tr = tr.previousSibling;
		var td = tr.firstChild;
		if(td.data)td=td.nextSibling;
		td.className="true"; test++;
	}else{
		var tr = $('departements').parentNode.parentNode.previousSibling;
		if( tr.data ) tr = tr.previousSibling;
		var td = tr.firstChild;
		if(td.data)td=td.nextSibling;
		td.className="false";
	}
	if(test==6){
		$('formError').style.visibility='hidden';
		return true;
	}else{
		$('formError').style.visibility='visible';
		return false;
	}
}

//-------------- HISTORIQUE --

function survolSujet(element){
	Element.setStyle(element,{
		textDecoration:'underline',
		cursor:'pointer'
	});
}
function outSujet(element){
	Element.setStyle(element,{
		textDecoration:'none',
		cursor:'default'
	});
}

function getDimBrowser(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	var dim ={width:myWidth,height:myHeight};
	return dim;
}

function afficheInfo(numInfo){
	var scroll = document.documentElement.scrollTop;
	var param = 'idInfo='+numInfo;
	var ajaxRequest = new Ajax.Request(
			'scripts/users/checkInfo.ajax.php',
			{
				"method": 'post',
				"postBody": param,
				"asynchronous":false
			});
	var reponseText = ajaxRequest.transport.responseText;
		//alert(reponseText);
		reponseText = reponseText.gsub('\\n','');
		reponseText = reponseText.gsub('\\r','');
		reponseText.toJSON();
		var info = reponseText.evalJSON();
		
	var body = document.getElementsByTagName('BODY')[0];
		
	var divGris = document.createElement('DIV');
		divGris.setAttribute('ID','divGris');
	var dim = getDimBrowser();
		Element.setStyle(divGris,{
			position:'absolute',
			top:'0px',
			left:'0px',
			width:dim.width+'px',
			height:(dim.height+scroll)+'px',
			opacity:'0.7',
			zIndex:'2',
			backgroundColor:'#555'
		});
		
	var infoDiv = document.createElement('Div');
		infoDiv.setAttribute('ID','infoDiv');
		Element.setStyle(infoDiv,{
			position:'absolute',
			top:'50%',
			left:'50%',
			marginLeft:'-305px',
			paddingBottom:'50px',
			marginTop:(-200+scroll)+'px',
			width:'600px',
			zIndex:'3',
			backgroundColor:'#fff'
		});
		
	var fermer = document.createElement('DIV');
		Element.setStyle(fermer,{
			position:'absolute',
			bottom:'15px',
			left:'50%',
			marginLeft:'-33px',
			background:'url(images/fermer.jpg) no-repeat',
			cursor:'pointer',
			width:'75px',
			height:'25px'
		});
		Event.observe(fermer, 'click', function(){body.removeChild(infoDiv);body.removeChild(divGris);});
		infoDiv.appendChild(fermer);
		
	var infoContent = document.createElement('TABLE');
		infoContent.className='infoContent';
	var tbody = document.createElement('TBODY');
		//-- Sujet
		var newTR = document.createElement('TR');
			var newTD = document.createElement('TD');
				newTD.setAttribute('colSpan','2');
				newTD.className='infoSujet';
				var text = document.createTextNode(info.sujet);
						newTD.innerHTML=info.sujet;
					newTR.appendChild(newTD);
				tbody.appendChild(newTR);
			//infoDiv.appendChild(infoContent);
			
		//-- Info
		var newTR = document.createElement('TR');
			var newTD = document.createElement('TD');
				newTD.setAttribute('colSpan','2');
				newTD.className='infoInfo';
				var text = document.createTextNode(info.info);
						newTD.innerHTML=info.info;
					newTR.appendChild(newTD);
				tbody.appendChild(newTR);
			//infoDiv.appendChild(infoContent);
			
		var infoTab = new Array();					var intitule = new Array();
			infoTab[0]= info.intituleCategorie;			intitule[0]= 'Catégorie : ';
			infoTab[1]= info.dateDiffusion;				intitule[1]= 'Date de diffusion : ';
			infoTab[2]= info.diffuseur;					intitule[2]= 'diffuseur : ';
			infoTab[3]= info.telInfo;					intitule[3]= 'Téléphone : ';
			infoTab[4]= info.adrInfo;					intitule[4]= 'Adresse : ';
			infoTab[5]= info.urlInfo;					intitule[5]= 'Lien internet : ';
			
		for( i=0;i<6;i++ ){
			var newTR = document.createElement('TR');
				var newTD = document.createElement('TD');
					newTD.className='infoPropriete';
					var text = document.createTextNode(intitule[i]);
							newTD.appendChild(text);
						newTR.appendChild(newTD);
			
				var newTD = document.createElement('TD');
					if(i!=5) var text = document.createTextNode(infoTab[i]);
						else{
							if(infoTab[i].length>50) var text = document.createTextNode(infoTab[i].substr(0,50)+'...');
								else var text = document.createTextNode(infoTab[i]);
						}
						if(i==5){
							var newA = document.createElement('A');
								newA.setAttribute('HREF',infoTab[5]);
								newA.appendChild(text);
								newTD.appendChild(newA);
						}else{
							newTD.appendChild(text);
						}
							newTR.appendChild(newTD);	
					tbody.appendChild(newTR);
		}
		
		infoContent.appendChild(tbody);
		infoDiv.appendChild(infoContent);
		body.appendChild(divGris);
		body.appendChild(infoDiv);

}

function activeTri(element){
	if(element.value!='') $('ordreTri').removeAttribute('disabled');
		else $('ordreTri').setAttribute('disabled','disabled');
}
function activeDate(element){
	if(element.value!='') $('ordreDate').removeAttribute('disabled');
		else $('ordreDate').setAttribute('disabled','disabled');
}
function activePeriode(element){
	if(element.value!=''){
		$('jourDate').removeAttribute('disabled');
		$('moisDate').removeAttribute('disabled');
		$('anneeDate').removeAttribute('disabled');
		$('submitDate').value='afficher';
	}else{
		$('jourDate').setAttribute('disabled','disabled');
		$('moisDate').setAttribute('disabled','disabled');
		$('anneeDate').setAttribute('disabled','disabled');
		$('submitDate').value='afficher tout';
	}
}

//-- zone lecteurs

	//-- inscription
	
function valideFormLecteurs(element,mode){
	var test=0;
	if( $('civilite').value!='' ) {$('civilite').parentNode.previousSibling.className="true";test++;}
		else $('civilite').parentNode.previousSibling.className="false";
		
	if( $('prenom').value!='' ) {$('prenom').parentNode.previousSibling.className="true";test++;}
		else $('prenom').parentNode.previousSibling.className="false";
		
	if( $('nom').value!='' ) {$('nom').parentNode.previousSibling.className="true";test++;}
		else $('nom').parentNode.previousSibling.className="false";
		
	if( $('departements').value!='' ) test++;
	
	if(test==4) return true;
		else{
			if(mode){
				$('errForm').style.visibility='visible';
				if( $('departements').value=='' ) $('errDep').style.visibility='visible';
					else $('errDep').style.visibility='hidden';
			}
			return false;
		}
}

function valideFormUpdateLecteurs(element){
	if( $('civilite').value!='' ) $('civilite').parentNode.previousSibling.className="true";
		else $('civilite').parentNode.previousSibling.className="false";
		
	if( $('prenom').value!='' ) $('prenom').parentNode.previousSibling.className="true";
		else $('prenom').parentNode.previousSibling.className="false";
		
	if( $('nom').value!='' ) $('nom').parentNode.previousSibling.className="true";
		else $('nom').parentNode.previousSibling.className="false";
	
	//-- Cas de l'email
	if( checkMail($('email').value) ){
			$('email').parentNode.previousSibling.className = "true";
			//$('errMail').style.visibility = 'hidden';
	}else{
			$('email').parentNode.previousSibling.className = "false";
			//if(element.id=='email') $('errMail').style.visibility='visible';
	}
}


function advancedSearch(){
	Element.setStyle($('advancedSearch'),{
							display : 'block'
					});
	$('validAdvancedSearch').value='1';
}
function rechercheSimple(){
	Element.setStyle($('advancedSearch'),{
							display : 'none'
					});
	$('validAdvancedSearch').value='0';
}

function selectGeo(){
	Element.setStyle($('searchDepDiv'),{display:'block'});
	Element.setStyle($('categories'),{visibility:'hidden'});
}
function hideGeo(){
	Element.setStyle($('searchDepDiv'),{display:'none'});
	Element.setStyle($('categories'),{visibility:'visible'});
}

function afficheDeps(num){
	for(i=1;i<=22;i++) Element.setStyle($('dep'+i),{display:'none'});
	
	Element.setStyle($('dep'+num),{display:'block'});
}

function testDep(element){

	var p = $('validGeo');
	var liste = p.innerHTML;
	if(element.checked==true){
		liste += element.value+'/';
		p.innerHTML=liste;
	}else{
		var tempon = element.value+'/';
		var newListe = liste.gsub(tempon,"");
		p.innerHTML=newListe;
	} 
	
	for(i=1;i<=95;i++){
		if(i<10) temp = '0'+i;
			else temp = i;
		if( $('idDep'+temp).checked==true ){			
			$('selectGeoBouton').innerHTML = 'sélection personalisée';
			break;
		}else{
			$('selectGeoBouton').innerHTML = 'toute la France';
		}
	}
}

function effacerDep(){
	$('selectGeoBouton').innerHTML = 'toute la France';
	$('validGeo').innerHTML = 'votre sélection : ';
	
	for(i=1;i<=95;i++){
		if(i<10) temp = '0'+i;
			else temp = i;
		$('idDep'+temp).checked=false;
	}
}

function validAnnee(annee){
	var maintenant = new Date();
		anneeEnCours = maintenant.getFullYear();
		if(anneeEnCours==annee){
			// on desactive les mois pas encore passés.
			var moisEnCours = maintenant.getMonth()+1;
			for(i=1;i<=12;i++){
				if(i>moisEnCours) $('mois'+i).setAttribute('disabled','disabled');
					else $('mois'+i).removeAttribute('disabled');
			}
		}
}
//-- Pour Ajax --
function verifPass(pass){
	var param = 'pass='+pass;
		var ajaxRequest = new Ajax.Request(
					'actions/verifPass.ajax.php',
					{
						"method": 'post',
						"postBody": param,
						"asynchronous":false
					}
							);
			var reponseText = ajaxRequest.transport.responseText; 
			if( reponseText != '0' ) $('pastPass').className='true';
				else $('pastPass').className='false';
}
function verifNewPass(pass){
	if(pass.length>=6) $('newPass').className='true';
		else $('newPass').className='false';
}
function verifNewPass2(pass){
	if($('pass1').value==$('pass2').value) $('newPass2').className='true';
		else $('newPass2').className='false';
}
function autorise(e){
	var keynum;
	
	if(window.event){ // IE
		keynum = e.keyCode;
	}else if(e.which){ // Firefox/Opera
		keynum = e.which;
	}
	if( (keynum>=97 && keynum<=122) || (keynum>=65 && keynum<=90) || (keynum>=48 && keynum<=57) || keynum==8 || !keynum ) return true;
		else return false;
}

function affCat(get,value){
	if(value!='') window.location.href = "index.php?"+get+"&cat="+value;
		else window.location.href = "index.php?"+get;
}
function affDate(get){
	if( $('dateFiltre').value=='' ||
		 $('ordreDate').value=='' || 
		 $('jourDate').value=='' || 
		 $('moisDate').value=='' || 
		 $('anneeDate').value=='' )
	{
		var url = "index.php?"+get;
		 	window.location.href = url;
	}else{
		var url = "index.php?"+get;
			url += "&t="+$('dateFiltre').value;
			url += "&p="+$('ordreDate').value;
			url += "&j="+$('jourDate').value;
			url += "&m="+$('moisDate').value;
			url += "&a="+$('anneeDate').value;
		 	window.location.href = url;
	}
}

function coche(element){
	$('tempCheck').checked = false;
}

function deCoche(num){
	for(var i=1;i<=num;i++) $('cat'+i).checked = false;
}