//cette fonction permet de créér un intérrupteur il suffit de mettre les Id des element a afficher/masquer en arguments
function vaEtViens(){
	for (i=0;i<arguments.length;i++) {
		var myElement=document.getElementById(arguments[i]);
		myElement.style.display=(myElement.style.display=="block")?"none":"block";
	}
}
function windowCenter(myId) {
	result=returnSize();
	var myWidth=result[0];
	var myHeight=result[1];
	var elementWidth=document.getElementById(myId).offsetWidth;
	var elementHeight=document.getElementById(myId).offsetHeight;
        var myScrollLeft=document.documentElement.scrollLeft;
	var myScrollTop=document.documentElement.scrollTop;
	var posX=myScrollLeft+myWidth-myWidth/2-elementWidth/2
	var posY=myScrollTop+myHeight-myHeight/2-elementHeight/2;
	document.getElementById(myId).style.left=posX+"px";
	document.getElementById(myId).style.top=posY+"px";
}
//récupère les informations de l'ecran de l'utilisateur
function returnSize() {
  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 result = new Array(myWidth,myHeight);
  return result;
}
//affiche un element et lance la fonction pour le centrer
function showPopup(myId,myEffect) {
	document.getElementById(myId).style.display="block";//hack IE qui pezu pas récupérer les dimensions d'un element en disply:none;
	nova.dom.centerObjectOnViewport(document.getElementById(myId));
	document.getElementById(myId).style.display="none";
	if (myEffect) {
		document.getElementById(myId).style.zIndex=10;//pali un defaut des div  en relative
		nova.effects.addToQueue(nova.effects.fadeIn,document.getElementById(myId),{duration:500});
		nova.effects.queueNext();
	}
	else {
		document.getElementById(myId).style.display="block";
	}
}
function hidePopup(myId) {	
	nova.effects.addToQueue(nova.effects.fadeOut,document.getElementById(myId),{duration:500});
	nova.effects.queueNext();
	//nova.effects.fadeOut(document.getElementById(myId),500);
	//document.getElementById(myId).style.display="none";
}
function inscriptionNewsletter() {
	listRadio=document.getElementsByName('civilite');
	for (i=0;i<listRadio.length;i++) {
		if(listRadio[i].checked) {
			sexe=listRadio[i].value;
		}
	}
	nom=document.getElementById('nom').value;
	prenom=document.getElementById('prenom').value;
	email=document.getElementById('email').value;
	if (document.getElementById('pro').checked) {
		societe=document.getElementById('societe').value;
	}
	else {
		societe="";
	}
	//alert(sexe+"|"+nom+"|"+prenom+"|"+email+"|"+societe);
	nova.io.send({
		file:"ajax/inscriptionnewsletter.php",
		method:"POST",
		queryString:"sexe="+sexe+"&nom="+nom+"&prenom="+prenom+"&email="+email+"&societe="+societe,
		onLoad:resultInscriptionNewsletter,
		onError:function () {}
	});
}
function resultInscriptionNewsletter(texte) {
	alert(texte);
	hidePopup('popNewsletter');
}
function RGBToHex(ColorString) {
	HexDigits = "0123456789abcdef";
    if (ColorString.charAt(0) == '#') {
    	return ColorString;
    } else {
   		ColorString = ColorString.substr(4);
    	pos = ColorString.indexOf(',');
    	Result = '#' + HexDigits.substr(Math.floor(ColorString.substr(0, pos) / 16), 1) + HexDigits.substr(ColorString.substr(0, pos) % 16, 1);
    	ColorString = ColorString.substr(pos + 1);
    	pos = ColorString.indexOf(',');
    	Result = Result + HexDigits.substr(Math.floor(ColorString.substr(0, pos) / 16), 1) + HexDigits.substr(ColorString.substr(0, pos) % 16, 1);
    	ColorString = ColorString.substr(pos + 1);
    	Result = Result + HexDigits.substr(Math.floor(ColorString.substr(0, pos) / 16), 1) + HexDigits.substr(ColorString.substr(0, pos) % 16, 1);
    	return Result;
    }
 }
function blinkMe(myElement,speed,firstColor,lastColor) {
	myTxt=document.getElementById(myElement);
	
	//alert(myTxt.style.color+"firstColor="+firstColor);
	myTxt.style.color=(RGBToHex(myTxt.style.color)==firstColor)?myTxt.style.color=lastColor:myTxt.style.color=firstColor;
	setTimeout("blinkMe('"+myElement+"',"+speed+",'"+firstColor+"','"+lastColor+"')",speed);
}
