//controle of oa alles geladen is
var StartOk  = false;
var mijngmap = null;
var GMapsOk = false;
var PreloadImgLst = new Array();
var FotoAktief = 0;
var FotoScroll = 0;
var TimerObj1 = null;
var TimerObj2 = null;

function maximizeWindow(WindowObj){
	if (parseInt(navigator.appVersion)>3){
		if (navigator.appName=="Netscape"){
			if(WindowObj.screenX>0 || WindowObj.screenY>0) WindowObj.moveTo(0,0);
			if(WindowObj.outerWidth < screen.availWidth) WindowObj.outerWidth=screen.availWidth;
			if(WindowObj.outerHeight < screen.availHeight) WindowObj.outerHeight=screen.availHeight;
		} else {
			WindowObj.moveTo(-4,-4);
			WindowObj.resizeTo(screen.availWidth+8,screen.availHeight+8);
		}
	}
}


function trim(value) {
	value = value.replace(/^\s+/,'');
	value = value.replace(/\s+$/,'');
	return value;
}


function Coord2Num(CoordIn){

	var CoordOut=0;

	//speciale karakters eruit filtere
	var MijnRExp = /&#\d*;/g;
	var ChkMijnPos=CoordIn.replace(MijnRExp," ");

	//alle niet numerieke karakters verwijderen
	var MijnRExp = /([^0-9/.])/g;
	var ChkMijnPos=trim(CoordIn.replace(MijnRExp," "));

	var PosParts=ChkMijnPos.split(" ");
	var ChkIndex=0;
	for(p=0;p<PosParts.length;p++){
		var ChkStr = trim(PosParts[p]);
		if(ChkStr!=''){
			if(ChkIndex==0) CoordOut+=1*ChkStr;
			if(ChkIndex==1) CoordOut+=ChkStr/60;
			if(ChkIndex==2) CoordOut+=ChkStr/3600;
			ChkIndex++;
		}
	}

	return CoordOut;
}


function StartGoogleMap(StrCoord,Kmlbestand_Url){

	XYcoord=StrCoord.split(",");
	if(XYcoord.length == 2){
		if(GBrowserIsCompatible()){

			XYcoord[0]=Coord2Num(XYcoord[0]);
			XYcoord[1]=Coord2Num(XYcoord[1]);

			GMapsOk = true;

			var mijngmap = new GMap2(document.getElementById("mijngmap"));

			mijngmap.addControl(new GSmallMapControl());
			mijngmap.addControl(new GMapTypeControl());
			mijngmap.setCenter(new GLatLng(1*XYcoord[0],1*XYcoord[1]),13);
			mijngmap.setMapType(G_HYBRID_MAP);//hybride map aktief zetten
			mijngmap.setZoom(16);

			if(Kmlbestand_Url){
				var mijnlokaties = new GGeoXml(Kmlbestand_Url);
				mijngmap.addOverlay(mijnlokaties);
			}

		}
	}
}


function NieuwVenster(waarheen){
	DetailVenster = window.open(waarheen,'Detail','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizeable=yes,width=800,height=600');
	DetailVenster.focus();
}


function VideoVenster(waarheen){
	DetailVenster = window.open(waarheen,'Detail','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,width=350,height=400');
	DetailVenster.focus();
}


function NaarWebsite(waarheen){
	DetailVenster = window.open(waarheen,'_blank');
	DetailVenster.focus();
}


function GaNaar(naarurl){
	document.location.href=naarurl;
}


function SluitAlbum(){
	document.getElementById('showfotoalbum').className='fotoalbumnietaktief';
}


function SchaalAchtergrond(){

	ChkStatus=document.getElementById('showfotoalbum').className;
	if(ChkStatus.indexOf('nietaktief',0)==-1){

		AlbumObj=document.getElementById('showfotoalbum');
		//parent = body
		OuderObj=AlbumObj.parentNode;

		WindowW=AlbumObj.clientWidth;
		WindowH=AlbumObj.clientHeight;

		ContentW=OuderObj.offsetWidth;
		ContentH=OuderObj.offsetHeight;

		if(WindowW>ContentW) ContentW=WindowW;
		if(WindowH>ContentH) ContentH=WindowH;

		//achtergrond breedte aan body afmetingen aanpassen
		document.getElementById('blendimg').setAttribute('width',ContentW);
		document.getElementById('blendimg').setAttribute('height',ContentH);

	}

}


function AktiveerAlbum(KeuzeFoto,curtitel){
	SchakelFoto(KeuzeFoto,curtitel);

	//album weergeven
	document.getElementById('showfotoalbum').className='fotoalbumaktief';

	//achtergrond breedte aan body afmetingen aanpassen
	SchaalAchtergrond();

}


function SchakelFoto(NieuweFoto,curtitel){
	if(NieuweFoto!=FotoAktief){
		document.getElementById('prevfoto'+FotoAktief).className='nietaktief';
		document.getElementById('prevfoto'+NieuweFoto).className='aktief';

		document.getElementById('fototitel').innerHTML=curtitel;

		FotoAktief=NieuweFoto;
	}
}


function ScrollNaar(Richting){

	Verplaatsing=Richting*10;

	if(Verplaatsing!=0){
		FotoStrookObj=document.getElementById('fotostrook');
		FotoFrameObj = FotoStrookObj.childNodes[0];//1e element binnen de div

		ViewBreedte=FotoStrookObj.offsetWidth;
		StrookBreedte=FotoFrameObj.offsetWidth;

		if(ViewBreedte < StrookBreedte){
			CurPos = parseInt(FotoFrameObj.style.left);
			if(isNaN(CurPos)) CurPos=0;

			MaxLeft = ViewBreedte-StrookBreedte;

			if(Verplaatsing < 0){
				if(CurPos + Verplaatsing >= MaxLeft){
					CurPos=CurPos + Verplaatsing;
				} else {
					CurPos=MaxLeft;
				}

			} else {

				if(CurPos + Verplaatsing <= 0){
					CurPos=CurPos + Verplaatsing;
				} else {
					CurPos=0;
				}
			}

			FotoFrameObj.style.left=CurPos + 'px';

		}

		TimerObj1=setTimeout('ScrollNaar('+Richting+')',40);
	} else {
		clearTimeout(TimerObj1);
	}

}



function onPreload(aImages, nImages){
	if(nImages == aImages.length){
	//	BlokeerInteraktie=false;
		return;
	}
}


//Image preload routines staan hieronder
function ImagePreloader(images, callback){

	this.callback = callback;// store the callback

	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = new Array;
 
	this.nImages = images.length;

	for(var i=0; i < images.length; i++){// for each image, call preload()
		this.preload(images[i]);
	}
}


ImagePreloader.prototype.preload = function(image){

	// create new Image object and add to array
	//var oImage = new Image;
	var oImage = document.createElement("img"); // met new Image() werkt 't zeker niet!

	this.aImages.push(oImage);

	// set up event handlers for the Image object
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;

	// assign pointer back to this.
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;

	// assign the .src property of the Image object
	oImage.src = image;
}

ImagePreloader.prototype.onComplete = function(){
	this.nProcessed++;

	if(this.nProcessed == this.nImages){
		this.callback(this.aImages, this.nLoaded);
	}
}

ImagePreloader.prototype.onload = function(){
	this.bLoaded = true;
	this.oImagePreloader.nLoaded++;
	this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function(){
   this.bError = true;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function(){
   this.bAbort = true;
   this.oImagePreloader.onComplete();

}


function StartScripts(){
	//initialisatie van enkele parameters
	StartOk = true;
	GMapsOk = false;
	FotoScroll = 0;
	TimerObj1 = null;
	TimerObj2 = null;

}

