////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// Achat
////////////////////////////////////////////////////////////////////////////////
self.name='MerchantWindow';
function authorize(productId) 
		{

			var url = 'http://ns6544.ovh.net/acteV2/pos_init?action=authorize&pId=' + productId ;
			window.location.href = url;
					
			//var win = window.open(url,'iPIN_PaymentPanel','width=544,height=370,left=10,top=10,resizable=yes,status,location=no');
			//openPaymentPanel(url);
		}
function valider(){ 
 	document.frm_liste_offres_ddeurs.v_cas_figure_offres_ddeur_libre.value = 1;
	document.frm_liste_offres_ddeurs.submit();
 }

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
function afficherMasquer()
/* change la classe CSS des objets donnés en paramètres. Syntaxe :
afficherMasquer('id_div1','afficher','id_div2','masquer','id_div3','masquer',...) */
{ 
   var args=afficherMasquer.arguments;
   var action, objet, css;
   
   // on parcours tous les arguments de la fonction
   for(var i=0; i<(args.length-1); i+=2)
   {
      if((objet=document.getElementById(args[i]))!=null)
      {
         action=args[i+1];
         switch(action)
         {
            /* la valeur de "css" est à remplacer avec les noms des classes
            utilisées dans la feuille de style */
            case 'afficher':
            case '1':
               css='apparent';
               break;

            case 'masquer':
            case '0':
            default:
               css='cache';
         }         
         objet.className=css;
      }
   }
}
function montre_pay(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) 
    {
		if (document.getElementById("cache_"+i)) 
      {document.getElementById('cache_'+i).style.visibility='hidden';
       document.getElementById('cache_'+i).style.display='none';}
	  }
if (d) {d.style.visibility='visible';
        d.style.display='block';}
}
///// Verification formulaire
function check_input(sub) {
validity=true;
blankInput=false;
//alert('ok');
for(var i=0;i<10;i++)
  {  
  var In = document.getElementById('ticket'+i);
  var com='';    
  
  if (In) 
    { Val = In.value;
      ///// 1 = Non traité 2 = ok 3 = Pas bon
      thisValidity = 2;    
      if(Val.length < 8 || Val.length > 10)
        {com= 'Taille du code incorrect.'; validity=false;thisValidity=3}           
      if(Val.substring(0,5) == ' code')
        {com = ''; validity=false;thisValidity=1;blankInput=true;}      
      if(Val == '0899707028')
        {com = 'Entrez le code que vous avez reçu au 08 99 70 70 28'; validity=false;thisValidity=3}
      if(Val == '08 99 70 70 28')
        {com = 'Entrez le code que vous avez reçu au 08 99 70 70 28'; validity=false;thisValidity=3}
      if(Val == '')
        {com = '';validity=false;thisValidity=1;blankInput=true;}

      if(In.readOnly==false)
        {
        document.getElementById('comment_'+i).innerHTML = "<span style='color:red'>"+com+"</span>";
        if(thisValidity==1)
          {In.style.backgroundColor="white";} 
        if(thisValidity==2)
          {In.style.backgroundColor="#94EA94";} 
        if(thisValidity==3)
          {In.style.backgroundColor="#EA9494";}  
        }     
    }  
  }

if(sub == 1 && validity==true)
  {
  var Sub = document.getElementById('tel_sub');
  var MyForm = document.getElementById('tel_form');
  with(Sub)
    {Sub.value = 'Patientez ...';Sub.disabled=true;}
  MyForm.submit();
  }
if(sub == 1 && validity==false && blankInput==true)
  document.getElementById('comment_sub').innerHTML = "<span style='color:red'>Remplissez d'abord tous les champs.</span>";  
else
  document.getElementById('comment_sub').innerHTML = "";
}

function getTimeLeft(secondLeft) {
seconde =           (    secondLeft % 60 )       ;
minute  = Math.floor( (secondLeft / 60 ) % 60);
heure   = Math.floor( (secondLeft / 60 ) / 60);
clockNewValue = heure+"h "+minute+"m "+seconde+"s";
document.getElementById("clock2").innerHTML = clockNewValue; 
secondLeft--;
window.setTimeout("getTimeLeft("+secondLeft+");",1000);
}

////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// MENU
////////////////////////////////////////////////////////////////////////////////
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
function hide() {
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
}
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// Aide Pratique
////////////////////////////////////////////////////////////////////////////////
// Fonctions 9 regles d'or
function LiveScroll(id_div) {
	if (id_div != '') action_div(id_div);
}
function action_div(id_div) {
	var item =null;
	if (document.getElementById) {
		item = document.getElementById(id_div);

	} else if (document.all){
		item = document.all[id_div];
		
	} else if (document.layers){
		item = document.layers[id_div];
			
	}
	
	if (!item) 
	{ // rien à faire
	} 
	else if (item.style) {
	
		if (item.style.display == "none" || item.style.display == null || item.style.display == "") 

		  {
			item.style.display = "block";
			}
		else
		{
		item.style.display = "none";
		}
	} 
	else 
	{
		item.visibility = "show";
		
		
	}
}


////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// NAVIGATION CONSULTATION
////////////////////////////////////////////////////////////////////////////////

function MailPopup(filetype)
{ 
  var divmail =null;
  var divspacer =null;
  
	if (document.getElementById) {
		divmail = document.getElementById("divmail");
    divspacer = document.getElementById("mailspacer");
    hidden = document.getElementById("inputfiletype");

    
	} else if (document.all){
		divmail = document.all["divmail"];
	  divspacer = document.all["mailspacer"];
	  hidden = document.all["inputfiletype"];

		
	} else if (document.layers){
		divmail = document.layers["divmail"];
		divspacer = document.layers["mailspacer"];
		hidden = document.layers["inputfiletype"];

			
	}
	
	if (!divmail) 
	{ // rien à faire
	} 
	else if (divmail.style) {
	
		if (divmail.style.display == "none" || divmail.style.display == null || divmail.style.display == "") 

		{
		  if(filetype == "word")
		  {
			  divmail.style.display = "block";
        divspacer.style.display = "block";
			  divspacer.style.width ="110px";
			  hidden.value = filetype;
			  
			  
			}
			if(filetype == "pdf")
		  {
			  divmail.style.display = "block";
			  divspacer.style.width ="428px";
			  divspacer.style.display = "block";
			  hidden.value = filetype;
			}
		}
		else
		{
		  if(filetype == hidden.value)
		  {
		    divmail.style.display = "none";
		    divspacer.style.display = "none";
		  }
		  if(filetype == "word")
		  {
			  divspacer.style.width ="110px";
			  hidden.value = filetype;
			  
			}
		  if(filetype == "pdf")
		  {
		  	divspacer.style.width ="428px";
		    hidden.value = filetype;

		  }
		}
	} 
	else 
	{
		divmail.visibility = "show";
		
		
	}
  
}

// Fonctions Offres d'emploi
function toggle( targetId ){
  if (document.getElementById){
        target = document.getElementById( targetId );
           if (target.style.display == "none"){
              target.style.display = "";
           } else {
              target.style.display = "none";
           }
     }
}
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// GESTION DES ONGLETS CV COMMENTES
////////////////////////////////////////////////////////////////////////////////

function tabShow(id_tab) {
  var currentItem =null;
  var otherItem1 =null;
  var otherItem2 =null;
  var fakeItem =null;
  
  if (document.getElementById) {
      Item = document.getElementById("id1");
      Item1 = document.getElementById("id2");
      Item2 = document.getElementById("id3");
      fakeItem = document.getElementById("faketab");
    } else if (document.all){
      Item = document.all["id1"];
      Item1 = document.all["id2"];
      Item2 = document.all["id3"];
      fakeItem = document.all["faketab"];
    } else if (document.layers){
      Item = document.layers["id1"];
      Item1 = document.layers["id2"];
      Item2 = document.layers["id3"];
      fakeItem = document.layers["faketab"];
    }
  switch(id_tab)
  {
    case "id1":
    Item.style.display = "block";
    Item1.style.display = "none";
    Item2.style.display = "none";
    fakeItem.style.backgroundColor = "#fcef85";
    
    
    break;
    case "id2":
    Item.style.display = "none";
    Item1.style.display = "block";
    Item2.style.display = "none";
    fakeItem.style.backgroundColor = "#7ce180";
    break;
    case "id3":
    Item.style.display = "none";
    Item1.style.display = "none";
    Item2.style.display = "block";
    fakeItem.style.backgroundColor = "#f07f53";
    break;
    
  }
  
  
 }
  
 function Affiche(e)
 {
    var ie = (document.all)? true:false;
	  var ns4 = (document.layers)? true:false;
		var ns6 = (document.getElementById)? true:false;
		
    if (ie) {
	  //Récupération de la position de la souris
		window.lastX=event.clientX; 
		window.lastY=event.clientY;
		divmail = document.all["idmail"];
		// Calcul de l'écart de position de la souris
		var difX=event.clientX-window.lastX;
    var difY=event.clientY-window.lastY;
		var newX1 = parseInt(divmail.style.left)+difX;
		var newY1 = parseInt(divmail.style.top)+difY;
		// Assignation des nouvelles coordonnées au div
		divmail.style.left=newX1+"px";
		divmail.style.top=newY1+"px";

		
		}else if (ns4) {
		//Récupération de la position de la souris
		window.lastX=e.pageX;
		window.lastY=e.pageY;
		divmail = document.layers["idmail"];
   	// Calcul de l'écart de position de la souris
		var difX=e.pageX-window.lastX;
		var difY=e.pageY-window.lastY;
		//Récupération de la position du div et ajout de l'écart de position de la souris
		var newX1 = parseInt(document.layers.divmail.left)+difX;
		var newY1 = parseInt(document.layers.divmail.top)+difY;
		// Assignation des nouvelles coordonnées au div
		document.layers.divmail.left=newX1;
		document.layers.divmail.top=newY1;
		//Assignation de l'anciènne position de la souris
		window.lastX=e.pageX;
		window.lastY=e.pageY;
		
		
		}else if (ns6) {
		//Récupération de la position de la souris
		window.lastX=e.clientX;
		window.lastY=e.clientY;
	  divmail = document.getElementById("idmail");
    // Calcul de l'écart de position de la souris
		var difX=e.clientX-window.lastX;
		var difY=e.clientY-window.lastY;
		//Récupération de la position du div et ajout de l'écart de position de la souris
		var newX1 = parseInt(document.getElementById("idmail").style.left)+difX;
		var newY1 = parseInt(document.getElementById("idmail").style.top)+difY;
	  // Assignation des nouvelles coordonnées au div
		document.getElementById("idmail").style.left=newX1+"px";
		document.getElementById("idmail").style.top=newY1+"px";
	  document.getElementById("idmail").style.display = "block";

		}
 }



////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// CV
////////////////////////////////////////////////////////////////////////////////
gk=window.Event?1:0; // navigateurs Gecko ou IE
D=document;popup=encours=0; 
function ctrl(e)
{
de=!D.documentElement.clientWidth?D.body:D.documentElement; // IE6
sx=gk?pageXOffset:de.scrollLeft; //scroll h
sy=gk?pageYOffset:de.scrollTop; //scroll v
x=gk?e.pageX:event.clientX+sx; //curseur x
y=gk?e.pageY:event.clientY+sy; //curseur y
el=gk?e.target:event.srcElement;
if(!el.tagName)el=el.parentNode; // noeud #text
if(el.className == 'pop')
  {   
  popup = D.getElementById(el.href.substring(el.href.lastIndexOf('#') + 1)).style; 
  if(popup!=encours) // seulement si changement  
    {      
    encours.visibility='hidden';
    encours=popup;
    }
  xDivHalfWidth=130; 
  with(popup){visibility='visible';left=x-xDivHalfWidth+'px';top=y+15+'px';}
  } 
else {encours.visibility='hidden';encours=0}
}
function makePopup(id)
  {
  link = D.getElementById(id);
  popup = D.getElementById(link.href.substring(link.href.lastIndexOf('#') + 1)).style; 
  var dom = net = iex = false;
  if (document.getElementById) dom = true; // IE5+ ou Netscape6+/Mozilla
  if (document.layers) net = true; // Netscape4
  if (document.all) iex = true; // IE4+  
  if (iex) {
    var larg_utile = document.body.offsetWidth;
    var haut_utile = document.body.offsetHeight;
    }
  else if (dom || net) {
    var larg_utile = window.innerWidth;
    var haut_utile = window.innerHeight;
    }  
  xDivHalfWidth=130;   
  with(popup){visibility='visible';left=(larg_utile / 2 - xDivHalfWidth) +'px';top=100+'px';}
  //D.getElementById(el.href.substring(el.href.lastIndexOf('#') + 1)).innerHTML = "X: "+ (larg_utile / 2 ) +" Y: "+100+"px";
  } 
function seePopup(id)
  {
  popup = D.getElementById(id).style;
   var dom = net = iex = false;
  if (document.getElementById) dom = true; // IE5+ ou Netscape6+/Mozilla
  if (document.layers) net = true; // Netscape4
  if (document.all) iex = true; // IE4+  
  if (iex) {
    var larg_utile = document.body.offsetWidth;
    var haut_utile = document.body.offsetHeight;
    }
  else if (dom || net) {
    var larg_utile = window.innerWidth;
    var haut_utile = window.innerHeight;
    }  
  xDivHalfWidth=200;   
  with(popup){left=(larg_utile / 2 - xDivHalfWidth) +'px';top=150+'px';}
  //alert('x=>'+(larg_utile / 2 - xDivHalfWidth)+" y=>150");
  }
function seeSendBox(id)
  {
  formDiv = document.getElementById('sendBox').style;
  inputPayId = document.getElementById('text_pay_id');
  
  inputPayId.value = id;
  with(formDiv) {display='block';}
  //alert(id);
  }
D.onmousemove=ctrl;  
