$(function(){
	$(".onderdeel .naam").click(function(){
		if($(this).parent().height() > 40)
			$(this)
				.parent()
				.stop()
				.animate({height : 36});
		else
			$(this)
				.parent()
				.stop()
				.animate({height : 123})
				.siblings()
				.each(function(){
					  if($(this).height() > 40)$(this).stop().animate({height : 36});
				});	
	});
	
	// Set youtube
	$("[youtubeid]").each(function(){
	    var $a = $("<a />")
	        .attr("href", "#TB_inline?height=350&amp;width=570&amp;inlineId=ytMovie")
	        .addClass("thickbox");
	    $(this).wrap($a).click(function(){
            $("#ytMovie").html(playYoutube($(this).attr("youtubeid")));  
	    });
	});
	
	initMouseOverIcon();
});

function submitit()
{
    document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    theForm.submit();      
    document.body.style.cursor = "default";
}


function submitform()
{ 
    //document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    theForm.submit();    
    //document.body.style.cursor = "default";
}

function submitSpecial(value)
{ 
    document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    theForm.action = value;
    theForm.submit();      
    document.body.style.cursor = "default";
}

var ImageSwapTimer;

function realswap(img,text,corner){
    MM_swapImage('imageOver','',img);
    document.getElementById('imageOverTekst').innerHTML = text;    
    $("#ProdImageCorner").removeClass("actie");
    $("#ProdImageCorner").removeClass("nieuw");
    if (corner != '') {$("#ProdImageCorner").addClass(corner);}
     //actie
}

function swapImg(img, text, corner){
   clearTimeout(ImageSwapTimer)
   ImageSwapTimer = setTimeout("realswap('" + img + "','" + text + "','" + corner + "');", 50);    
}

function ModelChoice(object)
{
    if (object.selectedIndex != 0)
    {
        document.body.style.cursor = "wait";
        document.getElementById('Modelid').value = object.options[object.selectedIndex].value;        
        document.getElementById('ModelText').value = object.options[object.selectedIndex].text;
        ProdSelection();
    }
}

function ModelChoiseByIcon(id,text,dual)
{
    document.getElementById('Modelid').value = id;        
    document.getElementById('ModelText').value = text;
    document.getElementById('ModelDualColor').value = dual;
    ProdSelection();
}

function FabricChoiseByIcon(id,text)
{
    document.getElementById('Stofid').value = id;
    document.getElementById('StofText').value = text;
    ProdSelection();
}

function FabricChoiseBottomByIcon(id,text)
{
    document.getElementById('Stofid2').value = id;
    document.getElementById('StofText2').value = text;
    ProdSelection();
}

function MaatChoice()
{
    document.getElementById('GekBreedte').value = document.getElementById('Breedte').value
    document.getElementById('GekHoogte').value= document.getElementById('Hoogte').value
    document.getElementById('MaatVoeringText').value = document.getElementById('Breedte').value + ' x ' + document.getElementById('Hoogte').value + ' cm'
    ProdSelection();
}

function VeluxSelect(object)
{
if (object.selectedIndex != 0)
    {
        document.body.style.cursor = "wait";
        document.getElementById('GekBreedte').value = 0;
        document.getElementById('GekHoogte').value = object.options[object.selectedIndex].value;        
        document.getElementById('MaatVoeringText').value = object.options[object.selectedIndex].text;
        ProdSelection();
    }
}

function LadderBandChoise(Text,id, meerp)
{
    if ($("#Nextstep").val() == $("#Currentstep").val())
    {
        $("#Nextstep").val(Number($("#Currentstep").val())+1)
    }
    document.getElementById('LadderID').value = id;        
    document.getElementById('LadderText').value = Text;
    document.getElementById('LadderMeerPrijs').value = meerp;
    ProdSelection();
}

function ColorChoice(Text,id, levertijd, meerprijs)
{
    if ($("#Nextstep").val() == $("#Currentstep").val())
    {
        $("#Nextstep").val(Number($("#Currentstep").val())+1)
    }
    
    var output ="";
    $("#KleurMeerPrijs").val(meerprijs);
    document.getElementById('KleurID').value = id;        
    document.getElementById('KleurText').value = Text;
    switch(levertijd)
    {
    case 0:
      output = "+/- 1 tot 2 werkweken"
      break;    
    case 1:
      output = "+/- 2 tot 3 werkweken"
      break;    
    case 2:
      output = "+/- 2 tot 4 werkweken"
      break;
    case 3:
      output = "+/- 3 tot 4 werkweken"
      break;
    case 4:
      output = "+/- 3 tot 5 werkweken"
      break;
    case 5:
      output = "+/- 4 tot 6 werkweken"
      break;
    case 6:
      output = "+/- 5 tot 6 werkweken"
      break;
    case 7:
      output = "+/- 6 tot 8 werkweken"
      break;
    case 8:
      output = "+/- 8 tot 10 werkweken"
      break;
    case 9:
      output = "+/- 10 tot 12 werkweken"
      break;
    default:
      output = "Onbekend"
    }
    document.getElementById('LevertijdID').value= levertijd ;
    document.getElementById('LevertijdText').value= output;
    ProdSelection();    
 }

function ColorChoiceBottom(Text,id, levertijd, meerprijs)
{
    if ($("#Nextstep").val() == $("#Currentstep").val())
    {
        $("#Nextstep").val(Number($("#Currentstep").val())+1)
    }
    var output ="";
    $("#KleurMeerPrijs").val(meerprijs);
    document.getElementById('KleurID2').value = id;        
    document.getElementById('KleurText2').value = Text;
    if (levertijd >=document.getElementById('LevertijdID').value)
    {
        switch(levertijd)
        {
        case 0:
          output = "+/- 1 tot 2 werkweken"
          break;    
        case 1:
          output = "+/- 2 tot 3 werkweken"
          break;    
        case 2:
          output = "+/- 2 tot 4 werkweken"
          break;
        case 3:
          output = "+/- 3 tot 4 werkweken"
          break;
        case 4:
          output = "+/- 3 tot 5 werkweken"
          break;
        case 5:
          output = "+/- 4 tot 6 werkweken"
          break;
        case 6:
          output = "+/- 5 tot 6 werkweken"
          break;
        case 7:
          output = "+/- 6 tot 8 werkweken"
          break;
        case 8:
          output = "+/- 8 tot 10 werkweken"
          break;
        case 9:
          output = "+/- 10 tot 12 werkweken"
          break;
        default:
          output = "Onbekend"
        }
        document.getElementById('LevertijdID').value= levertijd ;
        document.getElementById('LevertijdText').value= output;
    }
    ProdSelection();
}



function GoCheckDimensions()
{
    
    var wvBreedte = parseFloat(document.getElementById('Breedte').value.replace(',','.'));
    var wvHoogte = parseFloat(document.getElementById('Hoogte').value.replace(',','.'));
    var wvMinB = parseFloat(document.getElementById('MinB').value.replace(',','.'));
    var wvMaxB = parseFloat(document.getElementById('MaxB').value.replace(',','.'));
    var wvMinH = parseFloat(document.getElementById('MinH').value.replace(',','.'));
    var wvMaxH = parseFloat(document.getElementById('MaxH').value.replace(',','.'));
    var wvMaxM2 = parseFloat(document.getElementById('MaxM2').value.replace(',','.'));
    
    
    
    var enableButton = false;
    
    if (wvMaxM2 != 0)
    {
            var CalcM2 = parseFloat((wvBreedte/100) * (wvHoogte /100));
            if (CalcM2 <= wvMaxM2 )
            {
            document.getElementById('itemBtnEnabled').style.display = 'block';
            document.getElementById('itemBtnDisabled').style.display = 'none';
            }
            else
        {
            document.getElementById('itemBtnEnabled').style.display = 'none';
            document.getElementById('itemBtnDisabled').style.display = 'block';
        }
    }
    else
    {
    
    if ((wvBreedte >= wvMinB) && (wvBreedte <= wvMaxB))
    {
        if ((wvHoogte >= wvMinH) && (wvHoogte <= wvMaxH))
        {
            document.getElementById('itemBtnEnabled').style.display = 'block';
            document.getElementById('itemBtnDisabled').style.display = 'none';
        }
        else
        {
            document.getElementById('itemBtnEnabled').style.display = 'none';
            document.getElementById('itemBtnDisabled').style.display = 'block';
        }
    }
    else
    {
        document.getElementById('itemBtnEnabled').style.display = 'none';
        document.getElementById('itemBtnDisabled').style.display = 'block';
    }
    
    if ((wvMinB == -999) && (wvMinH == -999))
    {
        if ((wvBreedte >= 1) && (wvHoogte >= 1))
        {
           document.getElementById('itemBtnEnabled').style.display = 'block';
           document.getElementById('itemBtnDisabled').style.display = 'none';
        }
    }
    }
}

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

function gotoSubStep(value)
{
    document.getElementById('Nextstep').value = value;
    ProdSelection();  
}

function confirmGo()
{
    if (document.getElementById('Modelid').value == '')
    {
        document.location = "/"
    }
    else
    {
        var answer = confirm ("Als u nu weg gaat zult u al uw gemaakte keuzes verliezen")
        if (answer) 
        {
            document.location = "/"
        }
    }
}

function ChangeSelection(Group, Item)
{
    var GroupElements = document.getElementById('Group_' + Group + '_collection').value.split(',');
    var curvalue = document.getElementById('OptiesID').value
    for(i = 0; i < GroupElements.length; i++){
        
        var elementid = GroupElements[i].replace("|","").replace("|","")
        curvalue = curvalue.replace(GroupElements[i],"|" + Item + "|");
    }
    document.getElementById('OptiesID').value = curvalue 
    
    document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    
    action = new String;
    
    action = theForm.action;
    
    tempaction = action.split("#")
    
    action = tempaction[0] + '#JumpLocation_' + Group;
    theForm.action = action
    theForm.submit();      
    document.body.style.cursor = "default";
}

function SendMontageForm()
{
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    action = new String;
    
    action = theForm.action;
    
    tempaction = action.split("#")
    
    action = tempaction[0] + '#MontageLink';
    theForm.action = action
    theForm.submit();      
    document.body.style.cursor = "default";
}

function RecalculateOptions()
{
    
}

function ProdSelection()
{
 submitform();
}

function SendToBasket(value,target)
{
    document.body.style.cursor = "wait";
    document.getElementById('Action').value="AddNew";
//    document.getElementById('TotalePrijs').value = value;
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    theForm.action = "/" + target + ".aspx";
    
    theForm.submit();      
    document.body.style.cursor = "default";
}

function toggleVerzend()
{
if (document.getElementById('VisF').checked)
{
    document.getElementById('VerzendAdresBlok').style.display = 'none' 
}
else
{
    document.getElementById('VerzendAdresBlok').style.display = '' 
}

}

var DropDownTimer;
var openOne = "";

function displayBlock(value)
{
    if (openOne != "")
    {
     document.getElementById(openOne).style.display='none';   
    }
    openOne = 'Info_' + value + '_dropdown'
    document.getElementById('Info_' + value + '_dropdown').style.display='block';
    clearTimeout(DropDownTimer)
}

function HideBlock(value)
{    
    clearTimeout(DropDownTimer)
    DropDownTimer = setTimeout("RealClosePop(" + value + ");",2);
}

function RealClosePop(value)
{
    document.getElementById('Info_' + value + '_dropdown').style.display='none';
    openOne = "";
}

function OpenEigenschappen(kleurid,eigenschappen,currentStep)
{
//    var array = eigenschappen.split(",");
//    var output = '';
//    
//    var workstring ='';
//    
//    for (i=0; i<array.length; i++)
//    {
//        if (array[i] != '')
//        {
//            if (document.getElementById('_' + array[i] + '_omschrijving'))
//            {
//                workstring = '<div class="Properties">';
//                workstring += '<div class="PropImgContainer"><img class="PropertieImage" src="/img/icoontjes/' + array[i] + '.gif" /></div>';
//                workstring += '<div class="PropTextContainer">' + document.getElementById('_' + array[i] + '_omschrijving').innerHTML + '</div>';
//                workstring += '</div>'
//                output += workstring;
//            }
//        }
//    }
      $("#Nextstep").val(currentStep);
      $("#ajaxAction").val('Eigenschappen');
      document.getElementById('showColor').value = kleurid
    __doPostBack('ctl00$ContentPlaceHolder1$LinkButtonTriggerAjax2','')
//    document.getElementById('ViewportEigenschappen').innerHTML = output;
//    document.getElementById('ViewportImage').src = '/picture.aspx?productid=' + kleurid + '&formaatnaam=vergroting&fototype=productfoto' ;    
}

var Yinterval = 25;

function ScollContentDown()
{
    var oldvalue = document.getElementById('MateriaalEigenschappen').scrollTop
    var newvalue = oldvalue + Yinterval;
    document.getElementById('MateriaalEigenschappen').scrollTop= newvalue  ;
}

function ScollContentUp()
{
    var oldvalue = document.getElementById('MateriaalEigenschappen').scrollTop
    var newvalue = oldvalue - Yinterval;
    document.getElementById('MateriaalEigenschappen').scrollTop= newvalue  ;
}

function AddProductToWinkelmandjeAJAX(productid, description,Currentstep,currentGroup) {
    var oldvalue =$("#Nextstep").val()
    $("#ajaxAction").val('AddProd');
    $("#ChosenColorGroup").val(currentGroup);
    MM_findObj('addajaxproduct').value=productid;
    MM_findObj('addajaxproductdesc').value=description;
    $("#Nextstep").val(Currentstep)
    __doPostBack('ctl00$ContentPlaceHolder1$LinkButtonTriggerAjax','');
}

function ActiveScroll(value)
{
if (value == 'on')
{
    mouseOverContainer = true;
}
else
{
    mouseOverContainer = false
}
}

function Launch(value)
{
document.location = value;
}

function GaWinkelenMet(value)
{
    inputwaarde = new String;
    inputwaarde = value 
    
    if (inputwaarde.indexOf('.aspx') != -1)
    {
        document.location = inputwaarde;
    }
    else
    {    
    waarden = inputwaarde.split("|");
    $('.InterneOfferteWMOmschrijving').attr("disabled", true); 
    for (var i=0; i<=waarden.length-1; i++)
    {
        realvalues = waarden[i].split("#")
        if (document.getElementById(realvalues[0])) {document.getElementById(realvalues[0]).value = realvalues[1]}
    } 
    ShopAgain();
    }
}

function ShopAgain()
{
    document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    id = new String;
    id=document.getElementById('CatID').value
    theForm.action = "/P" + id  + "/Artikelen/" + document.getElementById('CatDescription').value + "/stap2.aspx";
    theForm.submit();      
    document.body.style.cursor = "default";
}

function OpenImageProduct()
{
    var img = document.getElementById('imageOver').src;
    document.getElementById('ViewPortRealImage').src = img.replace("formaatnaam=normaal","formaatnaam=vergroting");
}

 function OpenImage(img)
{
    
    document.getElementById('ViewPortRealImage').src = img;
}

function PositionImage()
{
    var width = document.getElementById('ViewportImage').width
    var height = document.getElementById('ViewportImage').height
}

function toggler(welke,hoe){
	element= document.getElementById(welke);
	if (hoe == "aan") {
		if (element.style.display == 'none'){
			element.style.display = '';
		}
	} else {
		if (element.style.display != 'none'){
			element.style.display = 'none';
		}
	}
}

function HideDagen(index)
{
    if (index == 2)
    {
    document.getElementById('Leverdagen').style.display='none';
    }
    else
    {
    document.getElementById('Leverdagen').style.display='block';
    }
}


window.onscroll = function() {
	var OffSet;
	var Base;
	var Max = 700;
	
	Base = document.documentElement.scrollTop;
   
	
	if (document.getElementById('ctl00_ContentPlaceHolder1_MaatVoering'))
	{
	    return false;
	}
	else
	{	
	    if (document.getElementById('stappenBestel') && (Base >=570 && document.getElementById('Nextstep').value == '3' ||Base >=570 && document.getElementById('Nextstep').value == '4'))
	    {
	    
	        if (Base >= 570 && $("#largeBlok").height() > $("#stappenBestel").height())
	        {
	            OffSet = (document.documentElement.scrollTop - 570)
	            
	            maxHeight = parseInt($("#largeBlok").innerHeight()) - parseInt($("#stappenBestel").innerHeight());
	            if ((document.documentElement.scrollTop - 570) >= maxHeight)
	            {
	                OffSet = maxHeight;
	            }
	            document.getElementById('stappenBestel').style.marginTop = OffSet + 'px';
	        }
	    }
	    else
        {
            if (document.getElementById('stappenBestel'))
            {
            document.getElementById('stappenBestel').style.marginTop = '0px';
            }
        }
    }
}

var StapTimer;

function showStap(div)
{
   document.getElementById('stappendrop1').style.display = 'none';
   document.getElementById('stappendrop2').style.display = 'none';
   document.getElementById('stappendrop3').style.display = 'none';
   
   document.getElementById('stappendrop' + div).style.display = 'block';
   clearTimeout(StapTimer)
}

function hideStap()
{
    clearTimeout(StapTimer)
    StapTimer = setTimeout("RealCloseStap();",200);
}

function RealCloseStap()
{
    document.getElementById('stappendrop1').style.display = 'none';
    document.getElementById('stappendrop2').style.display = 'none';
    document.getElementById('stappendrop3').style.display = 'none';
}

function ShowExtraProduct()
{
    document.getElementById('ExtraProduct').style.display = 'block';
    document.getElementById('ShowExtra').style.display = 'none';
}

function HideExtraProduct()
{
    document.getElementById('Extrabreedte').value = '';
    document.getElementById('Extrahoogte').value = '';
    document.getElementById('Extrabediening').selectedIndex =0;
    document.getElementById('ExtraPlaatsing').selectedIndex =0;    
    document.getElementById('ExtraProduct').style.display = 'none';
    document.getElementById('ShowExtra').style.display = 'block';
}


var huidigeaantal = 0;
var PublicFlex = '';
function AddExtraProducten(aantaltegelijk, flexopties) {
        if (flexopties != '')
        {
            PublicFlex = flexopties 
        }
        else
        {
            flexopties = PublicFlex 
        }
        for (i=1; i<=aantaltegelijk; i++) {	
    	huidigeaantal = huidigeaantal + 1;
    	oldid = huidigeaantal;
    	newid = huidigeaantal + 1;   	
    	var tekst = '';
    	    
    	    tekst = tekst + '<div class="stroke">&nbsp;</div><div class="formulier"><div class="titel">Productdetails :</div><div class="formRow"><div class="omschrijving">Kies raamdecoratie:</div><div class="verplicht">*</div><div class="inputVelden"> <select name="TypeFlex_'+oldid+'" id="TypeFlex_'+oldid+'">' + flexopties + '</select>  </div></div><div class="formRow"><div class="omschrijving">Type:</div><div class="verplicht"></div><div class="inputVelden"><input type="text" class="text" style="width: 100px;" name="type_'+oldid+'" onfocus="Juice_SelectVeld(this);"/></div></div><div class="formRow"><div class="omschrijving">Kleur:</div><div class="verplicht"></div><div class="inputVelden"><input type="text" class="text" style="width: 100px;" name="kleur_'+oldid+'" onfocus="Juice_SelectVeld(this);"/></div></div><div class="formRow"><div class="omschrijving">Lamelbreedte:</div><div class="verplicht"></div><div class="inputVelden"><input type="text" class="text" style="width: 100px;" name="lamelbreedte_'+oldid+'" onfocus="Juice_SelectVeld(this);"/></div></div><div class="formRow"><div class="omschrijving">Breedte (in cm):</div><div class="verplicht">*</div><div class="inputVelden"><input type="text" class="text" style="width: 39px;" name="breedte_'+oldid+'" onfocus="Juice_SelectVeld(this);"/></div></div><div class="formRow"><div class="omschrijving">Hoogte (in cm):</div><div class="verplicht">*</div><div class="inputVelden"><input type="text" class="text" style="width: 39px;" name="hoogte_'+oldid+'" onfocus="Juice_SelectVeld(this);"/></div></div><div class="formRow"><div class="omschrijving">Bedieningskant:</div><div class="verplicht">*</div><div class="inputVelden"> <select name="bediening_'+oldid+'" id="bediening_'+oldid+'"><option selected value="">Maak uw keuze</option><option value="Links">Links</option><option value="Midden">Midden</option><option value="Rechts">Rechts</option></select>  </div></div><div class="formRow"><div class="omschrijving">Plaatsing:</div><div class="verplicht">*</div><div class="inputVelden"> <select name="Plaatsing_'+oldid+'" id="Plaatsing_'+oldid+'"><option selected value="">Maak uw keuze</option><option value="Wandplaatsing">Wandplaatsing</option><option value="Plafondplaatsing">Plafondplaatsing</option></select>  </div></div>'
    	    tekst = tekst + '<div class="ie6fx"></div></div><div name="offerteveld_' + newid + '" id="offerteveld_' + newid + '"></div>';
        document.getElementById("offerteveld_"+oldid).innerHTML = tekst;	
	   }
	   
	   checkFlexButtons();
}

function RemoveExtraProduct() {
    document.getElementById("offerteveld_"+huidigeaantal).innerHTML = '';
    huidigeaantal = huidigeaantal - 1;
    checkFlexButtons();
}

function checkFlexButtons()
{
if (document.getElementById('HideExtra')){if (huidigeaantal >= 2){document.getElementById('HideExtra').style.display='block';}else{document.getElementById('HideExtra').style.display='none';}}
}

// Hide alle standaard
function hideDefaultHidden(){    
    $(".hideMe").each(function(i){
        $(this).hide();
    });
    changeArrowsLeftMenu();
}
function changeArrowsLeftMenu(){
    if($("#luxaProdMenu").is(":hidden")){
        $("#luxaProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowLeft.gif)"});
    }
    
    if($("#huisProdMenu").is(":hidden")){
        $("#huisProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowLeft.gif)"});
    }
    
    $("#luxaProdMenuTitle").bind("click",function() {
        if($("#luxaProdMenu").is(":hidden")){
            $("#luxaProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowDown.gif)"});        
        }else{
            $("#luxaProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowLeft.gif)"});
        }
        $("#luxaProdMenu").slideToggle("normal");
    });
    
    $("#huisProdMenuTitle").bind("click",function() {
        if($("#huisProdMenu").is(":hidden")){
            $("#huisProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowDown.gif)"});        
        }else{
            $("#huisProdMenuTitle").css({"background-image" : "url(/img/content/menuArrowLeft.gif)"});
        }
        $("#huisProdMenu").slideToggle("normal");
    });
}

function displayBetaal(value)
{
    for (var i=1; i<=5; i++)
        {
                document.getElementById("betaal_"+i).style.display = 'none';
        }
    document.getElementById("betaal_"+value).style.display = 'block';
}

function hideBetaal()
{
    for (var i=1; i<=5; i++)
        {
            document.getElementById("betaal_"+i).style.display = 'none';
        }
}

function toggleAfhaal()
{
if (document.getElementById('Afhaal').checked)
{
    document.getElementById('AfhaalBlok').style.display = 'block' 
    document.getElementById('Anderblok').style.display = 'none' 
    
    document.getElementById('VerzendAdresBlok').style.display = 'none' 
    document.getElementById('VerzendAdresBlok').style.display = 'none'
    
    document.getElementById('VisF').checked = false;
    document.getElementById('AfhaalSelected').value = 'true';
    
    if (document.getElementById('cash')) {document.getElementById('cash').disabled = false;}
    if (document.getElementById('rembours')) {document.getElementById('rembours').disabled = true;}
    
}
else
{
    if (document.getElementById('cash')) {document.getElementById('cash').disabled = true;}
    if (document.getElementById('rembours')) {document.getElementById('rembours').disabled = false;}
    document.getElementById('AfhaalBlok').style.display = 'none';
    document.getElementById('Anderblok').style.display = '' 
    document.getElementById('VerzendAdresBlok').style.display = '' 
    document.getElementById('AfhaalSelected').value = '';
}
}



function showHomePageText(div)
{
    $("#" + div).slideDown("normal");
}

function hideHomePageText(div)
{
    $("#" + div).stop('',true);
    $("#" + div).hide();
}


var KeyRun;

function checkBreedte(field)
{
    var re = /^[0-9\.,]*$/;
    if (!re.test(field.value)) 
        {
            field.value = field.value.replace(/[^0-9\.,]/g,"");
        }
    clearTimeout(KeyRun)
    KeyRun = setTimeout("GoCheckDimensions();",200);
}

function checkHoogte(field)
{
    var re = /^[0-9\.,]*$/;
    if (!re.test(field.value)) 
        {
            field.value = field.value.replace(/[^0-9\.,]/g,"");
        }
    clearTimeout(KeyRun)
    KeyRun = setTimeout("GoCheckDimensions();",200);
}

function redirectSearch(parent,model,product)
{
    var step = 0
    document.body.style.cursor = "wait";
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    var actiontarget;
    
    if (document.getElementById('_' + parent + '_CatID'))
    {
        actiontarget = '/P' + document.getElementById('_' + parent + '_CatID').value + '/Artikelen/'+document.getElementById('_' + parent + '_CatName').value + '/stap2.aspx';
        if (document.getElementById('_' + parent + '_' + model + '_ModelID'))
        {   
            step+=1
            document.getElementById('ModelText').value = document.getElementById('_' + parent + '_' + model + '_ModelName').value
            document.getElementById('Modelid').value = document.getElementById('_' + parent + '_' + model + '_ModelID').value
            document.getElementById('ModelDualColor').value = document.getElementById('_' + model + '_ModelDualColor').value
            if (product != '')
            {
                if (document.getElementById('_' + product + '_ProductID').value)
                {
                    step+=1;
                    if (document.getElementById('_' + parent + '_' + model + '_StofID'))
                    {
                        step+=1;
                        document.getElementById('Stofid').value = document.getElementById('_' + parent + '_' + model + '_StofID').value        
                        document.getElementById('StofText').value = document.getElementById('_' + parent + '_' + model + '_StofName').value
                    }
                    document.getElementById('KleurID').value = document.getElementById('_' + product + '_ProductID').value;        
                    document.getElementById('KleurText').value = document.getElementById('_' + product + '_ProductName').value;
                    document.getElementById('LevertijdID').value= document.getElementById('_' + product + '_ProductLevertijd').value ;
                    document.getElementById('LevertijdText').value= GetLevertijd(document.getElementById('_' + product + '_ProductLevertijd').value);    
                    document.getElementById('NextStep').value= 2;
                }
            }
        }
        document.getElementById('NextStep').value= step;
        theForm.action = actiontarget;
       theForm.submit();      
    }
    document.body.style.cursor = "default";
}

function GetLevertijd(levertijd)
{
    switch(levertijd)
    {
    case "0":
      output = "+/- 1 tot 2 werkweken"
      break;    
    case "1":
      output = "+/- 2 tot 3 werkweken"
      break;    
    case "2":
      output = "+/- 2 tot 4 werkweken"
      break;
    case "3":
      output = "+/- 3 tot 4 werkweken"
      break;
    case "4":
      output = "+/- 3 tot 5 werkweken"
      break;
    case "5":
      output = "+/- 4 tot 6 werkweken"
      break;
    case "6":
      output = "+/- 5 tot 6 werkweken"
      break;
    case "7":
      output = "+/- 6 tot 8 werkweken"
      break;
    case "8":
      output = "+/- 8 tot 10 werkweken"
      break;
    case "9":
      output = "+/- 10 tot 12 werkweken"
      break;
    default:
      output = "Onbekend"
    }
return output
}

function initColor()
{
    var objName = ".KleurOption";
    $(objName)
        .mouseover
        (
            function(e)
            {
             
            }
        )
        .mouseout
        (
            function(e)
            {
                $(objName + "Box").hide();            
            }
        );
        
}

function jumpToProduct(parent,parentname,modeltext,modelid,kleurtext,kleurid,levertijdid,dual)
{
    if (document.getElementById('Nextstep'))
    {
        if (dual=='0')
        {
            document.getElementById('ModelText').value = modeltext
            document.getElementById('Modelid').value = modelid
            document.getElementById('KleurText').value = kleurtext
            document.getElementById('KleurID').value = kleurid
            document.getElementById('LevertijdID').value = levertijdid
            document.getElementById('LevertijdText').value = GetLevertijd(levertijdid)
        }
        else
        {
            document.getElementById('Nextstep').value =1;
            document.getElementById('ModelText').value = modeltext;
            document.getElementById('Modelid').value = modelid;
            document.getElementById('KleurText').value = '';
            document.getElementById('KleurID').value = '';
            document.getElementById('LevertijdID').value = '';
            document.getElementById('LevertijdText').value = '';
            document.getElementById('ModelDualColor').value = dual;
        }
        actiontarget = '/P' + parent + '/Artikelen/' + parentname + '/stap2.aspx';
        theForm.action = actiontarget;
        theForm.submit();      
    }
}

function OpenHeader(color,resend,currentStep)
{
    if ($("#" + color).hasClass("itemHeaderUitgeklapt") == false )
    {
        $(".ShowItemText").slideUp("normal");
        $(".itemHeader").removeClass("itemHeaderUitgeklapt");
        $("#" + color).addClass("itemHeaderUitgeklapt");
        $("#ChosenColorGroup").val(color);
        $("#ajaxAction").val('ColorChoise');        
        $("#subOf_" + color).slideDown("normal");
        if (resend)
        { 
            $("#Nextstep").val(currentStep);
            $("body").css({cursor : 'progress'});
            __doPostBack('ctl00$ContentPlaceHolder1$LinkButtonTriggerAjax','')
        };
    }
}
$(function(){
    // Stap 2 kleuren
    $(".itemHeader").eq(0).trigger("click");
});
function init()
{
    $("body").css({cursor : 'default'});
}

function SendToForm(val)
{
    var link = '/F/' + val + '.aspx' ;
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    theForm.action = link;
    theForm.submit();
}
/*
    Topnav
*/
$(function(){
    initiateTopNav();
});
var timeOut;

function initiateTopNav()
{
    $(".nTopMenuSub").hide()
                    .mouseleave(function(){timeOut = setTimeout('hideTopMenuSub()', 1000);})	
                    .mouseenter(function(){clearTimeout(timeOut);});	
    $(".nTopMenu").click(showTopMenuSub);
    $(".nTopMenu").mouseleave(function(){timeOut = setTimeout('hideTopMenuSub()', 1000);});
}
function showTopMenuSub()
{
    if($(".nTopMenuSub").is(":visible"))
    {
        $(".nTopMenuSub").hide();
        hideTopMenuSub();
        return false;
    }
	$(".nTopMenuSub").show();
}

function hideTopMenuSub()
{
	$('.nTopMenuSub').hide();
    clearTimeout(timeOut);
}

var initImage;

function initMouseOverIcon()
{
    $(".DisplayOtherImage").mouseenter(function () {
        if ($(this).find(".displayID").html() != -1)
        {   initImage = $(".imgBlockOver").find("img").attr("src");
            var newImage = "/picture.aspx?fototype=Productfoto&formaatnaam=normaal&catid=" + $(this).find(".displayID").html()
            $(".imgBlockOver").find("img").attr("src", newImage);
            $("#ImageLink2").hide();
        }
    });
    
    $(".DisplayOtherImage").mouseleave(function () {
            $(".imgBlockOver").find("img").attr("src", initImage );
            $("#ImageLink2").show();
    });
}