// JavaScript Document
//vars for xml_parser See http://www.openjs.com/scripts/xml_parser/
var not_whitespace = new RegExp(/[^\s]/);//This can be given inside the funciton - I made it a global variable to make the scipt a little bit faster.
var parent_count;

function getPage(page, divid){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        //var file = 'view_'; //This is the path to the file we just finished making *
    	xmlhttp.open('GET', page , true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
	    xmlhttp.onreadystatechange=function() {

		if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(divid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					}
        	}
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}


/******************************************
* Popup Box
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////

function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("mod_content") : document.all.mod_content
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

function hidebox(){
crossobj=ns6? document.getElementById("mod_content") : document.all.mod_content
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.mod_content.visibility="hide"
}

////drag drop functions end here//////

function getMenu(page, divid ){
	
	var page  = 'pages/'+ page + '.html' ;
    //var divid = 'content'; 
	getPage(page, divid) ;
	if (divid =='mod_content') {
		document.getElementById('mod_content').style.left = '40px';
		document.getElementById('mod_content').style.top  = '30px';
		document.getElementById('mod_content').style.display = '';
		}
	return;
}


function sendStoring() {
	var divid = 'mod_content';
	

	scriptAr = new Array();
	
	var n = document.frmStoring.elements.length - 1;
	//alert(n) ;
	for (i = 0; i <= n; i++)
	{
		 var subArray = new Array() ;
		 subArray[0] = document.frmStoring.elements[i].name ;
		 subArray[1] = document.frmStoring.elements[i].value ;
		 scriptAr[i] = subArray ;
	} 
	
	var arg = scriptAr.toString();

	var page  = 'pages/save_storing.php?arg='+arg ;
	var pid = getPage(page, divid) ;
	document.getElementById('mod_content').style.display = 'none';
}

function winClose() {
	document.getElementById('mod_content').style.display = 'none';
	}

function CheckForm( hmm )
{
	if( this.document.frmStoring.huisnr.value.length < 1 )
	{
		alert("U heeft geen huisnummer ingevuld");
		this.document.frmStoring.huisnr.focus();
		return false;
	}
	if( this.document.frmStoring.postcode.value.length < 1 )
	{
		alert("U heeft geen postcode ingevuld");
		this.document.frmStoring.postcode.focus();
		return false;
	}
	if( this.document.frmStoring.postcode.value.length > 0 && this.document.frmStoring.postcode.value.toString().match(/[0-9]{4}[a-zA-Z]{2}/) == null )
	{
		alert("De postcode is niet in de vorm 6789AB");
		this.document.frmStoring.postcode.focus();
		return false;
	}
	if( this.document.frmStoring.voornaam.value.length < 1 )
	{
		alert("U heeft uw voornaam of voorletters niet ingevuld");
		this.document.frmStoring.voornaam.focus();
		return false;
	}
	if( this.document.frmStoring.achternaam.value.length < 1 )
	{
		alert("U heeft uw achternaam niet ingevuld");
		this.document.frmStoring.achternaam.focus();
		return false;
	}
	if( this.document.frmStoring.telefoon.value.length > 0 && this.document.frmStoring.telefoon.value.toString().match(/[0-9-]{5,11}/) == null )
	{
		alert("Het telefoonnummer is niet in de vorm 0182-585585");
		this.document.frmStoring.telefoon.focus();
		return false;
	}
	if( this.document.frmStoring.mobiel.value.length > 0 && this.document.frmStoring.mobiel.value.toString().match(/[0-9-]{5,11}/) == null )
	{ 
		alert("Het telefoonnummer is niet in de vorm 0182-585585");
		this.document.frmStoring.mobiel.focus();
		return false;
	}
	if( this.document.frmStoring.email.value.length < 1 )
	{
		alert("U heeft geen e-mailadres ingevuld");
		this.document.frmStoring.email.focus();
		return false;
	}
	if( this.document.frmStoring.email.value.length > 0 && this.document.frmStoring.email.value.toString().match(/[_.0-9A-Za-z-]+\@([0-9A-Za-z-]+\.)+[0-9A-Za-z]+/) == null )
	{
		alert("Het e-mailadres is niet in geldige vorm");
		this.document.frmStoring.email.focus();
		return false;
	}
	if( this.document.frmStoring.storing_klacht.value == "XX" && this.document.frmStoring.storing_tekst.value.length < 1 )
        {
		alert("U heeft geen klacht gekozen");
		this.document.frmStoring.storing_klacht.focus();
		return false;
        }
	if( this.document.frmStoring.storing_klacht.value == "Overig" && this.document.frmStoring.storing_tekst.value.length < 1 )
	{
		alert("U heeft geen klachtomschrijving ingevuld");
		this.document.frmStoring.storing_tekst.focus();
		return false;
	}
	if( this.document.frmStoring.storing_buurt.value == "K" )
	{
		alert("U heeft niet aangegeven of uw buren ook klachten hebben");
		this.document.frmStoring.storing_buurt.focus();
		return false;
	}
	if( this.document.frmStoring.storing_buurt.value == "J" && this.document.frmStoring.storing_buurt_huisnr.value.length < 1 )              
	{
		alert("U heeft geen huisnummer van uw buren ingevuld");
		this.document.frmStoring.storing_buurt_huisnr.focus();
		return false;
	}
	return true;
}

