/**
* Plus / Moins pour input
*
*/
function plus(form_name, field_name, max){
    var qte = (document.forms[form_name].elements[field_name].value * 1) + 1;
    if(qte > max) document.forms[form_name].elements[field_name].value = qte - 1;
    else document.forms[form_name].elements[field_name].value = qte;
    /*if(document.forms[form_name].elements[field_name].value == 0) document.forms[form_name].elements[field_name].value = '1';*/
}
function moins(form_name, field_name){
    var qte = (document.forms[form_name].elements[field_name].value * 1) - 1;
    if(qte >= 0) document.forms[form_name].elements[field_name].value = qte;
    else document.forms[form_name].elements[field_name].value = '0';
    /*if(document.forms[form_name].elements[field_name].value == 0) document.forms[form_name].elements[field_name].value = '1';*/
}

/**
* Vérification de la valeur d'une variable javascript
*
*/
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

/**
* Affichage/cachage d'une information
*
*/
function montre_statut(id,statut) {
    if(statut == "block"){
        var uls = document.getElementsByTagName('ul');
        for ( var i=0; i<uls.length; i++ )
        {   
            if(uls.item(i).id != id) uls.item(i).style.display = 'none';
        }
    }
    if(id != ""){
        var d = document.getElementById(id);
        if(statut != ""){
            if (d) {d.style.display=statut;}
        }
        else{
            if (d) {
                if(d.style.display == "block"){statut = "none";}
                else statut = "block";
                d.style.display=statut;
            }
        }
    }
}

/**
* Affichage d'une image en grand
*
*/
function Affichegrande(cheminImage,texte)
{
    newImage = new Image;
    newImage.src = cheminImage;
    html = '<HTML><HEAD><TITLE>'+texte+'</TITLE><meta http-equiv="Pragma" content="no-cache"></HEAD><BODY leftmargin=0 marginwidth=0 topmargin=0 marginheigth=0 oncontextmenu="return false"><CENTER>'+
    '<a href="#" onClick="window.close()"><IMG SRC="'+cheminImage+'" BORDER=0 NAME=monImage alt="'+texte+'"border="0" onLoad="window.resizeTo(document.monImage.width+20,document.monImage.height+80); window.moveTo((screen.width-document.monImage.width)/2,5)"> </a></CENTER></BODY></HTML>';
    ouvrirImage = window.open('','_blank','toolbar=0,location=0,menuBar=0,scrollbars=0,resizable=0');
    ouvrirImage.document.write(html);
}

/**
* Confirmation suppression
*
*/
function confirm_delete(autres){
    var valret;
    if(autres == "") valret = confirm("Confirmez-vous la suppression définitive de cet élément sans retour possible ?");
    else valret = confirm("Confirmez-vous la suppression définitive de cet élément et de ses dépendances sans retour possible ?");
    return valret;
}

/**
* Fonction d'ouverture d'une popup
*
*/
function OuvrirPop(theURL,features){
    if(theURL.substr(0,4) != "http") splits = theURL.split(".");
    else splits = "NewWindow";
    window.open(theURL,splits[0],features+',top='+((screen.height-600)/2)+',left='+((screen.width-600)/2));
}

var strUrl = "ajax.php";
var xmlhttp;

function getXmlRequest() {
  try
    {
    if (window.ActiveXObject) xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    // Firefox, Opera 8.0+, Safari
    else xmlhttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    return xmlhttp;
}

function checkPrix(id,qte)
{
  url = strUrl + "?cle=" + id + "&qte=" + qte;
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
    xmlhttp.open("GET", url, false);
    xmlhttp.send(null);
    return xmlhttp.responseText; 
  }               
  
}

function checkPrixReorder(id,qte)
{
  url = strUrl + "?cle_reorder=" + id + "&qte=" + qte;
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
    xmlhttp.open("GET", url, false);
    xmlhttp.send(null);
    return xmlhttp.responseText; 
  }               
  
}

function coupon_valide(code)
{
    url = strUrl + "?code=" + code;
    xmlhttp=getXmlRequest();
    if (xmlhttp)
    {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {                                                        
                document.getElementById("code_valide").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    }
}

function code_parrainage_valide(code,email)
{
    url = strUrl + "?code_parrainage=" + code + "&email=" + email;
    xmlhttp=getXmlRequest();
    if (xmlhttp)
    {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {                                                        
                document.getElementById("code_valide").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    }
}

function check_combinaison_options(combinaison,dataset,id_element)
{
    url = strUrl + "?combinaison=" + combinaison + "&dataset=" + dataset + "&id_element=" + id_element;
    xmlhttp=getXmlRequest();
    if (xmlhttp)
    {
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
        return xmlhttp.responseText; 
    }
}

function inputCheck(type,fieldname,fieldvalue,comparatif,annee)
{
  url = "/" + strUrl + "?type=" + type + "&value=" + fieldvalue + "&comparatif=" + comparatif + "&annee=" + annee;
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function(){
      var fieldid = fieldname + "_error";
      if(xmlhttp.readyState==4)
      {
        document.getElementById(fieldid).innerHTML=xmlhttp.responseText;
        if(xmlhttp.responseText.indexOf('ok.gif') > 0) document.forms["identification"].elements[fieldname].style.backgroundColor = "";
        }
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
  }
}               

function checkLogo()
{
  url = strUrl + "?logo=1";
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
    xmlhttp.open("GET", url, false);
    xmlhttp.send(null);
    return xmlhttp.responseText; 
  }               
  
}

function addFavoris(url,titre)
{
  var reg=new RegExp("(&)", "g");
  url = url.replace(reg,"µ")
  if(url.indexOf("#") != -1) url = url.substring(0,url.length-1);
  url = "url=" + url + "&titre=" + titre;
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {   
                if(xmlhttp.responseText == "true"){
                    alert('Lien ajouté');
                    window.document.location.reload();
                    return true;
                }
                else{
                    alert('Lien déjà présent !');
                    return false;
                }
            }
        }
        xmlhttp.open("POST", "../" + strUrl, true);
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xmlhttp.send(url);
  }               
  
}

function delFavoris(fav)
{
  url = "../" + strUrl + "?delFav=" + fav;
  //alert(url);
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {   
                if(xmlhttp.responseText == "true"){
                    alert('Lien supprimé');
                    window.document.location.reload();
                    return true;
                }
                else{
                    return false;
                }
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
  }               
  
}

function openMenu(id)
{
  url = "../" + strUrl + "?openMenu=" + id;
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {   
                return true;
            }
        }
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
  }               
}

function conserveOptions(url)
{
  url = strUrl + url;
  xmlhttp=getXmlRequest();
  if (xmlhttp)
  {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {   
                return true;
            }
        }
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
  }               
}

function kiala_info() {
  window.open("http://www.dvd-online.be/info_kiala.php","info_kiala","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes").focus();
}

function kiala_shop(sitecode,langcode,kp_id) {
    window.open("http://www.kiala."+sitecode+"/locator.jsp?language="+langcode+"&shortID="+kp_id,"kiala_shop","scrollbars=no,resizable=yes,width=800,height=450").focus();
}

function select_mode(mode) {
    url = strUrl + "?mode_livr=" + mode;
    //alert(url);
    xmlhttp=getXmlRequest();
    if (xmlhttp)
    {
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
    }               
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

var treeopened = null;
function opentree(tree)
{
    var cls = '';
    if (document.getElementById) {
        var el = document.getElementById (tree);
        if (el && el.className) {
            el.className = (el.className == 'navOpened courbure') ? 'navClosed courbure' : 'navOpened courbure';
        }
        montre_statut('data_'+tree,'');
    }
    //if (navigator.appName == 'Microsoft Internet Explorer' && document.documentElement && navigator.userAgent.indexOf ('Opera') == -1) parent.setScrollInIE();
    return false;
}
function mover (o)
{
    o.className = 'navTitleOver';
}

function mout (o)
{
    o.className = 'navTitle';
}

function cloture_paiement(mode_paie,type_paie,orderid)
{
    url = strUrl + "?mode_paie=" + mode_paie + "&type_paie=" + type_paie;
    //alert(url);
    xmlhttp=getXmlRequest();
    if (xmlhttp)
    {
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState==4 )
            {   
            }
        }
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
    }               
    if(xmlhttp.responseText == "OK : " + orderid){
        return true;
    }
    else{
        return false;
    }
}