//-----------------------------//

var my_basis_div_methods = 
{
	invoke: function ( element, $wat )
	{
		element = $(element);
		// do something
		
		if ( $wat == 'hide' )
		{
			element.style.visibility = 'hidden' ;
			element.style.display = 'none' ;
		//	element.style.backgroundColor = "#0f0";
			
			return;
		}
		
		if ( $wat == 'show' )
		{
			element.style.visibility = 'visible' ;
			element.style.display = 'block' ;
			element.style.backgroundColor = "#cf002a";
			//var blokverkleur = new verkleur ( element, 'rose', 'rood' );
			
			return;
		}
		
		if ( $wat == 'tab_aan' )
		{
//			element.style.backgroundColor = "#cf002a";
			//var tabverkleur = new verkleur ( element, 'rose', 'rood' );
			
			element.className = 'tab tab_select' ;
			return;
		}
		
		if ( $wat == 'tab_uit' )
		{
//			element.style.backgroundColor = "#fc90a6";
//			element.setStyle({backgroundImage: 'url(../foto/images/vrw_tab_maskerb_2.gif) top left'});
			element.className = 'tab' ;
			return;
		}



		if ( $wat == 'maak_transparant' )
		{
			var opacity = 75;
			//element.style.backgroundColor = "#f00";
			
			element.style.opacity = (opacity / 100); 
			element.style.MozOpacity = (opacity / 100); 
			element.style.KhtmlOpacity = (opacity / 100); 
			element.style.filter = "alpha(opacity=" + opacity + ")"; 

			return;
		}
	},

	transparatie: function ( element, opacity )
	{
		element = $(element);

		element.style.backgroundColor = "#f00";
		
		element.style.opacity = (opacity / 100); 
		element.style.MozOpacity = (opacity / 100); 
		element.style.KhtmlOpacity = (opacity / 100); 
		element.style.filter = "alpha(opacity=" + opacity + ")"; 

		return;
	}


};


Element.addMethods ( 'DIV' , my_basis_div_methods );


//-----------------------------//


var maak_transparant = Class.create ();

maak_transparant.prototype = 
{
	initialize: function ( element, van, naar, frequentie ) 
	{
		this.element		= $( element );
		this.van				= van;
		this.naar				= naar;
		this.fade_step	= 0;
		this.frequency	= frequentie;

		this.transparatie ( van );
		
		
		this.registerCallback();
	},
	
	transparatie: function ( opacity )
	{
		//this.element.style.backgroundColor = "#f00";
		
		this.element.style.opacity = (opacity / 100); 
		this.element.style.MozOpacity = (opacity / 100); 
		this.element.style.KhtmlOpacity = (opacity / 100); 
		this.element.style.filter = "alpha(opacity=" + opacity + ")"; 


		if ( opacity < 2 )
		{
			this.element.style.visibility = 'hidden' ;
			this.element.style.display = 'none' ;
		}
		else
		{
			this.element.style.visibility = 'visible' ;
			this.element.style.display = 'block' ;
		}

	},

	
	registerCallback: function() 
	{
		this.timer = setInterval ( this.onTimerEvent.bind(this), this.frequency );
	},

	execute: function() 
	{
		//this.callback(this);
		this.fade_step += 10;
		
		if ( this.fade_step >= 100 )
		{
			this.transparatie ( this.naar );
			
			
			this.stop();
			
			return;
		}

		var fade = this.van + ( ( this.naar - this.van )  / 100 * ( this.fade_step ));
		
		this.transparatie ( fade );
	},

	stop: function() 
	{
		if (!this.timer) return;
		
		clearInterval(this.timer);
		
		this.timer = null;
	},

	onTimerEvent: function() 
	{
		if (!this.currentlyExecuting) 
		{
			try 
			{
				this.currentlyExecuting = true;
				
				this.execute();
			} 
			finally
			{
				this.currentlyExecuting = false;
			}
		}
	}	
	
};

















function maak_mij_zichtbaar ( $button_id, $tekst_id ) 
{
	//new maak_transparant ( $tekst_id, 0, 100, 10 );
	
	var x = $( $button_id ).style.left ;
	var y = $( $button_id ).style.top ;

	$( $tekst_id ).style.left = x ;
	$( $tekst_id ).style.top = y ;
			
	$( $tekst_id ).style.visibility = "visible";
	$( $tekst_id ).style.height = "auto";
}

		

function maak_mij_onzichtbaar ( $tekst_id )
{
	//new maak_transparant ( $button_id, 75, 0, 10 );
	$( $tekst_id ).style.visibility = "hidden";
	$( $tekst_id ).style.height = "0px";
}


//--------------------------------//


function init_basis ()
{
	var alle_verborgen = $$('.verborgen');

	for ( f = 0 ; f < alle_verborgen.length ; f++ )
	{
		blok_element = alle_verborgen [ f ];
		
		$ ( blok_element ).className = '' ;
	}	
}
	



Event.observe 
(
	window, 
	'load', 
	init_basis
);


//--------------------------------//

function base64Decode(data) {
	data = data.replace(/[^a-z0-9\+\/=]/ig, '');
	if (typeof (atob) == 'function') return atob(data);
	var b64_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
	var byte1, byte2, byte3;
	var ch1, ch2, ch3, ch4;
	var result = new Array();
	var j = 0;
	while ((data.length % 4) != 0) {
		data += '=';
	}

	for (var i = 0; i < data.length; i += 4) {
		ch1 = b64_map.indexOf(data.charAt(i));
		ch2 = b64_map.indexOf(data.charAt(i + 1));
		ch3 = b64_map.indexOf(data.charAt(i + 2));
		ch4 = b64_map.indexOf(data.charAt(i + 3));

		byte1 = (ch1 << 2) | (ch2 >> 4);
		byte2 = ((ch2 & 15) << 4) | (ch3 >> 2);
		byte3 = ((ch3 & 3) << 6) | ch4;

		if (true) result[j++] = String.fromCharCode(byte1);
		if (ch3 != 64) result[j++] = String.fromCharCode(byte2);
		if (ch4 != 64) result[j++] = String.fromCharCode(byte3);
	}

	return result.join('');
}




