
function toggle(elementId, classEen, classTwee){
  if(document.getElementById(elementId)){
    if(document.getElementById(elementId).className == classEen){
      document.getElementById(elementId).className = classTwee;
    }else{
      document.getElementById(elementId).className = classEen;
    }
  }
}
function hideLand(num){
  var idTd   = document.getElementById("anderLand");
  var postcode = document.getElementById("inpPostcodeLetters");
  
  if(num == 3){
    idTd.className = "";
  }else{
    idTd.className = "hidden";
  }  
  
  if(num != 1){
    postcode.className = "hidden";
  }else{
    postcode.className = "";
  }
}

function anderAdres(num){
  var tbl = document.getElementById("anderAdresTable");
  
  if(num == 1){
    tbl.className = "";
  }else{
    tbl.className = "hidden";
  }
}

//Form versturen
function sendForm(formId){
  document.getElementById(formId).submit();
}

function empty(container){
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
}

function changeColor(id, newColor){
  var divid = document.getElementById(id);
  divid.style.color = newColor;  
}

//Banden op de home veranderen
function bandHover(id){
  var prijsid   = document.getElementById(id+"prijs");
  var imageid   = document.getElementById(id+"image");
  var knopid    = document.getElementById(id+"knop");
  
  var kleur = "#1ab8ec";
  
  prijsid.style.color = kleur;
  imageid.src         = "images/interface/addtocart_hover.png";
  knopid.style.color  = kleur;
}

//Banden op de home veranderen naar default
function bandBlur(id){
  var prijsid   = document.getElementById(id+"prijs");
  var imageid   = document.getElementById(id+"image");
  var knopid    = document.getElementById(id+"knop");
  
  prijsid.style.color = "#fff";
  imageid.src         = "images/interface/addtocart.png";
  knopid.style.color  = "#acbfc6";
}

function clearValue(id, txt){
  var divid = document.getElementById(id); 
  if(divid.value == txt){ 
    divid.value = "";
  }
}

function checkValue(id, txt){
  var divid = document.getElementById(id);    
  if(divid.value == ""){ 
    divid.value = txt;
  }
}

function updateCombiPrijs(spanId, curPrijs){
  prijsId = document.getElementById('CombiEindPrijs');
  
  prijsId.childNode["span"].innerHTML = "300px";
}

function changeClass(elementId, newClass){
  if(document.getElementById(elementId)){document.getElementById(elementId).className = newClass;}
}

function toonProvincie(landid, pid){
  var imageId = document.getElementById("hoverimage");
  
  if(landid == 1){   
    if(pid == 0){
      imageId.src = currUrl+"images/interface/kaart/nl_be.jpg";
    }else if(pid == 1){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_drenthe.gif";
    }else if(pid == 2){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_flevoland.gif";
    }else if(pid == 3){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_friesland.gif";
    }else if(pid == 4){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_gelderland.gif";
    }else if(pid == 5){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_groningen.gif";
    }else if(pid == 6){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_limburg.gif";
    }else if(pid == 7){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_noord-brabant.gif";
    }else if(pid == 8){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_noord-holland.gif";
    }else if(pid == 9){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_overijssel.gif";
    }else if(pid == 10){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_utrecht.gif";
    }else if(pid == 11){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_zeeland.gif";
    }else if(pid == 12){
      imageId.src = currUrl+"images/interface/kaart/kaart_nl_zuid-holland.gif";
    }
  }else if(landid == 2){
    if(pid == 0){
      imageId.src = currUrl+"images/interface/kaart/nl_be.jpg";
    }else if(pid == 1){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_antwerpen.gif";
    }else if(pid == 2){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_brussel.gif";
    }else if(pid == 3){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_henegouwen.gif";
    }else if(pid == 4){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_limburg.gif";
    }else if(pid == 5){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_luik.gif";
    }else if(pid == 6){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_luxemburg.gif";
    }else if(pid == 7){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_namen.gif";
    }else if(pid == 8){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_oost-vlaanderen.gif";
    }else if(pid == 9){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_vlaams-brabant.gif";
    }else if(pid == 10){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_waals-brabant.gif";
    }else if(pid == 11){
      imageId.src = currUrl+"images/interface/kaart/kaart_be_west-vlaanderen.gif";
    }
    
  }
}
/***************************************** Band Hoogte *****************************************/

function getBandHoogte(breedte){
  makeHttpRequest("http://www.winterbanden.nl/xml/getBandHoogte.php?breedte="+breedte, "fillBandHoogte", true);
} 

function fillBandHoogte(ajaxReturn){
    var selectContainer = document.getElementById("bandHoogte");
  empty(selectContainer);
  
  /***/
  
  var container = document.getElementById("bandHoogte");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandInch");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandDraagVermogen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandSnelheidsindex");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = ajaxReturn.getElementsByTagName("band");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var hoogte  = container[a].getElementsByTagName("hoogte")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = hoogte;
    option.appendChild(document.createTextNode(hoogte));
    
    selectContainer.appendChild(option);
     
  }
} 

/***************************************** Band Inch *****************************************/

function getBandInch(hoogte){
  var breedte = document.getElementById("bandBreedte").value;
  makeHttpRequest("http://www.winterbanden.nl/xml/getBandInch.php?breedte="+breedte+"&hoogte="+hoogte, "fillBandInch", true);
} 

function fillBandInch(ajaxReturn){
  var selectContainer = document.getElementById("bandInch");
  empty(selectContainer);
  
  /***/
  
  var container = document.getElementById("bandInch");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandDraagVermogen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandSnelheidsindex");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = ajaxReturn.getElementsByTagName("band");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var inch  = container[a].getElementsByTagName("inch")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = inch;
    option.appendChild(document.createTextNode(inch));
    
    selectContainer.appendChild(option);
     
  }
} 

/***************************************** Band Draagvermogen *****************************************/

function getBandDraagvermogen(inch){
  var breedte = document.getElementById("bandBreedte").value;
  var hoogte  = document.getElementById("bandHoogte").value;
  makeHttpRequest("http://www.winterbanden.nl/xml/getBandDraag.php?breedte="+breedte+"&hoogte="+hoogte+"&inch="+inch, "fillBandDraagvermogen", true);
} 

function fillBandDraagvermogen(ajaxReturn){
  var selectContainer = document.getElementById("bandDraagVermogen");
  empty(selectContainer);
  
  /***/
  
  var container = document.getElementById("bandDraagVermogen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = document.getElementById("bandSnelheidsindex");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  /***/
  
  var container = ajaxReturn.getElementsByTagName("band");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var inch  = container[a].getElementsByTagName("draagvermogen")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = inch;
    option.appendChild(document.createTextNode(inch));
    
    selectContainer.appendChild(option);
     
  }
}

/***************************************** Band Snelheidsindex *****************************************/

function getBandSnelheid(draagvermogen){
  
  var breedte = document.getElementById("bandBreedte").value;
  var hoogte  = document.getElementById("bandHoogte").value;
  var inch    = document.getElementById("bandInch").value;     
  makeHttpRequest("http://www.winterbanden.nl/xml/getBandSnelheid.php?breedte="+breedte+"&hoogte="+hoogte+"&inch="+inch+"&draagvermogen="+draagvermogen, "fillBandSnelheid", true);
} 

function fillBandSnelheid(ajaxReturn){
  var selectContainer = document.getElementById("bandSnelheidsindex");
  empty(selectContainer);
  
  var container = document.getElementById("bandSnelheidsindex");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("band");
  var i         = container.length;
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("snelheidscode")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = model;  
    option.appendChild(document.createTextNode(model.toUpperCase()));
    
    selectContainer.appendChild(option);          
  }
}

function showWinterbanden(){
  var breedte = document.getElementById("bandBreedte").value;
  var hoogte  = document.getElementById("bandHoogte").value;
  var inch    = document.getElementById("bandInch").value;  
  
  var draag    = document.getElementById("bandDraagVermogen").value;  
  var snelheid    = document.getElementById("bandSnelheidsindex").value;     
  
  if(breedte == 0 || hoogte == 0 || inch == 0){
    document.getElementById("errorZoekProduct").className = "error";
  }else{  
    var link = "banden/"+breedte+"-"+hoogte+"-"+inch;
      if(draag != 0){
        link = link+"-"+draag;
      }
      if(snelheid != 0){
        link = link+"-"+snelheid;
      }
    link = link+"/";
    window.location=currUrl+link;
  } 
}

function filterWinterbanden(){
  var bandUrl = document.getElementById("bandenUrl").value;

  var bandenMerk  = document.getElementById("bandenMerk").value;
  var prijsVan    = document.getElementById("bandPrijsVanaf").value;
  var prijsTot    = document.getElementById("bandPrijsTot").value;
  var kwaliteit   = document.getElementById("bandenKwaliteit").value;    
  
  if(prijsVan == "Prijs vanaf..."){prijsVan = "";}
  if(prijsTot == "Prijs tot..."){prijsTot = "";}
  
  var link        = "banden/"+bandUrl+"/";
  
  if(bandenMerk != 0){
    link = link+bandenMerk+"-banden/";      
  }else{
    link = link+"alle-banden/";
  }
  
  if(prijsVan != ""){
    link = link+"prijs-vanaf-"+prijsVan;
  }
  if(prijsTot != ""){
    if(prijsVan != ""){
      link = link+"-tot-"+prijsTot;
    }else{
      link = link+"prijs-tot-"+prijsTot;
    }
  }
  if(kwaliteit != 0){
    if(prijsVan != "" || prijsTot != ""){
      link = link+"-kwaliteit-"+kwaliteit;
    }else{
      link = link+"kwaliteit-"+kwaliteit;
    }
  }  
  
  if(prijsVan != "" || prijsTot != "" || kwaliteit != 0){
    link = link+"/";
  }

  window.location=currUrl+link;
}



function filterWinterbandenMerken(){
  var bandUrl = document.getElementById("bandenUrl").value;
  
  /*
    http://www.winterbanden.nl/banden/bridgestone-banden/breedte-155-hoogte-60-inch-16-prijs-vanaf-50-tot-70/
  */

  var breedte     = document.getElementById("bandBreedte").value;
  var hoogte      = document.getElementById("bandHoogte").value;
  var inch        = document.getElementById("bandInch").value;
  var prijsVan    = document.getElementById("bandPrijsVanaf").value;
  var prijsTot    = document.getElementById("bandPrijsTot").value;    
  
  if(prijsVan == "Prijs vanaf..."){prijsVan = "";}
  if(prijsTot == "Prijs tot..."){prijsTot = "";}
  
  var link        = "banden/"+bandUrl+"/";
  
  if(breedte != 0){
    link = link+"breedte-"+breedte;      
  }
  
  if(hoogte != 0){ 
    if(breedte != 0){          
      link = link+"-hoogte-"+hoogte;
    }else{
      link = link+"hoogte-"+hoogte;
    }      
  }
  
  if(inch != 0){
    if(hoogte != 0 || breedte != 0){      
      link = link+"-inch-"+inch;
    }else{
      link = link+"inch-"+inch;
    }    
  }
  
  if(prijsVan != ""){
    if(hoogte != 0 || breedte != 0 || inch != 0){      
      link = link+"-prijs-vanaf-"+prijsVan;
    }else{
      link = link+"prijs-vanaf-"+prijsVan;
    }    
  }
  
  if(prijsTot != ""){
    if(hoogte != 0 || breedte != 0 || inch != 0 || prijsVan != ""){      
      link = link+"-tot-"+prijsTot;
    }else{
      link = link+"prijs-tot-"+prijsTot;
    }    
  }
    var breedte     = document.getElementById("bandBreedte").value;
  var hoogte      = document.getElementById("bandHoogte").value;
  var inch        = document.getElementById("bandInch").value;
  var prijsVan    = document.getElementById("bandPrijsVanaf").value;
  var prijsTot    = document.getElementById("bandPrijsTot").value;    
  
  if(breedte != 0 || hoogte != 0 || inch != 0 || prijsVan != "" || prijsTot != ""){
    link = link+"/";
  }
  
  

  window.location=currUrl+link;
}


 

/***************************************** AUTO MODELLEN *****************************************/
function getModel(htMerk){
  makeHttpRequest("http://www.winterbanden.nl/xml/getAutoModel.php?htMerk="+htMerk, "fillAutoModel", true);
}

function fillAutoModel(ajaxReturn){
  var selectContainer = document.getElementById("stalenAutoModellen");
  empty(selectContainer);
  
  var container = document.getElementById("stalenAutoModellen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = document.getElementById("fillAutoMotorinhoud");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("modelNaam")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("modelHtName")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = htName;
    option.appendChild(document.createTextNode(model));
    
    selectContainer.appendChild(option);
     
  }
}



/***************************************** AUTO MOTORINHOUD *****************************************/
function getMotorinhoud(htBouwjaar){
  var htMerk = document.getElementById("stalenVelgenAutoMerk").value;
  var htModel = document.getElementById("stalenAutoModellen").value;
  
  makeHttpRequest("http://www.winterbanden.nl/xml/getMotorinhoud.php?htModel="+htModel+"&htMerk="+htMerk+"&htBouwjaar="+htBouwjaar, "fillAutoMotorinhoud", true);
}

function fillAutoMotorinhoud(ajaxReturn){
  var selectContainer = document.getElementById("fillAutoMotorinhoud");
  empty(selectContainer);
  
  var container = document.getElementById("fillAutoMotorinhoud");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("motorInhoud")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("motorHtName")[0].firstChild.data;
    
    var option = document.createElement("option");
    option.value = htName;  
    option.appendChild(document.createTextNode(model.toUpperCase()));
    
    selectContainer.appendChild(option);
     
  }
}



function getBouwjaar(htModel){
  var htMerk = document.getElementById("stalenVelgenAutoMerk").value;
  makeHttpRequest("http://www.winterbanden.nl/xml/getAutoBouwjaar.php?htModel="+htModel+"&htMerk="+htMerk, "fillAutoBouwjaar", true);
}

function fillAutoBouwjaar(ajaxReturn){
  var selectContainer = document.getElementById("fillAutoBouwjaar");
  empty(selectContainer);
  
  var container = document.getElementById("fillAutoBouwjaar");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("bouwjaar")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("bouwjaarHtName")[0].firstChild.data;
    
    var option = document.createElement("option");
    option.value = htName;  
    option.appendChild(document.createTextNode(model));
    
    selectContainer.appendChild(option);
     
  }
}




function showStalenVelgen(){
  var auto    = document.getElementById("stalenVelgenAutoMerk").value;
  var model   = document.getElementById("stalenAutoModellen").value;
  var inhoud  = document.getElementById("fillAutoMotorinhoud").value;
  var bouwjaar  = document.getElementById("fillAutoBouwjaar").value;
  
  if(auto == 0 || model == 0 || inhoud == 0){
    document.getElementById("errorZoekProduct").className = "error";
  }else{  
    var link = auto+"-stalen-velgen/"+auto+"-"+model+"-"+bouwjaar+"-"+inhoud+"/";
    window.location=currUrl+link;
  } 
}



function checkForProducts(){  
    
  var table = document.getElementById("overzichtWinkelMand");   
  var cells = table.getElementsByTagName("tr");
  var count = 0;                  
  
  for (var i = 0; i < cells.length; i++) {          
    if(cells[i].className == "productRow"){
      count = count +1;
    }  
  } 
  
  if(count == 0){
    
    for (var i = 0; i < cells.length; i++) {  
      table.removeChild(table.firstChild);         
    } 
      
    var winkelKnoppen = document.getElementById("winkelfooter");
    var knopStap2     = document.getElementById("knopStap2");
    winkelKnoppen.removeChild(knopStap2);
    
  }
  
  
}

window.combinatiebestelling = 0;
function inWinkelmand(aantal, product, productHt){
  if(product != "" && productHt != ""){
    if(combinatiebestelling == 1){
      if(document.getElementById("winkelwagenTekstCombinatie-"+productHt)){document.getElementById("winkelwagenTekstCombinatie-"+productHt).className = "winkelwagenTekst";} 
    }else if(document.getElementById("winkelwagenTekst-"+productHt)){
      document.getElementById("winkelwagenTekst-"+productHt).className = "winkelwagenTekst";              
    }
    makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product="+product+"&aantal="+aantal+"&ht="+productHt+"&partUrl="+partOffUrl, "dom_updateFronWinkelmandMessage", true);
  }
  combinatiebestelling = 0;                                                                        
}

function dom_updateFronWinkelmandMessage(ajxReturn){
  var totaalItems   = ajxReturn.getElementsByTagName("totaalItems")[0].firstChild.data;
  var totaalBedrag  = ajxReturn.getElementsByTagName("totaalBedrag")[0].firstChild.data;
  
  window.location = "http://www.winterbanden.nl/winkelwagen/";
  
  var aantalContainer = document.getElementById("winkelmandTotaalItems");
  while(aantalContainer.hasChildNodes()){
    aantalContainer.removeChild(aantalContainer.firstChild);
  }
  aantalContainer.appendChild(document.createTextNode(totaalItems)); 
  
  var prijsContainer = document.getElementById("winkelmandTotaalBedrag");
  while(prijsContainer.hasChildNodes()){
    prijsContainer.removeChild(prijsContainer.firstChild);
  }
  
  if(document.getElementById("winkelmandTotalValue")){
    var winkelmandTotalValue = document.getElementById("winkelmandTotalValue");
    while(winkelmandTotalValue.hasChildNodes()){
      winkelmandTotalValue.removeChild(winkelmandTotalValue.firstChild);
    }
    winkelmandTotalValue.appendChild(document.createTextNode("€ "+totaalBedrag));
  }
  
  if(document.getElementById("winkelmandPageTotalPrijs")){
    var winkelmandTotalValue = document.getElementById("winkelmandPageTotalPrijs");
    while(winkelmandTotalValue.hasChildNodes()){
      winkelmandTotalValue.removeChild(winkelmandTotalValue.firstChild);
    }
    winkelmandTotalValue.appendChild(document.createTextNode(totaalBedrag));
  }
  
   
  
  prijsContainer.appendChild(document.createTextNode(totaalBedrag));
  
  var productHt = ajxReturn.getElementsByTagName("itemHt")[0].firstChild.data;
  if(document.getElementById("winkelmandMessage"+productHt)){document.getElementById("winkelmandMessage"+productHt).className = "alertInWinkelmand";}
   
  if(document.getElementById("winkelmandMessage")){document.getElementById("winkelmandMessage").className = "alertInWinkelmand";}
  
  /** UPDATE VIEW **/
  totalRowItems = 0;
  if(document.getElementById("winkelmand")){
    var winkelmand = document.getElementById("winkelmand");
    aTrs = winkelmand.getElementsByTagName("div");
    for(var a=0; a<aTrs.length; ++a){
      if(aTrs[a].className == "winkelmandRow"){
        ++totalRowItems;
      }    
    }
  } 
  
  if(afterRemoveRefresh == 1){
    checkForProducts();
    afterRemoveRefresh = 0;
  } 
}


function updateAantal(product, productHt){
  var container = document.getElementById("winkelmandSetAantalProduct"+productHt);
  var newAantal = container.value;
  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product="+product+"&aantal="+newAantal+"&ht="+productHt, "dom_updateWinkelmand", true);  
}

function dom_updateWinkelmand(ajxReturn){
  var winkelmandItems   = ajxReturn.getElementsByTagName("winkelmandItem"); 
  var productHt         = winkelmandItems[0].getElementsByTagName("itemHt")[0].firstChild.data;
  var newAantal         = winkelmandItems[0].getElementsByTagName("itemAantal")[0].firstChild.data;
  var newPrice          = winkelmandItems[0].getElementsByTagName("itemPrijs")[0].firstChild.data;  
  

  
  if(document.getElementById("winkelmandProductPrice"+productHt)){
    var priceContainer = document.getElementById("winkelmandProductPrice"+productHt);
    if(priceContainer.hasChildNodes()){
      while(priceContainer.hasChildNodes()){
        priceContainer.removeChild(priceContainer.firstChild);
      }
    }  
    priceContainer.appendChild(document.createTextNode(newPrice));
   
    if(productHt != "balanceer-2-locaties-met-extra-transportkosten"){
      makeHttpRequest("http://www.winterbanden.nl/xml/updateBalanceerKosten.php", "dom_updateWinkelmand", true);
    }else{
      var aantal = document.getElementById("winkelmandSetAantalProduct"+productHt);
      empty(aantal);
      aantal.appendChild(document.createTextNode(newAantal));
    }
  }
  dom_updateFronWinkelmandMessage(ajxReturn);  
}

function dom_update_balanceer_kosten(ajxReturn){
  
  
  
}

window.afterRemoveRefresh=0;
function verwijderItem(product, productHt){
  var container = document.getElementById("winkelmandRow"+productHt).className = "hidden";  
  afterRemoveRefresh = 1;
  inWinkelmand(0, product, productHt); 
}




function calculateNewPrice(aantal, prijs){
  var newPrijs = prijs * aantal;
  newPrijs = newPrijs.toFixed(2);
  empty(document.getElementById("aantalPrijs"));
  document.getElementById("aantalPrijs").appendChild(document.createTextNode(newPrijs));
  
  
  /** velg **/
  var prevAantal    = document.getElementById("bandCombinatieAantalVelgen").innerHTML;
  var totalPrice    = document.getElementById("bandCombinatiePrijsVelg").innerHTML;
  var prevVelgPrijs = totalPrice;
  totalPrice        = parseFloat(totalPrice) * 1 / prevAantal;
  totalPrice        = parseFloat(totalPrice) * 1 * aantal; 
  totalPrice        = totalPrice.toFixed(2);
  var newVelgPrijs  = totalPrice;
  empty(document.getElementById("bandCombinatiePrijsVelg"));
  document.getElementById("bandCombinatiePrijsVelg").appendChild(document.createTextNode(totalPrice));
  
  empty(document.getElementById("bandCombinatieAantalVelgen"));
  document.getElementById("bandCombinatieAantalVelgen").appendChild(document.createTextNode(aantal));
  

    /** band **/
    var prevAantal    = document.getElementById("bandCombinatieAantalBanden").innerHTML;
    var totalPrice    = document.getElementById("bandCombinatiePrijsBanden").innerHTML;
    var prevBandPrijs = totalPrice;  
    totalPrice        = parseFloat(totalPrice) * 1 / prevAantal;  
    totalPrice        = parseFloat(totalPrice) * 1 * aantal; 
    totalPrice        = totalPrice.toFixed(2);
    var newBandPrijs  = totalPrice;
    empty(document.getElementById("bandCombinatiePrijsBanden"));
    document.getElementById("bandCombinatiePrijsBanden").appendChild(document.createTextNode(totalPrice));
    
    empty(document.getElementById("bandCombinatieAantalBanden"));
    document.getElementById("bandCombinatieAantalBanden").appendChild(document.createTextNode(aantal));

  
 
  calculateBestelCombinatie();
  

}


function calculateBestelCombinatie(){
  var velgPrijs = document.getElementById("bandCombinatiePrijsVelg").innerHTML;
  velgPrijs = parseFloat(velgPrijs);
  
  var bandPrijs = 0;
  if(document.getElementById("bandCombinatieBandChecked").checked == true){
    bandPrijs = document.getElementById("bandCombinatiePrijsBanden").innerHTML;
    bandPrijs = parseFloat(bandPrijs);
  }
  
  var accessoiresPrijs1 = 0;
  if(document.getElementById("bandCombinatieAccessoires1Checked").checked == true){
    accessoiresPrijs1 = document.getElementById("bandCombinatiePrijsAccessoires1").innerHTML;
    accessoiresPrijs1 = parseFloat(accessoiresPrijs1);
  }
  
  var accessoiresPrijs2 = 0;
  if(document.getElementById("bandCombinatieAccessoires12Checked").checked == true){
    accessoiresPrijs2 = document.getElementById("bandCombinatiePrijsAccessoires2").innerHTML;
    accessoiresPrijs2 = parseFloat(accessoiresPrijs2);
  }
  
  var totalPrijs = parseFloat(velgPrijs + bandPrijs + accessoiresPrijs1 + accessoiresPrijs2);
  totalPrijs = totalPrijs.toFixed(2);
  empty(document.getElementById("combinatiePrijs"));
    document.getElementById("combinatiePrijs").appendChild(document.createTextNode(totalPrijs));
  
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

/***************************************** AUTO MODELLEN LICHTMETALEN VELGEN*****************************************/
function getModelLicht(htMerk){
  makeHttpRequest("http://www.winterbanden.nl/xml/getAutoModelLicht.php?htMerk="+htMerk, "fillAutoModelLicht", true);
}

function fillAutoModelLicht(ajaxReturn){
  var selectContainer = document.getElementById("lichtAutoModellen");
  empty(selectContainer);
  
  var container = document.getElementById("lichtAutoModellen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }



  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("modelNaam")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("modelHtName")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = htName;
    option.appendChild(document.createTextNode(model));
    
    selectContainer.appendChild(option);
     
  }
}



/***************************************** AUTO UITVOERINGEN LICHTMETALEN VELGEN*****************************************/
function getUitvoeringLicht(htModel){
  var htMerk = document.getElementById("lichtVelgenAutoMerk").value;
  makeHttpRequest("http://www.winterbanden.nl/xml/getAutoUitvoeringLicht.php?htMerk="+htMerk+"&htModel="+htModel, "fillAutoUitvoeringLicht", true);
}

function fillAutoUitvoeringLicht(ajaxReturn){
  var selectContainer = document.getElementById("lichtAutoUitvoeringen");
  empty(selectContainer);
  
  var container = document.getElementById("lichtAutoUitvoeringen");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }



  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("modelNaam")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("modelHtName")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = htName;
    option.appendChild(document.createTextNode(model));
    
    selectContainer.appendChild(option);
     
  }
}



/***************************************** AUTO UITVOERINGEN LICHTMETALEN VELGEN*****************************************/
function getInchmaatLicht(htUitvoering){
  var htMerk = document.getElementById("lichtVelgenAutoMerk").value;
  var htModel = document.getElementById("lichtAutoModellen").value;
  makeHttpRequest("http://www.winterbanden.nl/xml/getAutoInchmaatLicht.php?htMerk="+htMerk+"&htModel="+htModel+"&htUitvoering="+htUitvoering, "fillAutoInchmatenLicht", true);
}

function fillAutoInchmatenLicht(ajaxReturn){
  var selectContainer = document.getElementById("lichtVelgenAutoInchmaat");
  empty(selectContainer);
  
  var container = document.getElementById("lichtVelgenAutoInchmaat");
  while(container.hasChildNodes()){
    container.removeChild(container.firstChild);
  }



  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies"));
  container.appendChild(option);
  
  var container = ajaxReturn.getElementsByTagName("model");
  var i         = container.length;
  
  for(var a=0; a<i; ++a){
    
    var model  = container[a].getElementsByTagName("modelNaam")[0].firstChild.data;
    var htName = container[a].getElementsByTagName("modelHtName")[0].firstChild.data;

    var option = document.createElement("option");
    option.value = htName;
    option.appendChild(document.createTextNode(model));
    
    selectContainer.appendChild(option);
     
  }
}

function showLichtVelgen(){
  var auto        = document.getElementById("lichtVelgenAutoMerk").value;
  var model       = document.getElementById("lichtAutoModellen").value;
  var uitvoering  = document.getElementById("lichtAutoUitvoeringen").value;
  var inch        = document.getElementById("lichtVelgenAutoInchmaat").value;
  
  var link = auto+"-lichtmetalen-velgen/"+model+"-"+uitvoering+"-"+inch+"-inch/";
  
   if(auto == 0 || model == 0 || uitvoering == 0 || inch == 0){
    document.getElementById("errorZoekProduct").className = "error";
  }else{  
    window.location=currUrl+link;
  }  

}


/******************************************************* CALCULATOR - WIKI  ******************************************************/
function refreshForm(formId){
  var form = document.getElementById(formId);
  var inputVelden = form.getElementsByTagName("input");  
  var lock = document.getElementById("lock");
  
  if(lock.checked == 0){  
    for(var i = 0; i < inputVelden.length; i++){
      var inputType = inputVelden[i].getAttribute("type");
      if(inputType == "text"){
        inputVelden[i].value= "";           
      }  
    }
  }  
}

function resetButton(formId){
  var form = document.getElementById(formId);
  var inputVelden = form.getElementsByTagName("input"); 
  
  for(var i = 0; i < inputVelden.length; i++){
    var inputType = inputVelden[i].getAttribute("type");
    if(inputType == "text"){
      inputVelden[i].value= "";           
    }  
  }      
}


function combinatiePrijsBereken(prijs, isChecked){
  var totalPrice = document.getElementById("combinatiePrijs").innerHTML;

  if(prijs == "bandCombinatiePrijsBanden"){
    var prijs = document.getElementById("bandCombinatiePrijsBanden").innerHTML;
  }

  if(isChecked == true){
    
    totalPrice = parseFloat(totalPrice) * 1 + parseFloat(prijs);
  }else{
    totalPrice = parseFloat(totalPrice) * 1 - parseFloat(prijs);
  }
  totalPrice = totalPrice.toFixed(2);
  empty(document.getElementById("combinatiePrijs"));
  document.getElementById("combinatiePrijs").appendChild(document.createTextNode(totalPrice)); 
}



function aanbevolenProductenInWinkelwagen(velgHtName){
  
  var container = document.getElementById("frmAanbevolenProducten");  
  var aInputs = container.getElementsByTagName("input");
  var i = aInputs.length;
  for(var a=0; a<i; ++a){
    if(aInputs[a].checked == true){
      inWinkelmand('1','accessoires',aInputs[a].value);
      var aantalGekozen = 1;
    }
  }
  
  if(aantalGekozen == 1){
    document.getElementById("winkelwagenTekstAanbevolenProducten").className = "winkelwagenTekst";
  }
}


function overigeProductenInWinkelwagen(velgHtName){
  
  var container = document.getElementById("frmOverigeProducten");  
  var aInputs = container.getElementsByTagName("input");
  var i = aInputs.length;
  for(var a=0; a<i; ++a){
    if(aInputs[a].checked == true){
      inWinkelmand(document.getElementById('detailAantal-'+velgHtName).value,'band',aInputs[a].value);
      inWinkelmand(document.getElementById('detailAantal-'+velgHtName).value,'velg',velgHtName);
      var aantalGekozen = 1;
    }
  }
  
  if(aantalGekozen == 1){
    document.getElementById("winkelwagenTekstOverigeProducten").className = "winkelwagenTekst";
  }
}


window.winkelwagenProductKey = 0;
function getPlaatsFromProvincie(provincie, key){
  winkelwagenProductKey = key;
  var containerSelect = document.getElementById("montagevestigingPlaats"+winkelwagenProductKey);
  empty(containerSelect);
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Bezig met laden.."));
  containerSelect.appendChild(option); 
  
  makeHttpRequest("http://www.winterbanden.nl/xml/getPlaatsFromProvincie.php?provincie="+provincie, "fillPlaatsen", true);
}

function fillPlaatsen(ajaxReturn){
  var container = ajaxReturn.getElementsByTagName("plaats");
  var i         = container.length;
  
  var containerSelect = document.getElementById("montagevestigingId"+winkelwagenProductKey);
  empty(containerSelect);
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies uw montagevestiging"));
  containerSelect.appendChild(option); 
  
  var containerSelect = document.getElementById("montagevestigingPlaats"+winkelwagenProductKey);
  empty(containerSelect);
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies uw plaats"));
  containerSelect.appendChild(option);
  for(var a=0; a<i; ++a){       
     var plaats = container[a].firstChild.data;
     var option = document.createElement("option");
     option.value = plaats;
     option.appendChild(document.createTextNode(plaats));
     containerSelect.appendChild(option);    
  }
}

function getMontagevestigingFromPlaats(plaats, key){
  winkelwagenProductKey = key;
  var containerSelect = document.getElementById("montagevestigingId"+winkelwagenProductKey);
  empty(containerSelect);
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Bezig met laden.."));
  containerSelect.appendChild(option);
  makeHttpRequest("http://www.winterbanden.nl/xml/getMontagevestigingFromPlaats.php?plaats="+plaats, "fillMontagevestigingen", true);
}

function fillMontagevestigingen(ajaxReturn){
  var container = ajaxReturn.getElementsByTagName("montagevestiging");
  var i         = container.length;
  
  var containerSelect = document.getElementById("montagevestigingId"+winkelwagenProductKey);
  empty(containerSelect);
  var option = document.createElement("option");
  option.value = 0;
  option.appendChild(document.createTextNode("Kies uw montagevestiging"));
  containerSelect.appendChild(option); 
  for(var a=0; a<i; ++a){       
     var naam = container[a].getElementsByTagName("naam")[0].firstChild.data;
     var id   = container[a].getElementsByTagName("id")[0].firstChild.data;
     var option = document.createElement("option");
     option.value = id;
     option.appendChild(document.createTextNode(naam));
     containerSelect.appendChild(option);    
  }
}



function updateAndereBandenPrijs(bandPrijs){
  
  var bandPrijs = parseFloat(bandPrijs);
  var newPrijs =  parseFloat(totaalWinkelmandZonderBandenPrijs) + bandPrijs;
  var container = document.getElementById("andereBandenToaalPrijs");
  empty(container);
  container.appendChild(document.createTextNode(newPrijs));
}



function updateWinkelmandAndereBand(nieuwBandHt, vervangBandHt, aantal, accessoiresHt){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=band&aantal=0&ht="+vervangBandHt, "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=band&aantal="+aantal+"&ht="+nieuwBandHt, "", true);
  
  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);
  
  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal="+aantal+"&ht="+accessoiresHt, "dom_refreshWinkelmandView", true);
  
  //window.location = 'http://www.winterbanden.nl/winkelwagen/';
  
  //updateWinkelmandView();
}

function dom_refreshWinkelmandView(){
  window.location = 'http://www.winterbanden.nl/winkelwagen/';
}

function updateWinkelmandView(){
  makeHttpRequest("http://www.winterbanden.nl/xml/getWinkelmand.php", "dom_updateWinkelmandView", true);
}

function dom_updateWinkelmandView(ajaxReturn){
  var container = ajaxReturn.getElementsByTagName("product");
  var i         = container.length;

  var productcontainer = document.getElementById("winkelmandStap1Producten");
  empty(productcontainer);
  for(var a=0; a<i; ++a){
    var htName      = container[a].getElementsByTagName("htName")[0].firstChild.data;
    var naam        = container[a].getElementsByTagName("naam")[0].firstChild.data;
    var aantal      = container[a].getElementsByTagName("aantal")[0].firstChild.data;
    var prijs       = container[a].getElementsByTagName("prijs")[0].firstChild.data;
    var prijsEnkel  = container[a].getElementsByTagName("prijsEnkel")[0].firstChild.data;
    var productType = container[a].getElementsByTagName("productType")[0].firstChild.data;           
    var afbeelding  = container[a].getElementsByTagName("afbeelding")[0].firstChild.data;
    
    var tr        = document.createElement("tr");
    tr.id         = "winkelmandRow"+htName;
    tr.className  = "productRow";
    
    var td        = document.createElement("td");
    td.className  = "rowimage";
    var link = document.createElement("a");
      link.href = "#";
        var img     = document.createElement("img");
        img.src     = afbeelding;
        img.width   = "50";
        img.height  = "50";
      link.appendChild(img);
    td.appendChild(link);        
    tr.appendChild(td);  
    
    var td        = document.createElement("td");
    td.className  = "rowNaam";
      var link = document.createElement("a");
      link.href = "#";
      link.appendChild(document.createTextNode(naam));  
    td.appendChild(link);    
    tr.appendChild(td);  
    
    var td        = document.createElement("td");
    td.className  = "rowAantal";
      var select    = document.createElement("select");
      select.id     = "winkelmandSetAantalProduct"+htName;
      select.onchange =  function(){
                          var container = document.getElementById("winkelmandSetAantalProduct"+htName);
                          var newAantal = container.value;                          
                          makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product="+productType+"&aantal="+newAantal+"&ht="+htName, "dom_updateWinkelmand", true);                           
                        }
      for(var b=1; b<13; ++b){
        var option = document.createElement("option");
        option.value = b;
        if(b == aantal){option.selected = "selected";}
        option.appendChild(document.createTextNode(b));
        select.appendChild(option);
      }    
    td.appendChild(select);
    tr.appendChild(td);  
 
    var td        = document.createElement("td");
    td.className  = "rowPerStuk";
    td.appendChild(document.createTextNode(prijsEnkel));    
    tr.appendChild(td);  
    
    var td        = document.createElement("td");
    td.className  = "rowPrijs";
      var span = document.createElement("span");
      span.id = "winkelmandProductPrice"+htName;
      span.appendChild(document.createTextNode(prijs));
    td.appendChild(span);    
    tr.appendChild(td); 
     
    
    var td        = document.createElement("td");
    td.className  = "rowVerwijder";
      var link = document.createElement("a");
      link.href = "#";
        var img = document.createElement("img");
        img.src = "http://www.winterbanden.nl/images/interface/winkelmand/verwijder.gif";
      link.appendChild(img);
    td.appendChild(link);    
    tr.appendChild(td); 
    
    
    productcontainer.appendChild(tr); 
  }
  
}


function goForMontageVestiging(aantal){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal="+aantal+"&ht=balancere-via-montagevestiging-regelen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=uitbalanceren-lichtmetaal", "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/setKeuzeLevering.php?viaMontage=1", "dom_refreshWinkelmandView", true);
}

function verwijderUitbalanceerKosten(){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balancere-via-montagevestiging-regelen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=uitbalanceren-lichtmetaal", "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/setKeuzeLevering.php?thuisAfleveren=1&uitbalanceren=0", "dom_refreshWinkelmandView", true);  
}

function normaalUitbalanceren(aantal){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal="+aantal+"&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balancere-via-montagevestiging-regelen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=uitbalanceren-lichtmetaal", "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/setKeuzeLevering.php?thuisAfleveren=1&uitbalanceren=1", "dom_refreshWinkelmandView", true);
}

function vestigingBalanceren(aantal){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal="+aantal+"&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balancere-via-montagevestiging-regelen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=uitbalanceren-lichtmetaal", "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/setKeuzeLevering.php?thuisAfleveren=1&uitbalanceren=1", "dom_refreshWinkelmandView", true);
}

function lichtmetaalUitbalanceren(aantal){
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-aanbieding", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-algemeen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balanceer-2-locaties-met-extra-transportkosten", "", true);  
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal=0&ht=balancere-via-montagevestiging-regelen", "", true);
  makeHttpRequest("http://www.winterbanden.nl/xml/updateWinkelmand.php?product=accessoires&aantal="+aantal+"&ht=uitbalanceren-lichtmetaal", "", true);
  
  makeHttpRequest("http://www.winterbanden.nl/xml/setKeuzeLevering.php?thuisAfleveren=1&uitbalanceren=1", "dom_refreshWinkelmandView", true);
}





function bestelCombinatie(velgHt){
  combinatiebestelling  = 1;
  var aantal      = document.getElementById('detailAantal-'+velgHt).value;  
  //var accessoires = document.getElementById("bandCombinatieAccessoires");       
  var band        = document.getElementById("bandCombinatieBand");  
  var slotbouten  = document.getElementById("bandCombinatieSlotbouten");

                                    inWinkelmand(aantal,'velg',velgHt);

  if(document.getElementById("bandCombinatieAccessoires2")){
    var accessoires2 = document.getElementById("bandCombinatieAccessoires2");
    if(accessoires2.checked  == true){ inWinkelmand(1,'accessoires',accessoires2.value); }
  }

 

  if(band.checked         == true){ inWinkelmand(aantal,'band',band.value); }
  if(slotbouten.checked   == true){ inWinkelmand(1,'accessoires',slotbouten.value); } 
}




function popup(elementId){
  document.getElementById(elementId).className = "";
  
}

function checkVoorraad(formId){
  document.getElementById(formId).submit();
}


function set_balanceren_nieuw(todo, key, product){
  if(todo == 1){
  
  }else{
    var container = document.getElementById("winkelmandSetAantalProduct"+key);
    empty(container);
    var option = document.createElement("option");
    option.value= "0"
    option.appendChild(document.createTextNode("0"));
    container.appendChild(option);        
  }
  updateAantal(product, key);
  
}


function winkelwagen_set_all_bezorging(todo){
  
  aInputs = document.getElementsByTagName("input");
  i = aInputs.length;
  for(var a=0; a<i; ++a){
    if(aInputs[a].type == "radio"){
      if(aInputs[a].value == todo){
        aInputs[a].checked = "checked";
      }
    }
  }
  if(todo == "bezorgen"){
    window.location = 'http://www.winterbanden.nl/winkelwagen/set-bezorging/bezorgen/';
  }
  
}

function winkelwage_set_montagevestiging(key){
  window.location = 'http://www.winterbanden.nl/winkelwagen/set-bezorging/afhalen/'+key+'/';
  
}

function winkelwagen_update_aantal(key, aantal){
  window.location = 'http://www.winterbanden.nl/winkelwagen/update/'+key+'/'+aantal+'/';
}


function winkelwagen_gebruik_coupon(){
  var coupon = document.getElementById("winkelwagen_coupon").value;
  window.location = 'http://www.winterbanden.nl/winkelwagen/couponcode/'+coupon+'/';
  
}


























/** AJAX DEFINITION */
function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE

       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }      
   }

   if (!http_request) {
       //alert('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
              // alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}

function noFunction(test){ }
