
function printemail(a) {
 document.write("<a href='mailto:"+a+"@zndmakelaardij.nl'>"+a+"@zndmakelaardij.nl</a>");
} 

function toggleDiv(id) {

	obj = document.getElementById(id);

	obj.style.display = ((obj.style.display != 'block') ? 'block' : 'none');
	
	return false;

}
function closeDiv(id) {

	obj = document.getElementById(id);
	obj.style.display = 'none';
	return false;

}
function houseover(house) {

	obj=document.getElementById(house);
	obj.className="house houseOver";
}
function houseout(house) {
	obj=document.getElementById(house);
	obj.className="house";
}
function houseopen(houseid,street) {
	window.location="http://www.wenm.nl/object/"+houseid+"/"+street+"/0";
}











function centerWindow(element) {
     if($(element) != null) {

               $(element).style.top = 
                    Math.round(document.viewport.getScrollOffsets().top + 
                    (( document.viewport.getHeight() - $(element).getHeight()))/2)+'px';
               $(element).style.left = 
                    Math.round(document.viewport.getScrollOffsets().left + 
                    (( document.viewport.getWidth() - $(element).getWidth()))/2)+'px';

     }
}


var Lightbox = Class.create({
	
    initialize : function(containerDiv) {
		this.container = containerDiv;
		this._hideLayer(this.container);
		this.flash = false;
		
		
	},
	_hideLayer : function hideLayer(userAction){
		$(userAction).style.display="none";
	},
	_makeVisible : function makeVisible(){

		if ($('shade')) {
			
			vHeight = document.viewport.getScrollOffsets().top + document.viewport.getHeight();
			
			$('shade').style.top = document.viewport.getScrollOffsets().top + 'px';
			$('shade').style.left = document.viewport.getScrollOffsets().left + 'px';
			
			
			
			Event.observe('shade', 'click', this.close.bindAsEventListener(this) );
			Event.observe(window, 'scroll', this.scroll.bindAsEventListener(this) );
			
			//Event.observe( this.container , 'click', this.close.bindAsEventListener(this) );
		}

	},
	_makeInvisible : function makeInvisible(){
		

	},
	_showLayer : function showLayer(userAction){
		
		$(userAction).style.display="block";
		centerWindow(userAction);
		
		if (this.flash) this.flashOpen();
		
	},
	_hideLayer : function hideLayer(userAction){
		$(userAction).style.display="none";
		
		if (this.flash) this.flashClose();
	},	
	_fade : function fadeBg(userAction,whichDiv){
		if(userAction=='close'){
			new Effect.Fade('shade',
					   {duration:.5,
					    from:0.5,
					    to:0,
					    afterFinish:this._makeInvisible(),
					    afterUpdate:this._hideLayer(whichDiv)});
		} else {
			
			new Effect.Appear('shade',
					   {duration:.5,
					    from:0,
					    to:0.5,
					    beforeUpdate:this._makeVisible(),
					    afterFinish:this._showLayer(whichDiv)});
		}
	},	
	open : function () {
		this._fade('open', this.container);
	},	
	close : function () {
		this._fade('close', this.container);
	},
	scroll : function () {
		
		if ( $('shade') ) {	
			vHeight = document.viewport.getScrollOffsets().top + document.viewport.getHeight();
			$('shade').style.top = document.viewport.getScrollOffsets().top + 'px';
			centerWindow(this.container);
		}
		
	},
	setFlash : function ( movie, width, height ) {
		this.flash = true;
		this.flash_movie = movie;
		this.flash_width = width;
		this.flash_height = height;
	},
	flashOpen : function () {

		swfobject.embedSWF( this.flash_movie , "movieholder", this.flash_width, this.flash_height, "9.0.0", "/flash/expressInstall.swf");
	},
	flashClose : function () {

		swfobject.removeSWF('movieholder');
		$('movie').innerHTML = '<div id="movieholder"><h1>Deze film werkt niet zonder JavaScript &amp; Flash</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div>';
	}

	
});







/* ############## 

	Flexibelpakket 

############## */
function flex_floatingprice() {
	
	var viewport_offset = document.viewport.getScrollOffsets();

	var div_price = $('price');

	//if ( !div_price.offset_org ) div_price.offset_org = div_price.positionedOffset()[1];
	

	if ( viewport_offset[1] > div_price.parentNode.parentNode.positionedOffset()[1]   ) {

		if (  ( viewport_offset[1] - div_price.parentNode.parentNode.positionedOffset()[1] ) < ( div_price.parentNode.parentNode.getHeight() - div_price.getHeight() - 80  )  ) {
			
			div_price.style.top = (viewport_offset[1] - div_price.parentNode.parentNode.positionedOffset()[1] )  + 'px';
		}

	} else {
		div_price.style.top = '0px';
	}
	
	
}
function flex_calcprice() {
	
	var sum = 0;
	
	$$('input.fo').each( function (el) {
		if (el.checked == true) {
			sum += parseInt(el.value.split('.')[1]);
		}
		
	});
	
	Effect.Pulsate('dynamicprice', { pulses: 1, duration: 0.5,  queue: { position: 'end', scope: 'dp', limit: 1 } });
	
	$('dynamicprice').innerHTML = '€ '+sum+',-';
	
}
function flex_initiate() {
	
	for (i=0;i<13;i++) {
		var my_tooltip = new Tooltip('o'+i, 'o'+i+'tooltip');	
	}

	Event.observe( window, 'scroll', function() { 
	  flex_floatingprice();
	});
	
	$$('div.flexoptie').each( function (el) {
		el.observe('click', function (ev) {
			var element = Event.element(ev);
			var checkbox = element.firstChild;
			
			if ( checkbox.checked == true ) {
				checkbox.checked=false;
				element.removeClassName('flexoptie_aan');

			} else {
				checkbox.checked=true;
				element.addClassName('flexoptie_aan');

			}
			flex_calcprice();
		});

	});

	$$('input.fo').each( function (el) {
		el.observe('click', function (ev) {
			var checkbox = Event.element(ev);
			var element = checkbox.parentNode;
			if ( !checkbox.checked ) {
				checkbox.checked=false;
				element.removeClassName('flexoptie_aan');

			} else {
				checkbox.checked=true;
				element.addClassName('flexoptie_aan');

			}
			
			flex_calcprice();
			
			
		});
	});
}