function change_regio() {
  var regio_selected = document.getElementById('regioselect').value;
  if(regio_selected == 0) {
    document.location.href = '/homepage.html';
  } else if(regio_selected == 1) {
    document.location.href = '/RML/homepage.html';
  } else if (regio_selected == 2) {
    document.location.href = '/NV/homepage.html';
  } else if (regio_selected == 3) {
    document.location.href = '/PL/homepage.html';
  }
  return false;
}

function change_foto(foto_id, foto) {
  document.getElementById('foto_' + foto_id).src = '/NL/images_items/' + foto;
}

var almostLoggedOutWarning = function() {
  SqueezeBox.open('/bijnauitgelogd.html',{
    "size": {
      x: 380, 
      y: 180
    },
    "closable": false,
    "closeBtn": false,
		"ajaxOptions": {
      "onComplete": almostLoggedOutWarningBoxOpen
    }
  });
};
var almostLoggedOutWarningTimer;
var loggedOutWarning = function() {
  SqueezeBox.open('/uitgelogd.html',{
    "size": {
      x: 380, 
      y: 180
    },
    "closable": false,
    "closeBtn": false,
		"ajaxOptions": {
			"onComplete": loggedOutWarningBoxOpen
		}
  });
};
var loggedOutWarningTimer;
function startTimedWarnings()
{
  almostLoggedOutWarningTimer = almostLoggedOutWarning.delay((timeloginsessionexpires-timebeforewarningalmostloggedout)*1000);
  loggedOutWarningTimer = loggedOutWarning.delay(timeloginsessionexpires*1000);
}
function keepLoggedIn() {
  if (!isloggedin) {
    return;
  }
	pingAlive(); // request dummy html page to be sure the session is refreshed, sometimes user action doesn't result in php reload
  almostLoggedOutWarningTimer = $clear(almostLoggedOutWarningTimer);
  loggedOutWarningTimer = $clear(loggedOutWarningTimer);
  startTimedWarnings();
}
function pingAlive()
{
  var req = new Request({
    method: 'get',
    url: '/ping.html',
    data: { 't' : $time() }
  }).send();
}
function almostLoggedOutWarningBoxOpen()
{
	if (!$('almostloggedoutspan')) {
		// html not yet loaded, try again sometime
		almostLoggedOutWarningBoxOpen.delay(100);
		return;
	}
  $('bijfingelogdknop').addEvent('click', function(e) {
    keepLoggedIn();
    pingAlive();
	  SqueezeBox.close();
  });
  $('uitloggenknop').addEvent('click', function(e) {
    loggedOutWarningTimer = $clear(loggedOutWarningTimer);
		loggedOutWarning();
  });
  $('sbox-btn-close').setStyle("display","none");
	var myspeed = (timebeforewarningalmostloggedout)*1000;
  pb = new dwProgressBar({
    container: $('put-bar-here'),
    startPercentage: 100,
    speed: myspeed,
    boxID: 'box',
    percentageID: 'perc',
    step:10,
    allowMore: 1
  });
}
function loggedOutWarningBoxOpen()
{
  if (!$('loggedoutwarningspan')) {
    // html not yet loaded, try again sometime
    loggedOutWarningBoxOpen.delay(100);
    return;
  }
  $('uitgelogdverderknop').addEvent('click', function(e) {
    document.location = requesturi;
  });
  $('inloggenknop').addEvent('click', function(e) {
    document.location = '/login.html';
  });
  $('sbox-btn-close').setStyle("display","none");
}
function makeCloseButVisible() {
  $('sbox-btn-close').setStyle("display","inline");
}

function debugPopup(text) {
  var debugWindow = window.open("/empty.html","error","width=300,height=300,scrollbars=1,resizable=1");
  var html = "<html><head></head><body>"+ text +"</body></html>";
  debugWindow.document.open();
  debugWindow.document.write(html);
  debugWindow.document.close();
}

/* top menu onmouse overs */
window.addEvent('domready', function() {
  $('topmenuhomebutton').addEvent('mouseover', function(element) {
    $('topmenuhomebutton').setAttribute('src','/NL/images/top_menu_knop_home_hover.gif');
  });
  $('topmenuhomebutton').addEvent('mouseout', function(element) {
    $('topmenuhomebutton').setAttribute('src','/NL/images/top_menu_knop_home.gif');
  });
  $('topmenucontactbutton').addEvent('mouseover', function(element) {
    $('topmenucontactbutton').setAttribute('src','/NL/images/top_menu_knop_contact_hover.gif');
  });
  $('topmenucontactbutton').addEvent('mouseout', function(element) {
    $('topmenucontactbutton').setAttribute('src','/NL/images/top_menu_knop_contact.gif');
  });
  if ($('topmenuinloggenbutton')) {
    $('topmenuinloggenbutton').addEvent('mouseover', function(element) {
      $('topmenuinloggenbutton').setAttribute('src','/NL/images/top_menu_knop_inloggen_hover.gif');
    });
    $('topmenuinloggenbutton').addEvent('mouseout', function(element) {
      $('topmenuinloggenbutton').setAttribute('src','/NL/images/top_menu_knop_inloggen.gif');
    });
  }
  if ($('topmenuuitloggenbutton')) {
    $('topmenuuitloggenbutton').addEvent('mouseover', function(element) {
      $('topmenuuitloggenbutton').setAttribute('src','/NL/images/top_menu_knop_uitloggen_hover.gif');
    });
    $('topmenuuitloggenbutton').addEvent('mouseout', function(element) {
      $('topmenuuitloggenbutton').setAttribute('src','/NL/images/top_menu_knop_uitloggen.gif');
    });
  }

  $('topmenutehuurbutton').addEvent('mouseover', function(element) {
    $('topmenutehuurbutton').setAttribute('src','/NL/images/top_menu_knop_tehuur_hover.gif');
  });
  $('topmenutehuurbutton').addEvent('mouseout', function(element) {
    $('topmenutehuurbutton').setAttribute('src','/NL/images/top_menu_knop_tehuur.gif');
  });

  $('topmenutekoopbutton').addEvent('mouseover', function(element) {
    $('topmenutekoopbutton').setAttribute('src','/NL/images/top_menu_knop_tekoop_hover.gif');
  });
  $('topmenutekoopbutton').addEvent('mouseout', function(element) {
    $('topmenutekoopbutton').setAttribute('src','/NL/images/top_menu_knop_tekoop.gif');
  });

  if ($('topmenureparatieverzoekbutton')) {
    $('topmenureparatieverzoekbutton').addEvent('mouseover', function(element) {
      $('topmenureparatieverzoekbutton').setAttribute('src','/NL/images/top_menu_knop_reparatieverzoek_hover.gif');
    });
    $('topmenureparatieverzoekbutton').addEvent('mouseout', function(element) {
      $('topmenureparatieverzoekbutton').setAttribute('src','/NL/images/top_menu_knop_reparatieverzoek.gif');
    });
  }

  if ($('topmenumijnwonenzuidbutton')) {
    $('topmenumijnwonenzuidbutton').addEvent('mouseover', function(element) {
      $('topmenumijnwonenzuidbutton').setAttribute('src','/NL/images/top_menu_knop_mijnwonenzuid_hover.gif');
    });
    $('topmenumijnwonenzuidbutton').addEvent('mouseout', function(element) {
      $('topmenumijnwonenzuidbutton').setAttribute('src','/NL/images/top_menu_knop_mijnwonenzuid.gif');
    });
  }

  if ($('submenumijnwonenzuidreparatieverzoekbutton')) {
    $('submenumijnwonenzuidreparatieverzoekbutton').addEvent('mouseover', function(element) {
      $('submenumijnwonenzuidreparatieverzoekbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_reparatieverzoek_hover.gif');
    });
    $('submenumijnwonenzuidreparatieverzoekbutton').addEvent('mouseout', function(element) {
      $('submenumijnwonenzuidreparatieverzoekbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_reparatieverzoek.gif');
    });
  }
  if ($('submenumijnwonenzuidinschrijvenbutton')) {
    $('submenumijnwonenzuidinschrijvenbutton').addEvent('mouseover', function(element) {
      $('submenumijnwonenzuidinschrijvenbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_inschrijven_hover.gif');
    });
    $('submenumijnwonenzuidinschrijvenbutton').addEvent('mouseout', function(element) {
      $('submenumijnwonenzuidinschrijvenbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_inschrijven.gif');
    });
  }
  if ($('submenumijnwonenzuidresultatentabelbutton')) {
    $('submenumijnwonenzuidresultatentabelbutton').addEvent('mouseover', function(element) {
      $('submenumijnwonenzuidresultatentabelbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_resultatentabel_hover.gif');
    });
    $('submenumijnwonenzuidresultatentabelbutton').addEvent('mouseout', function(element) {
      $('submenumijnwonenzuidresultatentabelbutton').setAttribute('src','/NL/images/sub_menu_mijnwonenzuid_resultatentabel.gif');
    });
  }
  
  if ($('submenurmlbutton1')) {
    $('submenurmlbutton1').addEvent('mouseover', function(element) {
      $('submenurmlbutton1').setAttribute('src','/NL/images/sub_menu_rml_hover.gif');
    });
    $('submenurmlbutton1').addEvent('mouseout', function(element) {
      $('submenurmlbutton1').setAttribute('src','/NL/images/sub_menu_rml.gif');
    });
  }
  if ($('submenunvbutton1')) {
    $('submenunvbutton1').addEvent('mouseover', function(element) {
      $('submenunvbutton1').setAttribute('src','/NL/images/sub_menu_nv_hover.gif');
    });
    $('submenunvbutton1').addEvent('mouseout', function(element) {
      $('submenunvbutton1').setAttribute('src','/NL/images/sub_menu_nv.gif');
    });
  }
  if ($('submenuplbutton1')) {
    $('submenuplbutton1').addEvent('mouseover', function(element) {
      $('submenuplbutton1').setAttribute('src','/NL/images/sub_menu_pl_hover.gif');
    });
    $('submenuplbutton1').addEvent('mouseout', function(element) {
      $('submenuplbutton1').setAttribute('src','/NL/images/sub_menu_pl.gif');
    });
  }

  if ($('submenurmlbutton2')) {
    $('submenurmlbutton2').addEvent('mouseover', function(element) {
      $('submenurmlbutton2').setAttribute('src','/NL/images/sub_menu_rml_hover.gif');
    });
    $('submenurmlbutton2').addEvent('mouseout', function(element) {
      $('submenurmlbutton2').setAttribute('src','/NL/images/sub_menu_rml.gif');
    });
  }
  if ($('submenunvbutton2')) {
    $('submenunvbutton2').addEvent('mouseover', function(element) {
      $('submenunvbutton2').setAttribute('src','/NL/images/sub_menu_nv_hover.gif');
    });
    $('submenunvbutton2').addEvent('mouseout', function(element) {
      $('submenunvbutton2').setAttribute('src','/NL/images/sub_menu_nv.gif');
    });
  }
  if ($('submenuplbutton2')) {
    $('submenuplbutton2').addEvent('mouseover', function(element) {
      $('submenuplbutton2').setAttribute('src','/NL/images/sub_menu_pl_hover.gif');
    });
    $('submenuplbutton2').addEvent('mouseout', function(element) {
      $('submenuplbutton2').setAttribute('src','/NL/images/sub_menu_pl.gif');
    });
  }
  
  if ($('submenurmlbutton3')) {
    $('submenurmlbutton3').addEvent('mouseover', function(element) {
      $('submenurmlbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijrml_hover.gif');
    });
    $('submenurmlbutton3').addEvent('mouseout', function(element) {
      $('submenurmlbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijrml.gif');
    });
  }
  if ($('submenunvbutton3')) {
    $('submenunvbutton3').addEvent('mouseover', function(element) {
      $('submenunvbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijnv_hover.gif');
    });
    $('submenunvbutton3').addEvent('mouseout', function(element) {
      $('submenunvbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijnv.gif');
    });
  }
  if ($('submenuplbutton3')) {
    $('submenuplbutton3').addEvent('mouseover', function(element) {
      $('submenuplbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijpl_hover.gif');
    });
    $('submenuplbutton3').addEvent('mouseout', function(element) {
      $('submenuplbutton3').setAttribute('src','/NL/images/sub_menu_meldenbijpl.gif');
    });
  }

  if ($('submenubetaalbaarbutton')) {
    $('submenubetaalbaarbutton').addEvent('mouseover', function(element) {
      $('submenubetaalbaarbutton').setAttribute('src','/NL/images/sub_menu_betaalbaar_hover.gif');
    });
    $('submenubetaalbaarbutton').addEvent('mouseout', function(element) {
      $('submenubetaalbaarbutton').setAttribute('src','/NL/images/sub_menu_betaalbaar.gif');
    });
  }
  if ($('submenubijzonderbutton')) {
    $('submenubijzonderbutton').addEvent('mouseover', function(element) {
      $('submenubijzonderbutton').setAttribute('src','/NL/images/sub_menu_bijzonder_hover.gif');
    });
    $('submenubijzonderbutton').addEvent('mouseout', function(element) {
      $('submenubijzonderbutton').setAttribute('src','/NL/images/sub_menu_bijzonder.gif');
    });
  }
  if ($('submenu55plusbutton')) {
    $('submenu55plusbutton').addEvent('mouseover', function(element) {
      $('submenu55plusbutton').setAttribute('src','/NL/images/sub_menu_55plus_hover.gif');
    });
    $('submenu55plusbutton').addEvent('mouseout', function(element) {
      $('submenu55plusbutton').setAttribute('src','/NL/images/sub_menu_55plus.gif');
    });
  }

  if ($('submenubetaalbaarbutton2')) {
    $('submenubetaalbaarbutton2').addEvent('mouseover', function(element) {
      $('submenubetaalbaarbutton2').setAttribute('src','/NL/images/sub_menu_betaalbaar2_hover.gif');
    });
    $('submenubetaalbaarbutton2').addEvent('mouseout', function(element) {
      $('submenubetaalbaarbutton2').setAttribute('src','/NL/images/sub_menu_betaalbaar2.gif');
    });
  }
  if ($('submenubijzonderbutton2')) {
    $('submenubijzonderbutton2').addEvent('mouseover', function(element) {
      $('submenubijzonderbutton2').setAttribute('src','/NL/images/sub_menu_bijzonder2_hover.gif');
    });
    $('submenubijzonderbutton2').addEvent('mouseout', function(element) {
      $('submenubijzonderbutton2').setAttribute('src','/NL/images/sub_menu_bijzonder2.gif');
    });
  }
  if ($('submenu55plusbutton2')) {
    $('submenu55plusbutton2').addEvent('mouseover', function(element) {
      $('submenu55plusbutton2').setAttribute('src','/NL/images/sub_menu_55plus2_hover.gif');
    });
    $('submenu55plusbutton2').addEvent('mouseout', function(element) {
      $('submenu55plusbutton2').setAttribute('src','/NL/images/sub_menu_55plus2.gif');
    });
  }
});

