// JavaScript Document
hs.graphicsDir = 'highslide/graphics/';
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'draggable-header';
hs.graphicsDir = 'highslide/graphics/';
hs.outlineType = 'custom';
hs.dimmingOpacity = 0.65;
hs.fadeInOut = true;
hs.align = 'center';
hs.captionEval = 'this.a.title';
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];}
}
/////////////////////////     controle champ email de newsletter   //////////////////////////

function VerificationEmail(elm)
{
if (elm.value.indexOf("@") != "-1" &&
    elm.value.indexOf(".") != "-1" &&
    elm.value != "")
    return true;

return false;
}
function controle(){
if ( document.ecrire.email.value=="Inserez votre e-mail" ||document.ecrire.email.value=="" || VerificationEmail(document.ecrire.email) == false )
                {     
alert("Veuillez remplir le champ E-mail correctement");
document.ecrire.email.focus();
return false;
} //alert("Votre EMAIL est enregistre");
return true; 	
		
    }

function efface()
{
 if(document.ecrire.email.value=='Inserez votre e-mail'){
 document.ecrire.email.value='';
	}
}
function returne()
{
 if(document.ecrire.email.value==''){
 document.ecrire.email.value='Inserez votre e-mail';
	}
}


function controle1(){
if ( document.ecrire.email.value=="Insert your e-mail" ||document.ecrire.email.value=="" || VerificationEmail(document.ecrire.email) == false )
                {     
alert("Please fill in the field E-mail correctly");
document.ecrire.email.focus();
return false;
} //alert("Your e-mail is saved");
return true; 	
		
    }
function efface1()
{
 if(document.ecrire.email.value=='Insert your e-mail'){
 document.ecrire.email.value='';
	}
}
function returne1()
{
 if(document.ecrire.email.value==''){
 document.ecrire.email.value='Insert your e-mail';
	}
}

////////////////////////////////////////////
	$(function() {
		$.nyroModalSettings({
			debug: true,
			processHandler: function(settings) {
				var url = settings.url;
				if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
					$.nyroModalSettings({
						type: 'swf',
						height: 355,
						width: 425,
						url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
					});
				}
			},
			endShowContent: function(elts, settings) {
				$('.resizeLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					$.nyroModalSettings({
						width: Math.random()*1000,
						height: Math.random()*1000
					});
					return false;
				});
				$('.bgLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					$.nyroModalSettings({
						bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
					});
					return false;
				});
			}
		});
		
		$('#manual').click(function(e) {
			e.preventDefault();
			var content = 'Content wrote in JavaScript<br />';
			jQuery.each(jQuery.browser, function(i, val) {
				content+= i + " : " + val+'<br />';
			});
			$.fn.nyroModalManual({
				bgColor: '#3333cc',
				content: content
			});
			return false;
		});
		$('#manual2').click(function(e) {
			e.preventDefault();
			$('#imgFiche').nyroModalManual({
				bgColor: '#cc3333'
			});
			return false;
		});
		$('#myValidForm').submit(function(e) {
			e.preventDefault();
			if ($("#myValidForm :text").val() != '') {
				$('#myValidForm').nyroModalManual();
			} else {
				alert("Enter a value before going to " + $('#myValidForm').attr("action"));
			}
			return false;
		});
		$('#block').nyroModal({
			'blocker': '#blocker'
		});
		
		function preloadImg(image) {
			var img = new Image();
			img.src = image;
		}
		
		preloadImg('img/ajaxLoader.gif');
		preloadImg('img/prev.gif');
		preloadImg('img/next.gif');
		
	});
	
	// Page enhancement
	$(function() {
		var allPre = $('pre');
		allPre.each(function() {
			var pre = $(this);
			var link = $('<a href="#" class="showCode">Show Code</a>');
			pre.hide().before(link).before('<br />');
			link.click(function(event) {
					event.preventDefault();
					pre.slideToggle('fast');
					return false;
				});
		});
		var shown = false;
		$('#showAllCodes').click(function(event) {
			event.preventDefault();
			if (shown)
				allPre.slideUp('fast');
			else
				allPre.slideDown('fast');
			shown = !shown;
			return false;
		});
	});
//////////////////////////////  contact  ///////////////////////////////////////////////////////////////////////

function changercontenue(toThis)
  {
  if (document.getElementById(toThis))
    {
	document.getElementById("web").style.display = 'none';
	document.getElementById("design").style.display = 'none';
	document.getElementById("troixd").style.display = 'none';
	document.getElementById("flash").style.display = 'none';
	document.getElementById("sou_trait").style.display = 'none';
	document.getElementById("referencement").style.display = 'none';
	document.getElementById("web_marketing").style.display = 'none';
	document.getElementById(toThis).style.display = 'block';
	
	document.getElementById("web1").style.display = 'none';
	document.getElementById("design1").style.display = 'none';
	document.getElementById("troixd1").style.display = 'none';
	document.getElementById("flash1").style.display = 'none';
	document.getElementById("sou_trait1").style.display = 'none';
	document.getElementById("referencement1").style.display = 'none';
	document.getElementById("web_marketing1").style.display = 'none';
	document.getElementById(toThis).style.display = 'block';
	
	document.formulaire.test.value=(toThis);
    }
	
 
  } 
  
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function checkForm(els){
var els = els.elements; // éléments du formulaire
var regEx =/^test-(.+)/; // expression régulière testant si le champs est à valider
for ( var i = 0 ; i < els.length ; i++ ) { // on boucle sur les éléments du formulaire
if(regEx.test(trim(els[i].name.toString()))){ // test si le champs est à valider
switch(els[i].type){ //Chaque élément à son test personnalisé

 //test des champs de type text
 case "text":
 if(trim(els[i].value).length <= 0){
alert("vous devez remplir le champs de text");
 els[i].focus();
 return false;
 }else{ // test si c'est un champs contenant un email
regExEmail = /^test-email-(.+)/;
if(regExEmail.test(trim(els[i].name.toString()))){
if(!isEmail(els[i].value)){
 alert("l'email saisie est invalide");
 els[i].focus();
 return false;
 }
 }
 }
 break;  
  //test des champs de type textarea
 case "textarea":
 if(trim(els[i].value).length <= 0){
 alert("vous devez remplir le champs de text");
 els[i].focus();
 return false;
 }
 break; 
  } // fin du switch
} // fin du for
 } // fin du if
 if(test){
 return false;
 }
 }
  
 function isEmail(strSaisie) {
 var verif = /^[^@]+@(([\w\-]+\.){1,4}[a-zA-Z]{2,4}|(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]))$/
return ( verif.test(strSaisie) );
 }

 //fonction trouvé à l'adresse suivante
 //http://anothergeekwebsite.com/fr/2007/03/trim-en-javascript
 function trim(aString) {
 var regExpBeginning = /^\s+/;
 var regExpEnd = /\s+$/;
 return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
 }
/////////////////////////////////////////////////////////////////////////////////////////////////

function enlargeSuite(iddiv)
	{    	var suite=document.getElementById(iddiv);
suite.style.display = "block";
	var largeur=suite.style.width.split("px");
	var hauteur=suite.style.height.split("px");
	suite.style._alpha += 0;
	suite.style.width=parseInt(largeur[0])+4+"px";
	suite.style.height=parseInt(hauteur[0])+2+"px";
	//alert(hauteur[0]);
	if(suite.style._alpha >= 100) {
     delete suite.style.onEnterFrame;
     }
	if(hauteur[0]<450)
	{
	 setTimeout("enlargeSuite('"+iddiv+"')",2);
	}
	}
 //////////////////////////////////////index.php//////////////////////////
 function affich_form_rec_client() {
	if(document.getElementById("formulaire_recommander_client").style.display=="") {
		document.getElementById("formulaire_recommander_client").style.display="none";
	} else {
		document.getElementById("formulaire_recommander_client").style.display="";	
	}
}
/////////////////////controle champ page devis.php///////////////////////////////////////////////

function MM_validateForm() { //v4.0

  if (document.getElementById){

    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);

      if (val) { nm=val.id; if ((val=val.value)!="") {

        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

          if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit être une adresse e-mail valide.\n';

        } else if (test!='R') { num = parseFloat(val);

          if (isNaN(val)) errors+='- '+nm+' doit être un numéro.\n';

          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

            min=test.substring(8,p); max=test.substring(p+1);

            if (num<min || max<num) errors+='- '+nm+' doit être un nombre compris entre '+min+' et '+max+'.\n';

      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est requis.\n'; }

    } if (errors) alert('Veuillez corriger les erreurs suivantes :\n'+errors);

    document.MM_returnValue = (errors == '');

	

} }


////////////// code d'attachement d'un fichier  //////////////////////////////
function InvertFileUpload() {

if (document.getElementById('attachp').style.display=="none") document.getElementById('attachp').style.display="block";

else document.getElementById('attachp').style.display="none";

if (document.getElementById('attachp2').style.display=="none") document.getElementById('attachp2').style.display="block";

else document.getElementById('attachp2').style.display="none";

if (document.getElementById('attachp3').style.display=="none") document.getElementById('attachp3').style.display="block";

else document.getElementById('attachp3').style.display="none";

if (document.getElementById('attachp4').style.display=="none") document.getElementById('attachp4').style.display="block";

else document.getElementById('attachp4').style.display="none";


if (document.getElementById('attachp5').style.display=="none") document.getElementById('attachp5').style.display="block";

else document.getElementById('attachp5').style.display="none";


if (document.getElementById('attachp6').style.display=="none") document.getElementById('attachp6').style.display="block";

else document.getElementById('attachp6').style.display="none";

if (document.getElementById('attachp7').style.display=="none") document.getElementById('attachp7').style.display="block";

else document.getElementById('attachp7').style.display="none";

if (document.getElementById('attachp8').style.display=="none") document.getElementById('attachp8').style.display="block";

else document.getElementById('attachp8').style.display="none";

if (document.getElementById('attachp9').style.display=="none") document.getElementById('attachp9').style.display="block";

else document.getElementById('attachp9').style.display="none";

if (document.getElementById('attachp10').style.display=="none") document.getElementById('attachp10').style.display="block";

else document.getElementById('attachp10').style.display="none";
if (document.getElementById('attachp11').style.display=="none") document.getElementById('attachp11').style.display="block";

else document.getElementById('attachp11').style.display="none";

if (document.getElementById('attachp14').style.display=="none") document.getElementById('attachp14').style.display="block";

else document.getElementById('attachp14').style.display="none";

if (document.getElementById('attachp15').style.display=="none") document.getElementById('attachp15').style.display="block";

else document.getElementById('attachp15').style.display="none";

if (document.getElementById('attachp141').style.display=="none") document.getElementById('attachp141').style.display="block";

else document.getElementById('attachp141').style.display="none";

if (document.getElementById('attachp151').style.display=="none") {document.getElementById('attachp151').style.display="block";  document.getElementByClassName('nom_fichier').style.display="block";}

else document.getElementById('attachp151').style.display="none";


}
/////////////////////  controle de formulaire de contact ////////////////////////





