var InMenu;

if (!Langue && !OtherLang)
{
	var Langue = false, OtherLang;
	var FN = document.location.href;

	if (FN.indexOf("_EN.php") != -1)
		FN = "index_EN.html";
	else if (FN.indexOf(".html") == -1)
		FN="index.html";
	else
		FN = FN.substring(FN.lastIndexOf("/") + 1);

	if (FN.search("_EN.html") != -1)
	{
		OtherLang = FN.substr(0, FN.lastIndexOf(".") - 3);
		OtherLang = OtherLang + ".html";
		Langue = true;
	}
	else
		OtherLang = FN.substr(0, FN.lastIndexOf(".")) + "_EN.html";
}

var Suff = (Langue) ? "_EN" : "";

var ObjMenu;
var PageH = 535, PageW = 780;

if (Langue)
{
	Menu1N = new Image;
	Menu1N.src = "http://www.gestion-pme.com/Image/Menu1_EN.gif";
	Menu1H = new Image;
	Menu1H.src = "http://www.gestion-pme.com/Image/Menu1H_EN.gif";

	Menu2N = new Image;
	Menu2N.src = "http://www.gestion-pme.com/Image/Menu2_EN.gif";
	Menu2H = new Image;
	Menu2H.src = "http://www.gestion-pme.com/Image/Menu2H_EN.gif";

	Menu3N = new Image;
	Menu3N.src = "http://www.gestion-pme.com/Image/Menu3_EN.gif";
	Menu3H = new Image;
	Menu3H.src = "http://www.gestion-pme.com/Image/Menu3H_EN.gif";

	Menu4N = new Image;
	Menu4N.src = "http://www.gestion-pme.com/Image/Menu4_EN.gif";
	Menu4H = new Image;
	Menu4H.src = "http://www.gestion-pme.com/Image/Menu4H_EN.gif";
}
else
{
	Menu1N = new Image;
	Menu1N.src = "http://www.gestion-pme.com/Image/Menu1.gif";
	Menu1H = new Image;
	Menu1H.src = "http://www.gestion-pme.com/Image/Menu1H.gif";

	Menu2N = new Image;
	Menu2N.src = "http://www.gestion-pme.com/Image/Menu2.gif";
	Menu2H = new Image;
	Menu2H.src = "http://www.gestion-pme.com/Image/Menu2H.gif";

	Menu3N = new Image;
	Menu3N.src = "http://www.gestion-pme.com/Image/Menu3.gif";
	Menu3H = new Image;
	Menu3H.src = "http://www.gestion-pme.com/Image/Menu3H.gif";

	Menu4N = new Image;
	Menu4N.src = "http://www.gestion-pme.com/Image/Menu4.gif";
	Menu4H = new Image;
	Menu4H.src = "http://www.gestion-pme.com/Image/Menu4H.gif";
}
document.writeln("<META http-equiv='Page-Enter' CONTENT='BlendTrans(Duration=1)'>");
document.writeln("<META http-equiv='Page-Exit' CONTENT='BlendTrans(Duration=1)'>");

var IE = (navigator.appName == "Microsoft Internet Explorer");

if (IE && 0)
{
	document.writeln("<EMBED NAME=\"BOverMenu\" SRC=\"Son/BOverMenu.wav\" TYPE=\"audio/x-wav\" AUTOSTART=FALSE HIDDEN=TRUE ENABLEJAVASCRIPT=TRUE>");
	document.writeln("<EMBED NAME=\"BOverA\" SRC=\"Son/BOverA.wav\" TYPE=\"audio/x-wav\" AUTOSTART=FALSE HIDDEN=TRUE ENABLEJAVASCRIPT=TRUE>");
	document.writeln("<EMBED NAME=\"BZoomIn\" SRC=\"Son/BZoomIn.wav\" TYPE=\"audio/x-wav\" AUTOSTART=FALSE HIDDEN=TRUE ENABLEJAVASCRIPT=TRUE>");
	document.writeln("<EMBED NAME=\"BZoomOut\" SRC=\"Son/BZoomOut.wav\" TYPE=\"audio/x-wav\" AUTOSTART=FALSE HIDDEN=TRUE ENABLEJAVASCRIPT=TRUE>");
}

function Prop(Obj, ObjName, UseAlert) 
{
   var Res = ""
   for (var t in Obj)
   {
	if (String(Obj[t]).indexOf("function") == -1)
         Res += ObjName + "." + t + " = " + Obj[t];
      if (UseAlert)
         Res += "\n";
      else
         Res += "<BR>";
   }
   if (window.clipboardData)
      window.clipboardData.setData("Text", Res);

   if (UseAlert)
      alert(Res);
   
   return Res;
}

function VariableEnv()
{
   var Value = '<!--#echo var="REDIRECT_STATUS"-->';
   document.write("Erreur " + Value);
}

function GetURLParam(Param)
{
   Page = window.location.href;
   Liste = Page.split(new RegExp(Param + "=", "g"));
   Find = "";

   if (Liste.length != 1)
   {
      Find = Liste[1].split(new RegExp("&", "g"));
      if (Find.length != 1)
         Find = Find[0];
   }
   return Find;
}

var X1, X2, Pos, MsgID = Math.round(Math.random() * 10) % 2;
var Msg = new Array(2);

Msg[0] = new ObjMessage("Gestion PME - Édition Travailleur Autonome, le LOGICIEL à votre IMAGE !", "GestionPME.html", 490);
Msg[1] = new ObjMessage("Imprimez directement sur votre rapport de taxes TPS et TVQ du gouvernement !", "GestionPME.html", 520);

function ObjMessage(Text, Link, Width)
{
   this.Text = Text;
   this.Link = Link;
   this.Width = Width;
}

function Scroll() 
{
   Pos = Pos - 2;
   if (Pos < X1 - Msg[MsgID].Width)
      Pos = X2;
   ClipL = X1 - Pos;
   ClipR = X2 - Pos;

   if (navigator.appName == "Netscape") 
   {
      document.DivMessage.pageX = Pos;
      document.DivMessage.clip.left = ClipL;
      document.DivMessage.clip.right = ClipR;
   }
   else 
   {
      DivMessage.style.posLeft = Pos;
      DivMessage.style.posWidth = ClipR;
      DivMessage.style.clip = "rect(auto " + ClipR + "px auto " + ClipL + "px)";
   }
}

LastIndex = -1;

function SelectTab(Index, Option)
{
   Obj = document.getElementsByName('Select')[Index];

   if (Option == 4)
   {
      if (Index == 0)
         top.location = 'Gestion_PME_Telechargement'+ Suff +'.html';
      else if (Index == 1)
         top.location = 'Gestion_PME_Facturation_Telechargement'+ Suff +'.html';
      else if (Index == 2)
         top.location = '';
      else if (Index == 3)
         top.location = '';
      else if (Index == 4)
         top.location = 'Gestion_PME_Telechargement'+ Suff +'.html';
      else if (Index == 5)
         top.location = 'Gestion_PME_Central_Alarme_Telechargement'+ Suff +'.html';
      else if (Index == 6)
         top.location = '';
      else
         top.location = '';
   }
   else if (Option == 3)
   {
      if (Index == 0)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html';
      else if (Index == 1)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=4';
      else if (Index == 2)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=6';
      else if (Index == 3)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=7';
      else if (Index == 4)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=5';
      else if (Index == 5)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=2';
      else if (Index == 6)
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=3';
      else
         top.location = 'Gestion_PME_Paiement_en_Ligne'+ Suff +'.html?Mod=3&Qty=3';
   }
   else if (Option == 2)
   {
      if (Index == 0)
         top.location = 'Gestion_PME'+ Suff +'.html';
      else if (Index == 1)
         top.location = 'Gestion_PME_Facturation'+ Suff +'.html';
      else if (Index == 2)
         top.location = 'Gestion_PME_Point_de_Vente'+ Suff +'.html';
      else if (Index == 3)
         top.location = 'Gestion_PME_Point_de_Vente'+ Suff +'.html';
      else if (Index == 4)
         top.location = 'Gestion_PME_Module_de_Paie'+ Suff +'.html';
      else if (Index == 5)
         top.location = 'Gestion_PME_Central_Alarme'+ Suff +'.html';
      else if (Index == 6)
         top.location = 'Gestion_PME_Reseau'+ Suff +'.html';
      else
         top.location = 'Gestion_PME_Reseau'+ Suff +'.html';
   }
   else if (Option == 1)
   {
      Obj.style.backgroundImage = 'url(Image/BackSelectOn.gif)';

      if (LastIndex != Index)
      {
         LastIndex = Index;
         Beep(1);
      }
   }
   else if (Option == -1)
   {
      Obj = document.getElementsByName('Select');

      Obj[2].style.visibility = 'hidden';
      Obj[3].style.visibility = 'hidden';
      Obj[6].style.visibility = 'hidden';
      Obj[7].style.visibility = 'hidden';
   }
   else
      Obj.style.backgroundImage = 'url(Image/BackSelectOff.gif)';
}

function ZoomIn(ObjName, Inc)
{
   Obj = document.getElementsByName(ObjName)[0];

   if (Obj.width < 714)
   {
      Obj.width += Inc;
      Inc += 13;
      setTimeout("ZoomIn('" +ObjName+ "', " +Inc+ ")",10);
   }
   else
      Obj.width = 753;

   if (Obj.style.visibility != "visible")
   {
      Beep(2);

      Obj.style.visibility = "visible";

      Obj = document.getElementById('ContentTable');
      Obj.style.visibility = "hidden";

      if (Obj = document.getElementById('DivNav'))
         Obj.style.visibility = "hidden";
   }
} 

function ZoomOut(ObjName, Inc)
{
   Obj = document.getElementsByName(ObjName)[0];

   if (Obj.width == 753)
      Beep(3);

   if (Obj.width > 12)
   {
      Obj.width -= Inc;
      Inc += 13;
      setTimeout("ZoomOut('" +ObjName+ "', " +Inc+ ")",10);
   }
   else  
   {
      Obj.width = 0;
      Obj.style.visibility = "hidden";

      Obj = document.getElementById('ContentTable');
      Obj.style.visibility = "visible";

      if (Obj = document.getElementById('DivNav'))
         Obj.style.visibility = "visible";
   }
}
 
function CheckBorder()
{
   var W, H;

   if (0 && navigator.appName == "Netscape")
   {
      W = window.innerWidth;
      H = window.innerHeight;

      if (Obj = document.getElementById('DivNav'))
      {
         Obj.pageX = (W / 2) + 240;
         Obj.clip.left = document.DivNav.pageX;
         Obj.clip.right = document.DivNav.pageX + 108;
      }

      if (Obj = document.getElementsByName('DivZoom'))
         for (t = 0; t < Obj.length; t++)
            Obj[t].PageX = (W / 2) - 388;
   }
   else
   {
      W = document.body.offsetWidth;
      H = document.body.offsetHeight;
   
      if (Obj = document.getElementById('DivNav'))
      {
         Obj.style.left = (W / 2) + 255;
         Obj.style.width = 108;
      }
   
      if (Obj = document.getElementsByName('DivZoom'))
         for (t = 0; t < Obj.length; t++)
            Obj[t].style.left = (W / 2) - 368;
   }

   if (W < 810 && H < 330)
   {
      window.resizeBy(810 - W, 330 - H);
      return true;
   }
   else if (W < 810 && H >= 330)
   {
      window.resizeBy(810 - W, 0);
      return true;
   }
   else if (W >= 810 && H < 330)
   {
      window.resizeBy(0, 330 - H);
      return true;
   }
}

function ResizeBorder()
{
   CheckBorder();
   location.reload();
}

function OpenMenu(EnterMenu)
{
   InMenu = EnterMenu;

   if (document.layers)
      document.DivMenu.document.images[EnterMenu].src = eval(EnterMenu + "H.src");
   else
      document.images[EnterMenu].src = eval(EnterMenu + "H.src");

   Beep(1);
}

function Beep(Option)
{
	if (!IE || 1)
		return;

   if (Option == 3)
   {
      if (document.BZoomOut.ReadyState == 4)
        document.BZoomOut.Play();
   }
   else if (Option == 2)
   {
      if (document.BZoomIn.ReadyState == 4)
        document.BZoomIn.Play();
   }
/*   else if (Option == 1)
   {
      if (document.BOverMenu.ReadyState == 4)
        document.BOverMenu.Play();
   }*/
   else if (document.BOverA.ReadyState == 4)
      document.BOverA.Play();
}

function SetBeep()
{
   var Tag = document.getElementsByTagName("A");

   for (t = 0; t < Tag.length; t++) 
   {
      if (Tag[t].onmouseover == null) // && Tag[t].innerHTML.indexOf("IMG") == -1)
         Tag[t].onmouseover = Beep;
   }
}

function CloseMenu(ExitMenu)
{
   if (InMenu == ExitMenu)
   {
      if (document.layers)
         document.DivMenu.document.images[ExitMenu].src = eval(ExitMenu + "N.src");
      else
         document.images[ExitMenu].src = eval(ExitMenu + "N.src");
   }
}

function CheckEmail(Str) 
{
   var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
   var emailPat = /^(.+)@(.+)$/;
   var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
   var validChars = "\[^\\s" + specialChars + "\]";
   var quotedUser = "(\"[^\"]*\")";
   var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
   var atom = validChars + '+';
   var word = "(" + atom + "|" + quotedUser + ")";
   var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
   var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
   var matchArray = Str.match(emailPat);

   if (!matchArray) 
   {
      alert("Adresse de « Courrier Électronique » invalide !");
      return false;
   }
   var user = matchArray[1];
   var domain = matchArray[2];

   for (i = 0; i < user.length; i++) 
      if (user.charCodeAt(i) > 127) 
      {
         alert("Adresse de « Courrier Électronique » invalide !");
         return false;
      }

   for (i = 0; i < domain.length; i++)
      if (domain.charCodeAt(i) > 127) 
      {
         alert("Adresse de « Courrier Électronique » invalide !");
         return false;
      }

   if (!user.match(userPat)) 
   {
      alert("Adresse de « Courrier Électronique » invalide !");
      return false;
   }
   var IPArray = domain.match(ipDomainPat);
   if (IPArray) 
   {
      for (i = 1; i <= 4; i++) 
      {
         if (IPArray[i] > 255) 
         {
            alert("Adresse de « Courrier Électronique » invalide !");
            return false;
         }
      }
      return true;
   }
   var atomPat = new RegExp("^" + atom + "$");
   var domArr = domain.split(".");
   var len = domArr.length;
   for (i = 0; i < len; i++) 
      if (domArr[i].search(atomPat) == -1) 
      {
         alert("Adresse de « Courrier Électronique » invalide !");
         return false;
      }

   if (domArr[domArr.length - 1].length != 2 && domArr[domArr.length - 1].search(knownDomsPat) == -1)
   {
      alert("Adresse de « Courrier Électronique » invalide !");
      return false;
   }
   if (len < 2) 
   {
      alert("Adresse de « Courrier Électronique » invalide !");
      return false;
   }
   return true;
}

function OP(Value)
{
	document.forms.namedItem('Formulaire').elements.namedItem('OP').value = Value;
	document.forms.namedItem('Formulaire').submit();
}

function LOG(Value, Form)
{
	Obj = (!Form) ? document.forms.namedItem('Formulaire') :	document.forms.namedItem('FormFacture');
	
	if (Value == 5)
	{
		Obj.elements.namedItem('LOG').value = Value;
		Obj.submit();
	}	
	else if (Validation())
	{
		Obj.action = 'Facture/index.php';
		Obj.elements.namedItem('LOG').value = Value;
		Obj.submit();
	}
}

function Validation()
{
   if (document.Formulaire.Q && document.Formulaire.Q.value == "" && document.Formulaire.Q.length < 3)
   {
		alert("Vous devez spécifier un minimum de « 3 Caractères » pour la recherche !");
		document.Formulaire.Q.focus();
		return false;
   }
   if (document.Formulaire.Nom && document.Formulaire.Nom.value == "")
   {
		alert("Vous devez spécifier une « Personne à Contacter » !");
		document.Formulaire.Nom.focus();
		return false;
   }
   if (document.Formulaire.Courrier && document.Formulaire.Courrier.value == "")
   {
		alert("Vous devez spécifier un « Courrier Électronique » !");
		document.Formulaire.Courrier.focus();
		return false;
   }
   else if (document.Formulaire.Courrier && document.Formulaire.Courrier.value != "123" && !CheckEmail(document.Formulaire.Courrier.value))
   {
		document.Formulaire.Courrier.focus();
		return false;
   }
   if (document.Formulaire.Password && document.Formulaire.Password.value == "")
   {
		alert("Vous devez spécifier un « Mot de Passe » !");
		document.Formulaire.Password.focus();
		return false;
   }
   if (document.Formulaire.Commentaire && document.Formulaire.Commentaire.value == "")
   {
		alert("Vous devez spécifier un « Commentaire » !");
		document.Formulaire.Commentaire.focus();
	   return false;
   }
   if (document.Formulaire.xxxCompany && document.Formulaire.xxxCompany.value == "")
   {
      alert("Vous devez spécifier un « Nom de Compagnie » !");
		document.Formulaire.xxxCompany.focus();
		return false;
   }
   if (document.Formulaire.xxxAddress && document.Formulaire.xxxAddress.value == "")
   {
      alert("Vous devez spécifier une « Adresse Civic » !");
		document.Formulaire.xxxAddress.focus();
		return false;
   }
   if (document.Formulaire.xxxCity && document.Formulaire.xxxCity.value == "")
   {
      alert("Vous devez spécifier une « Ville » !");
		document.Formulaire.xxxCity.focus();
		return false;
   }
   if (document.Formulaire.xxxPostal && document.Formulaire.xxxPostal.value == "")
   {
      alert("Vous devez spécifier un « Code Postal » !");
		document.Formulaire.xxxPostal.focus();
		return false;
   }
   if (document.Formulaire.xxxName && document.Formulaire.xxxName.value == "")
   {
      alert("Vous devez spécifier un « Nom sur la Carte » !");
		document.Formulaire.xxxName.focus();
		return false;
   }
   if (document.Formulaire.xxxEmail && document.Formulaire.xxxEmail.value == "")
   {
      alert("Vous devez spécifier un « Courrier Électronique » !");
		document.Formulaire.xxxEmail.focus();
		return false;
   }
   if (document.Formulaire.xxxNoFacture && document.Formulaire.xxxNoFacture.value == "")
   {
      alert("Vous devez spécifier un « Numéro de Facture de Départ » !");
		document.Formulaire.xxxEmail.focus();
		return false;
   }
   else if (document.Formulaire.xxxNoFacture && parseInt(document.Formulaire.xxxNoFacture.value) != NaN && 
				(parseInt(document.Formulaire.xxxNoFacture.value) < 1 || parseInt(document.Formulaire.xxxNoFacture.value) > 999999))
   {
      alert("Vous devez spécifier un « Numéro de Facture entre 1 et 999999 » !");
		document.Formulaire.xxxEmail.focus();
		return false;
   }
   else if (document.Formulaire.xxxEmail && !CheckEmail(document.Formulaire.xxxEmail.value))
   {
		document.Formulaire.xxxEmail.focus();
		return false;
   }

   if (document.Formulaire.xxxPhone && document.Formulaire.xxxPhone.value == "")
   {
      alert("Vous devez spécifier un « Numéro de Téléphone » !");
		document.Formulaire.xxxPhone.focus();
		return false;
   }
   return true;
}

function ValidationAchat()
{
   if (document.FormAchat.xxxCompany && document.FormAchat.xxxCompany.value == "")
   {
      alert("Vous devez spécifier un « Nom de Compagnie » !");
		document.FormAchat.xxxCompany.focus();
		return false;
   }
   if (document.FormAchat.xxxAddress && document.FormAchat.xxxAddress.value == "")
   {
      alert("Vous devez spécifier une « Adresse Civic » !");
		document.FormAchat.xxxAddress.focus();
		return false;
   }
   if (document.FormAchat.xxxCity && document.FormAchat.xxxCity.value == "")
   {
      alert("Vous devez spécifier une « Ville » !");
		document.FormAchat.xxxCity.focus();
		return false;
   }
   if (document.FormAchat.xxxPostal && document.FormAchat.xxxPostal.value == "")
   {
      alert("Vous devez spécifier un « Code Postal » !");
		document.FormAchat.xxxPostal.focus();
		return false;
   }
   if (document.FormAchat.xxxName && document.FormAchat.xxxName.value == "")
   {
      alert("Vous devez spécifier un « Nom sur la Carte » !");
		document.FormAchat.xxxName.focus();
		return false;
   }
   if (document.FormAchat.xxxEmail && document.FormAchat.xxxEmail.value == "")
   {
      alert("Vous devez spécifier un « Courrier Électronique » !");
		document.FormAchat.xxxEmail.focus();
		return false;
   }
   else if (document.FormAchat.xxxEmail && !CheckEmail(document.FormAchat.xxxEmail.value))
   {
		document.FormAchat.xxxEmail.focus();
		return false;
   }

   if (document.FormAchat.xxxPhone && document.FormAchat.xxxPhone.value == "")
   {
      alert("Vous devez spécifier un « Numéro de Téléphone » !");
		document.FormAchat.xxxPhone.focus();
		return false;
   }
   x = screen.width - 12;
   if (x > 840)
	x = 840;

   y = screen.height - 80;
   if (y > 880)
       y = 880;

   return true;
}
