function getRooster(form, id, val) {
var formData = new FormData(form);
r_xmlhttp=new XMLHttpRequest();
r_xmlhttp.onreadystatechange=function()
{
if (r_xmlhttp.readyState==4 && r_xmlhttp.status==200)
{
$('#main_content').animate({opacity: "0"}, 300, function(){
document.getElementById("main_content").innerHTML=r_xmlhttp.responseText;
$('#main_content').animate({opacity: "1", top: "0px"}, 400);
$('#main_content').fadeIn('fast');
});
}
}
history.pushState("", document.title, window.location.pathname + '?page=' + id + "/" + val);
$('#main_content').animate({opacity: "0", top: "15px"}, 400, function(){
$('#main_content').html('
');
$('#main_content').animate({opacity: "1"}, 300);
});
setTimeout(function(){
if(id=='account'){
r_xmlhttp.open("POST","php/getAccount.php",true);
}
else if(id=='log'){
r_xmlhttp.open("POST","php/getLog.php",true);
}
else if(id=='bericht'){
r_xmlhttp.open("POST","php/getBericht.php",true);
}
else if(id=='verzondenbericht'){
r_xmlhttp.open("POST","php/getVerBericht.php",true);
}
else{
r_xmlhttp.open("POST","php/getRooster.php",true);
}
r_xmlhttp.send(formData);
}, 700);
}
function clearSelect(id){
document.getElementById(id).value = [' '];
}
var lastPage = '';
var button = '';
function changePage(page, fade){
if(typeof(fade)==='undefined') fade = true;
if(lastPage==page){return true;}
else{
p_xmlhttp=new XMLHttpRequest();
p_xmlhttp.onreadystatechange=function()
{
if (p_xmlhttp.readyState==4 && p_xmlhttp.status==200 && p_xmlhttp.responseText != false)
{
var lastPage = page;
$('#main_top').slideDown('fast', function(){
if(fade){$('#main_content').fadeIn('fast'); }
$('#main_top_content').fadeIn('fast');
});
document.getElementById("main_top_content").innerHTML=p_xmlhttp.responseText;
}
}
button = '#' + page + '_knop';
$('a.button_top, a.button_top_first').removeClass('current');
$(button).addClass('current');
history.pushState("", document.title, window.location.pathname + '?page=' + page);
if(fade){$('#main_content').fadeOut('fast'); }
$('#main_top_content').fadeOut('fast',function(){
$('#main_top').slideUp('fast');
document.getElementById("main_content").innerHTML="";
});
setTimeout(function(){
p_xmlhttp.open("POST","pages/" + page + "_header.php",true);
p_xmlhttp.send(null);
}, 400);
}
}
function setPageValue(variable){
var array = variable.split('/');
var page = array[0];
var value = array[1];
changePage(page, false);
if(variable.indexOf('/') >= 0){
form = document.createElement('form');
input = document.createElement('input');
input.setAttribute('name', page);
input.setAttribute('type', 'text');
input.setAttribute('value', value);
form.appendChild(input);
getRooster(form, page, value);
setTimeout(function(){
$("#" + page).val([value]);
}, 1500);
}
}
function updateMail(name){
var form = document.getElementById('mailform');
var formData = new FormData(form);
um_xmlhttp=new XMLHttpRequest();
um_xmlhttp.onreadystatechange=function()
{
if (um_xmlhttp.readyState==4 && um_xmlhttp.status==200)
{
document.getElementById("mailcontainer").innerHTML=um_xmlhttp.responseText;
setTimeout(function(){
$('#mailcontainer').fadeIn('fast');
}, 200);
}
}
$('#mailcontainer').fadeOut('fast', function(){
um_xmlhttp.open("POST","php/updateMail.php",true);
um_xmlhttp.send(formData);
});
}
function confirmMail(){
var form = document.getElementById('confirmmailform');
var formData = new FormData(form);
cm_xmlhttp=new XMLHttpRequest();
cm_xmlhttp.onreadystatechange=function()
{
if (cm_xmlhttp.readyState==4 && cm_xmlhttp.status==200)
{
var array = cm_xmlhttp.responseText.split('#');
var response = array[0];
var mail = array[1];
document.getElementById("mailcontainer").innerHTML=response;
document.getElementById("mailholder").innerHTML=mail;
setTimeout(function(){
$('#mailcontainer').fadeIn('fast');
}, 200);
}
}
$('#mailcontainer').fadeOut('fast', function(){
cm_xmlhttp.open("POST","php/confirmMail2.php",true);
cm_xmlhttp.send(formData);
});
}
function updatePass(){
var form = document.getElementById('passform');
var formData = new FormData(form);
up_xmlhttp=new XMLHttpRequest();
up_xmlhttp.onreadystatechange=function()
{
if (up_xmlhttp.readyState==4 && up_xmlhttp.status==200)
{
document.getElementById("passcontainer").innerHTML=up_xmlhttp.responseText;
$('#passcontainer').fadeIn('fast');
}
}
$('#passcontainer').fadeOut('fast', function(){
up_xmlhttp.open("POST","php/updatePass.php",true);
up_xmlhttp.send(formData);
});
}
function resetPass(name){
rp_xmlhttp=new XMLHttpRequest();
rp_xmlhttp.onreadystatechange=function()
{
if (rp_xmlhttp.readyState==4 && rp_xmlhttp.status==200)
{
document.getElementById("passcontainer").innerHTML=rp_xmlhttp.responseText;
$('#passcontainer').fadeIn('fast');
}
}
$('#passcontainer').fadeOut('fast', function(){
form = document.createElement('form');
input = document.createElement('input');
input.setAttribute('name', 'naam');
input.setAttribute('type', 'text');
input.setAttribute('value', name);
form.appendChild(input);
var formData = new FormData(form);
rp_xmlhttp.open("POST","php/setPass2.php",true);
rp_xmlhttp.send(formData);
});
}
$('input').bind('input propertychange', function() {
var form = document.getElementById('form');
var formData = new FormData(form);
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("sideresult").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","php/search.php",true);
xmlhttp.send(formData);
});
var i = true;
function toggle(){
if(i){
$('#sidebar').show();
$('#sidebar').animate({width: '400px'}, 200, function(){
$('#sidebarcontent').fadeIn('fast');
});
$('#sidebarToggle').animate({left: '343px'}, 200);
i = false;
}
else{
$('#sidebarcontent').fadeOut('fast', function(){
$('#sidebar').animate({width: '0px'}, 200, function(){
$('#sidebar').hide();
});
$('#sidebarToggle').animate({left: '-57px'}, 200);
});
i=true
}
}
$(document).ready(function() {
$('#input').keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});
function sendMail() {
var form = document.getElementById('berichtform')
var formData = new FormData(form);
sm_xmlhttp=new XMLHttpRequest();
sm_xmlhttp.onreadystatechange=function()
{
if (sm_xmlhttp.readyState==4 && sm_xmlhttp.status==200)
{
$('#main_content').animate({opacity: "0"}, 300, function(){
document.getElementById("main_content").innerHTML=sm_xmlhttp.responseText;
$('#main_content').animate({opacity: "1", top: "0px"}, 400);
$('#main_content').fadeIn('fast');
});
}
}
$('#main_content').animate({opacity: "0", top: "15px"}, 400, function(){
$('#main_content').html('
');
$('#main_content').animate({opacity: "1"}, 300);
});
setTimeout(function(){
sm_xmlhttp.open("POST","php/sendMail.php",true);
sm_xmlhttp.send(formData);
}, 700);
}