// fonction permettant ecrire flash

function flash_object(url,anim,width,height,button){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">')
	document.write('<param name="movie" value="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="wmode" value="transparent">')
	document.write('<embed src="'+url+'flash/'+anim+'.swf?url='+url+'&link='+button+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent">')
	document.write('</embed></object>')
}

//fonction pour récupérer le préfixe téléphonique selon le pays
function writediv(prefixe){
	document.forms['form_inscription'].elements['prefixe_tel'].value = prefixe;
	document.forms['form_inscription'].elements['prefixe_fax'].value = prefixe;
}

function getTelephone(id){
     prefixe = file('getprefixe.php?id='+escape(id))
     writediv(prefixe);
}

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);
}

//////////////////////////////////////////////////////////////////////////////////////

//fonction pour vérifier en temps réel si l'email est pas déjà utilisé
function ecrit(texte){
     document.getElementById('valid').innerHTML = texte;
	 document.getElementById('valid2').innerHTML = texte;
}

function verifMail(email){
	if(email != ''){
		texte = renvoi('verifmail.php?email='+escape(email))
        if(texte == 1){
               ecrit('<span style="color:#cc0000">Cet email est déjà utilisé </span>');
		}else{
               ecrit('');
        }
     }
}

function renvoi(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);
}
	 
// popup simple => 1 ou 0 pr le scroll
function popup(page, nom, largeur, hauteur, scrol) {
 	window.open(page, ""+nom+"", "scrollbars="+ scrol +",menubar=no,toolbar=no,resizable=yes,width="+ largeur + ",height=" + hauteur);
}

//affiche le bon formulaire selon pro ou perso
function radioclick (b) {
	document.getElementById('perso').style.display = (b? 'block':'none');
	document.getElementById('pro').style.display = (b? 'none':'block');
}

//change la casse de la pemière lettre du mot
function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
	for (index = 0; index < strLen; index++)  {
	if (index == 0)  {
	tmpChar = tmpStr.substring(0,1).toUpperCase();
	postString = tmpStr.substring(1,strLen);
	tmpStr = tmpChar + postString;
	}
	else {
	tmpChar = tmpStr.substring(index, index+1);
	if (tmpChar == " " && index < (strLen-1))  {
	tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
	preString = tmpStr.substring(0, index+1);
	postString = tmpStr.substring(index+2,strLen);
	tmpStr = preString + tmpChar + postString;
			 }
		  }
	   }
	}
	frmObj.value = tmpStr;
}


