/* ----------------------------------------
		RESIZE IMG
------------------------------------------- */
function SF_resize() {
		
	var screenwidth		= 0;
	var screenheight	= 0;

  	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
    	screenwidth 	= window.innerWidth;
    	screenheight 	= window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
    	screenwidth 	= document.documentElement.clientWidth;
    	screenheight 	= document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {//IE 4 compatible
    	screenwidth 	= document.body.clientWidth;
    	screenheight 	= document.body.clientHeight;
  	}

    var scale 			= 0;
	var maxwaarde 		= 1316; //screen h * 1.33  (screen / 1500 = scalefactor)
		
	if (  (screenwidth / screenheight) > 1.22) { // breedbeeld			
		scale	= (screenheight >= 950) ? 1 : (screenheight * 1.33) / maxwaarde; // scale in verhouding 2/3	
	} else {
		scale	= (screenheight >= 950) ? 1 : screenwidth / maxwaarde;
	}
	
	$$('.item').each(function(el) {
			
		var orgineel_w =  820; 
		var orgineel_h =  520; 
		var new_w = orgineel_w * scale;
		var new_h = orgineel_h * scale;
		
		$(el).setStyle('width', new_w );
		$(el).getChildren($('img')).setStyle('width', new_w);
		$('teaser').setStyles({'width': new_w, 'height': new_h });
		$('container_p').setStyle('height', (new_h + 87) );
		$('teaser_nav').setStyle('top',new_h + 10);

	});	
}

window.addEvents({
	'domready': function() {
			
		SF_resize();
		
		/* -----------------------------
			ACCORDION
		-------------------------------- */
		var myAccordion = new Fx.Accordion( $$('.toggle-bar'), $$('.toggle'), {

			show: 0,
			alwaysHide: true,
			opacity: false,

			onActive: function(toggler, accordion){
			
				toggler.getChildren($('img')).set('src','img/vast/pijl_enkel_wit.gif');
				
			},
			onBackground: function(toggler, accordion){
			
				toggler.getChildren($('img')).set('src','img/vast/pijl_leeg.gif');
			}	
		});

		//open the accordion section relative to the url	
		var found = 0;
		var myclass = '';
		$$('.toggle-bar').each(function(el, i){
		
			myclass = $(el).get('class').substring(20,22);
	
			if (window.location.hash.test(myclass)) {
			
				found = i;
				myAccordion.display(found);		
			}
		});
	},
	'resize': function() {
		SF_resize();	
	}
});