function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    ("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
("<li>["+p+"] => "+typeof(theObj)+"</li>");
        ("<ul>")
        print_r(theObj[p]);
        ("</ul>")
      } else {
("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    ("</ul>")
  }
}

function forgetpass(country,email) {
	melding=trl["sendingmessage"];
	if(melding=="") {
		melding="sending message...";
	}
	reporttxt(melding);
	data=new Array();
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/forgotpassword?country="+country+"&email="+email+"";
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	xmlophalen(url,post,'getpass', callbackPass,data);
	return false;
}

function callbackPass(response,data) {
	melding=trl["yourmessageissenttocamelot"];
	if(melding=="") {
		melding="Your message is sent to Camelot!";
	}
	reporttxt(melding);
	//document.getElementById("fp").style.display="none";
	document.getElementById("fp").style.visibility="hidden";
}

//todo: http://www.camelotproperty.com/cwa/o/gbr-en/main.client.mycorrespondence
//590+30
function vets(x,id,country) {
	if(x=="") {
		x="cd";
	}
	if(document.getElementById(x)) {
		document.getElementById(x).style.display="none";	
   }
		//i_id=deze.id.value;
		//var prop = document.getElementById("props").value;
		//prop = selectBox.options[selectBox.selectedIndex].value
		//prop=deze.prop_id.options[deze.prop_id.selectedIndex].value;
		
		data=new Array();
		data['id']=id;
		data['x']=x;
		data['country']=country;
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/GuardVet?country="+country+"&vet_id="+id;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		//alert(url);
		xmlophalen(url,post,'getvets', callbackVets,data);
		return false;
	}


function callbackVets(responseText,data,text) {
	//alert(text);
	id=data['id'];
	x=data['x'];
	country=data['country'];
//alert("!2");
	/////////////
	p=0;
	data3="  <table>";
	//alert("geladen");
	//for(p=0; p<count; p++) {
		//c_id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;	
		if(responseText.getElementsByTagName("vid").length>0) {
			id=responseText.getElementsByTagName("vid")[p].childNodes.item(0).nodeValue;
		} else {
			id="";
		}
		if(responseText.getElementsByTagName("description").length>0) {
			c_desc=responseText.getElementsByTagName("description")[p].childNodes.item(0).nodeValue;
		} else {
			c_desc="";
		}
		if(responseText.getElementsByTagName("date").length>0) {
			c_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;
		} else {
			c_date="";
		}
		if(responseText.getElementsByTagName("name").length>0) {
			c_name=responseText.getElementsByTagName("name")[p].childNodes.item(0).nodeValue;
		} else {
			c_name="";
		}
		if(responseText.getElementsByTagName("size").length>0) {
			c_size=responseText.getElementsByTagName("size")[p].childNodes.item(0).nodeValue;
		} else {
			c_size="";
		}
		
		
		data3+="<tr>";
        data3+="<td width=\"116\">Date</td>"; 
         data3+="<td width=\"726\" class=\"colored\" id=\"\">"+c_date+"</td>"; 
         data3+="</tr>"; 
		     data3+="<tr>"; 
           data3+="<td>Type</td>"; 
          data3+="<td class=\"colored\">"+c_type+" </td>"; 
        data3+="</tr>"; 
		 data3+="<tr>";
        data3+="<td width=\"116\">Direction</td>"; 
         data3+="<td width=\"726\" class=\"colored\" id=\"\">"+c_dir+"</td>"; 
         data3+="</tr>";
         data3+="<tr>"; 
         data3+="<td>Sent By</td>"; 
         data3+="<td class=\"colored\">"+c_sender+"</td>"; 
        data3+="</tr>"; 
         data3+="<tr>"; 
         data3+="<td>Subject</td>"; 
         data3+="<td class=\"colored\">"+c_subject+"</td>"; 
        data3+="</tr>"; 
      if(bodyhtml!="" && bodyhtml!="&#160;" && bodyhtml!=" " && bodyhtml!="&nbsp;") {
         data3+="<tr>"; 
         data3+="<td>Body</td>"; 
        data3+="<td class=\"colored\">"+bodyhtml+"</td>"; 
         data3+="</tr>";
		}
         data3+="<tr>"; 
        data3+="<td>Recipient</td>"; 
        data3+="<td class=\"colored\">"+c_recipient+" </td>"; 
      data3+="</tr>"; 
    
		if(responseText.getElementsByTagName("attachment").length>0) {
			data3+="<tr>"; 
			data3+="<td>Attachment(s)</td>"; 
			data3+="<td class=\"colored\">";
			for(at=0; at<(responseText.getElementsByTagName("attachment").length); at++) {
				c_desc=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("filename")[0].childNodes.item(0).nodeValue;	
				c_aid=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("a_id")[0].childNodes.item(0).nodeValue;	
				data3+="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?fileid="+id2+"\">"+c_desc+" </a><br/>"; 
				
			}
			data3+="</td></tr>"; 
		}
			
		/*if(responseText.getElementsByTagName("filename").length>0) {
			c_desc=responseText.getElementsByTagName("filename")[p].childNodes.item(0).nodeValue;	
		} else {
			c_desc="";
		}
		if(c_desc!="" && c_desc!="&#160;" && c_desc!=" " && c_desc!="&nbsp;") {
         data3+="<tr>"; 
          data3+="<td>Attachment(s)</td>"; 
         data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?fileid="+id2+"\">"+c_desc+" </a></td>"; 
        data3+="</tr>"; 
		}*/
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		//data3+="</tr>"; 
	//}
	data3+="</table>";
	if(x=="") {
		x="cd";	
	}
	//alert(x);
	//alert(document.getElementById("cdata").innerHTML);
	//if(document.getElementById(x)) {
		
		document.getElementById(x).style.cursor="auto";	
		document.getElementById(x).style.display="block";	
		document.getElementById(x).style.visibility="visible";
	//}
	//if(document.getElementById('cdata')) {
		document.getElementById('cdata').innerHTML=data3;
		document.getElementById('cdata').style.display="block";	
		document.getElementById('cdata').style.visibility="visible";
		document.getElementById('cd').style.display="block";	
		document.getElementById('cd').style.visibility="visible";	
	//}
}


function extraservices(deze,country,id) {
		//i_id=deze.id.value;
		//var prop = document.getElementById("props").value;
		//prop = selectBox.options[selectBox.selectedIndex].value
		//prop=deze.prop_id.options[deze.prop_id.selectedIndex].value;
		prop=deze.type.options[deze.type.selectedIndex].value;
		comm=deze.comments.value;
		data=new Array();
		data['report']="Your message is sent to Camelot!";
		data['reportid']="report";
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/RequestInfo?country="+country+"&cont_id="+id+"&prop_id="+prop+"&comments="+comm;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		//alert(url);
		xmlophalen(url,post,'gettypes', callbackServices,data);
		return false;
	}


function callbackServices(responseText,data,text) {
	//alert(text);
	txt=data['report'];
	id=data['reportid'];
document.getElementById(id).innerHTML=txt;	
}

//typedd
function gettypes(country) {
		//i_id=deze.id.value;
		
		data=new Array();
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/IncidentTypes?country="+country;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		xmlophalen(url,post,'gettypes', callbackTypes,data);
		return false;
	}


function callbackTypes(responseText,data,text) {
	//alert(text);
	html="<select name=\"type\" style=\"width: 150px;\"><option value=\"\">...</option>";
	aantal=responseText.getElementsByTagName("i_id").length;
	aantal2=responseText.getElementsByTagName("description").length;
	//alert("aantal: "+aantal+"-"+aantal2);
	for(a=0; a<aantal; a++) {
		html+="<option value=\""+(responseText.getElementsByTagName("i_id")[a].childNodes.item(0).nodeValue)+"\">"+(responseText.getElementsByTagName("description")[a].childNodes.item(0).nodeValue)+"</option>";	
	}
	html+="</select>";
	//document.getElementById('typedd').innerHTML=html;	
}










var httphandler;
function createHTTPHandler(){
            httphandler = false;
            
            if (!httphandler && typeof XMLHttpRequest!='undefined') {
            httphandler = new XMLHttpRequest();
            }
            return httphandler;
    }

function xmlcon(pagina,post,oproepnaam, callback,data){
	//alert(idx);
   var XMLHTTPObject = createHTTPHandler2();
	returntxt="";
	XMLHTTPObject.open('POST', pagina, true);
	   
	XMLHTTPObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	if(post!=null) {
		XMLHTTPObject.setRequestHeader("Content-length", post.length);
	}
	XMLHTTPObject.setRequestHeader("Connection", "close");
	XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
	XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
	
	XMLHTTPObject.send(post);
	
	XMLHTTPObject.onreadystatechange=function() {
		if (XMLHTTPObject.readyState==4) {
			callback( XMLHTTPObject.responseXML,data,XMLHTTPObject.responseText );
		}
	   
	} 
}

function createHTTPHandler2(){
	httphandler = false;
	
	if (!httphandler && typeof XMLHttpRequest!='undefined' && window.XMLHttpRequest) {
		httphandler = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		httphandler=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return httphandler;
}


function xmlophalen(pagina,post,oproepnaam, callback,dat){
	//alert(pagina);
	//document.write(pagina);
  // XMLHTTPObject = createHTTPHandler();
  /*try{
		// Opera 8.0+, Firefox, Safari
		XMLHTTPObject = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			XMLHTTPObject = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				XMLHTTPObject = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}*/
		var XMLHTTPObject = createHTTPHandler2();
	if(XMLHTTPObject) {
		returntxt="";
		//XMLHTTPObject.preserveWhiteSpace = true;
		XMLHTTPObject.open('GET', pagina, true);
		//XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
		//XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
		if(post!=null) {
			XMLHTTPObject.setRequestHeader("Content-length", post.length);
		}
		
		XMLHTTPObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		//XMLHTTPObject.send(null);
		XMLHTTPObject.send(post);
			XMLHTTPObject.onreadystatechange=function() {
				if (XMLHTTPObject.readyState==4) {
					callback( XMLHTTPObject.responseXML,dat,XMLHTTPObject.responseText );
				}
			} 
	} else {
		alert("Er is een fout opgetreden! (1.227)");	
	}
}


function voerPaginaUit(pagina,oproepnaam, callback,dat){
      /* try{
			// Opera 8.0+, Firefox, Safari
			XMLHTTPObject = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				XMLHTTPObject = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					XMLHTTPObject = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}*/
		var XMLHTTPObject = createHTTPHandler2();
		if(XMLHTTPObject) {
			returntxt="";
			XMLHTTPObject.open('GET', pagina, true);
			//XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
			//XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
			
			//XMLHTTPObject.send(null);
			 XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
        XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
			XMLHTTPObject.send(null);
				XMLHTTPObject.onreadystatechange=function() {
					if (XMLHTTPObject.readyState==4) {
						//alert("status= "+pagina);
						callback( XMLHTTPObject.responseXML,dat );
					}
				} 
		} else {
			alert("Er is een fout opgetreden! (2.268)");	
		}
	/*
		var XMLHTTPObject = createHTTPHandler2();
        
        XMLHTTPObject.open('GET', pagina, true);
        XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
        XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
        
        XMLHTTPObject.send(null);
        
        XMLHTTPObject.onreadystatechange=function() {
            if (XMLHTTPObject.readyState==4) {
                callback( XMLHTTPObject.responseXML );
            }
           
        }   */      
    }

    
    function voerPaginaUit2(pagina,oproepnaam){
        var terug="test";
        var XMLHTTPObject = createHTTPHandler2();
        
        XMLHTTPObject.open('GET', pagina, true);
        XMLHTTPObject.setRequestHeader("Cache-Control", "no-cache");
        XMLHTTPObject.setRequestHeader("X_USERAGENT", oproepnaam);
        
        XMLHTTPObject.send(null);
        
        XMLHTTPObject.onreadystatechange=function() {
            if (XMLHTTPObject.readyState==4) {
                
                terug = XMLHTTPObject.responseText;
                
                
                
            }
           
        }
        
       return terug;
         
    }
	
function showLayer(which,id,country) {
	//incident_date,incident_sender,incident_recipient,incident_subject,incident_body,incident_attachments,
	document.getElementById(which).style.visibility="hidden";
	//document.getElementById("incident_date").innerHTML=incident_date;
	//document.getElementById("incident_sender").innerHTML=incident_sender;
	//document.getElementById("incident_recipient").innerHTML=incident_recipient;
	//document.getElementById("incident_subject").innerHTML=incident_subject;
	//document.getElementById("incident_body").innerHTML=incident_body;
	//document.getElementById("incident_attachments").innerHTML=incident_attachments;
	information(id,country);
	//document.getElementById(which).style.visibility="visible";
}

function showLayer2(which,id,country) {
	//incident_date,incident_sender,incident_recipient,incident_subject,incident_body,incident_attachments,
	document.getElementById(which).style.visibility="visible";
	
	document.getElementById('cd').style.visibility="hidden";
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var dsocleft=document.all? iebody.scrollLeft : pageXOffset
	var dsoctop=document.all? iebody.scrollTop : pageYOffset
	t=dsoctop;
	document.getElementById('cd').style.top=(t+100)+"px";
	//document.getElementById("incident_date").innerHTML=incident_date;
	//document.getElementById("incident_sender").innerHTML=incident_sender;
	//document.getElementById("incident_recipient").innerHTML=incident_recipient;
	//document.getElementById("incident_subject").innerHTML=incident_subject;
	//document.getElementById("incident_body").innerHTML=incident_body;
	//document.getElementById("incident_attachments").innerHTML=incident_attachments;
	information3(id,country);
	//document.getElementById(which).style.visibility="visible";
}

function showLayer2b(which,id,country) {
	//incident_date,incident_sender,incident_recipient,incident_subject,incident_body,incident_attachments,
	document.getElementById(which).style.visibility="visible";
	//document.getElementById("incident_date").innerHTML=incident_date;
	//document.getElementById("incident_sender").innerHTML=incident_sender;
	//document.getElementById("incident_recipient").innerHTML=incident_recipient;
	//document.getElementById("incident_subject").innerHTML=incident_subject;
	//document.getElementById("incident_body").innerHTML=incident_body;
	//document.getElementById("incident_attachments").innerHTML=incident_attachments;
	//information3(id,country);
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/MeterDets?country="+country+"&Meter_id="+id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackMeterDets,dat );
	//document.getElementById(which).style.visibility="visible";
}


function showLayer3(which) {
	document.getElementById(which).style.visibility="visible";
}
function showLayer4(which,id,country,c_id) {
	std="http://www.camelotproperty.com/cwa/extern.php?file=";
	document.getElementById('bd').style.visibility="hidden";
	document.getElementById('ir').style.visibility="hidden";
	document.getElementById('cd').style.visibility="hidden";
	document.getElementById('cd2').style.visibility="hidden";
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var dsocleft=document.all? iebody.scrollLeft : pageXOffset
	var dsoctop=document.all? iebody.scrollTop : pageYOffset
	t=dsoctop;
	document.getElementById('bd').style.top=(t+100)+"px";
	//document.getElementById("p_id").innerHTML=id;
	document.getElementById("nr").innerHTML=id;
	if(country=="") {
		country=5;
	}
	//informationb(id);
	//+ andere tabs info laden
	//foto http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropPhotos?country=string&prop_id=string
	//PropPhotos(id);
	//inci http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropIncidents?country=string&prop_id=string
	//PropIncidents(id);
	//insp http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropInspections?country=string&prop_id=string
	//PropInspections(id);
	//http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropMeters?country=string&prop_id=string
	//PropMeters(id);
	//!omzetten!
	dat=new Array();
	dat['id']=id;
	dat['country']=country;
	dat['c_id']=c_id;
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropDets?country="+country+"&prop_id="+id;
	turl=""+std+url;
	
	voerPaginaUit( turl, 'test', callbackDetails,dat );

	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropPhotos?country="+country+"&prop_id="+id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackPhoto,dat );
	
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropIncidents?country="+country+"&prop_id="+id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackIncidents,dat );
	
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropInspections?country="+country+"&prop_id="+id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackInspections,dat );
	
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropMeters?country="+country+"&prop_id="+id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackMeters,dat );

	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropContacts?country="+country+"&prop_id="+id+"&cont_id="+c_id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackContacts,dat );
	
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropFacilities?country="+country+"&prop_id="+id;
	turl=""+std+url;
	//alert(id);
	voerPaginaUit( turl, 'test', callbackFacilities,dat );
	
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropCorr?country="+country+"&prop_id="+id+"&cont_id="+c_id;
	turl=""+std+url;
	voerPaginaUit( turl, 'test', callbackPropCorr,dat );

	
	
}

function showLayer6(which,id) {
	std="http://www.camelotproperty.com/cwa/extern.php?file=";
	//document.getElementById(which).style.visibility="visible";
	//!omzetten!
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ContCorr?country="+country+"&cont_id="+id;
	turl=""+std+url;
	//alert(url);
	data=new Array();
		data['id']=id;
	voerPaginaUit( turl, 'test', callbackCorr,data );
	
	
	document.getElementById(which).style.visibility="visible";
}

function showLayer7(whiche,id,country) {
	if(document.getElementById('wrap')) {
		document.getElementById('wrap').style.cursor="wait";
	}
	if(document.getElementById('cdata')) {
		document.getElementById('cdata').style.visibility="hidden";
	}
	std="http://www.camelotproperty.com/cwa/extern.php?file=";
	//document.getElementById(which).style.visibility="visible";
	//!omzetten!
	//url="http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/DocCorr?corr_id="+id+"&country=5";
	url="http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/DocCorr?corr_id="+id+"&country="+country;
	//url="http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/DocCorr?corr_id=1&country="+country;
	turl=""+std+url;
	//alert(url);
	data=new Array();
		data['id']=id;
	voerPaginaUit( turl, 'test', callbackCorr2,data );
	if(whiche=="") {
			whiche="cd";
	}
	//if(document.getElementById(which)) {
		document.getElementById(whiche).style.visibility="visible";
	//}
}

function callbackCorr( responseText,dat ) {
	count=responseText.getElementsByTagName("Correspondence").length;
	data3="  <table>";
	for(p=0; p<count; p++) {
		c_id=responseText.getElementsByTagName("c_id")[p].childNodes.item(0).nodeValue;	
		c_type=responseText.getElementsByTagName("c_type")[p].childNodes.item(0).nodeValue;	
		c_sender=responseText.getElementsByTagName("c_sender")[p].childNodes.item(0).nodeValue;	
		c_recipient=responseText.getElementsByTagName("c_recipient")[p].childNodes.item(0).nodeValue;	
		c_subject=responseText.getElementsByTagName("c_subject")[p].childNodes.item(0).nodeValue;	
		
		data3+="<tr>"; 
		data3+="<td width=\"116\">Date</td> <td width=\"726\" class=\"colored\">"+c_id+"</td>";
		data3+="</tr><tr>"; 
		data3+="<td width=\"116\">Date</td> <td width=\"726\" class=\"colored\">"+c_type+"</td>";
		data3+="</tr><tr>"; 
		data3+="<td width=\"116\">Date</td> <td width=\"726\" class=\"colored\">"+c_sender+"</td>";
		data3+="</tr><tr>"; 
		data3+="<td width=\"116\">Date</td> <td width=\"726\" class=\"colored\">"+c_recipient+"</td>";
		data3+="</tr><tr>"; 
		data3+="<td width=\"116\">Date</td> <td width=\"726\" class=\"colored\">"+c_subject+"</td>";
		data3+="</tr><tr>"; 
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	//document.getElementById("cdata").innerHTML=data3;
}

function callbackCorr2( responseText,dat ) {
	//count=responseText.getElementsByTagName("correspondence").length;
	p=0;
	data3="  <table>";
	//alert("geladen");
	//for(p=0; p<count; p++) {
		//c_id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;	
		if(responseText.getElementsByTagName("cid").length>0) {
			id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;
		} else {
			id="";
		}
		if(responseText.getElementsByTagName("type").length>0) {
			c_type=responseText.getElementsByTagName("type")[p].childNodes.item(0).nodeValue;
		} else {
			c_type="";
		}
		if(responseText.getElementsByTagName("sender").length>0) {
			c_sender=responseText.getElementsByTagName("sender")[p].childNodes.item(0).nodeValue;	
		} else {
			c_sender="";
		}
		if(responseText.getElementsByTagName("dir").length>0) {
			c_dir=responseText.getElementsByTagName("dir")[p].childNodes.item(0).nodeValue;	
		} else {
			c_dir="";
		}
		if(responseText.getElementsByTagName("date").length>0) {
			c_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
		} else {
			c_date="";
		}
		if(responseText.getElementsByTagName("recipient").length>0) {
			c_recipient=responseText.getElementsByTagName("recipient")[p].childNodes.item(0).nodeValue;	
		} else {
			c_recipient="";
		}
		if(responseText.getElementsByTagName("desc").length>0) {
			c_desc=responseText.getElementsByTagName("desc")[p].childNodes.item(0).nodeValue;	
		} else {
			c_desc="";
		}
		if(responseText.getElementsByTagName("binary").length>0) {
			binary=responseText.getElementsByTagName("binary")[p].childNodes.item(0).nodeValue;	
		} else {
			binary="";
		}
		data3+="<tr>";
        data3+="<td width=\"116\">Date</td>"; 
         data3+="<td width=\"726\" class=\"colored\" id=\"\">"+c_date+"</td>"; 
         data3+="</tr>"; 
		 data3+="<tr>";
        data3+="<td width=\"116\">Type</td>"; 
         data3+="<td class=\"colored\" id=\"\">"+c_type+"</td>"; 
         data3+="</tr>"; 
		 data3+="<tr>";
        data3+="<td width=\"116\">Direction</td>"; 
         data3+="<td class=\"colored\" id=\"\">"+c_dir+"</td>"; 
         data3+="</tr>"; 
         data3+="<tr>"; 
         data3+="<td>Sent By</td>"; 
         data3+="<td class=\"colored\">"+c_sender+"</td>"; 
        data3+="</tr>"; 
         data3+="<tr>"; 
         data3+="<td>Desc.</td>"; 
         data3+="<td class=\"colored\">"+c_desc+"</td>"; 
        data3+="</tr>"; 
         data3+="<tr>"; 
        data3+="<td>Recipient</td>"; 
        data3+="<td class=\"colored\">"+c_recipient+" </td>"; 
      
        // data3+="<tr>"; 
         //data3+="<td>Body</td>"; 
        //data3+="<td class=\"colored\">"+c_desc+"</td>"; 
         data3+="</tr>"; 
         data3+="<tr>"; 
			data3+="<td>Attachment(s)</td>"; 
			data3+="<td class=\"colored\">"; 
         data3+="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+id+"\">"+c_desc+" </a></td>"; 
        
		if(responseText.getElementsByTagName("attachment").length>0) {
			data3+="<tr>"; 
			data3+="<td>Attachment(s)</td>"; 
			data3+="<td class=\"colored\">";
			for(at=0; at<(responseText.getElementsByTagName("attachment").length); at++) {
				c_desc=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("filename")[0].childNodes.item(0).nodeValue;	
				c_aid=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("a_id")[0].childNodes.item(0).nodeValue;	
				data3+="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+id2+"\">"+c_desc+" </a><br/>"; 
				
			}
			
		}
		data3+="</td></tr>"; 
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		
	//}
	data3+="</table>";
	//alert(document.getElementById("cdata").innerHTML);
	//if(document.getElementById("cdata")) {
		document.getElementById("cdata").innerHTML=data3;
		document.getElementById('cdata').style.visibility="visible";
	//}
	//if(document.getElementById("wrap")) {
		document.getElementById('wrap').style.cursor="auto";
	//}
	//getInformation(id,country);
	//alert(document.getElementById("cdata").innerHTML);
}

function callbackDetails( responseText,dat ) {
	//document.getElementById('bd').style.visibility="hidden"; //mag deze uitgecomment?

	document.getElementById('bd').style.visibility="hidden";	
	id=dat['id'];
country=dat['country'];
		document.getElementById("p_photo").innerHTML="";
		//document.getElementById("p_id").innerHTML=responseText.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;
		if(responseText.getElementsByTagName("p_id").length>0) {
			document.getElementById("p_id").innerHTML=afkappen(responseText.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_id").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_addr1").length>0) {
			document.getElementById("p_addr1").innerHTML=afkappen(responseText.getElementsByTagName("p_addr1")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_addr1").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_addr2").length>0) {
			document.getElementById("p_addr2").innerHTML=afkappen(responseText.getElementsByTagName("p_addr2")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_addr2").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_addr3").length>0) {
			document.getElementById("p_addr3").innerHTML=afkappen(responseText.getElementsByTagName("p_addr3")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_addr3").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_addr4").length>0) {
			document.getElementById("p_addr4").innerHTML=afkappen(responseText.getElementsByTagName("p_addr4")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_addr4").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_city").length>0) {
			document.getElementById("p_city").innerHTML=afkappen(responseText.getElementsByTagName("p_city")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_city").innerHTML="";
		}
		//document.getElementById("p_count").innerHTML=responseText.getElementsByTagName("p_count")[0].childNodes.item(0).nodeValue;
		if(responseText.getElementsByTagName("p_code").length>0) {
			document.getElementById("p_code").innerHTML=afkappen(responseText.getElementsByTagName("p_post")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_code").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_max").length>0) {
			document.getElementById("p_max").innerHTML=afkappen(responseText.getElementsByTagName("p_max")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_max").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_type").length>0) {
			document.getElementById("p_type").innerHTML=afkappen(responseText.getElementsByTagName("p_type")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_type").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_status").length>0) {
			document.getElementById("p_status").innerHTML=afkappen(responseText.getElementsByTagName("p_status")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_status").innerHTML="";
		}
		if(responseText.getElementsByTagName("p_date").length>0) {
			document.getElementById("p_date").innerHTML=afkappen(responseText.getElementsByTagName("p_date")[0].childNodes.item(0).nodeValue,100);
		} else {
			document.getElementById("p_date").innerHTML="";
		}
		
		if(responseText.getElementsByTagName("p_photo").length>0) {
			//if(responseText.getElementsByTagName("p_photo")[0].childNodes.item(0).nodeValue!="") {
				document.getElementById("p_photo").innerHTML='<img src="/cwa/image_prop.php?id=' + id + '&country='+country+'">';
			//}
		} else {
			document.getElementById("p_photo").innerHTML="";
		}
	//document.getElementById('bd').style.visibility="visible";	
	showframe(id);
	hideLayer('ir');
}

function callbackPhoto( responseText,dat ) {
	//p4_id=responseText.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;	
	//p4_photo=responseText.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;	
	 document.getElementById("photoData").innerHTML="";
	 count=responseText.getElementsByTagName("photo").length;
	data1="";
	id=dat['id'];
country=dat['country'];
	for(p=0; p<count; p++) {
		photo_id=responseText.getElementsByTagName("pid")[p].childNodes.item(0).nodeValue;	
		data1+="<a href=\"/cwa/image_prop2.php?id=" + photo_id + "&country="+country+"\" target=\"_blank\"><img src=\"/cwa/image_prop3.php?id=" + id + "&country="+country+"&photo="+p+"\" border=\"0\"></a>&nbsp;&nbsp;";
	}
	data1+="";
   document.getElementById("photoData").innerHTML=data1;
}

function callbackIncidents( responseText,dat ) {
	document.getElementById("incData").innerHTML="";
	country=dat['country'];
	count=responseText.getElementsByTagName("Incident").length;
	data2="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	//data2+="<td class=\"txthighlight\">Property</td>";
	data2+="<td class=\"txthighlight\">"+tl("reporter",trl)+"</td>";
	//data2+="<td class=\"txthighlight\">Incident Type </td>";
	data2+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	data2+="<td class=\"txthighlight\">"+tl("description",trl)+" </td>";	
	data2+=" <td class=\"txthighlight\">"+tl("incidentstatus",trl)+" </td>";	
	//data2+="  <td class=\"txthighlight\">Last action </td>";
	data2+=" </tr>";
	for(p=0; p<count; p++) {
		i3_id=responseText.getElementsByTagName("i_id")[p].childNodes.item(0).nodeValue;	
		i3_rep=responseText.getElementsByTagName("reporter")[p].childNodes.item(0).nodeValue;	
		i3_prop=responseText.getElementsByTagName("property")[p].childNodes.item(0).nodeValue;	
		//i3_type=responseText.getElementsByTagName("i_type")[p].childNodes.item(0).nodeValue;	
		i3_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
		i3_description=responseText.getElementsByTagName("description")[p].childNodes.item(0).nodeValue;			
		i3_status=responseText.getElementsByTagName("status")[p].childNodes.item(0).nodeValue;	
		//i3_action=responseText.getElementsByTagName("description")[p].childNodes.item(0).nodeValue;	
		
		data2+="<tr>"; 
		//data2+="<td class=\"colored\"><a href=\"#\" onclick=\"showincident('ir','"+i3_id+"','"+country+"')\">"+i3_id+"</a></td>";
		data2+="<td class=\"colored\">"+afkappen(i3_rep,100)+" </td>";
		//data2+="<td class=\"colored\">"+i3_type+"</td>";
		data2+="<td class=\"colored\">"+afkappen(i3_date,100)+"</td>";
		data2+="<td class=\"colored\"><a href=\"#\" onclick=\"showincident('ir','"+i3_id+"','"+country+"')\">"+afkappen(i3_description,100)+"</a></td>";		
		data2+="<td class=\"colored\">"+afkappen(i3_status,100)+"</td>";
		//data2+="<td class=\"colored\">"+i3_action+"</td>";
		//data2+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data2+="</tr>"; 
	}
	data2+="</table>";
	//if(document.getElementById("incData")) {
		document.getElementById("incData").innerHTML=data2;
	//}
}

function callbackMeterDets( responseText,dat ) {
	count=responseText.getElementsByTagName("reading").length;
	data3="";
	data3+="<table border=\"0\" style=\"border-width: 0px;\">";
		m_type=responseText.getElementsByTagName("type")[0].childNodes.item(0).nodeValue;	
	data3+="<tr><td><strong>Type</strong></td><td>"+m_type+"</td></tr>";
		m_location=responseText.getElementsByTagName("location")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>Location</strong></td><td>"+m_location+"</td></tr>";
		m_serial=responseText.getElementsByTagName("serial")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>Serial</strong></td><td>"+m_serial+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("inuse")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>In use</strong></td><td>"+m_inuse+"</td></tr>";
	
	data3+="</table><br/>";
	data3+="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
//	data3+="<td class=\"txthighlight\">id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	if(responseText.getElementsByTagName("reading2").length>0) {
		data3+=" <td class=\"txthighlight\">"+tl("day",trl)+"</td>";
		data3+="  <td class=\"txthighlight\">"+tl("night",trl)+"</td>";
	} else {
		data3+="  <td class=\"txthighlight\">"+tl("reading",trl)+"</td>";
	}
	data3+=" </tr>";
	start=0;
	maxi=1024;
	count=count*1;
	if(count>=maxi) {
		count=maxi;
	}
	for(p=start; p<count; p++) {
		
			i2_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
		//}
		i2_comm=responseText.getElementsByTagName("reading1")[p].childNodes.item(0).nodeValue;	
		//fout in ie6:
		i2_insp="";
		if(responseText.getElementsByTagName("reading2").length>0) {
			i2_insp=responseText.getElementsByTagName("reading2")[p].childNodes.item(0).nodeValue;	
		}
		
		data3+="<tr>"; 
//		data3+="<td class=\"colored\">"+i2_id+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_date,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_comm,100)+"</td>";
		if(responseText.getElementsByTagName("reading2").length>0) {
			data3+="<td class=\"colored\">"+afkappen(i2_insp,100)+"</td>";
		}
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	document.getElementById("metersdets").innerHTML=data3;
}

function callbackInspections( responseText,dat ) {
	document.getElementById("frame4").innerHTML="";
	country=dat['country'];
	count=responseText.getElementsByTagName("inspection").length;
	data3="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
//	data3+="<td class=\"txthighlight\">id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("comm",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("insp",trl)+"</td>";
	data3+=" </tr>";
	for(p=0; p<count; p++) {
		//if(responseText.getElementsByTagName("i_id").length>0) {
			i2_id=responseText.getElementsByTagName("id")[p].childNodes.item(0).nodeValue;	
		//}
		//if(responseText.getElementsByTagName("i_date").length>0) {
			i2_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
		//}
		i2_comm=responseText.getElementsByTagName("remarks")[p].childNodes.item(0).nodeValue;	
		i2_insp=responseText.getElementsByTagName("insp")[p].childNodes.item(0).nodeValue;	
		
		data3+="<tr>"; 
		//data3+="<td class=\"colored\"><a href=\"#\" onclick=\"showinspection('ir','"+i2_id+"','"+country+"')\">"+i2_id+"</a></td>";
		data3+="<td class=\"colored\"><a href=\"#\" onclick=\"showinspection('ir','"+i2_id+"','"+country+"')\">"+afkappen(i2_date,100)+"</a></td>";
		data3+="<td class=\"colored\">"+afkappen(i2_comm,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_insp,100)+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	document.getElementById("frame4").innerHTML=data3;
}

function callbackMeters( responseText,dat ) {
	document.getElementById("frame5").innerHTML="";
	count=responseText.getElementsByTagName("meter").length;
	data3="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	//data3+="<td class=\"txthighlight\">Id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("serial",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("location",trl)+"</td>";
//	data3+="  <td class=\"txthighlight\">read </td>";
//	data3+="  <td class=\"txthighlight\">date </td>";
	data3+=" </tr>";
	start=0;
	maxi=100;
	count=count*1;
	if(count>maxi) {
		count=maxi;
	}
	for(p=start; p<count; p++) {
		m_id=responseText.getElementsByTagName("mid")[p].childNodes.item(0).nodeValue;	
		m_type=responseText.getElementsByTagName("type")[p].childNodes.item(0).nodeValue;	
		m_serial=responseText.getElementsByTagName("serial")[p].childNodes.item(0).nodeValue;	
		m_location=responseText.getElementsByTagName("location")[p].childNodes.item(0).nodeValue;	
//		m_read=responseText.getElementsByTagName("m_read")[p].childNodes.item(0).nodeValue;	
//		m_date=responseText.getElementsByTagName("m_date")[p].childNodes.item(0).nodeValue;	
		
		data3+="<tr>"; 
		//data3+="<td class=\"colored\"><a href=\"javascript:showLayer2b('cd2','"+m_id+"','"+country+"')\">"+afkappen(m_id,100)+"</a></td>";
		
		
		data3+="<td class=\"colored\">"+afkappen(m_type,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(m_serial,100)+"</td>";
		data3+="<td class=\"colored\"><a href=\"javascript:showLayer2b('cd2','"+m_id+"','"+country+"')\">"+afkappen(m_location,100)+"</a></td>";
//		data3+="<td class=\"colored\">"+m_read+"</td>";
//		data3+="<td class=\"colored\">"+m_date+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	document.getElementById("frame5").innerHTML=data3;
}

function callbackContacts( responseText ,dat) {
	document.getElementById("frame6").innerHTML="";
	count=responseText.getElementsByTagName("Contact").length;
	data3="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	//data3+="<td class=\"txthighlight\">id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("name",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("phone",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("mobile",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("company",trl)+"</td>";
	data3+=" </tr>";
	for(p=0; p<count; p++) {
		var c_id=chechdata(responseText.getElementsByTagName("c_id"),p);
		var c_name=chechdata(responseText.getElementsByTagName("c_name"),p);
		var c_type=chechdata(responseText.getElementsByTagName("type"),p);
		var c_phone=chechdata(responseText.getElementsByTagName("phone"),p);
		var c_mobile=chechdata(responseText.getElementsByTagName("mobile"),p);
		var c_company=chechdata(responseText.getElementsByTagName("company"),p);
		data3+="<tr>"; 
		//data3+="<td class=\"colored\">"+c_id+"</td>";
		data3+="<td class=\"colored\"><a href=\"javascript:showLayer2('cd','"+c_id+"','"+country+"')\">"+afkappen(c_name,100)+"</a></td>";
		data3+="<td class=\"colored\">"+afkappen(c_type,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(c_phone,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(c_mobile,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(c_company,100)+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	document.getElementById("frame6").innerHTML=data3;
}

function chechdata(tag,p) {
	var dat="";
	//alert(p+"="+tag.length);
	
	if(tag) {
		
		if(tag.length>p) {
			//ie-fout:x//
			if(tag[p]) {
				if(tag[p].childNodes.length>0) {
					dat=tag[p].childNodes.item(0).nodeValue;
				}
			}
			//c_phone="";
		
		}
	}
	return dat;
}

function callbackFacilities( responseText,dat ) {
	document.getElementById("frame7").innerHTML="";
	count=responseText.getElementsByTagName("Facility").length;
	//alert(count);
	data3="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	//data3+="<td class=\"txthighlight\">id</td>";
	//data3+=" <td class=\"txthighlight\">Id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("description",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("location",trl)+"</td>";
	data3+=" </tr>";
	for(p=0; p<count; p++) {
		f_id="";
		f_name="";
		f_desc="";
		f_type="";
		var f_desc=chechdata(responseText.getElementsByTagName("desc"),p);
		var f_name=chechdata(responseText.getElementsByTagName("location"),p);
		var f_type=chechdata(responseText.getElementsByTagName("type"),p);
		var f_id=chechdata(responseText.getElementsByTagName("f_id"),p);
		//type
		//f_id
		if(f_type!="" || f_desc!="" || f_name!="") {
		data3+="<tr>"; 
		//data3+="<td class=\"colored\">"+c_id+"</td>";
		//data3+="<td class=\"colored\">"+f_id+"</td>";
		
		
		data3+="<td class=\"colored\"><a href=\"#\" onclick=\"showfacdet('cd','"+f_id+"','"+dat['country']+"')\">"+f_type+"</a></td>";
		data3+="<td class=\"colored\">"+afkappen(f_desc,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(f_name,100)+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
		}
	}
	data3+="</table>";
	document.getElementById("frame7").innerHTML=data3;
}

function showfacdet(popup,id,country) {
	data=new Array();
	data['id']=id;
	data['country']=country;
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/FacDets?country="+country+"&fac_id="+id;
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	xmlophalen(url,post,'getvets', callbackfacdetv,data);
	return false;
}

function callbackfacdetv(responseText,data,text) {
	aantal=responseText.getElementsByTagName("facility").length;
	//alert(aantal);
	//alert(text);
	document.getElementById('cdx').style.display="none";
	document.getElementById('cdx').style.visibility="hidden";
	document.getElementById("cddets").innerHTML="";
	html="<h2>Facility details:</h2>";
	
	html+="<table>";
	f=responseText.getElementsByTagName("facility")[0];
	html+="<tr><td><strong>"+tl("type",trl)+"</strong></td><td>"+(f.getElementsByTagName("type")[0].childNodes.item(0).nodeValue)+"</td></tr>";
	html+="<tr><td><strong>"+tl("description",trl)+"</strong></td><td>"+(f.getElementsByTagName("desc")[0].childNodes.item(0).nodeValue)+"</td></tr>";
	html+="<tr><td><strong>"+tl("location",trl)+"</strong></td><td>"+(f.getElementsByTagName("loc")[0].childNodes.item(0).nodeValue)+"</td></tr>";
	html+="<tr><td><strong>"+tl("date",trl)+"</strong></td><td>"+(f.getElementsByTagName("ins_date")[0].childNodes.item(0).nodeValue)+"</td></tr>";
	html+="<tr><td><strong>"+tl("serial",trl)+"</strong></td><td>"+(f.getElementsByTagName("serial")[0].childNodes.item(0).nodeValue)+"</td></tr>";
	html+="</table>";
	document.getElementById("cddets").innerHTML=html;	
	document.getElementById('cdx').style.visibility="visible";
	document.getElementById('cdx').style.display="block";
	
}

function callbackPropCorr( responseText,dat ) {
	document.getElementById("frame8").innerHTML="";
	count=responseText.getElementsByTagName("correspondence").length;
	//alert(count);
	data3=" <div id=\"auth\">Loading...</div><br/> <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	data3+="<tr><td colspan=\"10\"><strong>"+tl("correspondences",trl)+"</strong></td></tr>";
	data3+="<tr>";
	std="http://www.camelotproperty.com/cwa/extern.php?file=";
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropAuthOff?country="+country+"&prop_id="+id+"&cont_id="+userid;
	turl=""+std+url;
	voerPaginaUit( turl, 'authoff', callbackPropAuthOff,dat );
	//data3+="<td class=\"txthighlight\">id</td>";
	//data3+=" <td class=\"txthighlight\">Id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("dir",trl)+".</td>";
	data3+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("sender",trl)+"</td>";
	//data3+=" <td class=\"txthighlight\">Bulk</td>";
	data3+=" <td class=\"txthighlight\">"+tl("desc",trl)+".</td>";
	data3+=" </tr>";
	for(p=0; p<count; p++) {
		
		
		
			var c_id;
			if(responseText.getElementsByTagName("cid").length>0) {
				c_id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;	
			}
			var c_date;
			if(responseText.getElementsByTagName("date").length>0) {
				c_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
			}
			var c_type;
			if(responseText.getElementsByTagName("type").length>0) {
				c_type=responseText.getElementsByTagName("type")[p].childNodes.item(0).nodeValue;	
			}
			var c_dir;
			if(responseText.getElementsByTagName("dir").length>0) {
				c_dir=responseText.getElementsByTagName("dir")[p].childNodes.item(0).nodeValue;	
			}
			var c_sender;
			if(responseText.getElementsByTagName("sender").length>0) {
				c_sender=responseText.getElementsByTagName("sender")[p].childNodes.item(0).nodeValue;	
			}
			var c_bulk;
			if(responseText.getElementsByTagName("bulk").length>0) {
				c_bulk=responseText.getElementsByTagName("bulk")[p].childNodes.item(0).nodeValue;	
			}
			var c_desc;
			if(responseText.getElementsByTagName("desc").length>0) {
				c_desc=responseText.getElementsByTagName("desc")[p].childNodes.item(0).nodeValue;	
			}
			
			data3+="<tr>"; 
			//data3+="<td class=\"colored\">"+c_id+"</td>";
			//if(c_type=="Email") {
				//data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?corrid="+c_id+"\">"+c_id+"</a></td>";
			//} else {
				//data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+c_id+"\">"+c_id+"</a></td>";
			//}
			data3+="<td class=\"colored\">"+c_type+"</td>";
			data3+="<td class=\"colored\">"+c_dir+"</td>";
			data3+="<td class=\"colored\">"+c_date+"</td>";
			data3+="<td class=\"colored\">"+c_sender+"</td>";
			//data3+="<td class=\"colored\">"+c_bulk+"</td>";
			if(c_type=="Email") {
				data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?corrid="+c_id+"\">"+afkappen(c_desc,100)+"</a></td>";
			} else {
				data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+c_id+"\">"+afkappen(c_desc,100)+"</a></td>";
			}
			//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
			data3+="</tr>"; 
		}
		data3+="</table>";
		document.getElementById("frame8").innerHTML=data3;
	}
function  callbackPropAuthOff( responseText,dat ) {
	count=responseText.getElementsByTagName("correspondence").length;
	//alert(count);
	data3=" <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	data3+="<tr><td colspan=\"10\"><strong>"+tl("theauthorisationagreementandoffer",trl)+"</strong></td></tr>";
	//data3+="<td class=\"txthighlight\">id</td>";
	//data3+=" <td class=\"txthighlight\">Id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("dir",trl)+".</td>";
	data3+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("sender",trl)+"</td>";
	//data3+=" <td class=\"txthighlight\">Bulk</td>";
	data3+=" <td class=\"txthighlight\">"+tl("desc",trl)+".</td>";
	data3+=" </tr>";
	for(p=0; p<count; p++) {
		
		
		
			var c_id;
			if(responseText.getElementsByTagName("cid").length>0) {
				c_id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;	
			}
			var c_date;
			if(responseText.getElementsByTagName("date").length>0) {
				c_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
			}
			var c_type;
			if(responseText.getElementsByTagName("type").length>0) {
				c_type=responseText.getElementsByTagName("type")[p].childNodes.item(0).nodeValue;	
			}
			var c_dir;
			if(responseText.getElementsByTagName("dir").length>0) {
				c_dir=responseText.getElementsByTagName("dir")[p].childNodes.item(0).nodeValue;	
			}
			var c_sender;
			if(responseText.getElementsByTagName("sender").length>0) {
				c_sender=responseText.getElementsByTagName("sender")[p].childNodes.item(0).nodeValue;	
			}
			var c_bulk;
			if(responseText.getElementsByTagName("bulk").length>0) {
				c_bulk=responseText.getElementsByTagName("bulk")[p].childNodes.item(0).nodeValue;	
			}
			var c_desc;
			if(responseText.getElementsByTagName("desc").length>0) {
				c_desc=responseText.getElementsByTagName("desc")[p].childNodes.item(0).nodeValue;	
			}
			
			data3+="<tr>"; 
			//data3+="<td class=\"colored\">"+c_id+"</td>";
			//if(c_type=="Email") {
				//data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?corrid="+c_id+"\">"+c_id+"</a></td>";
			//} else {
				//data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+c_id+"\">"+c_id+"</a></td>";
			//}
			data3+="<td class=\"colored\">"+c_type+"</td>";
			data3+="<td class=\"colored\">"+c_dir+"</td>";
			data3+="<td class=\"colored\">"+c_date+"</td>";
			data3+="<td class=\"colored\">"+c_sender+"</td>";
			//data3+="<td class=\"colored\">"+c_bulk+"</td>";
			if(c_type=="Email") {
				data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?corrid="+c_id+"\">"+afkappen(c_desc,100)+"</a></td>";
			} else {
				data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+c_id+"\">"+afkappen(c_desc,100)+"</a></td>";
			}
			//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
			data3+="</tr>"; 
		}
		data3+="</table>";
		//alert(data3);
		document.getElementById("auth").innerHTML=data3;
	}

function afkappen(str,maxi) {
	if(str!="" && str!=" " && str!="&#160;" && str!="\n" && str!=null) {
		if(str.length<maxi) {
			return str;
		} else {
			return str.substring(0,maxi)+"...";
		}
	}
}


function showLayer5(which) {
	document.getElementById(which).style.visibility="visible";
	informationi('1');
}
function hideLayer(whiche) {
	if(whiche!="") {
		document.getElementById(whiche).style.visibility="hidden";
	}
	//document.getElementById('bd1').style.visibility="hidden";
	//document.getElementById('bd2').style.visibility="hidden";
	//document.getElementById('bd3').style.visibility="hidden";
	
	if(document.getElementById('ir')) {
		document.getElementById('ir').style.visibility="hidden";
	}
}
var http;
function report(deze) {
	countryd=deze.country.value;
	idd=deze.contid.value;
	typed=deze.type.value;
	descd=deze.desc.value;
	/*if (window.XMLHttpRequest)
	  {
			http=new XMLHttpRequest();
		  	http.onreadystatechange=xmlhttpChange;
			http.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/AddGuardInc?country='+countryd+'&guard_id='+idd+'&type='+typed+'&desc='+descd+'');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http=new ActiveXObject("Microsoft.XMLHTTP");
		if (http)
		{
		  	http.onreadystatechange=xmlhttpChange;
			http.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/AddGuardInc?country='+countryd+'&guard_id='+idd+'&type='+typed+'&desc='+descd+'');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }*/
	  typed=escape(typed);
	 descd=escape(descd);
	  data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/AddGuardInc?country='+countryd+'&guard_id='+idd+'&type='+typed+'&desc='+descd+'';
	
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	//alert('http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/AddInc?country='+countryd+'&cont_id='+idd+'&type='+typed+'&desc='+descd+'');
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChange()
{
  switch(http.readyState)
  {
   case 0: reporttxt("get the information"); break;
   case 1: reporttxt("sending message..."); break;
   case 2: reporttxt("message is loaded"); break;
   case 3: reporttxt("get information back"); break;
   case 4: reporttxt("Your message is sent to Camelot!"); break;
   default: reporttxt("new"); break;
  }
}

function reporttxt(txt) {
	document.getElementById("report").innerHTML=txt;	
}

function information(id,country) {
	if (window.XMLHttpRequest)
	  {
			http=new XMLHttpRequest();
		  	http.onreadystatechange=xmlhttpChange2;
			//!omzetten!
			http.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/DocCorr?corr_id='+id+'&country='+country);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http=new ActiveXObject("Microsoft.XMLHTTP");
		if (http)
		{
		  	http.onreadystatechange=xmlhttpChange2;
			//!omzetten!
			http.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/DocCorr?corr_id='+id+'&country='+country);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }
	 
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChange2()
{
  switch(http.readyState)
  {
   case 0: reporttxt2("get the information"); break;
   case 1: reporttxt2("sending message..."); break;
   case 2: reporttxt2("message is loaded"); break;
   case 3: reporttxt2("get information back"); break;
   case 4: reporttxt2("message complete"); break;
   default: reporttxt2("new"); break;
  }
}
var cur="";
//var cur2="";
var stdcur="";
//var stdcur2="";
function reporttxt2(txt) {
	//html=document.getElementById('cd').innerHTML;
	document.getElementById('cd').style.visibility="hidden";
	cur=document.getElementById('wrap').style.cursor;
	//cur2=document.getElementById('cs').style.cursor;
	if(cur!="wait") {
		stdcur=cur;
	}
	//if(cur2!="wait") {
		//stdcur2=cur2;
	//}
	document.getElementById('wrap').style.cursor="wait";
	if(txt=="") {
		//txt=http.responseXML.getElementsByTagName("c_type")[0].childNodes.item(0).nodeValue;
	}
	//if(http) {
		if (http.status == 200) {
			if (http.responseText !="") {
				if (http.responseXML) {
					//
					
					//document.getElementById('cd').innerHTML=html;
					if(http.responseXML.getElementsByTagName("date").length>0) {
						datestring=http.responseXML.getElementsByTagName("date")[0].childNodes.item(0).nodeValue;
						document.getElementById("incident_date").innerHTML=datestring.replace(/[/]/g,"-");
					} else {
						document.getElementById("incident_date").innerHTML="";
					}
					if(http.responseXML.getElementsByTagName("sender").length>0) {
						document.getElementById("incident_sender").innerHTML=http.responseXML.getElementsByTagName("sender")[0].childNodes.item(0).nodeValue;
					} else {
						document.getElementById("incident_sender").innerHTML="";
					}
					if(http.responseXML.getElementsByTagName("recipient").length>0) {
						document.getElementById("incident_recipient").innerHTML=http.responseXML.getElementsByTagName("recipient")[0].childNodes.item(0).nodeValue;
					} else {
						document.getElementById("incident_recipient").innerHTML="";
					}
					if(http.responseXML.getElementsByTagName("type").length>0) {
						document.getElementById("incident_subject").innerHTML=http.responseXML.getElementsByTagName("type")[0].childNodes.item(0).nodeValue;
					} else {
						document.getElementById("incident_subject").innerHTML="";
					}
					if(document.getElementById("incident_body")) {
					if(http.responseXML.getElementsByTagName("desc").length>0) {
						document.getElementById("incident_body").innerHTML=http.responseXML.getElementsByTagName("desc")[0].childNodes.item(0).nodeValue;
					} else {
						document.getElementById("incident_body").innerHTML="";
					}
					}
					//bijlage=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/CorrDoc->binary
					//.gif=gif.php
					//getInformation(x,id,country)
					//id=http.responseXML.getElementsByTagName("cid")[0].childNodes.item(0).nodeValue;
					if(http.responseXML.getElementsByTagName("cid").length>0) {
						cid=http.responseXML.getElementsByTagName("cid")[0].childNodes.item(0).nodeValue;
						document.getElementById("incident_attachments").innerHTML="";
						country=document.getElementById("country").innerHTML;
						getInformation(cid,country);
					}
					
					//aantal=http.responseXML.getElementsByTagName("binary").length;
					//fputs($fp,$binary,strlen($binary));
					tekst="";
					//for(a=0; a<aantal; a++) {
						//t=http.responseXML.getElementsByTagName("d_name")[a].childNodes.item(0).nodeValue;
						//tekst+="<img src=\"/cwa/markup/templates/images/img_pdf.gif\"> <a href=\"/cwa/markup/templates/upload/"+t+"\">"+t+"</a><br/>";
					//}
					/*cd->
					 <a class="closebtn" href="javascript:hideLayer('cd')">X</a>
					  <h2>
						<translate>Correspondence details: Incident</translate>
					  </h2>
					  <table>
						<tr>
						  <td width="116" valign="top"><tl>Date</tl></td>
						  <td width="726" class="colored" id="incident_date" valign="top">16 April, 2007 18:12</td>
						</tr>
						<tr>
						  <td valign="top"><tl>Sender</tl></td>
						  <td class="colored" id="incident_sender" valign="top">Mary Smith </td>
						</tr>
						<tr>
						  <td valign="top"><tl>Recipient</tl></td>
						  <td class="colored" id="incident_recipient" valign="top">Aidan Devlin </td>
						</tr>
						<tr>
						  <td valign="top"><tl>Subject</tl></td>
						  <td class="colored" id="incident_subject" valign="top">Lorem ipsum dolor sit amet ad el dolum dar. Set via alum deos nost atoffu, elem nias diam beas. Arim et alam dias dot nelum! </td>
						</tr>
						<tr>
						  <td valign="top"><tl>Attachment(s)</tl></td>
						  <td class="colored" id="incident_attachments" valign="top"><img src="/cwa/markup/templates/images/img_pdf.gif"> <a href="#">Error report.pdf (184kB)</a></td>
						</tr>
					  </table>*/
					document.getElementById("incident_attachments").innerHTML=tekst;
					document.getElementById('cd').style.visibility="visible";
					if(stdcur!="") {
						document.getElementById('wrap').style.cursor=stdcur;
					} else {
						document.getElementById('wrap').style.cursor="auto";
					}
					//if(stdcur2!="") {
						//document.getElementById('wrap').style.cursor=stdcur2;
					//} else {
						//document.getElementById('wrap').style.cursor="auto";
					//}
				} else {
					//document.getElementById('cd').innerHTML="loading";	
				}
			} else {
				//document.getElementById('cd').innerHTML="loading";	
			}
		}else if (xmlhttp.status == 404) {
			alert("Deze URL bestaat niet!") ;
		}else{    
			alert("De status is "+xmlhttp.status);
		}
	//}
	//document.getElementById("report").innerHTML=txt;	
}

function getInformation(id,country) {
		//i_id=deze.id.value;
		//var prop = document.getElementById("props").value;
		//prop = selectBox.options[selectBox.selectedIndex].value
		//prop=deze.prop_id.options[deze.prop_id.selectedIndex].value;
		
		data=new Array();
		data['id']=id;
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/CorrDoc?country="+country+"&corr_id="+id;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		//alert(url);
		xmlophalen(url,post,'getvets', callbackInformation,data);
		return false;
	}
	
	function getInformationv(id,country) {
		//i_id=deze.id.value;
		//var prop = document.getElementById("props").value;
		//prop = selectBox.options[selectBox.selectedIndex].value
		//prop=deze.prop_id.options[deze.prop_id.selectedIndex].value;
		
		data=new Array();
		data['id']=id;
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/GuardVet?country="+country+"&vet_id="+id;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		//alert(url);
		xmlophalen(url,post,'getvets', callbackInformationv,data);
		return false;
	}


function callbackInformation(responseText,data,text) {
	//alert(text);
	id=data['id'];

		binary=responseText.getElementsByTagName("binary")[0].childNodes.item(0).nodeValue;
		desc=responseText.getElementsByTagName("desc")[0].childNodes.item(0).nodeValue;
		cid=responseText.getElementsByTagName("cid")[0].childNodes.item(0).nodeValue;
		
		encoder="gif";
		desc2=desc.toLowerCase();
		if(desc2.indexOf('.gif')>0) {
			encoder="gif";
		} else if(desc2.indexOf('.doc')>0) {
			encoder="word";
		} else if(desc2.indexOf('.dot')>0) {
			encoder="word";
		} else if(desc2.indexOf('.jpg')>0) {
			encoder="image";
		} else if(desc2.indexOf('.png')>0) {
			encoder="image";
		} else if(desc2.indexOf('.htm')>0) {
			encoder="html";
		}
		document.getElementById("incident_attachments").innerHTML="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/file2.php?fileid="+cid+"\">"+desc+" </a>";
		//<a href=\"http://www.camelotproperty.com/cwa/"+encoder+".php?data="+binary+"\">"+desc+"</a>
}
function callbackInformationv(responseText,data,text) {
	//alert(text);
	id=data['id'];

		binary=responseText.getElementsByTagName("binary")[0].childNodes.item(0).nodeValue;
		desc=responseText.getElementsByTagName("name")[0].childNodes.item(0).nodeValue;
		vid=responseText.getElementsByTagName("vid")[0].childNodes.item(0).nodeValue;
		
		encoder="image";
		desc2=desc.toLowerCase();
		if(desc2.indexOf('.gif')>0) {
			encoder="gif";
		} else if(desc2.indexOf('.doc')>0) {
			encoder="word";		
		} else if(desc2.indexOf('.dot')>0) {
			encoder="word";
		} else if(desc2.indexOf('.jpg')>0) {
			encoder="image";
		} else if(desc2.indexOf('.png')>0) {
			encoder="image";
		}else if(desc2.indexOf('.htm')>0) {
			encoder="html";
		}
		document.getElementById("incident_attachments").innerHTML="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/vet.php?fileid="+vid+"\">"+desc+" </a>";
		//document.getElementById("incident_attachments").innerHTML="<a href=\"http://www.camelotproperty.com/cwa/"+encoder+".php?data="+binary+"\">"+desc+"</a>";
		
}
//transform binary to file
function binarytransform(desc2,binary) {
	encoder="image";
	desc2=desc.toLowerCase();
	if(desc2.indexOf('.gif')>0) {
		encoder="gif";
	} else if(desc2.indexOf('.doc')>0) {
		encoder="word";
	} else if(desc2.indexOf('.dot')>0) {
			encoder="word";
	} else if(desc2.indexOf('.jpg')>0) {
		encoder="image";
	} else if(desc2.indexOf('.png')>0) {
		encoder="image";
	}else if(desc2.indexOf('.htm')>0) {
		encoder="html";
	}
	return "http://www.camelotproperty.com/cwa/"+encoder+".php?data="+binary+"";
}
/*XMLHTTPObject.onreadystatechange=function() {
	if (XMLHTTPObject.readyState==4) {
		terug = XMLHTTPObject.responseText;
	}
}

xmlhttp.onreadystatechange=function(div) { <!-- functie --> }
http://www.quirksmode.org/dom/importxml.html
*/



var http;
function updateinformation(deze) {
	url="";
	countryd=deze.country.value;
	idd=deze.guard_id.value;
	mobiled=deze.mobile.value;
	emaild=deze.email.value;
	sortd=deze.sort2.value;
	accountd=deze.account.value;
	accountnamed=deze.accountname.value;
	bankd=deze.bank.value;
	bankaddrd=deze.bankaddr.value;
	if(deze.post) {
		postd=deze.post.value;
	} else {
		postd="";
	}
	//?country=string&guard_id=string&email=string&mobile=string&accountname=string&sort=string&account=string&bank=string&bankaddr=string&post=string
	//?country=string&guard_id=string&email=string&mobile=string&accountname=string&sort=string&account=string&bank=string&bankaddr=string
	/*if (window.XMLHttpRequest)
	  {
			http=new XMLHttpRequest();
		  	http.onreadystatechange=xmlhttpChangex;
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http=new ActiveXObject("Microsoft.XMLHTTP");
		if (http)
		{
		  	http.onreadystatechange=xmlhttpChangex;	
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }*/
	  
	 emaild=escape(emaild);
	 mobiled=escape(mobiled);
	 accountnamed=escape(accountnamed);
	 sortd=escape(sortd);
	 accountd=escape(accountd);
	 bankd=escape(bankd);
	 bankaddrd=escape(bankaddrd);
	 postd=escape(postd);
	   data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
	
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function termination(deze,prop,user,country) {
	url="";
	d = new Date();
	nu=d;
	if(document.getElementById("t_date")) {
		nu=document.getElementById("t_date").value;
	}
	if(nu+""=="" || nu*1<14) {
		nu=14;
	}
	//var today = new Date();
	//today.setTime(Date.parse(nu));
	//nu2=new Date (nu);
	//alert(today);
	d=timeshift(d,(1000*3600*24*(nu*1)));
	
	/*if (window.XMLHttpRequest)
	  {
			http=new XMLHttpRequest();
		  	http.onreadystatechange=xmlhttpChangex;
			//!omzetten!
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/GuardTerm?country='+country+'&guard_id='+user+'&date='+d.formatDate("YmdHis");
			//alert(url);
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http=new ActiveXObject("Microsoft.XMLHTTP");
		if (http)
		{
		  	http.onreadystatechange=xmlhttpChangex;	
			//!omzetten!
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/GuardTerm?country='+country+'&guard_id='+user+'&date='+d.formatDate("YmdHis");
			//alert(url);
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }*/
	  
	  data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/GuardTerm?country='+country+'&guard_id='+user+'&date='+d.formatDate("Ymd");
		data["url"]=url;	
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function mailafriend(deze,user,countryd) {
	url="";
	rnamed=deze.rname.value;
	emaild=deze.email.value;
	d = new Date();
	/*
	http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ReferFriend
	?country=string&guard_id=string&rname=string&email=string
	*/
	/*if (window.XMLHttpRequest)
	  {
			http=new XMLHttpRequest();
		  	http.onreadystatechange=xmlhttpChangex;
			//!omzetten!
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ReferFriend?country='+countryd+'&guard_id='+user+'&rname='+rnamed+'&email='+emaild;
			//alert(url);
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http=new ActiveXObject("Microsoft.XMLHTTP");
		if (http)
		{
		  	http.onreadystatechange=xmlhttpChangex;	
			//!omzetten!
			url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ReferFriend?country='+countryd+'&guard_id='+user+'&rname='+rnamed+'&email='+emaild;
			//alert(url);
			http.open('get', url);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }*/
	  rnamed=escape(rnamed);
	 emaild=escape(emaild);
	  data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ReferFriend?country='+countryd+'&guard_id='+user+'&rname='+rnamed+'&email='+emaild;
					
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChangenew(responseText,b,c)
{
	if(usertype=="g" || usertypeid==2) {
		manager="guardian";
	} else {
		manager="client";
	}
	//uit vertaal tabel halen!
	//alert("Your message is sent!");
	response=responseText.getElementsByTagName("Result")[0].childNodes.item(0).nodeValue;	
	if(response=="OK") {
  		reporttxt(tl("sending_complete",trl));
	} else {
		 reporttxt("An error has occurred while sending the information. If trying again fails, please contact your "+manager+" manager.");
	}
}

function xmlhttpChangex()
{
  switch(http.readyState)
  {
   case 0: reporttxt("get the information"); break;
   case 1: reporttxt("sending message..."); break;
   case 2: reporttxt("message is loaded"); break;
   case 3: reporttxt("get information back"); break;
   case 4: reporttxt("Your message is sent to Camelot!"); break;
   default: reporttxt("new"); break;
  }
}

function reporttxtx(txt) {
	document.getElementById("report").innerHTML=txt;	
}

var http;
function updateinformation2(deze) {
	url="";
	alerttekst="";
	countryd=deze.country.value;
	if(countryd=="") {
		alerttekst+="1\n";
	}
	idd=deze.client_id.value;
	if(idd=="") {
		alerttekst+="2\n";	
	}
	phoned=deze.phone.value;
	if(phoned=="") {
		alerttekst+=deze.phone.name+"\n";	
	}
	faxd=deze.fax.value;
	if(faxd=="") {
		alerttekst+=deze.fax.name+"\n";	
	}
	emaild=deze.email.value;
	if(emaild=="") {
		alerttekst+=deze.email.name+"\n";	
	}
	//mobiled="";
	mobiled=deze.mobile.value;
	if(mobiled=="") {
		alerttekst+=deze.mobile.name+"\n";	
	}
	//jobd="";
	jobd=deze.job.value;
	if(jobd=="") {
		alerttekst+=deze.job.name+"\n";	
	}
	coid=deze.co_id.value;
	//if(alerttekst!="") {
		//alerttekst="Vul de volgende gegevens in\n"+alerttekst;
		//alert(alerttekst);	
	//} else {
		//sortd=deze.sort2.value;
		//accountd=deze.account.value;
		//accountnamed=deze.accountname.value;
		/*if (window.XMLHttpRequest)
		  {
				http=new XMLHttpRequest();
				http.onreadystatechange=xmlhttpChangex2;
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+countryd+'&cont_id='+idd+'&phone='+phoned+'&fax='+faxd+'&email='+emaild+'&mobile='+mobiled+'&job='+jobd+'';
				http.open('get', url);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.send(null);
		  }
		else if (window.ActiveXObject)
		  {
		  http=new ActiveXObject("Microsoft.XMLHTTP");
			if (http)
			{
				http.onreadystatechange=xmlhttpChangex2;	
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+countryd+'&cont_id='+idd+'&phone='+phoned+'&fax='+faxd+'&email='+emaild+'&mobile='+mobiled+'&job='+jobd+'';
				http.open('get', url);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.send(null);
			}
		  }
		  else
		  {
			tekst("Your browser cannot handle this script");
		  }*/
	phoned=escape(phoned);
	 faxd=escape(faxd);
	 emaild=escape(emaild);
	 mobiled=escape(mobiled);
	 jobd=escape(jobd);
	 
		   data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+countryd+'&cont_id='+idd+'&phone='+phoned+'&fax='+faxd+'&email='+emaild+'&mobile='+mobiled+'&job='+jobd+'';
						
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	
	//bank_accountname
	bank_accountname=deze.bank_accountname.value;
	bank_accountname=escape(bank_accountname);
	//bank_sort
	bank_sort=deze.bank_sort.value;
	bank_sort=escape(bank_sort);
	//bank_account
	bank_account=deze.bank_account.value;
	bank_account=escape(bank_account);
	//bank
	bank=deze.bank.value;
	bank=escape(bank);
	//bank_addr
	bank_addr=deze.bank_addr.value;
	bank_addr=escape(bank_addr);
	//bank_post
	bank_post=deze.bank_post.value;
	bank_post=escape(bank_post);
	
	url2='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCompBank?country='+countryd+'&comp_id='+coid+'&cont_id='+idd+'&accountname='+bank_accountname+'&sort='+bank_sort+'&account='+bank_account+'&bank='+bank+'&bankaddr='+bank_addr+'&post='+bank_post;
			
	url2="http://www.camelotproperty.com/cwa/extern.php?file="+url2;
	post=null;
	//alert(url);
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets2', xml3,data);
	//}
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xml3(a,b) {
	
}

function xmlhttpChangex2()
{
  switch(http.readyState)
  {
   case 0: reporttxtx2("get the information"); break;
   case 1: reporttxtx2("sending message..."); break;
   case 2: reporttxtx2("message is loaded"); break;
   case 3: reporttxtx2("get information back"); break;
   case 4: reporttxtx2("Your message is sent to Camelot!"); break;
   default: reporttxtx2("new"); break;
  }
}

function reporttxtx2(txt) {
	document.getElementById("report").innerHTML=txt;	
}





var http3;
function information3(id,country) {
	/*if (window.XMLHttpRequest)
	  {
			http3=new XMLHttpRequest();
		  	http3.onreadystatechange=xmlhttpChange3;
			//!omzetten!
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ContDets?country='+country+'&cont_id='+id);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http3=new ActiveXObject("Microsoft.XMLHTTP");
		if (http3)
		{
		  	http3.onreadystatechange=xmlhttpChange3;
			//!omzetten!
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ContDets?country='+country+'&cont_id='+id);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }*/ 
	  data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/ContDets?country='+country+'&cont_id='+id;
						
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	xmlophalen(url,post,'getvets', reporttxt3,data);
	 
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChange3()
{
  switch(http3.readyState)
  {
   case 0: reporttxt3("get the information",http3); break;
   case 1: reporttxt3("sending message...",http3); break;
   case 2: reporttxt3("message is loaded",http3); break;
   case 3: reporttxt3("get information back",http3); break;
   case 4: reporttxt3("message complete",http3); break;
   default: reporttxt3("new",http3); break;
  }
}

function reporttxt3(http3,data,httptxt) {
	document.getElementById("report").innerHTML="";	
	document.getElementById('cd').style.visibility="hidden";
	
	//if(txt=="") {
		//txt=http.responseXML.getElementsByTagName("c_type")[0].childNodes.item(0).nodeValue;
	//}
		/*
			c_country
			c_id
			c_job
			c_email
			c_phone
			c_fax
			c_mobile
		*/
	//if(txt=="message complete") {	
		if(document.getElementById("c_id")) {
			document.getElementById("c_id").value="";
		}
		if(http3.getElementsByTagName("c_id").length>0) {
			//alert("!");
			document.getElementById("c_id").value=http3.getElementsByTagName("c_id")[0].childNodes.item(0).nodeValue;
			//alert(http3.getElementsByTagName("c_id")[0].childNodes.item(0).nodeValue);
		} else if(document.getElementById("c_id").length==1) {
			document.getElementById("c_id").value="";
		}
		
		document.getElementById("c_firstname").innerHTML="";
		if(http3.getElementsByTagName("c_fname").length>0) {
			document.getElementById("c_firstname").innerHTML=http3.getElementsByTagName("c_fname")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_firstname").length==1) {
			document.getElementById("c_firstname").innerHTML="";
		}
		document.getElementById("c_mname").innerHTML="";
		if(http3.getElementsByTagName("c_mname").length>0) {
			document.getElementById("c_mname").innerHTML=http3.getElementsByTagName("c_mname")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_mname").length==1) {
			document.getElementById("c_mname").innerHTML="";
		}
		document.getElementById("c_lastname").innerHTML="";
		if(http3.getElementsByTagName("c_lname").length>0) {
			document.getElementById("c_lastname").innerHTML=http3.getElementsByTagName("c_lname")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_lastname").length==1) {
			document.getElementById("c_lastname").innerHTML="";
		}
		if(document.getElementById("c_completename")) {
			document.getElementById("c_completename").innerHTML="";
			if(http3.getElementsByTagName("c_fname").length>0 && http3.getElementsByTagName("c_lname").length>0) {
				document.getElementById("c_completename").innerHTML=http3.getElementsByTagName("c_fname")[0].childNodes.item(0).nodeValue+" "+http3.getElementsByTagName("c_lname")[0].childNodes.item(0).nodeValue;
			} else if(document.getElementById("c_completename").length==1) {
				document.getElementById("c_completename").innerHTML="";
			}
		}
		
		
		//document.getElementById("c_id").innerHTML=http3.getElementsByTagName("c_id")[0].childNodes.item(0).nodeValue;
		document.getElementById("c_job").innerHTML="";
		if(http3.getElementsByTagName("c_job").length>0) {
			document.getElementById("c_job").innerHTML=http3.getElementsByTagName("c_job")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_job").length==1) {
			document.getElementById("c_job").innerHTML="";
		}
		document.getElementById("c_email").innerHTML="";
		if(http3.getElementsByTagName("c_email").length>0) {
			document.getElementById("c_email").innerHTML=http3.getElementsByTagName("c_email")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_email").length==1) {
			document.getElementById("c_email").innerHTML="";
		}
		document.getElementById("c_phone").innerHTML="";
		if(http3.getElementsByTagName("c_phone").length>0) {
			document.getElementById("c_phone").innerHTML=http3.getElementsByTagName("c_phone")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_phone").length==1) {
			document.getElementById("c_phone").innerHTML="";
		}
		document.getElementById("c_fax").innerHTML="";
		if(http3.getElementsByTagName("c_fax").length>0) {
			document.getElementById("c_fax").innerHTML=http3.getElementsByTagName("c_fax")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_fax").length==1) {
			document.getElementById("c_fax").innerHTML="";
		}
		
		document.getElementById("c_mobile").innerHTML="";
		if(http3.getElementsByTagName("c_mobile").length>0) {
			document.getElementById("c_mobile").innerHTML=http3.getElementsByTagName("c_mobile")[0].childNodes.item(0).nodeValue;
		} else if(document.getElementById("c_mobile").length==1) {
			document.getElementById("c_mobile").innerHTML="";
		}
	
	
	
	
	
	
	document.getElementById('cd').style.visibility="visible";
	
	//}
	
	document.getElementById("report").innerHTML="";	
}

function updateinformation3g(deze) {
	//update guardians?
	//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
	url="";
	alerttekst="";
	countryd=deze.country.value;
	idd=deze.guard_id.value;
	mobiled=deze.mobile.value;
	emaild=deze.email.value;
	sortd=deze.sort2.value;
	accountd=deze.account.value;
	accountnamed=deze.accountname.value;
	bankd=deze.bank.value;
	bankaddrd=deze.bankaddr.value;
	ccountry=deze.c_country.value;
	if(ccountry=="") {
		alerttekst+="country\n";	
	}
	cid=deze.c_id.value;
	if(cid=="") {
		alerttekst+="id\n";	
	}
	cphone=deze.phone.value;
	if(cphone=="") {
		alerttekst+=deze.phone.name+"\n";	
	}
	cfax=deze.fax.value;
	if(cfax=="") {
		alerttekst+=deze.fax.name+"\n";	
	}
	cemail=deze.email.value;
	if(cemail=="") {
		alerttekst+=deze.email.name+"\n";	
	}
	cmobile=deze.mobile.value;
	if(cmobile=="") {
		alerttekst+=deze.mobile.name+"\n";	
	}
	cjob=deze.job.value;
	if(cjob=="") {
		alerttekst+=deze.job.name+"\n";	
	}
	if(country!="") {
		countryd=country;
	}
	if(cid!="") {
		idd=cid;
	}
	if(cemail!="") {
		emaild=cemail;
	}
	if(cmobile!="") {
		mobiled=cmobile;
	}
	//ccountnamed="";
	//sortd="";
	//accountd="";
	//bankd="";
	//bankaddrd="";
	//postd="";
	//if(alerttekst!="") {
		//alerttekst="Vul de volgende gegevens in\n"+alerttekst;
		//alert(alerttekst);	
	//} else {
		//sortd=deze.sort2.value;
		//accountd=deze.account.value;
		//accountnamed=deze.accountname.value;
		if (window.XMLHttpRequest)
		  {
				http3=new XMLHttpRequest();
				http3.onreadystatechange=xmlhttpChangex4;
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+ccountry+'&cont_id='+cid+'&phone='+cphone+'&fax='+cfax+'&email='+cemail+'&mobile='+cmobile+'&job='+cjob+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
				http3.open('get', url);
				http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http3.send(null);
		  }
		else if (window.ActiveXObject)
		  {
		  http3=new ActiveXObject("Microsoft.XMLHTTP");
			if (http3)
			{
				http3.onreadystatechange=xmlhttpChangex4;	
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+ccountry+'&cont_id='+cid+'&phone='+cphone+'&fax='+cfax+'&email='+cemail+'&mobile='+cmobile+'&job='+cjob+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'&bank='+bankd+'&bankaddr='+bankaddrd+'&post='+postd;
				http3.open('get', url);
				http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http3.send(null);
			}
		  }
		  else
		  {
			tekst("Your browser cannot handle this script");
		  }
	//}
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function updateinformation3(deze) {
	url="";
	alerttekst="";
	ccountry=deze.c_country.value;
	if(ccountry=="") {
		alerttekst+="country\n";	
	}
	cid=deze.c_id.value;
	if(cid=="") {
		alerttekst+="id\n";	
	}
	cphone=deze.phone.value;
	if(cphone=="") {
		alerttekst+=deze.phone.name+"\n";	
	}
	cfax=deze.fax.value;
	if(cfax=="") {
		alerttekst+=deze.fax.name+"\n";	
	}
	cemail=deze.email.value;
	if(cemail=="") {
		alerttekst+=deze.email.name+"\n";	
	}
	cmobile=deze.mobile.value;
	if(cmobile=="") {
		alerttekst+=deze.mobile.name+"\n";	
	}
	cjob=deze.job.value;
	if(cjob=="") {
		alerttekst+=deze.job.name+"\n";	
	}
	//if(alerttekst!="") {
		//alerttekst="Vul de volgende gegevens in\n"+alerttekst;
		//alert(alerttekst);	
	//} else {
		//sortd=deze.sort2.value;
		//accountd=deze.account.value;
		//accountnamed=deze.accountname.value;
		/*if (window.XMLHttpRequest)
		  {
				http3=new XMLHttpRequest();
				http3.onreadystatechange=xmlhttpChangex4;
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+ccountry+'&cont_id='+cid+'&phone='+cphone+'&fax='+cfax+'&email='+cemail+'&mobile='+cmobile+'&job='+cjob+'';
				http3.open('get', url);
				http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http3.send(null);
		  }
		else if (window.ActiveXObject)
		  {
		  http3=new ActiveXObject("Microsoft.XMLHTTP");
			if (http3)
			{
				http3.onreadystatechange=xmlhttpChangex4;	
				//url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateGuard?country='+countryd+'&guard_id='+idd+'&email='+emaild+'&mobile='+mobiled+'&accountname='+accountnamed+'&sort='+sortd+'&account='+accountd+'';
				url='http://www.camelotproperty.com/cwa/extern.php?file=http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+ccountry+'&cont_id='+cid+'&phone='+cphone+'&fax='+cfax+'&email='+cemail+'&mobile='+cmobile+'&job='+cjob+'';
				http3.open('get', url);
				http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http3.send(null);
			}
		  }
		  else
		  {
			tekst("Your browser cannot handle this script");
		  }*/
			cphone=escape(cphone);
			cfax=escape(cfax);
			cemail=escape(cemail);
			cmobile=escape(cmobile);
			cjob=escape(cjob);
		   data=new Array();
	url='http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/UpdateCont?country='+ccountry+'&cont_id='+cid+'&phone='+cphone+'&fax='+cfax+'&email='+cemail+'&mobile='+cmobile+'&job='+cjob+'';
								
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	hideLayer('cd');
	reporttxt(tl("sending_information",trl));
	xmlophalen(url,post,'getvets', xmlhttpChangenew,data);
	//}
	//alert("."+url);
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChangex4()
{
  switch(http3.readyState)
  {
   case 0: reporttxtx3("get the information"); break;
   case 1: reporttxtx3("sending message..."); break;
   case 2: reporttxtx3("message is loaded"); break;
   case 3: reporttxtx3("get information back"); break;
   case 4: reporttxtx3("Your message is sent to Camelot!"); hideLayer('cd'); break;
   default: reporttxtx3("new"); break;
  }
}

function reporttxtx3(txt) {
	document.getElementById("report").innerHTML=txt;	
}





//buildinglist


function informationb(id) {
	if (window.XMLHttpRequest)
	  {
			http3=new XMLHttpRequest();
		  	http3.onreadystatechange=xmlhttpChangeb;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropDets?country="+country+"&prop_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http3=new ActiveXObject("Microsoft.XMLHTTP");
		if (http3)
		{
		  	http3.onreadystatechange=xmlhttpChangeb;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropDets?country="+country+"&prop_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }
	 
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChangeb()
{
  switch(http3.readyState)
  {
   case 0: reporttxtb("get the information",http3); break;
   case 1: reporttxtb("sending message...",http3); break;
   case 2: reporttxtb("message is loaded",http3); break;
   case 3: reporttxtb("get information back",http3); break;
   case 4: reporttxtb("message complete",http3); break;
   default: reporttxtb("new",http3); break;
  }
}

function reporttxtb(txt,http3) {
	//alert("!"+txt);
	document.getElementById('bd').style.visibility="hidden";
	if(txt=="") {
		//txt=http.responseXML.getElementsByTagName("c_type")[0].childNodes.item(0).nodeValue;
	}
	if(txt=="message complete") {	
		//document.getElementById("p_id").innerHTML=http3.responseXML.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr1").innerHTML=http3.responseXML.getElementsByTagName("p_addr1")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr2").innerHTML=http3.responseXML.getElementsByTagName("p_addr2")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr3").innerHTML=http3.responseXML.getElementsByTagName("p_addr3")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_town").innerHTML=http3.responseXML.getElementsByTagName("p_town")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_count").innerHTML=http3.responseXML.getElementsByTagName("p_count")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_code").innerHTML=http3.responseXML.getElementsByTagName("p_code")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_max").innerHTML=http3.responseXML.getElementsByTagName("p_max")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_type").innerHTML=http3.responseXML.getElementsByTagName("p_type")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_status").innerHTML=http3.responseXML.getElementsByTagName("p_status")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_date").innerHTML=http3.responseXML.getElementsByTagName("p_date")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_photo").innerHTML=http3.responseXML.getElementsByTagName("p_photo")[0].childNodes.item(0).nodeValue;
		
	document.getElementById('bd').style.visibility="visible";	
	//hideLayer('bd1');
	//hideLayer('bd2');	
	//hideLayer('bd3');	
	hideLayer('ir');
	}
	
	document.getElementById("report").innerHTML=txt;
}


var pastframe=0;
var frametabs=new Array();
var frametab=0;

/*
	zie ajax voor cookie functie om te onthouden welke item bij welke tab was
*/

function showframe(a) {
	frametab=a;
	if(!frametabs[a] || frametabs[a]=="" || frametabs[a]<1) {
		switchtoframe('1',a);
	} else {
		switchtoframe(frametabs[a],a);
	}
	document.getElementById('nr').innerHTML=a;
	document.getElementById('bd').style.display="block";
	document.getElementById('bd').style.visibility="visible";
}

function hideframe() {
	document.getElementById('bd').style.display="none";
	document.getElementById('bd').style.visibility="hidden";
}

function switchtoframe(a,b) {
	if(b>0) {
		waarde=frametabs[b];
		frametabs[b]=a;
		frametab=b;
	} else {
		waarde=frametabs[frametab];
		frametabs[frametab]=a;
	}
	document.getElementById('frame'+a).style.display="block";
	document.getElementById('tab'+a).className="tabselected";
	if(pastframe!=a && pastframe>0) {
		document.getElementById('frame'+pastframe).style.display="none";
		document.getElementById('tab'+pastframe).className="tab";
	}
	pastframe=a;
}

/*
	//http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/IncidentDets?country=string&inc_id=string
	
*/
function informationi(id) {
	if (window.XMLHttpRequest)
	  {
			http3=new XMLHttpRequest();
		  	http3.onreadystatechange=xmlhttpChangei;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/IncidentDets?country="+country+"&inc_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http3=new ActiveXObject("Microsoft.XMLHTTP");
		if (http3)
		{
		  	http3.onreadystatechange=xmlhttpChangei;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/IncidentDets?country="+country+"&inc_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }
	 
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChangei()
{
  switch(http3.readyState)
  {
   case 0: reporttxti("get the information",http3); break;
   case 1: reporttxti("sending message...",http3); break;
   case 2: reporttxti("message is loaded",http3); break;
   case 3: reporttxti("get information back",http3); break;
   case 4: reporttxti("message complete",http3); break;
   default: reporttxti("new",http3); break;
  }
}

function reporttxti(txt,http3) {
	//alert("!"+txt);
	showLayer3('ir');
	document.getElementById('ir').style.visibility="hidden";
	if(txt=="") {
		//txt=http.responseXML.getElementsByTagName("c_type")[0].childNodes.item(0).nodeValue;
	}
	if(txt=="message complete") {	
		//document.getElementById("p_id").innerHTML=http3.responseXML.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_id").innerHTML=http3.responseXML.getElementsByTagName("i_id")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_date").innerHTML=http3.responseXML.getElementsByTagName("i_date")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_urg").innerHTML=http3.responseXML.getElementsByTagName("i_urg")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_res").innerHTML=http3.responseXML.getElementsByTagName("i_res")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_rep").innerHTML=http3.responseXML.getElementsByTagName("i_rep")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_type").innerHTML=http3.responseXML.getElementsByTagName("i_type")[0].childNodes.item(0).nodeValue;
		//document.getElementById("i_prop").innerHTML=http3.responseXML.getElementsByTagName("p_max")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_desc").innerHTML=http3.responseXML.getElementsByTagName("i_desc")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_exp_res").innerHTML=http3.responseXML.getElementsByTagName("i_exp_res")[0].childNodes.item(0).nodeValue;
		document.getElementById("i_status").innerHTML=http3.responseXML.getElementsByTagName("i_status")[0].childNodes.item(0).nodeValue;
		aantalactions=http3.responseXML.getElementsByTagName("Action").length;
		actionstekst="<ul>";
		for(a=0; a<aantalactions; a++) {
			a_id=http3.responseXML.getElementsByTagName("Action")[a].getElementsByTagName("a_id")[0].childNodes.item(0).nodeValue;
			a_type=http3.responseXML.getElementsByTagName("Action")[a].getElementsByTagName("a_type")[0].childNodes.item(0).nodeValue;
			a_desc=http3.responseXML.getElementsByTagName("Action")[a].getElementsByTagName("a_desc")[0].childNodes.item(0).nodeValue;
			actionstekst+="<li>"+a_desc+"</li>";
		}
		actionstekst+="</ul>";
		document.getElementById("i_actions").innerHTML=actionstekst;
		
	document.getElementById('ir').style.visibility="visible";	
	//hideLayer('bd1');
	//hideLayer('bd2');	
	//hideLayer('bd3');	
	//hideLayer('ir');
	}
	
	document.getElementById("report").innerHTML=txt;
}









function PropPhotos(id) {
	if (window.XMLHttpRequest)
	  {
			http3=new XMLHttpRequest();
		  	http3.onreadystatechange=xmlhttpChangep;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropDets?country="+country+"&prop_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
	  }
	else if (window.ActiveXObject)
	  {
	  http3=new ActiveXObject("Microsoft.XMLHTTP");
		if (http3)
		{
		  	http3.onreadystatechange=xmlhttpChangep;
			//!omzetten!
			url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/PropDets?country="+country+"&prop_id="+id;
			http3.open('get', 'http://www.camelotproperty.com/cwa/extern.php?file='+url);
			http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http3.send(null);
		}
	  }
	  else
	  {
		tekst("Your browser cannot handle this script");
	  }
	 
	//alert(deze.desc.value);
	//http.send('country=5&guard_id=1183&email=string&mobile=string&accountname=string&sort=string&account=string');
	return false;	
}

function xmlhttpChangep()
{
  switch(http3.readyState)
  {
   case 0: reporttxtp("get the information",http3); break;
   case 1: reporttxtp("sending message...",http3); break;
   case 2: reporttxtp("message is loaded",http3); break;
   case 3: reporttxtp("get information back",http3); break;
   case 4: reporttxtp("message complete",http3); break;
   default: reporttxtp("new",http3); break;
  }
}

function reporttxtp(txt,http3) {
	//alert("!"+txt);
	document.getElementById('bd').style.visibility="hidden";
	if(txt=="") {
		//txt=http.responseXML.getElementsByTagName("c_type")[0].childNodes.item(0).nodeValue;
	}
	if(txt=="message complete") {	
		//document.getElementById("p_id").innerHTML=http3.responseXML.getElementsByTagName("p_id")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr1").innerHTML=http3.responseXML.getElementsByTagName("p_addr1")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr2").innerHTML=http3.responseXML.getElementsByTagName("p_addr2")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_addr3").innerHTML=http3.responseXML.getElementsByTagName("p_addr3")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_town").innerHTML=http3.responseXML.getElementsByTagName("p_town")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_count").innerHTML=http3.responseXML.getElementsByTagName("p_count")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_code").innerHTML=http3.responseXML.getElementsByTagName("p_code")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_max").innerHTML=http3.responseXML.getElementsByTagName("p_max")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_type").innerHTML=http3.responseXML.getElementsByTagName("p_type")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_status").innerHTML=http3.responseXML.getElementsByTagName("p_status")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_date").innerHTML=http3.responseXML.getElementsByTagName("p_date")[0].childNodes.item(0).nodeValue;
		document.getElementById("p_photo").innerHTML=http3.responseXML.getElementsByTagName("p_photo")[0].childNodes.item(0).nodeValue;
		
	document.getElementById('bd').style.visibility="visible";	
	//hideLayer('bd1');
	//hideLayer('bd2');	
	//hideLayer('bd3');	
	hideLayer('ir');
	}
	
	document.getElementById("report").innerHTML=txt;
}


// formatDate :
// a PHP date like function, for formatting date strings
// authored by Svend Tofte <www.svendtofte.com>
// the code is in the public domain
//
// see http://www.svendtofte.com/code/date_format/
// and http://www.php.net/date
//
// thanks to 
//  - Daniel Berlin <mail@daniel-berlin.de>,
//    major overhaul and improvements
//  - Matt Bannon,
//    correcting some stupid bugs in my days-in-the-months list!
//
// input : format string
// time : epoch time (seconds, and optional)
//
// if time is not passed, formatting is based on 
// the current "this" date object's set time.
//
// supported switches are
// a, A, B, c, d, D, F, g, G, h, H, i, I (uppercase i), j, l (lowecase L), 
// L, m, M, n, N, O, P, r, s, S, t, U, w, W, y, Y, z, Z
// 
// unsupported (as compared to date in PHP 5.1.3)
// T, e, o



function gendatelist() {
   html="";
	m="";
	for(a=0;a<90; a++) {
		d = new Date();
		d=timeshift(d,(1000*3600*24*(a+14)));
		k=d.formatDate("Y-m-d");
		mn=d.formatDate("m");
		//monthnumber = now.formatDate("m");
  		//monthname   = months[(monthnumber*1)];
		if(m!=mn) {
			if(a>0) {
				html+="</OPTGROUP>";
			}
			html+="<OPTGROUP LABEL=\"&#160;\">";
		}
		m=d.formatDate("m");
		html+="<option value=\""+(a+14)+"\">"+k+"</option>";
		
		document.getElementById("t_date").options[a] =new Option(k+"",(a+14));
	}	
	html+="</OPTGROUP>";
	//document.getElementById("t_date").innerHTML=html;
}

function timeshift(date,plus) {
	date.setTime(date.getTime()+(plus)); 
	return date;	
}

Date.prototype.formatDate = function (input,time) {
    
    var daysLong =    ["Sunday", "Monday", "Tuesday", "Wednesday", 
                       "Thursday", "Friday", "Saturday"];
    var daysShort =   ["Sun", "Mon", "Tue", "Wed", 
                       "Thu", "Fri", "Sat"];
    var monthsShort = ["Jan", "Feb", "Mar", "Apr",
                       "May", "Jun", "Jul", "Aug", "Sep",
                       "Oct", "Nov", "Dec"];
    var monthsLong =  ["January", "February", "March", "April",
                       "May", "June", "July", "August", "September",
                       "October", "November", "December"];

    var switches = { // switches object
        
        a : function () {
            // Lowercase Ante meridiem and Post meridiem
            return date.getHours() > 11? "pm" : "am";
        },
        
        A : function () {
            // Uppercase Ante meridiem and Post meridiem
            return (this.a().toUpperCase ());
        },
    
        B : function (){
            // Swatch internet time. code simply grabbed from ppk,
            // since I was feeling lazy:
            // http://www.xs4all.nl/~ppk/js/beat.html
            var off = (date.getTimezoneOffset() + 60)*60;
            var theSeconds = (date.getHours() * 3600) + 
                             (date.getMinutes() * 60) + 
                              date.getSeconds() + off;
            var beat = Math.floor(theSeconds/86.4);
            if (beat > 1000) beat -= 1000;
            if (beat < 0) beat += 1000;
            if ((String(beat)).length == 1) beat = "00"+beat;
            if ((String(beat)).length == 2) beat = "0"+beat;
            return beat;
        },
        
        c : function () {
            // ISO 8601 date (e.g.: "2004-02-12T15:19:21+00:00"), as per
            // http://www.cl.cam.ac.uk/~mgk25/iso-time.html
            return (this.Y() + "-" + this.m() + "-" + this.d() + "T" + 
                    this.h() + ":" + this.i() + ":" + this.s() + this.P());
        },
        
        d : function () {
            // Day of the month, 2 digits with leading zeros
            var j = String(this.j());
            return (j.length == 1 ? "0"+j : j);
        },
        
        D : function () {
            // A textual representation of a day, three letters
            return daysShort[date.getDay()];
        },
        
        F : function () {
            // A full textual representation of a month
            return monthsLong[date.getMonth()];
        },
        
        g : function () {
            // 12-hour format of an hour without leading zeros
            return date.getHours() > 12? date.getHours()-12 : date.getHours();
        },
        
        G : function () {
            // 24-hour format of an hour without leading zeros
            return date.getHours();
        },
        
        h : function () {
            // 12-hour format of an hour with leading zeros
            var g = String(this.g());
            return (g.length == 1 ? "0"+g : g);
        },
        
        H : function () {
            // 24-hour format of an hour with leading zeros
            var G = String(this.G());
            return (G.length == 1 ? "0"+G : G);
        },
        
        i : function () {
            // Minutes with leading zeros
            var min = String (date.getMinutes ());
            return (min.length == 1 ? "0" + min : min);
        },
        
        I : function () {
            // Whether or not the date is in daylight saving time (DST)
            // note that this has no bearing in actual DST mechanics,
            // and is just a pure guess. buyer beware.
            var noDST = new Date ("January 1 " + this.Y() + " 00:00:00");
            return (noDST.getTimezoneOffset () == 
                    date.getTimezoneOffset () ? 0 : 1);
        },
        
        j : function () {
            // Day of the month without leading zeros
            return date.getDate();
        },
        
        l : function () {
            // A full textual representation of the day of the week
            return daysLong[date.getDay()];
        },
        
        L : function () {
            // leap year or not. 1 if leap year, 0 if not.
            // the logic should match iso's 8601 standard.
            // http://www.uic.edu/depts/accc/software/isodates/leapyear.html
            var Y = this.Y();
            if (         
                (Y % 4 == 0 && Y % 100 != 0) ||
                (Y % 4 == 0 && Y % 100 == 0 && Y % 400 == 0)
                ) {
                return 1;
            } else {
                return 0;
            }
        },
        
        m : function () {
            // Numeric representation of a month, with leading zeros
            var n = String(this.n());
            return (n.length == 1 ? "0"+n : n);
        },
        
        M : function () {
            // A short textual representation of a month, three letters
            return monthsShort[date.getMonth()];
        },
        
        n : function () {
            // Numeric representation of a month, without leading zeros
            return date.getMonth()+1;
        },
        
        N : function () {
            // ISO-8601 numeric representation of the day of the week
            var w = this.w();
            return (w == 0 ? 7 : w);
        },
        
        O : function () {
            // Difference to Greenwich time (GMT) in hours
            var os = Math.abs(date.getTimezoneOffset());
            var h = String(Math.floor(os/60));
            var m = String(os%60);
            h.length == 1? h = "0"+h:1;
            m.length == 1? m = "0"+m:1;
            return date.getTimezoneOffset() < 0 ? "+"+h+m : "-"+h+m;
        },
        
        P : function () {
            // Difference to GMT, with colon between hours and minutes
            var O = this.O();
            return (O.substr(0, 3) + ":" + O.substr(3, 2));
        },      
        
        r : function () {
            // RFC 822 formatted date
            var r; // result
            //  Thu         ,     21               Dec              2000
            r = this.D() + ", " + this.d() + " " + this.M() + " " + this.Y() +
            //    16          :    01          :    07               0200
            " " + this.H() + ":" + this.i() + ":" + this.s() + " " + this.O();
            return r;
        },

        s : function () {
            // Seconds, with leading zeros
            var sec = String (date.getSeconds ());
            return (sec.length == 1 ? "0" + sec : sec);
        },        
        
        S : function () {
            // English ordinal suffix for the day of the month, 2 characters
            switch (date.getDate ()) {
                case  1: return ("st"); 
                case  2: return ("nd"); 
                case  3: return ("rd");
                case 21: return ("st"); 
                case 22: return ("nd"); 
                case 23: return ("rd");
                case 31: return ("st");
                default: return ("th");
            }
        },
        
        t : function () {
            // thanks to Matt Bannon for some much needed code-fixes here!
            var daysinmonths = [null,31,28,31,30,31,30,31,31,30,31,30,31];
            if (this.L()==1 && this.n()==2) return 29; // ~leap day
            return daysinmonths[this.n()];
        },
        
        U : function () {
            // Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
            return Math.round(date.getTime()/1000);
        },

        w : function () {
            // Numeric representation of the day of the week
            return date.getDay();
        },
        
        W : function () {
            // Weeknumber, as per ISO specification:
            // http://www.cl.cam.ac.uk/~mgk25/iso-time.html
        
            var DoW = this.N ();
            var DoY = this.z ();

            // If the day is 3 days before New Year's Eve and is Thursday or earlier,
            // it's week 1 of next year.
            var daysToNY = 364 + this.L () - DoY;
            if (daysToNY <= 2 && DoW <= (3 - daysToNY)) {
                return 1;
            }

            // If the day is within 3 days after New Year's Eve and is Friday or later,
            // it belongs to the old year.
            if (DoY <= 2 && DoW >= 5) {
                return new Date (this.Y () - 1, 11, 31).formatDate ("W");
            }
            
            var nyDoW = new Date (this.Y (), 0, 1).getDay ();
            nyDoW = nyDoW != 0 ? nyDoW - 1 : 6;

            if (nyDoW <= 3) { // First day of the year is a Thursday or earlier
                return (1 + Math.floor ((DoY + nyDoW) / 7));
            } else {  // First day of the year is a Friday or later
                return (1 + Math.floor ((DoY - (7 - nyDoW)) / 7));
            }
        },
        
        y : function () {
            // A two-digit representation of a year
            var y = String(this.Y());
            return y.substring(y.length-2,y.length);
        },        
        
        Y : function () {
            // A full numeric representation of a year, 4 digits
    
            // we first check, if getFullYear is supported. if it
            // is, we just use that. ppks code is nice, but wont
            // work with dates outside 1900-2038, or something like that
            if (date.getFullYear) {
                var newDate = new Date("January 1 2001 00:00:00 +0000");
                var x = newDate .getFullYear();
                if (x == 2001) {              
                    // i trust the method now
                    return date.getFullYear();
                }
            }
            // else, do this:
            // codes thanks to ppk:
            // http://www.xs4all.nl/~ppk/js/introdate.html
            var x = date.getYear();
            var y = x % 100;
            y += (y < 38) ? 2000 : 1900;
            return y;
        },

        
        z : function () {
            // The day of the year, zero indexed! 0 through 366
            var t = new Date("January 1 " + this.Y() + " 00:00:00");
            var diff = date.getTime() - t.getTime();
            return Math.floor(diff/1000/60/60/24);
        },

        Z : function () {
            // Timezone offset in seconds
            return (date.getTimezoneOffset () * -60);
        }        
    
    }

    function getSwitch(str) {
        if (switches[str] != undefined) {
            return switches[str]();
        } else {
            return str;
        }
    }

    var date;
    if (time) {
        var date = new Date (time);
    } else {
        var date = this;
    }

    var formatString = input.split("");
    var i = 0;
    while (i < formatString.length) {
        if (formatString[i] == "\\") {
            // this is our way of allowing users to escape stuff
            formatString.splice(i,1);
        } else {
            formatString[i] = getSwitch(formatString[i]);
        }
        i++;
    }
    
    return formatString.join("");
}


// Some (not all) predefined format strings from PHP 5.1.1, which 
// offer standard date representations.
// See: http://www.php.net/manual/en/ref.datetime.php#datetime.constants
//

// Atom      "2005-08-15T15:52:01+00:00"
Date.DATE_ATOM    = "Y-m-d\\TH:i:sP";
// ISO-8601  "2005-08-15T15:52:01+0000"
Date.DATE_ISO8601 = "Y-m-d\\TH:i:sO";
// RFC 2822  "Mon, 15 Aug 2005 15:52:01 +0000"
Date.DATE_RFC2822 = "D, d M Y H:i:s O";
// W3C       "2005-08-15T15:52:01+00:00"
Date.DATE_W3C     = "Y-m-d\\TH:i:sP";

function emailatt(x,id,country) {
	if(x=="") {
		x="cd";
	}
	if(document.getElementById(x)) {
		document.getElementById(x).style.display="none";	
	}
		//i_id=deze.id.value;
		//var prop = document.getElementById("props").value;
		//prop = selectBox.options[selectBox.selectedIndex].value
		//prop=deze.prop_id.options[deze.prop_id.selectedIndex].value;
		//alert("!1");
		data=new Array();
		data['id']=id;
		data['x']=x;
		data['country']=country;
		url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/EmailCorr?country="+country+"&corr_id="+id;
		url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
		post=null;
		//alert(url);
		xmlophalen(url,post,'getvets', callbackEmailAtt,data);
		return false;
	}


function callbackEmailAtt(responseText,data,text) {
	//alert(text);
	id=data['id'];
	x=data['x'];
	country=data['country'];
//alert("!2");
	/////////////
	p=0;
	data3="  <table>";
	//alert("geladen");
	//for(p=0; p<count; p++) {
		//c_id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;	
		if(responseText.getElementsByTagName("cid").length>0) {
			id=responseText.getElementsByTagName("cid")[p].childNodes.item(0).nodeValue;
		} else {
			id="";
		}
		if(responseText.getElementsByTagName("type").length>0) {
			c_type=responseText.getElementsByTagName("type")[p].childNodes.item(0).nodeValue;
		} else {
			c_type="";
		}
		if(responseText.getElementsByTagName("subject").length>0) {
			c_subject=responseText.getElementsByTagName("subject")[p].childNodes.item(0).nodeValue;
		} else {
			c_subject="";
		}
		if(responseText.getElementsByTagName("sender").length>0) {
			c_sender=responseText.getElementsByTagName("sender")[p].childNodes.item(0).nodeValue;	
		} else {
			c_sender="";
		}
		if(responseText.getElementsByTagName("dir").length>0) {
			c_dir=responseText.getElementsByTagName("dir")[p].childNodes.item(0).nodeValue;	
		} else {
			c_dir="";
		}
		if(responseText.getElementsByTagName("date").length>0) {
			c_date=responseText.getElementsByTagName("date")[p].childNodes.item(0).nodeValue;	
		} else {
			c_date="";
		}
		c_recipient="";
		if(responseText.getElementsByTagName("recipient").length>10) {
			c_recipient="BULK";
		} else if(responseText.getElementsByTagName("recipient").length>0) {
			c_recipient="";
			for(at=0; at<(responseText.getElementsByTagName("recipient").length); at++) {
				c_recipient+=(responseText.getElementsByTagName("recipient")[at].childNodes.item(0).nodeValue);	
				c_recipient+=" ";
			}
			
		} else {
			c_recipient="";
		}
		if(responseText.getElementsByTagName("filename").length>0) {
			c_desc=responseText.getElementsByTagName("filename")[p].childNodes.item(0).nodeValue;	
		} else {
			c_desc="";
		}
		if(responseText.getElementsByTagName("binary").length>0) {
			binary=responseText.getElementsByTagName("binary")[p].childNodes.item(0).nodeValue;	
		} else {
			binary="";
		}
		if(responseText.getElementsByTagName("body").length>0) {
			bodyhtml=responseText.getElementsByTagName("body")[p].childNodes.item(0).nodeValue;	
		} else {
			bodyhtml="";
		}
		if(responseText.getElementsByTagName("a_id").length>0) {
			id2=responseText.getElementsByTagName("a_id")[p].childNodes.item(0).nodeValue;	
		} else {
			id2="";
		}
		
		data3+="<tr>";
        data3+="<td width=\"116\">Date</td>"; 
         data3+="<td width=\"726\" class=\"colored\" id=\"\">"+c_date+"</td>"; 
         data3+="</tr>"; 
		     data3+="<tr>"; 
           data3+="<td>Type</td>"; 
          data3+="<td class=\"colored\">"+c_type+" </td>"; 
        data3+="</tr>"; 
		 data3+="<tr>";
        data3+="<td width=\"116\">Direction</td>"; 
         data3+="<td width=\"726\" class=\"colored\" id=\"\">"+c_dir+"</td>"; 
         data3+="</tr>";
         data3+="<tr>"; 
         data3+="<td>Sent By</td>"; 
         data3+="<td class=\"colored\">"+c_sender+"</td>"; 
        data3+="</tr>"; 
         data3+="<tr>"; 
         data3+="<td>Subject</td>"; 
         data3+="<td class=\"colored\">"+c_subject+"</td>"; 
        data3+="</tr>"; 
      if(bodyhtml!="" && bodyhtml!="&#160;" && bodyhtml!=" " && bodyhtml!="&nbsp;") {
         data3+="<tr>"; 
         data3+="<td valign=\"top\">Body</td>"; 
        data3+="<td class=\"colored\">"+bodyhtml+"</td>"; 
         data3+="</tr>";
		}
         data3+="<tr>"; 
        data3+="<td>Recipient</td>"; 
        data3+="<td class=\"colored\">"+c_recipient+" </td>"; 
      data3+="</tr>"; 
    
		if(responseText.getElementsByTagName("attachment").length>0) {
			data3+="<tr>"; 
			data3+="<td>Attachment(s)</td>"; 
			data3+="<td class=\"colored\">";
			for(at=0; at<(responseText.getElementsByTagName("attachment").length); at++) {
				c_desc=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("filename")[0].childNodes.item(0).nodeValue;	
				c_aid=responseText.getElementsByTagName("attachment")[at].getElementsByTagName("a_id")[0].childNodes.item(0).nodeValue;	
				data3+="<a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?fileid="+id2+"\">"+c_desc+" </a><br/>"; 
				
			}
			data3+="</td></tr>"; 
		}
			
		/*if(responseText.getElementsByTagName("filename").length>0) {
			c_desc=responseText.getElementsByTagName("filename")[p].childNodes.item(0).nodeValue;	
		} else {
			c_desc="";
		}
		if(c_desc!="" && c_desc!="&#160;" && c_desc!=" " && c_desc!="&nbsp;") {
         data3+="<tr>"; 
          data3+="<td>Attachment(s)</td>"; 
         data3+="<td class=\"colored\"><a target=\"_blank\" href=\"http://www.camelotproperty.com/cwa/fileatt.php?fileid="+id2+"\">"+c_desc+" </a></td>"; 
        data3+="</tr>"; 
		}*/
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		//data3+="</tr>"; 
	//}
	data3+="</table>";
	if(x=="") {
		x="cd";	
	}
	//alert(x);
	//alert(document.getElementById("cdata").innerHTML);
	//if(document.getElementById(x)) {
		
		document.getElementById(x).style.cursor="auto";	
		document.getElementById(x).style.display="block";	
		document.getElementById(x).style.visibility="visible";
	//}
	//if(document.getElementById('cdata')) {
		document.getElementById('cdata').innerHTML=data3;
		document.getElementById('cdata').style.display="block";	
		document.getElementById('cdata').style.visibility="visible";
		document.getElementById('cd').style.display="block";	
		document.getElementById('cd').style.visibility="visible";	
	//}
}

function showincident(tag,id,country) {
	data=new Array();
	data['id']=id;
	data['x']=tag;
	data['country']=country;
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/IncidentDets?country="+country+"&inc_id="+id;
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	xmlophalen(url,post,'getvets', callbackIncidentDets,data);
	return false;
}

function callbackIncidentDets(responseText,data,text) {
	id=data['id'];
	x=data['x'];
	if(x=="") {
		x="ir";	
	}
	country=data['country'];
	p=0;
	data3="  <table>";
	
		count=responseText.getElementsByTagName("a_id").length;
	data3="<a class=\"closebtn\" href=\"javascript:hideLayer('"+x+"')\">X</a><h2>Incident</h2>";
	data3+="<table border=\"0\" style=\"border-width: 0px;\">";
		m_type=responseText.getElementsByTagName("date")[0].childNodes.item(0).nodeValue;	
	data3+="<tr><td><strong>"+tl("date",trl)+"</strong></td><td>"+m_type+"</td></tr>";
		m_location=responseText.getElementsByTagName("property")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("property",trl)+"</strong></td><td>"+m_location+"</td></tr>";
		//m_serial=responseText.getElementsByTagName("r_date")[0].childNodes.item(0).nodeValue;
	//data3+="<tr><td><strong>Request date</strong></td><td>"+m_serial+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("type")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("type",trl)+"</strong></td><td>"+m_inuse+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("urgency")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("urgency",trl)+"</strong></td><td>"+m_inuse+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("c_name")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("contacts",trl)+"</strong></td><td>"+m_inuse+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("description")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("description",trl)+"</strong></td><td>"+m_inuse+"</td></tr>";
		m_inuse=responseText.getElementsByTagName("solution")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("solution",trl)+"</strong></td><td>"+m_inuse+"</td></tr>";
	
	data3+="</table><br/>";
	data3+="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
//	data3+="<td class=\"txthighlight\">id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("date",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("action",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("desc",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("status",trl)+"</td>";
	data3+=" </tr>";
	start=0;
	maxi=1024;
	count=count*1;
	if(count>=maxi) {
		count=maxi;
	}
	for(p=start; p<count; p++) {
		i2_date="";
		if(responseText.getElementsByTagName("action")[p].getElementsByTagName("date").length>0) {
			i2_date=responseText.getElementsByTagName("action")[p].getElementsByTagName("date")[0].childNodes.item(0).nodeValue;	
		}
		//}
		i2_action="";
		if(responseText.getElementsByTagName("action")[p].getElementsByTagName("action").length>0) {
			i2_action=responseText.getElementsByTagName("action")[p].getElementsByTagName("action")[0].childNodes.item(0).nodeValue;	
		}
		//fout in ie6:
		i2_desc="";
		if(responseText.getElementsByTagName("action")[p].getElementsByTagName("description").length>0) {
			i2_desc=responseText.getElementsByTagName("action")[p].getElementsByTagName("description")[0].childNodes.item(0).nodeValue;	
		}
		i2_status="";
		if(responseText.getElementsByTagName("action")[p].getElementsByTagName("status").length>0) {
			i2_status=responseText.getElementsByTagName("action")[p].getElementsByTagName("status")[0].childNodes.item(0).nodeValue;		
		}
		
		data3+="<tr>"; 
//		data3+="<td class=\"colored\">"+i2_id+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_date,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_action,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_desc,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_status,100)+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	//document.getElementById("metersdets").innerHTML=data3;
	//alert(document.getElementById("cdata").innerHTML);
	if(x=="") {
		x="ir";	
	}
	//if(document.getElementById(x)) {
		document.getElementById(x).innerHTML=data3;
		
		//document.getElementById(x).style.cursor="auto";	
		
		document.getElementById(x).style.display="block";	
		document.getElementById(x).style.visibility="visible";
	//}
}

function extendtab(x,deze) {
	switch(document.getElementById(x).style.display) {
		case "block": document.getElementById(x).style.display="none";	deze.innerHTML="<img src=\"/images/arrow-rit-sharp.gif\"/>"; break;
		case "none": document.getElementById(x).style.display="block";	deze.innerHTML="<img src=\"/images/arrow-dn-sharp.gif\"/>"; break;
		default: document.getElementById(x).style.display="block";	deze.innerHTML="<img src=\"/images/arrow-dn-sharp.gif\"/>"; break;
	}
}

function showinspection(tag,id,country) {
	data=new Array();
	data['id']=id;
	data['x']=tag;
	data['country']=country;
	url="http://apps.stichtingcamelot.nl/cwa/cwaserv.asmx/InspectionDets?country="+country+"&insp_id="+id;
	url="http://www.camelotproperty.com/cwa/extern.php?file="+url;
	post=null;
	//alert(url);
	xmlophalen(url,post,'getvets', callbackInspectionDets,data);
	return false;
}

function callbackInspectionDets(responseText,data,text) {
	id=data['id'];
	x=data['x'];
	if(x=="") {
		x="ir";	
	}
	country=data['country'];
	p=0;
	data3="  <table>";
	
		count=responseText.getElementsByTagName("meter").length;
	data3="<a class=\"closebtn\" href=\"javascript:hideLayer('"+x+"')\">X</a><h2>Incident</h2>";
	data3+="<table border=\"0\" style=\"border-width: 0px;\">";
		m_type=responseText.getElementsByTagName("date")[0].childNodes.item(0).nodeValue;	
	data3+="<tr><td><strong>"+tl("date",trl)+"</strong></td><td>"+m_type+"</td></tr>";
		m_location=responseText.getElementsByTagName("inspector")[0].childNodes.item(0).nodeValue;
	data3+="<tr><td><strong>"+tl("inspector",trl)+"</strong></td><td>"+m_location+"</td></tr>";
	count2=responseText.getElementsByTagName("comment").length;
	start2=0;
	maxi2=1024;
	count2=count2*1;
	if(count2>=maxi2) {
		count2=maxi2;
	}
	m_serial="";
	for(p=start2; p<count2; p++) {
		m_serial+=responseText.getElementsByTagName("comment")[p].childNodes.item(0).nodeValue;
		m_serial+="<br/>\n";
	}
	if(m_serial!="") {
		data3+="<tr><td><strong>"+tl("comment",trl)+"</strong></td><td>"+m_serial+"</td></tr>";
	}
	
	data3+="</table><br/>";
	data3+="  <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
//	data3+="<td class=\"txthighlight\">id</td>";
	data3+=" <td class=\"txthighlight\">"+tl("type",trl)+"</td>";
	data3+=" <td class=\"txthighlight\">"+tl("serial",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("rate",trl)+"</td>";
	data3+="  <td class=\"txthighlight\">"+tl("reading",trl)+"</td>";
	data3+=" </tr>";
	start=0;
	maxi=1024;
	count=count*1;
	if(count>=maxi) {
		count=maxi;
	}
	for(p=start; p<count; p++) {
		i2_date="";
		if(responseText.getElementsByTagName("meter")[p].getElementsByTagName("type").length>0) {
			i2_date=responseText.getElementsByTagName("meter")[p].getElementsByTagName("type")[0].childNodes.item(0).nodeValue;	
		}
		//}
		i2_action="";
		if(responseText.getElementsByTagName("meter")[p].getElementsByTagName("serial").length>0) {
			i2_action=responseText.getElementsByTagName("meter")[p].getElementsByTagName("serial")[0].childNodes.item(0).nodeValue;	
		}
		//fout in ie6:
		i2_desc="";
		if(responseText.getElementsByTagName("meter")[p].getElementsByTagName("rate").length>0) {
			i2_desc=responseText.getElementsByTagName("meter")[p].getElementsByTagName("rate")[0].childNodes.item(0).nodeValue;	
		}
		i2_status="";
		if(responseText.getElementsByTagName("meter")[p].getElementsByTagName("reading").length>0) {
			i2_status=responseText.getElementsByTagName("meter")[p].getElementsByTagName("reading")[0].childNodes.item(0).nodeValue;		
		}
		
		data3+="<tr>"; 
//		data3+="<td class=\"colored\">"+i2_id+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_date,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_action,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_desc,100)+"</td>";
		data3+="<td class=\"colored\">"+afkappen(i2_status,100)+"</td>";
		//data3+="<td class=\"colored\">"+p+"/"+count+"</td>";
		data3+="</tr>"; 
	}
	data3+="</table>";
	//document.getElementById("metersdets").innerHTML=data3;
	//alert(document.getElementById("cdata").innerHTML);
	if(x=="") {
		x="ir";	
	}
	//if(document.getElementById(x)) {
	document.getElementById(x).innerHTML=data3;
	
	//document.getElementById(x).style.cursor="auto";	

	document.getElementById(x).style.display="block";	
	document.getElementById(x).style.visibility="visible";
	//}
}

function tl(word,trl) {
	word2=word.toLowerCase();
	word2=word2.replace(/ /,"");
	if(trl[word2]) {
		return trl[word2]
	} else if(trl[word2]!=null && trl[word2]!="" && trl[word2]!="null" && trl[word2]!="undefined") {
		return trl[word2]
	} else {
		return word;	
	}
}
