function lib_bwcheck() {
	this.ver = navigator.appVersion;
	this.agent = navigator.userAgent;
	this.dom = document.getElementById?1:0;
	this.print = window.print?1:0;
	this.opera5 = this.agent.indexOf("Opera 5")>-1;
	this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0;
	this.ie = this.ie4||this.ie5||this.ie6;
	this.mac = this.agent.indexOf("Mac")>-1;
	this.ns6 = (this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4 = (document.layers && !this.dom)?1:0;
	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
	return this;
}
var bw = new lib_bwcheck();
var consoleRef = null;

function positionImage() {
	if(document.body.clientWidth > 750) {
		ow1Resize = (document.body.clientWidth/2) - 410;
		document.getElementById("golfer2").style.left=ow1Resize;
		ow2Resize = ((document.body.clientWidth)/2)+90;
		document.getElementById("golfer").style.left=ow2Resize;
	}
}

function CheckMail() {
	validRegExp = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}$/i;
	if (document.frmMail.Name.value.length<2) {
		alert("Uw naam is niet ingevuld.");
	}else if(document.frmMail.EmailFriend.value.search(validRegExp) == -1) {
		alert("Het e-mailadres is onjuist ingevuld.");
	} else {
		document.frmMail.submit();
	}
}

function DateStyle(lcDate){
	var lcRet = "";
	if (lcDate.length==2 || lcDate.length==5){
		lcRet = lcDate+"-";
	} else {
		lcRet = lcDate.substring(0,10);
	}
//	if (lcDate.length==10){
//		document.forms[1].postcode.focus();
//	}
	return lcRet;
}

function FocusField(lcField) {
	var lcFocus = "";
	if (arguments.length<1){
		lcFocus="";
	} else {
		if (lcFocus==""){
			lcFocus=lcField;
		}
		document.reservationForm[lcFocus].focus();
	}
}

function Uword(lcWord){
	var lcRet = "";
	lcRet = lcWord.substring(0,1).toUpperCase();
	lcRet = lcRet+lcWord.substring(1,lcWord.length);
	return lcRet;
}

function OpenWindow(lcUrl) {
	top.consoleRef = window.open(lcUrl,"w","fullscreen=no");
	top.consoleRef.resizeTo(500,500);
}

function ShowNewPhoto(p_strElement,p_arrImageSmall,p_arrImageBig,p_intPosition)
{
	if(p_intPosition >= 0 && p_intPosition < p_arrImageSmall.length)
		m_intPhotoPosition = p_intPosition;
	else if(p_intPosition == p_arrImageSmall.length)
		m_intPhotoPosition = 0;
	else if(p_intPosition == -1)
		m_intPhotoPosition = p_arrImageSmall.length-1;

	ShowSmallImage(p_strElement,p_arrImageSmall[m_intPhotoPosition],p_arrImageBig[m_intPhotoPosition]);
	document.getElementById('PhotoCount').innerHTML = m_intPhotoPosition + 1;
}

function ShowSmallImage(lcElement,lcImageSmall,lcImageBig){
	if(!llImageLoaded){
		return false;
	}else{
		llImageLoaded = false;
	
		loImageSmall = new Image();
		loImageSmall.src = lcImageSmall;
		
		if(loImageSmall.height>0 && loImageSmall.height != null){
			Loaded();
		}else{
			loImageSmall.onload = Loaded;
		}
	}
	function Loaded(){
		llImageLoaded = true;
		document.getElementById(lcElement).big = lcImageBig;
		/*document.getElementById(lcElement).filters(0).Apply();
		document.getElementById(lcElement).filters(0).Play();*/
		Slide(lcElement,lcImageSmall,loImageSmall.height,document.getElementById(lcElement).height,10);
	}
}

function Slide(lcElement,lcImage,lnMinMaxHeight,lnCurrentHeight,lnSpeed){
	/*
	if(lnMinMaxHeight > 200){
		ShowBigImage(lcImage);
		return true;
	}
	*/
	
	if(lnCurrentHeight < lnMinMaxHeight){
		if(lnCurrentHeight+lnSpeed > lnMinMaxHeight){
			lnCurrentHeight = lnMinMaxHeight;
		}else{
			lnCurrentHeight = lnCurrentHeight + lnSpeed;
		}
		document.getElementById(lcElement).src = lcImage;
		document.getElementById(lcElement).height = lnCurrentHeight;
		setTimeout('Slide("'+lcElement+'","'+lcImage+'",'+lnMinMaxHeight+','+lnCurrentHeight+','+lnSpeed+')', 1);
	}else if(lnCurrentHeight > lnMinMaxHeight){
		if(lnCurrentHeight-lnSpeed < lnMinMaxHeight){
			lnCurrentHeight = lnMinMaxHeight;
		}else{
			lnCurrentHeight = lnCurrentHeight - lnSpeed;
		}
		document.getElementById(lcElement).src = lcImage;
		document.getElementById(lcElement).height = lnCurrentHeight;
		setTimeout('Slide("'+lcElement+'","'+lcImage+'",'+lnMinMaxHeight+','+lnCurrentHeight+','+lnSpeed+')', 1);
	}else{
		document.getElementById(lcElement).src = lcImage;
	}

}

function ShowBigImage(lcImageBig, lcComment) {
	if(consoleRef != null)
		consoleRef.close();

	loImageBig = new Image();
	loImageBig.src = lcImageBig;
	if(loImageBig.height>0 && loImageBig.height != null)
		Loaded();
	else
		loImageBig.onload = Loaded;
		
	function Loaded() {
		llImageBigLoaded = true;
		lnWidth = loImageBig.width;
		lnHeight = loImageBig.height;
		if(typeof lcComment != "undefined") lnHeight+=60;
		consoleRef = window.open('','popup','width='+lnWidth+',height='+lnHeight+',menubar=0,toolbar=0,status=0,scrollbars=auto,resizable=0');
		consoleRef.document.writeln('<html><head>');
		consoleRef.document.writeln('<title>'+document.title+'</title></head>');
		consoleRef.document.writeln('<body style="margin:0px">');
		consoleRef.document.writeln('<a href="JavaScript:close()"><img src="'+loImageBig.src+'" border="0"></a>');
		if(typeof lcComment != "undefined")
			consoleRef.document.writeln('<center><font face="Arial" size="2"><b>'+lcComment+'</b></font></center>');
		consoleRef.document.writeln('</body></html>');
		consoleRef.document.close();
	}
}

function ShowBigImages(cImages) {
	if(consoleRef != null) {
		if(!document.all)
			consoleRef.focus();
		consoleRef.close();
		consoleRef = null;
	}
	
	var cImagesArray = cImages.split(",");
	var nWidth = 800;
	var nHeight = 600;
	
	for(i=0;i<cImagesArray.length; i++) {
		var oImageTemp = new Image();
		oImageTemp.src = cImagesArray[i];
		nHeight += oImageTemp.height;
		if(oImageTemp.width > nWidth)
			nWidth = oImageTemp.width;
		oImageTemp = null;
	}
	
	consoleRef = window.open('','popup','width=' + nWidth + ',height=' + nHeight + ',menubar=0,toolbar=0,status=0,scrollbars=1,resizable=0');
	consoleRef.document.writeln('<html><head>');
	consoleRef.document.writeln('<title>'+document.title+'</title></head>');
	consoleRef.document.writeln('<body style="margin:0px;cursor:pointer;">');

	for(i=0;i<cImagesArray.length; i++) {
		consoleRef.document.writeln('<img src="' + cImagesArray[i] + '" border="0" onclick="window.close();">');
	}
	consoleRef.document.writeln('</body></html>');
	consoleRef.document.close();
}


function CreateIframe(lcUrl){
	this.frameName = 'FileLoader' + this.id;
	if (document.all) {
		var html = '';
		html += '<IFRAME ID="' + this.frameName + '"';
		html += ' NAME="' + this.frameName + '"';
		html += ' STYLE="display: none;"';
		html += ' SRC="'+lcUrl+'">';
		html += '<\/IFRAME>';
		document.body.insertAdjacentHTML('beforeEnd', html);
	} else if (document.getElementById) {
		var ifr = document.createElement('IFRAME');
		ifr.id = ifr.name = this.frameName;
		ifr.style.visibility = 'none';
		ifr.src = lcUrl;
		document.body.appendChild(ifr);
	}
}

var llImageLoaded = true;
var llImageBigLoaded = true;

function CenterMapBounds(minLat, minLong, maxLat, maxLong) {
	var bounds = new GLatLngBounds; 
	bounds.extend(new GLatLng(minLat, minLong)); 
	bounds.extend(new GLatLng(maxLat, maxLong)); 
	map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
}	
 

