﻿var currentopenpop = '';

var totaldrops = 0;	
if (document.attachEvent){
	document.attachEvent("onclick", function () { 									
											  HideOnClick(); 
											  }
											   );
}else{
	document.addEventListener("click", function () { 
												 HideOnClick(); 
												 }
												 , false);
}	



function showLayer(whichdiv){
	if (document.getElementById(whichdiv.id+"Hover").style.display == ''){
		document.getElementById(whichdiv.id+"Hover").style.display = 'none';
	}else {
		document.getElementById(whichdiv.id+"Hover").style.display = '';
	}
	
}

function HideOnClick() {
	for (i=1;i<=totaldrops;i++){
	    if (document.getElementById("drop"+ i +"_down"))
		    document.getElementById("drop"+ i +"_down").style.display = 'none';
	}
}	

function Juice_SelectVeld(veld) {
    veld.style.backgroundColor='#dddddd';
}

function GoSearch(zoekstr) {
     /* 
      Alles eruit filteren behalve:
        - 0-9 (0-9)
        - a-z (a-z)
        - A-Z (A-Z)
        - Koppelstreepje (-)
        - Spaties (\s)
      Extra uitleg
        - begin met / Start regex
        - Eind met / Eind regex
        - Achter de laatste / nog een letter dus g staat voor global. Dus over hele string uitvoeren
      */
  zoekstr = zoekstr.replace(/[^0-9a-z''A-Z-\s]/g,"");
   /* 
      Kijken of er niet alleen een spatie over blijft      
   */
  if(zoekstr.replace(/[\s]/g,"")==''){
    alert("U dient minimaal 1 zoekwoord in te vullen.");
  }else{
  
    if (zoekstr=='Zoeken naar') zoekstr='alles';
    if (zoekstr=='') zoekstr='alles';
    if (zoekstr != 'alles')
    {
        location.href = '/zoeken/' + zoekstr + '.aspx';
       }
  }
}

function checkInput(input, was, wordt){
	if(input.value==was){
		input.value=wordt;
	}
}

function kiesWaarde(string1,string2){
	setTimeout("vulWaarde('" + string1 + "','" + string2 + "')",100); 
}
function vulWaarde(waarde,locatie){
	// controleren of andere vensters open staan
	for (i=1;i<=totaldrops;i++){
	    if (document.getElementById("drop"+ i +"_down")) {
		    if (document.getElementById("drop"+ i +"_down").style.display == '') {
			    // als aangeklikte venster niet het openstaande venster is
			    if(("drop"+i) != locatie){
				    document.getElementById("drop"+ i +"_down").style.display = 'none';
			    }
		    }
		}
	}
	// controleren of andere waarde is gekozen
	if (document.getElementById(locatie).innerHTML != document.getElementById(waarde).innerHTML){
		document.getElementById(locatie).innerHTML = document.getElementById(waarde).innerHTML;
		alert(locatie+"_down");
		document.getElementById(locatie+"_down").style.display = 'none';
	} else {
		if (waarde == locatie){
			if (document.getElementById(locatie+"_down").style.display == ''){
				document.getElementById(locatie+"_down").style.display = 'none';
			} else {
				document.getElementById(locatie+"_down").style.display = '';
			}
		}
	}	
}

function wisselFoto(value)
{
    document.getElementById('ProdDetail').src = value;
}

function aantallenAanpassen(aantalveld){
    if (aantalveld.value!='') {
        document.body.style.cursor = "wait";
		MM_findObj('mode').value='aantallenaangepast';
		MM_findObj('ProdAanpas').value=aantalveld.id;
		url = document.location;
		document.aspnetForm.action = url;
		setTimeout("submitform();",500);	     
	}
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function checkForm(value)
{
    switch (value)
    {	
        case "Luxaflex-offerte":
            var val = "";
            for(i=1;i<=huidigeaantal;i++){
                val += ",'TypeFlex_"+i+"','','R'" ;
                val += ",'breedte_"+i+"','','R'" ;
                val += ",'hoogte_"+i+"','','R'" ;
                val += ",'bediening_"+i+"','','R'" ;
                val += ",'Plaatsing_"+i+"','','R'" ;
            }
            
            
            eval("MM_validateForm('Voorletters','','R','Achternaam','','R','Straatnaam','','R','huisnummer','','R','postcode','','R','woonplaats','','R','E-Mail','','RisEmail','Telefoonnummer','','R'" + val +");");
            
             break;
        case "Gastenboek":
            MM_validateForm(   'Naam','','R',  
                               'E-Mail','','RisEmail');
        break;
        case "KleurStaal":
            MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'E-Mail','','RisEmail',
                               'Telefoonnummer','','R',
                               'Mobiel','','R',
                               'Straat','','R',
                               'Huisnummer','','R',
                               'Postcode','','R',
                               'Woonplaats','','R');
            break;
        case "Bestel-formulier":
            if (document.getElementById('VisF').checked)
            {
            MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'E-Mail','','RisEmail',
                               'Telefoonnummer','','R',
                               'facStraatnaam','','R',
                               'fachuisnummer','','R',
                               'facpostcode','','R',
                               'facwoonplaats','','R',
                               'facland','','R',
                               'betalingsmethode','','RisRadio',  
                               'AfleverKeuze','','R',
                               'leveringsvoorwaarden','','RisCheckbox');
            }
            else
            {
                if (document.getElementById('Afhaal'))
                {
                    if (document.getElementById('Afhaal').checked)
                {
                    MM_validateForm(   'Voorletters','','R',  
                                       'Achternaam','','R',
                                       'E-Mail','','RisEmail',
                                       'Telefoonnummer','','R',
                                       'facStraatnaam','','R',
                                       'fachuisnummer','','R',
                                       'facpostcode','','R',
                                       'facwoonplaats','','R',
                                       'facland','','R',
                                       'betalingsmethode','','RisRadio',  
                                       'AfleverKeuze','','R',
                                       'leveringsvoorwaarden','','RisCheckbox');
                }
                else
                {
                    MM_validateForm(   'Voorletters','','R',  
                                       'Achternaam','','R',
                                       'E-Mail','','RisEmail',
                                       'Telefoonnummer','','R',
                                       'facStraatnaam','','R',
                                       'fachuisnummer','','R',
                                       'facpostcode','','R',
                                       'facwoonplaats','','R',
                                       'facland','','R',
                                       'verzendStraatnaam','','R',
                                       'verzendHuisnummer','','R',
                                       'verzendPostcode','','R',
                                       'verzendWoonplaats','','R',
                                       'verzendLand','','R',
                                       'betalingsmethode','','RisRadio',  
                                       'AfleverKeuze','','R',
                                       'leveringsvoorwaarden','','RisCheckbox');
                    }
                }
                else
                {
                    MM_validateForm(   'Voorletters','','R',  
                                       'Achternaam','','R',
                                       'E-Mail','','RisEmail',
                                       'Telefoonnummer','','R',
                                       'facStraatnaam','','R',
                                       'fachuisnummer','','R',
                                       'facpostcode','','R',
                                       'facwoonplaats','','R',
                                       'facland','','R',
                                       'verzendStraatnaam','','R',
                                       'verzendHuisnummer','','R',
                                       'verzendPostcode','','R',
                                       'verzendWoonplaats','','R',
                                       'verzendLand','','R',
                                       'betalingsmethode','','RisRadio',  
                                       'AfleverKeuze','','R',
                                       'leveringsvoorwaarden','','RisCheckbox');
                }
                
            }
            break;
        case "InterneOfferteFormulier":
            if (document.getElementById('VisF').checked)
            {
            MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'E-Mail','','RisEmail',
                               'Telefoonnummer','','R',
                               'facStraatnaam','','R',
                               'fachuisnummer','','R',
                               'facpostcode','','R',
                               'facwoonplaats','','R',
                               'facland','','R');
            }
            else
            {
            if (document.getElementById('Afhaal').checked)
            {
                MM_validateForm(   'Voorletters','','R',  
                                   'Achternaam','','R',
                                   'E-Mail','','RisEmail',
                                   'Telefoonnummer','','R',
                                   'facStraatnaam','','R',
                                   'fachuisnummer','','R',
                                   'facpostcode','','R',
                                   'facwoonplaats','','R',
                                   'facland','','R');
            }
            else
            {
                MM_validateForm(   'Voorletters','','R',  
                                   'Achternaam','','R',
                                   'E-Mail','','RisEmail',
                                   'Telefoonnummer','','R',
                                   'facStraatnaam','','R',
                                   'fachuisnummer','','R',
                                   'facpostcode','','R',
                                   'facwoonplaats','','R',
                                   'facland','','R',
                                   'verzendStraatnaam','','R',
                                   'verzendHuisnummer','','R',
                                   'verzendPostcode','','R',
                                   'verzendWoonplaats','','R',
                                   'verzendLand','','R');
                }
            }
            break;
        case "Kleurstaal-aanvragen":
             MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'Straat','','R',
                               'Huisnummer','','R',
                               'Postcode','','R',
                               'Woonplaats','','R',
                               'E-Mail','','RisEmail');
        break;
        case "Contact-formulier":
            MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'Straat','','R',
                               'Huisnummer','','R',
                               'Postcode','','R',
                               'Woonplaats','','R',
                               'E-Mail','','RisEmail',
                               'Telefoonnummer','','R');
            break;
        case "Service-formulier":
            MM_validateForm(   'Voorletters','','R',  
                               'Achternaam','','R',
                               'Straat','','R',
                               'Huisnummer','','R',
                               'Postcode','','R',
                               'Woonplaats','','R',
                               'E-Mail','','RisEmail',
                               'Telefoonnummer','','R',
                               'Mobiel','','R',
                               'ordernummer','','R',
                               'Adviseur','','R',
                               'datum','','R',
                               'art_nr','','R',
                               'art_omschrijving','','R',
                               'art_merk','','R');
            break;
            case "Nieuwsbrief":
            MM_validateForm(    'Voornaam','','R',
                                'Achternaam','','R',
                                'E-Mail','','RisEmail');
            break;
            case "none":
                document.MM_returnValue = true
                break;
        default:
            document.MM_returnValue = false 
    }

    if (document.MM_returnValue)
        submitform();
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height,menubar)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,scrollbar=no,resizable=no,copyhistory=yes,' + menubar +', width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function simpleToggle(thediv){
	element= document.getElementById(thediv);
	if (element.style.display != 'none'){
		element.style.display = 'none';
	} else {
		element.style.display = '';
	}
}


function OpenWinkelPopup(width, height, value, outerpopup)
{
    currentopenpop = value;
    document.getElementById('PopupDiv').style.display = 'block';
    document.getElementById('RealPop').style.height = height + 'px';
    document.getElementById('RealPop').style.width = width + 'px';
    document.getElementById('RealPop').style.marginLeft = '-' + (width / 2) + 'px';
    document.getElementById('RealPop').style.marginTop = '-' + (height / 2) + 'px';
    document.getElementById(value).style.display = 'block';
    
    PlacePop();
}

function CloseWinkelPopup()
{
    document.getElementById('PopupDiv').style.display = 'none';
    document.getElementById(currentopenpop).style.display = 'none';
    document.getElementById('TheMovieBox').innerHTML = '';
}

//function AddProductToWinkelmandjeAJAX(productid) {
//    $("#ajaxAction").val('AddProd');
//    MM_findObj('addajaxproduct').value = productid;
//    __doPostBack('ctl00$ContentPlaceHolder1$LinkButtonTriggerAjax', '');
//}


function PlacePop()
{
    if (currentopenpop != 'MovieBlock' && currentopenpop !='Eigenschappen' && currentopenpop !='ImageBlock')
    {
        var Height;
        Height = 45 + 20 + parseInt(document.getElementById('ShoppingBody').scrollHeight)
        document.getElementById('RealPop').style.marginTop = '-' + parseInt(Height/2) + 'px';
        document.getElementById('RealPop').style.height = Height + 'px';
    }
}

function KoppelMe(tekst)
{
    AddKoppelProduct(tekst);
    PlacePop();   
}



function AddKoppelProduct(tekst) {
    
    document.getElementById('ulAjax').innerHTML = document.getElementById('ulAjax').innerHTML + '<li>' + tekst + '</li>';
    
}

function NieuwsBriefFromHome() {
   location.href = '/Formulieren.aspx?form=Nieuwsbrief&email=' + MM_findObj("email").value;
}

function CreateBookmarkLink() {

 title = "Raamdecoratietotaalmarkt"; 
 url = "http://www.Raamdecoratietotaalmarkt.nl";
  
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
 
// PopUp Window voor Luxaflex-producten
function popupw(page,extra) {
	
  var url;

  url = page + "?crt=" + extra.replace(/&/g,"%26"); 
	
  window.open(url, 'Popup', 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizeable=0,fullscreen=0,width=600,height=600');
}

 
// Tijdelijk PopUp Window voor oude videopagina
function PopUpFilm(url, wi, he, winm) {
	if (winm == 0) {
		window.open(url, '', 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=no,width=' + wi + ',height=' + he);
	} else {
		window.open(url, '', 'toolbar=1,location=1,directories=1,menubar=1,scrollbars=1,resizable=yes,width=' + (wi + 16) + ',height=' + he);
	}
}