﻿function divOn(id)
{
    if (document.layers){ document.layers[''+id+''].display = "block";}
    else if (document.all){ document.all[''+id+''].style.display = "block";}
    else if (document.getElementById){ document.getElementById(''+id+'').style.display = "block";}
}
function divOn2(id)
{
    if (document.layers){ document.layers[''+id+''].display = "inline";}
    else if (document.all){ document.all[''+id+''].style.display = "inline";}
    else if (document.getElementById){ document.getElementById(''+id+'').style.display = "inline";}
}
function divOff(id)
{
    if (document.layers){ document.layers[''+id+''].display = "none";}
    else if (document.all){ document.all[''+id+''].style.display = "none";}
    else if (document.getElementById){ document.getElementById(''+id+'').style.display = "none";}
}

function toggleDiv3(id)
{
    if (document.getElementById(''+id+'').style.display == "none" || document.getElementById(''+id+'').style.display.length == 0)
    {
        if (document.layers){ document.layers[''+id+''].display = "block";}
        else if (document.all){ document.all[''+id+''].style.display = "block";}
        else if (document.getElementById){ document.getElementById(''+id+'').style.display = "block";}
    }
    else
    {
        if (document.layers){ document.layers[''+id+''].display = "none";}
        else if (document.all){ document.all[''+id+''].style.display = "none";}
        else if (document.getElementById){ document.getElementById(''+id+'').style.display = "none";}
    }
 }
  
function toggleDiv2(id, minus)
{
    var id2 = id + 'Box';
    if (document.getElementById(''+id2+'') != null)
    {
        if (document.getElementById(''+id2+'').style.display == "none" || document.getElementById(''+id2+'').style.display.length == 0)
        {
            document.getElementById(''+id2+'').style.display = "block";
            document.getElementById(''+id+'').innerHTML = "<img src=\"" + minus + "\" border=\"none\" style=\"margin-top:8px;\">";

        }
        else
        {
            document.getElementById(''+id2+'').style.display = "none";
            document.getElementById(''+id+'').innerHTML = "+";
        }
    }
 }

function toggleDiv(id,id2,id3,flag) 
    {
        if (flag=="1")
        {
            if (document.layers){ document.layers[''+id+''].visibility = "show";}
            else if (document.all){ document.all[''+id+''].style.visibility = "visible";}
            else if (document.getElementById){ document.getElementById(''+id+'').style.visibility = "visible";}
            
            if (document.layers){ document.layers[''+id2+''].visibility = "show";}
            else if (document.all){ document.all[''+id2+''].style.visibility = "visible";}
            else if (document.getElementById){ document.getElementById(''+id2+'').style.visibility = "visible";}
            
            if (document.layers){ document.layers[''+id3+''].visibility = "show";}
            else if (document.all){ document.all[''+id3+''].style.visibility = "visible";}
            else if (document.getElementById){ document.getElementById(''+id3+'').style.visibility = "visible";}
        }
        else if (flag=="0")
        {
            if (document.layers){ document.layers[''+id+''].visibility = "hide";}
            else if (document.all){ document.all[''+id+''].style.visibility = "hidden";}
            else if (document.getElementById){ document.getElementById(''+id+'').style.visibility = "hidden";}
            
            if (document.layers){ document.layers[''+id2+''].visibility = "hide";}
            else if (document.all){ document.all[''+id2+''].style.visibility = "hidden";}
            else if (document.getElementById){ document.getElementById(''+id2+'').style.visibility = "hidden";}
            
            if (document.layers){ document.layers[''+id3+''].visibility = "hide";}
            else if (document.all){ document.all[''+id3+''].style.visibility = "hidden";}
            else if (document.getElementById){ document.getElementById(''+id3+'').style.visibility = "hidden";}
        }
    }
    
function submitForm()
{
  document.Enquete.submit();
}

function submitForm2()
{
  document.SearchForm2.submit();
}

function CheckLogin()
{
    var l_blnGO = true;
    var l_strAlert = '';
    if(document.getElementById('LoginEmail').value=='' || document.getElementById('LoginEmail').value==' - E-mailadres')
    {
        l_strAlert = l_strAlert + 'E-mailadres is verplicht.';
        document.getElementById('LoginEmail').focus();
        l_blnGO = false;
    }
    if(document.getElementById('LoginWachtwoord').value=='' || document.getElementById('LoginWachtwoord').style.display == "none")
    {
        if (l_strAlert != '') {
        l_strAlert = l_strAlert + '\nWachtwoord is verplicht.';
        }
        else {
            l_strAlert = 'Wachtwoord is verplicht.';
            document.getElementById('LoginWachtwoord').focus();
        }
        l_blnGO = false;
    }
    
    if(l_blnGO){
        document.Login.submit();
    }else{
        window.alert(l_strAlert + '\nNog niet geregistreerd?\nKlik dan op "Registreren"');
    }
}

function CheckLogin2()
{
    var l_blnGO = true;
    var l_strAlert = '';
    if(document.getElementById('LoginEmail2').value=='' || document.getElementById('LoginEmail2').value==' - E-mailadres')
    {
        l_strAlert = l_strAlert + 'E-mailadres is verplicht.';
        document.getElementById('LoginEmail2').focus();
        l_blnGO = false;
    }
    if(document.getElementById('LoginWachtwoord2').value=='' || document.getElementById('LoginWachtwoord2').value==' - Wachtwoord')
    {
        if (l_strAlert != '') {
        l_strAlert = l_strAlert + '\nWachtwoord is verplicht.';
        } else {
            l_strAlert = 'Wachtwoord is verplicht.';
            document.getElementById('LoginWachtwoord2').focus();
        }
        l_blnGO = false;
    }
    
    if(l_blnGO){
        document.Login2.submit();
    }else{
        window.alert(l_strAlert);
    }
}

function checkWinkelWagen(stap)
{
    var a = 0;
    var l_blnCorrect = true;
    var radio_choice = false;
    var regex = /^([1-9]{1}\d{3}\s{1}[A-Z]{2}$)/;
    var regexEmail = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
    var regexTel = /^(0[0-9]{9,}$)/;
    var l_strAlert = 'De volgende problemen zijn gevonden:';
    if (stap == 'Korting'){
        var g_arrKorting = ["Korting"];
        var g_intKortingLength = g_arrKorting.length;
        
        while(a < g_intKortingLength){
            if(document.getElementById(g_arrKorting[a]) != null){
                for (i=0;i<document.Winkelwagen.Korting.length;i++){
                    if (document.Winkelwagen.Korting[i].checked){
                        radio_choice = true;
                    }
                }
            }
            a++;
        }
        if (radio_choice == false){
            alert('U bent vergeten een optie in te vullen');
            l_blnCorrect = false;
        } 
    }
    if (stap == 'Gegevens'){
        var g_arrPers = ["Achternaam", "Voorletters", "Tussenvoegsel", "Geslacht"];
        var g_intPersLength = g_arrPers.length;
        var g_arrAdres = ["Organisatienaam", "Afdeling", "Functie", "Straat", "Postcode", "Plaats", "Telefoon", "Fax", "Mobiel", "Afwijkend_factuuradres", "Organisatienaam_factuur", "Afdelingsnaam_factuur", "Factuuradres_straat", "Factuuradres_postcode", "Factuuradres_plaats"];
        var g_intAdresLength = g_arrAdres.length;
        //debugger;
        while(a < g_intPersLength){
            if(document.getElementById(g_arrPers[a]) != null){
                //alert(document.getElementById(g_arrPers[a]).value);
                if(document.getElementById(g_arrPers[a]).value.length == 0){
                    if(g_arrPers[a] != 'Tussenvoegsel'){
                        document.getElementById(g_arrPers[a]).style.backgroundColor = '#FF4747';
                        document.getElementById(g_arrPers[a]).focus();
                        l_strAlert = l_strAlert + '\nU bent vergeten om ' + g_arrPers[a] + ' in te vullen';
                        l_blnCorrect = false;
                    }else{
                        document.getElementById(g_arrPers[a]).style.backgroundColor = '#FFFFFF';
                    }
                }
                else if (g_arrPers[a] == 'Emailadres')
                {
                    if (!regexEmail.test(document.getElementById(g_arrPers[a]).value)){
                        document.getElementById(g_arrPers[a]).style.backgroundColor = '#FF4747';
                        document.getElementById(g_arrPers[a]).focus();
                        l_strAlert = l_strAlert + '\n' + document.getElementById(g_arrPers[a]).value + ' is geen geldig e-mailadres';
                        l_blnCorrect = false;
                    }else{
                        document.getElementById(g_arrPers[a]).style.backgroundColor = '#FFFFFF';
                    }
                }else{
                    document.getElementById(g_arrPers[a]).style.backgroundColor = '#FFFFFF';
                }
                if(g_arrPers[a] == 'Geslacht'){
                    for (i=0;i<document.Winkelwagen.Geslacht.length;i++){
                        if (document.Winkelwagen.Geslacht[i].checked){
                            radio_choice = true;
                        }
                    }
                }
            }else{
                document.getElementById(g_arrPers[a]).style.backgroundColor = '#FFFFFF';
            }
            a++;
        }
        if (radio_choice == false){
            l_strAlert = l_strAlert + '\nU bent vergeten om geslacht in te vullen';
            l_blnCorrect = false;
       } 
       a = 0;
       //debugger;
       while(a < g_intAdresLength){
            if(document.getElementById(g_arrAdres[a]) != null){
                if(document.getElementById(g_arrAdres[a]).value.length > 0){
                    if(g_arrAdres[a] == 'Postcode' || g_arrAdres[a] == 'Factuuradres_postcode'){
                        if (!regex.test(document.getElementById(g_arrAdres[a]).value)){
                            document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FF4747';
                            document.getElementById(g_arrAdres[a]).focus();
                            l_strAlert = l_strAlert + '\n' + g_arrAdres[a].replace("_", " ") + ' is niet in het juiste formaat (1234 AA)';
                            l_blnCorrect = false;
                        }
                        else if (g_arrAdres[a] == 'Factuuradres_postcode' && document.getElementById('Afwijkend_factuuradres').checked == false) {
                            document.getElementById(g_arrAdres[a]).style.backgroundColor = '#E0E0E0';
                        }else{
                            document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FFFFFF';
                        }
                    }else if (g_arrAdres[a] == 'Telefoon' || g_arrAdres[a] == 'Mobiel' || g_arrAdres[a] == 'Fax'){
                        if (!regexTel.test(document.getElementById(g_arrAdres[a]).value)){
                            document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FF4747';
                            document.getElementById(g_arrAdres[a]).focus();
                            l_strAlert = l_strAlert + '\n' +g_arrAdres[a].replace("_", " ") + ' is niet in het juiste formaat (0612345678)';
                            l_blnCorrect = false;
                        }
                    }else if(document.getElementById('Afwijkend_factuuradres').checked == true && document.getElementById('Afwijkend_factuuradres').checked == true || (g_arrAdres[a] != 'Organisatienaam_factuur' && g_arrAdres[a] != 'Afdelingsnaam_factuur' && g_arrAdres[a] != 'Factuuradres_straat' && g_arrAdres[a] != 'Factuuradres_postcode' && g_arrAdres[a] != 'Factuuradres_plaats')){
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FFFFFF';
                    }else{
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#E0E0E0';
                    }
                }else{
                    if (g_arrAdres[a] != 'Organisatienaam_factuur' && g_arrAdres[a] != 'Afdelingsnaam_factuur' && g_arrAdres[a] != 'Factuuradres_straat' && g_arrAdres[a] != 'Factuuradres_postcode' && g_arrAdres[a] != 'Factuuradres_plaats' && g_arrAdres[a] != 'Telefoon' && g_arrAdres[a] != 'Fax' && g_arrAdres[a] != 'Mobiel' && g_arrAdres[a] != 'Organisatienaam' && g_arrAdres[a] != 'Afdeling' && g_arrAdres[a] != 'Functie'){
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FF4747';
                        document.getElementById(g_arrAdres[a]).focus();
                        l_strAlert = l_strAlert + '\nU bent vergeten om ' + g_arrAdres[a].replace('_',' ') + ' in te vullen';
                        l_blnCorrect = false;
                    }
                    else if (document.getElementById('Afwijkend_factuuradres').checked == true && g_arrAdres[a] != 'Organisatienaam_factuur' && g_arrAdres[a] != 'Afdelingsnaam_factuur' && g_arrAdres[a] != 'Telefoon' && g_arrAdres[a] != 'Fax' && g_arrAdres[a] != 'Mobiel' && g_arrAdres[a] != 'Organisatienaam' && g_arrAdres[a] != 'Afdeling' && g_arrAdres[a] != 'Functie'){
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FF4747';
                        document.getElementById(g_arrAdres[a]).focus();
                        l_strAlert = l_strAlert + '\nU bent vergeten om ' + g_arrAdres[a].replace('_',' ') + ' in te vullen';
                        l_blnCorrect = false;
                    }
                    else if(document.getElementById('Afwijkend_factuuradres').checked == true && document.getElementById('Afwijkend_factuuradres').checked == true || (g_arrAdres[a] != 'Organisatienaam_factuur' && g_arrAdres[a] != 'Afdelingsnaam_factuur' && g_arrAdres[a] != 'Factuuradres_straat' && g_arrAdres[a] != 'Factuuradres_postcode' && g_arrAdres[a] != 'Factuuradres_plaats')){
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#FFFFFF';
                    }else{
                        document.getElementById(g_arrAdres[a]).style.backgroundColor = '#E0E0E0';
                    }
                }
            }
            a++;
        }
    }
    a = 0;
    if (stap == 'Controle')
    {
        if (!document.getElementById("AlgemeneVoorwaarden").checked)
        {
            l_strAlert = "U dient akkoord te gaan met de algemene voorwaarden";
            l_blnCorrect = false;
        }
    }
    if (stap == 'Extra')
    {
        while(document.getElementById("Postcode_"+a) != null)
        {
            if (!regex.test(document.getElementById("Postcode_"+a).value)){
                document.getElementById("Postcode_"+a).style.backgroundColor = '#FF4747';
                document.getElementById("Postcode_"+a).focus();
                if (l_blnCorrect == true){
                    l_strAlert = l_strAlert + '\nNiet alle postcodes zijn in het juiste formaat (1234 AA)';
                }
                l_blnCorrect = false;
            }
            a++;
        }    
    }
    if (l_blnCorrect == true){
        document.Winkelwagen.submit();
    }else{
        window.alert(l_strAlert);
    }
}

function changeTotaal(changeDiv, prijs)
{
    document.getElementById('Totaal_'+changeDiv+'_b').innerHTML = '€ ' + document.getElementById('Aantal_'+changeDiv+'_a').value * prijs;
}

function Calculate(p_strIdPart, p_intPrijs)
{
    var l_strValue = document.getElementById('Aantal_'+p_strIdPart).value;
    var l_strBTWValue = document.getElementById('BTWValue_' + p_strIdPart).value;
    var l_strBTW = 0;
    var l_strBTWCent = 0;
    var l_strOutput = '';
    var l_intLength = p_intPrijs.indexOf(',');
    var l_strPrijs = '';
    if(l_intLength > -1)
    {
        var l_aryPrijs = [];
        l_aryPrijs = p_intPrijs.split(",");
        
        l_strOutput = l_aryPrijs[0] * l_strValue;
        var l_strCent = ',' + (l_aryPrijs[1] * l_strValue) + '00';
        l_strOutput = '€ ' + l_strOutput + l_strCent.substring(0,3);
    }
    else
    {
        l_strOutput = '€ ' + p_intPrijs * l_strValue + ',00';
    }
   
    
    l_strPrijs = l_strOutput.replace('€ ','').replace(',','.');
    //l_aryPrijs = l_strPrijs.replace(',','.');
    //alert(l_aryPrijs[0])
    //l_strPrijs = Math.round(l_strPrijs * (l_strValue))/100;
    //alert(l_strPrijs)
    //if
    //l_strPrijs = l_strPrijs.replace('.',',')
    document.getElementById('BTW_' + p_strIdPart).value = l_strBTW + l_strBTWCent; 
    l_strPrijs = '€ ' + l_strPrijs;
    //alert(document.getElementById('Totaal_'+p_strIdPart).innerHTML)
    document.getElementById('Totaal_'+p_strIdPart).innerHTML = l_strPrijs.replace('.',',');
    //alert(document.getElementById('Totaal_'+p_strIdPart).innerHTML)
}

function CalculateAll()
{
    var l_objBTW = document.getElementById('BTW_0');
    var l_strBTWValue = document.getElementById('BTWValue_0').value;
    var l_strBTWValueOld;
    var l_aryArray = [];
    var l_strBTWTypes = '';
    var l_arrBTW = [];
    var l_intCounter = 0;
    var l_intOldCounter = 0;
    var l_strOldValue = '';
    var l_strCurrentValue = '';
    var l_strSubTotal = '0';
    var l_strSubTotalEuro = '';
    var l_strSubTotalBTW = '0';
    var l_strTotalAll = '';
    var l_strTotalAllEuro = '0';
    var l_strCurrentValueBTW = '';
    var l_intCount2 = 0;

    
    while(document.getElementById('BTWValue_' + l_intCounter))
    {
        //document.getElementById('BTWTotal_' + l_strBTWValue).innerHTML = '';
        l_strBTWValue = document.getElementById('BTWValue_' + l_intCounter).value;
        l_objBTW = document.getElementById('BTWTotal_' + l_strBTWValue);
        if (l_strBTWTypes.indexOf(l_strBTWValue) == -1){
            l_strBTWTypes = l_strBTWTypes + l_strBTWValue + ',';
        }
        if (l_strBTWValueOld != l_strBTWValue){
            document.getElementById('BTWTotal_' + l_strBTWValue).innerHTML = '';
        }
        
        l_strOldValue = l_objBTW.innerHTML;
        l_strOldValue = l_strOldValue.replace(',','.').replace('€ ','');
        l_strCurrentValue = document.getElementById('Totaal_' + l_intCounter).innerHTML;
        l_strCurrentValue = l_strCurrentValue.replace(',','.').replace('€ ','');
        if(l_strOldValue.indexOf('.') > -1)
        {
            l_aryArray = l_strOldValue.split('.');
            l_aryArray[1] = l_aryArray[1] + '00';
            l_strOldValue = l_aryArray[0] + ',' + l_aryArray[1].substring(0,2);
        }
        else
        {
            l_strOldValue = l_strOldValue + ',00';
        }
        l_strSubTotal = Math.abs(l_strSubTotal) + Math.abs(l_strCurrentValue);
        
        l_strCurrentValueBTW = Math.abs(((Math.abs(l_strCurrentValue) * Math.abs(l_strBTWValue))/100));
        l_strOldValue = 'aa' + l_strOldValue;
        l_strOldValue = l_strOldValue.replace(',','.').replace('aa','');
        l_strOldValue = Math.abs(l_strOldValue) + Math.abs(l_strCurrentValueBTW);
        l_strOldValue = '€ ' + l_strOldValue;
        
        l_strOldValue = l_strOldValue.replace('NaN', '');
        if(l_strOldValue.indexOf('.') > -1)
        {
            l_aryArray = l_strOldValue.split('.');
            l_aryArray[1] = l_aryArray[1] + '00';
            l_strOldValue = l_aryArray[0] + ',' + l_aryArray[1].substring(0,2);
        }
        else
        {
            l_strOldValue = l_strOldValue + ',00';
        }
        
        l_strOldValue = l_strOldValue.replace('€ 0', '€ ');
        if (l_strOldValue.indexOf('€ ,') != -1){
            l_strOldValue = l_strOldValue.replace('€ ', '€ 0');
        }
        
        l_objBTW.innerHTML = l_strOldValue;
        if (l_strBTWValueOld != l_strBTWValue){
            l_strSubTotalBTW = Math.abs(l_strSubTotalBTW) + Math.abs(l_objBTW.innerHTML.replace(',','.').replace('€ ',''));
        }else{
            l_strSubTotalBTW = l_objBTW.innerHTML.replace(',','.').replace('€ ','');
        }
        l_strSubTotalEuro = '€ ' + l_strSubTotal;
        if(l_strSubTotalEuro.indexOf('.') > -1)
        {
            l_aryArray = l_strSubTotalEuro.split('.');
            l_aryArray[1] = l_aryArray[1] + '00';
            l_strSubTotalEuro = l_aryArray[0] + ',' + l_aryArray[1].substring(0,2);
        }
        else
        {
            l_strSubTotalEuro = l_strSubTotalEuro + ',00';
        }
        document.getElementById('SubTotal').innerHTML = l_strSubTotalEuro;
        
        l_strBTWValueOld = l_strBTWValue;
        l_intCounter++;
    }
    
    
    l_strTotalAllEuro = Math.abs(document.getElementById('SubTotal').innerHTML.replace('€ ', '').replace(',','.'));
    l_strBTWTypes = l_strBTWTypes.substring(0,(l_strBTWTypes.length-1));
    l_arrBTW = l_strBTWTypes.split(',');
    while(l_intCount2 < l_arrBTW.length)
    {
        l_strTotalAllEuro = Math.abs(l_strTotalAllEuro) + Math.abs(document.getElementById('BTWTotal_'+l_arrBTW[l_intCount2]).innerHTML.replace('€ ', '').replace(',','.'));
        l_intCount2++;
    }
    l_strTotalAllEuro = '€ ' + l_strTotalAllEuro;
    if(l_strTotalAllEuro.indexOf('.') > -1)
    {
        l_aryArray = l_strTotalAllEuro.split('.');
        l_aryArray[1] = l_aryArray[1] + '00';
        l_strTotalAllEuro = l_aryArray[0] + ',' + l_aryArray[1].substring(0,2);
    }
    else
    {
        l_strTotalAllEuro = l_strTotalAllEuro + ',00';
    }
    document.getElementById('TotalAll').innerHTML = l_strTotalAllEuro;
    
    
    l_intCounter = 0;
    while (document.getElementById('BTWRow_' + l_intCounter))
    {
        if (document.getElementById('BTWRow_' + l_intCounter).innerHTML.indexOf('€ 0,00') > -1)
        {
                divOff('BTWRow_' + l_intCounter);
        }
        else
        {
            
            if (document.layers){ document.layers['BTWRow_' + l_intCounter].display = "";}
            else if (document.all){ document.all['BTWRow_' + l_intCounter].style.display = "";}
            else if (document.getElementById){ document.getElementById('BTWRow_' + l_intCounter).style.display = "";}
        }
        
        l_intCounter++;
    }
    //debugger;
    setCookies();
}

function Calculate2(p_strIdPart, p_intPrijs, p_blnGo)
{
    var l_strValue = document.getElementById('Aantal_'+p_strIdPart).value;
    //alert(document.getElementById('BTWValue_'+p_strIdPart).value);
    var l_strBTWValue = document.getElementById('BTWValue_'+p_strIdPart).value;
    var l_strBTW = '';
    var l_strPrijs = p_intPrijs;
    var l_aryPrijs = [];
    if(p_intPrijs.indexOf(',') >-1)
    {
        l_strPrijs = p_intPrijs.replace(',','.');
    }
    l_strPrijs = '€ ' + l_strPrijs * l_strValue;

    if(l_strPrijs.indexOf('.') > -1)
    {
        l_aryPrijs = l_strPrijs.split('.');
        l_aryPrijs[1] = l_aryPrijs[1] + '00';
        l_strPrijs = l_aryPrijs[0] + ',' + l_aryPrijs[1].substring(0,2);
    }
    else
    {
        l_strPrijs = l_strPrijs + ',00';
    }

    document.getElementById('Totaal_'+p_strIdPart).innerHTML = l_strPrijs;
    l_strBTW = '€ ' + l_strPrijs.replace(',','.').replace('€ ','') * (l_strBTWValue/100);

    if(l_strBTW.indexOf('.') > -1)
    {
        l_aryPrijs = l_strBTW.split('.');
        l_aryPrijs[1] = l_aryPrijs[1] + '00';
        l_strBTW = l_aryPrijs[0] + ',' + l_aryPrijs[1].substring(0,2);
    }
    document.getElementById('BTW_'+p_strIdPart).value = l_strBTW;
    //alert(l_strBTW);

    if(p_blnGo)
    {
        CalculateAll();
    }
}

function setCookies()
{
    var l_intCounter        = 0;
    var l_intCounterAbbo    = 0;
    var l_strValue          = '';
    var l_strAboType        = '';
    var l_intAboAantal      = 0;
    var l_intNumber         = 0;
    while (document.getElementById('Aantal_' + l_intCounter))
    {
        if (document.getElementById('Aantal_' + l_intCounter).value != 0)
        {
            //Aantal
            l_strValue = l_strValue + document.getElementById('Aantal_' + l_intCounter).value + ',--,';
            //Titel
            l_strValue = l_strValue + document.getElementById('Titel_' + l_intCounter).innerHTML + ',--,';
            //Totaal
            l_strValue = l_strValue + document.getElementById('Totaal_' + l_intCounter).innerHTML + ',--,';
            //Table
            l_strValue = l_strValue + document.getElementById('Table_' + l_intCounter).value + ',--,';
            //Als het een abonnement is
            if (document.getElementById('Titel_' + l_intCounter).innerHTML == 'S&amp;RO Abonnement' || document.getElementById('Titel_' + l_intCounter).innerHTML == 'TVV Abonnement')
            {
                if (document.getElementById('Titel_' + l_intCounter).innerHTML == 'S&amp;RO Abonnement')
                {
                    l_strAboType = 'SRO';
                }else{
                    l_strAboType = 'TVV'
                }
                while (document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo))
                {
                    if (l_strValue.indexOf(',--,' + l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.replace(';','')) > -1)
                    {
                        l_intNumber = parseInt(l_strValue.substring((l_strValue.indexOf(',--,' + l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.replace(';','')) - 1), l_strValue.indexOf(',--,' + l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.replace(';',''))));
                        
                        l_strValue = l_strValue.replace(l_intNumber+',--,' + l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.replace(';',''), (l_intNumber+1)+',--,' +l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.replace(';',''));
                    }else{
                        //Aantal
                        l_strValue = l_strValue + '1,--,';
                        //Titel
                        l_strValue = l_strValue + l_strAboType + 'Cadeau - '+document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.substring(0, document.getElementById(l_strAboType + 'Cadeau' + l_intCounterAbbo).value.lastIndexOf('_')).replace(';','') + ',--,';
                        //Totaal
                        l_strValue = l_strValue + '€ 0,00,--,';
                        //ItemId
                        l_strValue = l_strValue + l_strAboType + 'Cadeau,--,';
                    }
                    l_intCounterAbbo++;
                }
                l_intCounterAbbo = 0;
            }
        }
        l_intCounter++;
    }
    l_strValue = l_strValue.substring(0,(l_strValue.length-4));
    while (l_strValue.indexOf('&amp;') > -1)
        l_strValue = l_strValue.replace('&amp;', 'xfzjvu');

    l_strValue = l_strValue.replace("'", "''");
    l_strValue = l_strValue.replace('”˜ ', '"');
    
    createCookie('Artikelen', l_strValue, 1);
    l_intCounter = 0;
    l_strValue = '';
    while (document.getElementById('BTWRow_' + l_intCounter))
    {
        var l_strInner = document.getElementById('BTWRow_' + l_intCounter).innerHTML;
        l_strInner = l_strInner.replace(/\<.+?\>/g, '');
        
        l_strInner = l_strInner.replace('BTW€', 'BTW,--,€');
        if (document.getElementById('BTWRow_' + l_intCounter).innerHTML.indexOf('€ 0,00') == -1)
        {
            l_strValue = l_strValue + l_strInner + ',--,';
        }
        l_intCounter++;
    }
    l_strValue = l_strValue.substring(0,(l_strValue.length-4));
    createCookie('BTW', l_strValue, 1);
    createCookie('Total', document.getElementById('TotalAll').innerHTML, 1);
    //alert(readCookie('Artikelen'));
}

function createCookie(name,value,days) {
    //debugger;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}else{ 
	    var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
	//alert(document.cookie)
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') {c = c.substring(1,c.length);}
		if (c.indexOf(nameEQ) == 0) {return c.substring(nameEQ.length,c.length);}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function fillHiddenFields()
{
    document.getElementById('ArtikelenJS').value = readCookie('Artikelen');
    document.getElementById('BTWJS').value = readCookie('BTW');
    document.getElementById('TotalJS').value = readCookie('Total');
}

function deleteRecord(oldvalue)
{
    document.getElementById('Stap').value = 'Overzicht';
    document.getElementById('RecordRemove').value = oldvalue;
    var test = document.getElementById('RecordRemove').value;
    document.Winkelwagen.submit();
}

function recordRemoved(removedvalue)
{
    var value = removedvalue;
    if (value.indexOf('L') != -1) {
        document.getElementById('Stap').value = 'Korting';
    }else{
        document.getElementById('Stap').value = 'Overzicht';
    }
    document.getElementById('RecordRemove').value = 'removed';
    document.Winkelwagen.submit();
}

if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function getData(dataSource,documentElement)
{
    if(XMLHttpRequestObject) {
        var obj = document.getElementById(documentElement);
        XMLHttpRequestObject.open("GET", dataSource, true);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                obj.innerHTML = XMLHttpRequestObject.responseText; 
            }
        };
        XMLHttpRequestObject.send(null);
    }
}

function goStepBack(step)
{
    document.getElementById('Stap').value = step;
    document.Winkelwagen.submit();
}

function ValueCheck(p_objThis, p_strIf, p_strThan)
{
    if(p_objThis.value == p_strIf)
        p_objThis.value = p_strThan;
}

function AboDiv(p_strIdPart, p_strTypeAbo)
{
    var l_strValue = document.getElementById('Aantal_'+p_strIdPart).value;
    var l_strCadeaus = document.getElementById('AboCadeaus').value;
    l_strCadeaus = l_strCadeaus.replace(/TypeAbo/gi, p_strTypeAbo);
    var l_intCount = 0
    var l_strInnerHTML = ''
    if (l_strValue == '0')
        document.getElementById(p_strTypeAbo+'Abo').innerHTML = '';
    else 
    {
        l_strInnerHTML = l_strInnerHTML + '<table>';
        while (l_intCount < l_strValue)
        {
            l_strInnerHTML = l_strInnerHTML + l_strCadeaus.replace(p_strTypeAbo+'Cadeau\'', p_strTypeAbo+'Cadeau'+l_intCount + '\'').replace(p_strTypeAbo+'Cadeau\'', p_strTypeAbo+'Cadeau'+l_intCount + '\'');
            l_intCount++;
        }
        l_strInnerHTML = l_strInnerHTML + '</table>';
        document.getElementById(p_strTypeAbo+'Abo').innerHTML = l_strInnerHTML;
    }
    setCookies();
}