function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function modif_check(i){
	var choix = document.form1.modif;
	choix[i].checked = true;
}

function isIE() {
	if (navigator.appName == "Microsoft Internet Explorer")
		return 1
	else
		return 0
}

function isMozilla() {
	if (navigator.appName == "Netscape")
		return 1
	else
		return 0
}

function SetText(text) 
{ 
document.formulaire.contenu.value=text 
document.formulaire.contenu.focus() 
document.formulaire.sig.checked = false 
}

function SetMpText(titre, text) 
{ 
document.formulaire.msg_subject.value=titre 
document.formulaire.contenu.value=text 
document.formulaire.contenu.focus() 
document.formulaire.sig.checked = false 
} 


function ahrefThis() {
	var invite="Entrez ici l'URL que vous voulez lier :"
	if (isIE()) {
		var strSelection = document.selection.createRange().text
		if (strSelection == "") document.formulaire.contenu.focus()
                var strHref = prompt(invite,"http://")
	        if (strHref == null) return
	        document.selection.createRange().text = "<a href=" + strHref + " target=\"_blank\">" + strSelection + "</a>"
        }
        else if (isMozilla())
        {
                var editBox = document.formulaire.contenu;
                var textString = editBox.value;
                var positionStart = editBox.selectionStart;
                var scrollTop = editBox.scrollTop;
                var positionEnd = editBox.selectionEnd;
                var linkText = "";
                if (positionEnd != positionStart)
                {
                        linkText = textString.substring(positionStart, positionEnd);
                }
                var linkHref = prompt(invite,"http://");
                if (linkHref == null) return;

                var revisedMessage = textString.substring(0, positionStart) + "<a href=" + linkHref + " target=\"_blank\">" + linkText + "</a>" +  textString.substring(positionEnd, textString.length);
                editBox.value = revisedMessage;
                editBox.focus();
                editBox.setSelectionRange(positionStart, positionStart + linkHref.length + linkText.length + 12);
                editBox.scrollTop = scrollTop;
        }
        else {
		var strHref = prompt(invite,"http://")
		if (strHref == null) return
		var currentMessage = document.formulaire.contenu.value
		var revisedMessage = currentMessage + "<a href=" + strHref + "></a>"
		document.formulaire.contenu.value=revisedMessage
		document.formulaire.contenu.focus()
	}
}


function picture(from) {
	document.formulaire.contenu.focus();
	var stPic = prompt("Entrez ici l'URL de l'image que vous souhaitez insérer :","http://");
	if (stPic == null) return;
        var picTag = "<img border=\"0\" src=\"" + stPic + "\">";
	if (isIE()) {
		document.selection.createRange().text = picTag;
	}
	else if (isMozilla())
	{
                var editBox = document.formulaire.contenu;
                var textString = editBox.value;
                var position = editBox.selectionStart;
                var scrollTop = editBox.scrollTop;
                var revisedMessage = textString.substring(0, position) + picTag +  textString.substring(position, textString.length);
                editBox.value = revisedMessage;
                editBox.focus();
                editBox.setSelectionRange(position, position);
                editBox.scrollTop = scrollTop;
        }
	else {
		var currentMessage = document.formulaire.contenu.value;
		var revisedMessage = currentMessage + picTag;
		document.formulaire.contenu.value=revisedMessage;
		document.formulaire.contenu.focus();
	}
}


function boldThis(from) {
	var invite="Entrez ici le contenu à mettre en gras :"
	if (isIE()) {
		var strSelection = document.selection.createRange().text
		if (strSelection == "") {
			document.formulaire.contenu.focus()
			strSelection = prompt(invite,"")
			if (strSelection == null) return
		}
		document.selection.createRange().text = "<b>" + strSelection + "</b>"
	}
        else if (isMozilla())
        {
                var editBox = document.formulaire.contenu;
                var textString = editBox.value;
                var positionStart = editBox.selectionStart;
		var scrollTop = editBox.scrollTop;
                var positionEnd = editBox.selectionEnd;
                var boldText;
                if (positionEnd != positionStart)
                {
                        boldText = textString.substring(positionStart, positionEnd);
                }
                else
                {
                        boldText = prompt(invite,"");
                        if (boldText == null) return;
                }
                var revisedMessage = textString.substring(0, positionStart) + "<b>" + boldText + "</b>" +  textString.substring(positionEnd, textString.length);
                editBox.value = revisedMessage;
                editBox.focus();
                editBox.setSelectionRange(positionStart, positionStart + boldText.length + 7);
                editBox.scrollTop = scrollTop;
        }
	else {
		var strSelection = prompt(invite,"")
		var currentMessage = document.formulaire.contenu.value
		var revisedMessage = currentMessage + "<b>" + strSelection + "</b>"
		document.formulaire.contenu.value=revisedMessage
		document.formulaire.contenu.focus()
	}
}



function italicThis(from) {
	var invite="Entrez ici le contenu à mettre en italique :"
	if (isIE()) {
		var strSelection = document.selection.createRange().text
		if (strSelection == "") {
			document.formulaire.contenu.focus()
			strSelection = prompt(invite,"")
			if (strSelection == null) return
		}
		document.selection.createRange().text = "<i>" + strSelection + "</i>"
	}
        else if (isMozilla())
        {
                var editBox = document.formulaire.contenu;
                var textString = editBox.value;
                var positionStart = editBox.selectionStart;
                var scrollTop = editBox.scrollTop;
		var positionEnd = editBox.selectionEnd;
                var italicText;
                if (positionEnd != positionStart)
                {
                        italicText = textString.substring(positionStart, positionEnd);
                }
                else
                {
                        italicText = prompt(invite,"");
                        if (italicText == null) return;
                }
                var revisedMessage = textString.substring(0, positionStart) + "<i>" + italicText + "</i>" +  textString.substring(positionEnd, textString.length);
                editBox.value = revisedMessage;
                editBox.focus();
                editBox.setSelectionRange(positionStart, positionStart + italicText.length + 7);
                editBox.scrollTop = scrollTop;
        }
	else {
		var strSelection = prompt(invite,"")
		var currentMessage = document.formulaire.contenu.value
		var revisedMessage = currentMessage + "<i>" + strSelection + "</i>"
		document.formulaire.contenu.value=revisedMessage
		document.formulaire.contenu.focus()
	}
}


function underlineThis(from) {
	var invite="Entrez ici le contenu à souligner :"
	if (isIE()) {
		var strSelection = document.selection.createRange().text
		if (strSelection == "") {
			document.formulaire.contenu.focus()
			strSelection = prompt(invite,"")
			if (strSelection == null) return
		}
		document.selection.createRange().text = "<u>" + strSelection + "</u>"
	}
        else if (isMozilla())
        {
                var editBox = document.formulaire.contenu;
                var textString = editBox.value;
                var positionStart = editBox.selectionStart;
                var scrollTop = editBox.scrollTop;
                var positionEnd = editBox.selectionEnd;
                var underlineText;
                if (positionEnd != positionStart)
                {
                        underlineText = textString.substring(positionStart, positionEnd);
                }
                else
                {
                        underlineText = prompt(invite,"");
                        if (underlineText == null) return;
                }
                var revisedMessage = textString.substring(0, positionStart) + "<u>" + underlineText + "</u>" +  textString.substring(positionEnd, textString.length);
                editBox.value = revisedMessage;
                editBox.focus();
                editBox.setSelectionRange(positionStart, positionStart + underlineText.length + 7);
                editBox.scrollTop = scrollTop;
        }
	else {
		var strSelection = prompt(invite,"")
		var currentMessage = document.formulaire.contenu.value
		var revisedMessage = currentMessage + "<u>" + strSelection + "</u>"
		document.formulaire.contenu.value=revisedMessage
		document.formulaire.contenu.focus()
	}
}

function regleTaille() {
	var madiv = document.getElementById('menu_gauche');
	var centre = document.getElementById('centre');
	madiv.style.height=document.body.offsetHeight-233+'px';
	madiv.style.minHeight=centre.offsetHeight+'px';
}

function verif_form_contact(){
		if(window.document.form_contact.nom.value==''){
			alert('Le nom doit être saisi');
			window.document.form_contact.nom.focus();
			return false;
		}else if(window.document.form_contact.mail.value=='' || window.document.form_contact.mail.value.indexOf("@") == "-1" || window.document.form_contact.mail.value.indexOf(".") == "-1"){
			alert('L\'email doit être saisi et valide');
			window.document.form_contact.mail.focus();
			return false;
		}else if(window.document.form_contact.vous_etes.value==0){
			alert('Vous devez choisir votre profession');
			window.document.form_contact.vous_etes.focus();
			return false;
		}else if(window.document.form_contact.sujet_message.value==0){
			alert('Vous devez choisir le sujet de votre message');
			window.document.form_contact.sujet_message.focus();
			return false;
		}else if(window.document.form_contact.message.value==0){
			alert('Vous devez saisir votre message');
			window.document.form_contact.message.focus();
			return false;
		}else
			window.document.form_contact.submit();
			return true;
}

function verif_nom(){
		if(window.document.form_contact.nom.value==''){
			document.getElementById('spanNom').innerHTML  = "&nbsp;&nbsp;<img src='images/wrong.gif'>";
		}else{
			document.getElementById('spanNom').innerHTML  = "&nbsp;&nbsp;<img src='images/right.gif'>";
		}
}
function verif_mail(){
		if(window.document.form_contact.mail.value=='' || window.document.form_contact.mail.value.indexOf("@") == "-1" || window.document.form_contact.mail.value.indexOf(".") == "-1"){
			document.getElementById('spanMail').innerHTML  = "&nbsp;&nbsp;<img src='images/wrong.gif'>";
		}else{
			document.getElementById('spanMail').innerHTML  = "&nbsp;&nbsp;<img src='images/right.gif'>";
		}
}
function verif_prof(){
		if(window.document.form_contact.vous_etes.value==0){
			document.getElementById('spanProf').innerHTML  = "&nbsp;&nbsp;<img src='images/wrong.gif'>";
		}else{
			document.getElementById('spanProf').innerHTML  = "&nbsp;&nbsp;<img src='images/right.gif'>";
		}
}
function verif_sujet(){
		if(window.document.form_contact.sujet_message.value==0){
			document.getElementById('spanSujet').innerHTML  = "&nbsp;&nbsp;<img src='images/wrong.gif'>";
		}else{
			document.getElementById('spanSujet').innerHTML  = "&nbsp;&nbsp;<img src='images/right.gif'>";
		}
}

function afficher(id){
    if(document.getElementById)
		if(document.getElementById(id).style.display == "none"){
			document.getElementById(id + "_message").style.display = "none";
        	document.getElementById(id).style.display = "block";			
		}else{
			document.getElementById(id + "_message").style.display = "block";
			document.getElementById(id).style.display = "none";			
		}
}

function ajoutFavoris() {
	if ( navigator.appName != 'Microsoft Internet Explorer' ){
		window.sidebar.addPanel('ESPACE ELEC. - Dstributeur de matériel électrique en Corse','http://www.espace-elec.net','');
	}else{
		window.external.AddFavorite('http://www.espace-elec.net','ESPACE ELEC. - Dstributeur de matériel électrique en Corse');
	}
}

function wait(span) {
	document.getElementById(span).innerHTML = "<img src='images/loading.gif'>"
}