function oLogboek() {
	var id;
	var stat;
	this.stat="closed";
	
	this.setID=function(shipid){
		this.id=shipid;
	}
	
	this.read=function() {
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null) {
			alert("Your browser does not support AJAX!");
			return;
		} 
		var url="/php/readlog.php?i="+this.id;
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4) {
				document.getElementById("logboek").innerHTML=xmlHttp.responseText;
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	
	this.show=function(test) {
		if(this.stat=="closed") {
			this.read();
			if(el=document.getElementById("flowplayer")) el.style.display="none";
			document.getElementById("logboek").style.display="block";
			document.getElementById("logboek").style.top="120px";
			this.stat="open";
			if(test=="link") {
				this.inner=document.getElementById("logboek_link").innerHTML;
				document.getElementById("logboek_link").innerHTML="Logboek sluiten";
			}
		}
		else {
			document.getElementById("logboek").style.display="none";
			if(el=parent.document.getElementById("flowplayer")) el.style.display="block";
			this.stat="closed";
			if(test=="link") {
				document.getElementById("logboek_link").innerHTML=this.inner;
			}
		}
	}
	
	this.update=function() {
		document.getElementById("uform").submit();
		while(this.updated==false) {
		}
		this.read();
	}
	
	this.clear_entry=function(num) {
		if(confirm("Klik op OK om dit bericht te verwijderen")) {
			xmlHttp=GetXmlHttpObject();
			xmlHttp.variable=this;
			if (xmlHttp==null) {
				alert("Your browser does not support AJAX!");
				return;
			}
			var url="/php/clearlog.php?i="+num;
			xmlHttp.onreadystatechange=function() {
				if (xmlHttp.readyState==4) {
					xmlHttp.variable.read();
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
	}
}

function oContract() {
	this.contracturl="bemcontract.php?";
	this.keys=new Array(0);
	this.values=new Array(0);
	
	this.addVar = function(keyvar,valvar) {
		found=0;
		for(i=0;i<this.keys.length;i++) {
			if(this.keys[i]==keyvar) { this.values[i]=valvar; found=1;
		    }
		}
		if(!found) { this.keys[this.keys.length]=keyvar; this.values[this.values.length]=valvar; }
	}
	
	this.addOnChange = function(inp) {
		found=0;
		for(i=0;i<this.keys.length;i++) {
			if(this.keys[i]==inp.id) { this.values[i]=inp.value; found=1;
			}
		}
		if(!found) { this.keys[this.keys.length]=inp.id; this.values[this.values.length]=inp.value; }
	}
	
	this.maak=function() {
		this.contracturl=this.contracturl+this.keys[0]+"="+this.values[0];
		if(this.keys.length>0) {
			for(i=1;i<this.keys.length;i++) this.contracturl=this.contracturl+"&"+this.keys[i]+"="+this.values[i];
		}
		window.open(this.contracturl);
	}
	
	this.fill=function(i) {
		this.x=GetXmlHttpObject();
		if(this.x==null) {
			alert("Your browser does not support AJAX!");
			return;
		}
		var url="/php/findship.php?i="+i;
		this.addVar("ship",i);
		this.x.onreadystatechange=function() {
			if(this.readyState==4) {
				document.getElementById("weergave").innerHTML=this.responseText;
			}
		}
		this.x.open("GET",url,true);
		this.x.send(null);
	}
	
}