/************************************************************************************
 *  Copyright Spyder Innov 2010 pour MEMSOFT
 *  Créateur JC LABRADOR
 *  Date de modification : 08/2010
*************************************************************************************/     
  if (objPopup!=undefined) {
    objPopup.imgclosepath="/images/popclose.gif";
    objPopup.backgroundColor="#ffffff";
  }
  var winpdf=null;
	function ajouterpanier(id, alea) {
// 		var sel=makeOptionsSel("document.frmMain.chk"+id);
		sel="";
		if (alea!=undefined) obj=document.getElementById("txtqte"+id+alea);
		else obj=document.getElementById("txtqte"+id);
 		data="action=ajout&artid="+id+"&qte="+obj.value;
 		HTTPrequestSync("/dynamic/actionspanier.php", data);
	}
	
  function changeErreurQtePanier(ligneid, qte) {
    var obj=document.getElementById("txtqte"+ligneid);
    obj.value=qte;
  }
  
  function changeQtePanier(ligneid, totalligne, totalht, totaltva, totalttc) {
    setIfExists("totligne"+ligneid, totalligne+"&nbsp;&euro;");
    setIfExists("totalht", totalht+"&nbsp;&euro;");
    setIfExists("totaltva", totaltva+"&nbsp;&euro;");
    setIfExists("totalttc", totalttc+"&nbsp;&euro;");
    setIfExists("aregler", totalttc);
    if (document.frmPaiements.Haregler) document.frmPaiements.Haregler.value=totalttc;
  }
  
	function ctrlCGV() {
	  if (document.getElementById("chkCGV")) {
	    var objCHK=document.getElementById("chkCGV");
	    if (objCHK.checked) window.location="info-factur-livraison.html";
	    else alert("Vous devez accepter les 'Conditions gÃ©nÃ©rales de vente'");
	  }
	}

  function ctrlQtePanier(id, value, ligne) {
 		data="action=ctrlqte&artid="+id+"&qte="+value+"&ligneid="+ligne;
 		HTTPrequestSync("/dynamic/actionspanier.php", data);
//     alert(id+" "+value+" "+ligne);
  }
  	
	function identification(redirect) {
	  var objCtrl=new testform();
	  var strmsg="";
	  if (!objCtrl.MailValide(document.frmIdent.identifiant.value)) strmsg="Adresse e-mail invalide";
	  if (strmsg=="") {
	    var data="Haction=IDENTIFICATION&identifiant="+encodeURIComponent(document.frmIdent.identifiant.value)
	      +"&mdp="+encodeURIComponent(document.frmIdent.mdp.value)+"&redirect="+redirect;
	    HTTPrequestSync("/dynamic/common/GenActionsFront.php", data);
	  } else alert(strmsg);
	}
	
	function qtepanier(id, alea) {
	  var id2use="";
	  if (alea!=undefined) id2use="qte"+id+alea;
	  else id2use="qte"+id;
	  showitem(id2use);
	}
	
	function resendMailPassword(email, captcha) {
	  var objCtrl=new testform();
	  var strmsg="";
	  if (!objCtrl.MailValide(email)) strmsg="Adresse e-mail invalide";
	  if (strmsg=="") {
	    var data="Haction=RESENDMAIL&mail="+encodeURIComponent(document.frmIdent.txtMail2Resend.value)
	      +"&captcha="+encodeURIComponent(document.frmIdent.txtCaptchaIdent.value);
	    HTTPrequestSync("/dynamic/common/GenActionsFront.php", data);
	  } else alert(strmsg);
	}

  function sendmailCompte(id) {
    var data="Haction=MAILINFOCOMPTE&userid="+id;
    HTTPrequestSync("/dynamic/common/GenActionsFront.php", data);
  }
	
	var popclosecontent;
	var popclosecontenttmp;
	var poptimer;
	var poppgbar;
	var poplastpercent;
	
  function setVideo(flashfile) {
    if (flashfile!="") {
      var objswfcontent=AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','640','height','498','title','Memsoft','src','../xchange/fichiers/videos/Actiform2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
        'movie','/xchange/fichiers/videos/'+flashfile, 'id', 'mmovie', 'name', 'mmovie', 'width', '540', 'height', '420' ); //end AC code
      objPopup.setContent(objswfcontent);
      objPopup.initPopupClose(document.getElementById("popupclose"));
      objPopup.setAlignement("C", "C");
      objPopup.setContentStyle("", "", "center");
      objPopup.showPopupSize(600, 480);
    }
  }
  
// 	var popclosecontent;
// 	var popclosecontenttmp;
// 	var poptimer;
// 	var poppgbar;
// 	var poplastpercent;
//   function setVideo(flashfile) {
//     if (flashfile!="") {
//       var objswfcontent=AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','640','height','498','title','Memsoft','src','../xchange/fichiers/videos/Actiform2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
//         'movie','/xchange/fichiers/videos/'+flashfile, 'id', 'mmovie', 'name', 'mmovie', 'width', '540', 'height', '420' ); //end AC code
//       clearInterval(poptimer);
//       objPopup.setContent(objswfcontent);
//       objPopup.initPopupClose(document.getElementById("popupclose"));
//       popclosecontent=document.getElementById("popupclose").innerHTML;
//       popclosecontenttmp="<div style=\"background-color:#D5D5D5; width:540px; height:14px; border:#D8D8D8 solid 1px; margin-left:30px;\"><div id=\"alrternattext\" style=\"text-align: center;background-color:#ff0000; width:1px; height:14px; margin:0px; font-size:12px; color:#ffffff;\"></div></div>"+document.getElementById("popupclose").innerHTML;
//       document.getElementById("popupclose").innerHTML=popclosecontenttmp;
//       poppgbar=document.getElementById("alrternattext");
//       poplastpercent=0;
//       objPopup.setAlignement("C", "C");
//       objPopup.setContentStyle("", "", "center");
//       poptimer=window.setTimeout("testSWFLoad()", 400);
//       objPopup.showPopupSize(600, 480);
//     }
//   }
  
  function testSWFLoad() {
    if (document.getElementById("popcontent")&&objPopup.isshow==1) {
      if ((isIE&&window.document.mmovie!=undefined)||(!isIE&&document.mmovie!=undefined)) {
        var testMovie = isIE ? window.document.mmovie.object : document.mmovie;
        if ((isIE&&(testMovie.ReadyState==0||testMovie.ReadyState==1))||(!isIE&&testMovie.PercentLoaded==undefined)) {
          poppgbar.style.width="0px"; poppgbar.innerHTML="";
          poptimer=window.setTimeout("testSWFLoad()", 200);
        } else if ((isIE&&testMovie.ReadyState==4)||(!isIE&&testMovie.PercentLoaded()>=100)||poplastpercent>=100) {
          objPopup.initPopupClose(document.getElementById("popupclose"));
          clearTimeout(poptimer);
        } else if (testMovie.PercentLoaded()<100) {
          var percent=testMovie.PercentLoaded();
          if (percent<0) {
            objPopup.initPopupClose(document.getElementById("popupclose"));
            clearTimeout(poptimer);
          } else {
            poplastpercent=percent;
            var pgbar=document.getElementById("alrternattext");
            poppgbar.style.width=(538*percent/100)+"px";
            poppgbar.innerHTML=percent+" %";
            poptimer=window.setTimeout("testSWFLoad()", 200);
          }
        }
      } else {
        objPopup.initPopupClose(document.getElementById("popupclose"));
        clearTimeout(poptimer);
      }
    } else {
        objPopup.initPopupClose(document.getElementById("popupclose"));
        clearTimeout(poptimer);
    }
  }
  
  function showVideo(videoid) {
    data = "Haction=PLAYVIDEO&Hvideoid="+videoid;
  	HTTPrequestSync("/dynamic/common/GenActionsFront.php", data);
  }
  
	function supprpanier(id) {
 		data="action=suppr&lineid="+id+"&targetfile=panier.php";
 		HTTPrequestSync("/dynamic/actionspanier.php", data);
	}
  
  function swapIdent() {
    showorhide('dividentification'); showorhide('divmdpoublie');
  }
    
  function preloadImagesMenu(relativePath) {
    MM_preloadImages(relativePath+'images/on/bt-nav-accueil.jpg',relativePath+'images/on/bt-nav-produits.jpg',relativePath+'images/on/bt-nav-support.jpg',relativePath+'images/on/bt-nav-reseau-mem.jpg',relativePath+'images/on/bt-nav-a-propos.jpg',relativePath+'images/on/bt-nav-actualites.jpg',relativePath+'images/home/on/bt-en-savoir-plus.gif',relativePath+'images/home/on/bt-acheter.jpg',relativePath+'images/home/on/bt-en-savoir-plus-small.jpg',relativePath+'images/on/bt-se-deconnecter.jpg',relativePath+'images/on/bt-page-prec.gif');
  }
  
  var isfileexist=0;	
  function telechargerHTTP(filename) {
    data = "Haction=TESTFILEEXIST&filename="+filename;
  	HTTPrequestSync("/dynamic/common/GenActionsFront.php", data);
    if (isfileexist==1) window.location=filename;
    else alert("Fichier inexistant");
  }

  function telechargerExe(fileid) {
    var objForm, objField, objField2;
    if (document.getElementById("down_form")==undefined) {
      objForm=createForm("down_form", "/dynamic/telecharger.php", "POST", "_self"); 
      objField=createFormField("input", "hidden", "filetype", '_EXE_');
      objForm.appendChild(objField);
      objField2=createFormField("input", "hidden", "fileid", fileid);
      objForm.appendChild(objField2);
      objField2=createFormField("input", "hidden", "filename", "");
      objForm.appendChild(objField2);
      document.body.appendChild(objForm);
    } else {
      objForm=document.getElementById("down_form");
      objForm.action="/dynamic/telecharger.php";
      objForm.filetype.value="_EXE_";
      objForm.fileid.value=fileid;
      objForm.filename.value=""; 
    }
    objForm.submit();
  }

  function telechargement(fileid, captcha) {
    var objForm, objField, objField2;
    if (document.getElementById("down_form")==undefined) {
      objForm=createForm("down_form", "/common/telecharger_exe.php", "POST", "_self"); 
      objField=createFormField("input", "hidden", "filetype", '_EXE_');
      objForm.appendChild(objField);
      objField2=createFormField("input", "hidden", "fileid", fileid);
      objForm.appendChild(objField2);
      objField2=createFormField("input", "hidden", "filename", "");
      objForm.appendChild(objField2);
      objField2=createFormField("input", "hidden", "captcha", captcha);
      objForm.appendChild(objField2);
      document.body.appendChild(objForm);
    } else {
      objForm=document.getElementById("down_form");
      objForm.action="/common/telecharger_exe.php";
      objForm.filetype.value="_EXE_";
      objForm.fileid.value=fileid;
      objForm.filename.value=""; 
      objForm.captcha.value=captcha;
    }
    objForm.submit();
  }
 
  function telechargerItem(filetype, fileid, filename) {
    var objForm, objField, objField2;
    if (document.getElementById("down_form")==undefined) {
      if (filetype=='_EXE_') objForm=createForm("down_form", "/common/telecharger_exe.php", "POST", "_self"); 
      else objForm=createForm("down_form", "/common/telecharger.php", "POST", "_self");
      objField=createFormField("input", "hidden", "filetype", filetype);
      objForm.appendChild(objField);
      objField2=createFormField("input", "hidden", "fileid", fileid);
      objForm.appendChild(objField2);
      if (filename==undefined) filename=""; 
      objField2=createFormField("input", "hidden", "filename", filename);
      objForm.appendChild(objField2);
      document.body.appendChild(objForm);
    } else {
      objForm=document.getElementById("down_form");
      if (filetype=='_EXE_') objForm.action="/common/telecharger_exe.php";
      else objForm.action="/common/telecharger.php";
      objForm.filetype.value=filetype;
      objForm.fileid.value=fileid;
      if (filename==undefined) filename="";
      objForm.filename.value=filename; 
    }
    objForm.submit();
  }

/************************************************************************************
 * Code de suivi google  
*************************************************************************************/     
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20543526-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

