// JavaScript Document
var navi 			= navigator.appVersion;
var browserIE 		= false;
var browserIE6 		= false;
var browserSAF 		= false;
var scrollSpeed 	= 50;
var scrollHeight	= 10;
var notification 	= '';

if(navi.indexOf("MSIE")>-1){
	browserIE = true;
	var navAr = navi.split(";");
	browserIE6 = (parseFloat(navAr[1].split(" ")[2])<=6.0?true:false);
} else if(navi.indexOf("Safari")>-1){
	browserSAF = true;
}

var width_Avail 	= screen.availWidth;
var heigth_Avail 	= screen.availHeight;
var innerWidth 		= 0;
var innerHeight 	= 0;

//window.moveTo(0,0);
//window.resizeTo(width_Avail,heigth_Avail);

if(!browserSAF){
	innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 17);
	innerHeight	= parseInt((document.documentElement.clientHeight * 1));
}else{
	innerWidth 	= parseInt((document.documentElement.clientWidth * 1)- 16);
	innerHeight	= parseInt((document.documentElement.clientHeight * 1));
}

var middleX				= innerWidth / 2;
var middleY				= innerHeight / 2;

var http_request 		= false;
var rootdomain			= "http://"+window.location.hostname

var status 				= 0;
var active_option 		= '';


var flash_can			= false;
var flash_message		= '';

if(FlashDetect.majorAtLeast(9)){
	flash_can		= true;
}else{
	flash_can		= false;
	flash_message 	= "You need at least flashplayer 9 to see this part of<br>the site.<br><br>Click <a href='http://www.adobe.com/products/flashplayer/' target='_blank'>here</a> to download flashplayer from Adobes website.";
}

function resizing(){
	//$('main_container').setStyle('opacity' , 0);
	if(!browserSAF){
		innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
		innerHeight	= parseInt((document.documentElement.clientHeight * 1));
	}else{
		innerWidth 	= parseInt((document.documentElement.clientWidth * 1)- 16);
		innerHeight	= parseInt((document.documentElement.clientHeight * 1));
	}
	middleX				= innerWidth / 2;
	middleY				= innerHeight / 2;
	
	$('main_container').setStyle('width' , innerWidth);

	//ChangeAnim('opacity', 'main_container', 1, 600, Fx.Transitions.Sine.easeOut);
	ChangeAnim('left', 'bg1', innerWidth - 330, 400, Fx.Transitions.Sine.easeOut);
	ChangeAnim('left', 'bg2', middleX - 600, 400, Fx.Transitions.Sine.easeOut);
	ChangeAnim('left', 'header', middleX - 487, 400, Fx.Transitions.Sine.easeOut);
	ChangeAnim('left', 'content', middleX - 487, 400, Fx.Transitions.Sine.easeOut);

	ChangeAnim('width', 'label_background', innerWidth, 400, Fx.Transitions.Sine.easeOut);
	ChangeAnim('left', 'label_container', (innerWidth - 1000)/2, 400, Fx.Transitions.Sine.easeOut);

}

function openHomeVideo(){
	if($('heroes')){
		$('heroes').setStyle('width' , innerWidth);
		$('heroes_bg').setStyle('width' , innerWidth);
		//$('heroes').setStyle('display' , 'block');
	}
}

var fx_mouse_overs	= new Array;
var fx_inner_content_menu;
var fx_inner_content;
var fx_calender;
var fx_calender_info;
var fx_calender_info_close;

var menulist, calendarlist;
var mouseY,mouseX;
var temp_date,temp_title,temp_location,titles,locations,timetable,items_string;

var item_page_array 	= new Array('','flow_headlines_item.php','','','','flow_photo_item.php','','','');
var start_content 		= new Array('flow_home.php','flow_headlines.php','flow_agenda.php','flow_music.php','flow_video.php','flow_photo.php','flow_bio.php','flow_contact.php','flow_guestbook.php');

var load_innercontent	= new Array(0,1,0,0,0,0,0,0,0);
var swfLoad				= new Array(false,false,false,false,true,false,false,false,false);
var class_array 		= new Array('home','headlines','agenda','music','video','photo');
var categories_array 	= new Array(0,2,1,3,4,5,0,0,0);
var pages_array 		= new Array('','','','','','',1,2,'');

//side positions
//agenda, music, newsletter, remote, links, sponsors
var sidepositions_array 	= new Array(new Array(226,573,0,866,1107, 996),new Array(0,573,347,866,1107,996), new Array(0,347,640,866,1107,996), new Array(604,130,951,0,534,423), new Array(604,130,951,0,534,423), new Array(293,0,640,866,1107, 996), new Array(631,0,293,977,1107,520), new Array(406,752,0,1044,337,226), new Array(518,226,0,866,1107));





var months_array		= new Array('','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

var active_current		  	= 0;	
var active_item				= 0;
var active_calender		  	= 0;	 //element	
var active_calender_count 	= 0;	//items_id
var calender_info_isset		= false;		
var insideLabels 			= false;
var LabelsInfoShower;
var fx_LabelsInfoShower;
//labels
var scrollerLabels;

var heroesAni;
var heroesAni_close;

var wkAni;
var wkAni_close;

function LoadInit(){
	
	
	getQueryStrVars();

	if(browserIE6==true){
		notification		= 'You are currently using Internet Explorer 6.0. For optimal perfomance: upgrade to <a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx" target="_blank">Internet Explorer 7.0</a> or try <a href="http://www.mozilla.com/en-US/firefox/" target="_blank">Mozilla Firefox</a>.';
		$('header_notification').innerHTML = notification;
	}
	LoadPageAll();
	
}
function closeHeroes(){
    heroesAni.cancel();
    heroesAni_close		= MorpheItems('heroes', 1000, Fx.Transitions.Cubic.easeOut);
    heroesAni_close.onComplete = function(){
        $('heroes_content').innerHTML         = '';
        $('heroes').setStyle('display','none');
    };
    heroesAni_close.start({'opacity':0});


}
function closeWK(){
    wkAni.cancel();
    wkAni_close		= MorpheItems('wk', 1000, Fx.Transitions.Cubic.easeOut);
    wkAni_close.onComplete = function(){
        $('wk_content').innerHTML         = '';
        $('wk').setStyle('display','none');
    };
    wkAni_close.start({'opacity':0});


}

function getQueryStrVars() {
	var hu = window.location.search.substring(1);
	var gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		var ft = gy[i].split("=");
		switch(ft[0]){
			case 'cat':
				active_current 	= ft[1];
				if(active_current < 0){
					active_current = 0;
				}
			break;
			case 'item':
				active_item 	= ft[1];
				if(active_item < 0){
					active_item = 0;
				}
			break;
		}
	}
}

function LoadPageAll(){
	
	$('bg1').setStyle('left' , innerWidth - 330);
	$('bg2').setStyle('left' , middleX - 600);
	$('header').setStyle('left' , middleX - 487);
	$('content').setStyle('left' , middleX - 487);
	
	$('label_background').setStyle('width' , innerWidth);
	$('label_background').setStyle('opacity' , 0.5);
	$('label_container').setStyle('left' , (innerWidth - 1000)/2);
	
	$('main_container').setStyle('width' , innerWidth);
	
	menulist	= $$('#foort_menu .navigation_div');
	menulist.each(function(element) {
		var current = parseInt(element.getProperty('id').substring(4));
		fx_mouse_overs[current] = MorpheItems('menu'+current, 800, Fx.Transitions.Cubic.easeOut);
		
		element.addEvent('mouseenter', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			fx_mouse_overs[current].cancel();
			fx_mouse_overs[current].start({'top': 20});
		});
		element.addEvent('mouseleave', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			if(current!=active_current){
				fx_mouse_overs[current].cancel();
				fx_mouse_overs[current].start({'top': 50});
			}
		});
		element.addEvent('click', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			processClick(current, '?include_header=1');
		});
   	});
	
	calendarListing();
	
	$('flow_side_agenda_content').addEvent('mouseenter', function(event){
		if(calender_info_isset == false && active_current != 2){
			//mouseY 			= event.page.y - 220;
			mouseY 			= event.page.y;
			mouseX 			= event.page.x - 270;
			$('flow_side_agenda_content_shower').setStyle('left', mouseX);
			$('flow_side_agenda_content_shower').setStyle('top', mouseY);
		}
	});

	$('flow_side_agenda_content').addEvent('mousemove', function(event){
		if(calender_info_isset == false && active_current != 2){
			//mouseY 			= event.page.y - 220;
			mouseY 			= event.page.y;
			mouseX 			= event.page.x - 270;
			$('flow_side_agenda_content_shower').setStyle('left', mouseX);
			$('flow_side_agenda_content_shower').setStyle('top', mouseY);
		}
	});
	
	$('flow_side_agenda_content').addEvent('mouseleave', function(event){
		if(calender_info_isset == false && active_current != 2){
			mouseY 					= -600;
			mouseX 					= -100;
			$('flow_side_agenda_content_shower').setStyle('left', mouseX);
			$('flow_side_agenda_content_shower').setStyle('top', mouseY);
			active_calender_count	= 0;
		}
	});
	
	fx_inner_content 	 		= MorpheItems('inner_content', 500, Fx.Transitions.Cubic.easeOut);
	fx_inner_content_menu 		= MorpheItems('inner_content_menu', 500, Fx.Transitions.Cubic.easeOut);
	
	fx_calender	 				= MorpheItems('flow_side_agenda_content', 500, Fx.Transitions.Cubic.easeOut);
	fx_calender_info			= MorpheItems('flow_side_agenda_content_shower', 800, Fx.Transitions.Cubic.easeOut);
	fx_calender_info_close		= MorpheItems('flow_side_agenda_content_shower', 1000, Fx.Transitions.Cubic.easeOut);
	fx_calender_info_close.onComplete = function(){ 
		calender_info_isset 	= false; 
		active_calender			= 0;
	};
	
	
	//var TipsSponsors = new Tips($$('.sponsors'),{ fixed: false, className:'sponsorInfo', showDelay: 0, hideDelay: 0, offsets: {'x': -55, 'y': -40} });
	
	
	scrollerLabels = new Scroller('label_content', {area: 220, velocity: 0.1});
	$('label_content').addEvent('mouseover', scrollerLabels.start.bind(scrollerLabels));
	$('label_content').addEvent('mouseout', scrollerLabels.stop.bind(scrollerLabels));	
	
	//var scrollerSponsors = new Scroller('sponsor_content', {area: 220, velocity: 0.1});
	//$('sponsor_content').addEvent('mouseover', scrollerSponsors.start.bind(scrollerSponsors));
	//$('sponsor_content').addEvent('mouseout', scrollerSponsors.stop.bind(scrollerSponsors));	
	
	$('flow_label_content_shower').setStyle('opacity', 0);
	fx_LabelsInfoShower 	 		= MorpheItems('flow_label_content_shower', 500, Fx.Transitions.Cubic.easeOut);
	
	$('label_container').addEvent('mouseenter', function(event){
		insideLabels 		= true;
		if(event.page.x > middleX){
			mouseX 			= event.page.x - 195;
		}else{
			mouseX 			= event.page.x + 5;
		}
		$('flow_label_content_shower').setStyle('left', mouseX);
		LabelsInfoShower = function() {
			if(insideLabels==true){
//				$('flow_label_content_shower').setStyle('opacity', 1);
				fx_LabelsInfoShower.cancel();
				fx_LabelsInfoShower.start({
					'opacity' : 1
				});
			}
		}.delay(600);
	});

	$('label_container').addEvent('mousemove', function(event){
		if(event.page.x > middleX){
			mouseX 			= event.page.x - 195;
		}else{
			mouseX 			= event.page.x + 5;
		}
		$('flow_label_content_shower').setStyle('left', mouseX);
	});
	
	$('label_container').addEvent('mouseleave', function(event){
		insideLabels 		= false;
		fx_LabelsInfoShower.cancel();
		fx_LabelsInfoShower.start({
			'opacity' : 0,
			'left' : -300			
		});
	});
	
	var brandlist = $$('.labels');
	brandlist.each(function(element) {
	 
		var fxvalues = new Fx.Morph(element, {duration:400, wait:false, transition: Fx.Transitions.Cubic.easeOut});
		
		fxvalues.set({'opacity': 0.5, 'height': 40, 'width': 60});
		
		element.addEvent('mouseenter', function(){
			fxvalues.cancel();
			fxvalues.onComplete = function() {
			
				$('flow_label_content_shower').addClass('loading');
				loadNshow('flow_labels_details.php?include_header=1&label='+label_id,'flow_label_content_shower_content', 'get', false);
				
			};
			fxvalues.start({
				'height': 67, 'width': 100
			});
			
			
			var label_id = element.getProperty('id');
			$('flow_label_content_shower_content').innerHTML 	= '<br>';
			$('flow_label_content_shower_ttl').innerHTML 		= '<br>'+element.getProperty('name');
			
		});
	 
		element.addEvent('mouseleave', function(){
			fxvalues.onComplete = function() {};
			fxvalues.cancel();
			fxvalues.start({
				'height': 40, 'width': 60
			});
		});
	});
	
	setSomeForm('newsletter');
	
	
	var TipsInBasket = new Tips($$('.flyer_icon'),{ fixed: false, className:'FlyOver', showDelay: 0, hideDelay: 0, offsets: {'x': 55, 'y': -250} });
	
	$('load_container').setStyle('display' , 'none');
	$('main_container').setStyle('opacity' , '0');
	$('main_container').setStyle('display' , 'block');
	//$('main_container').setStyle('opacity' , '1');
	
	ChangeAnim('opacity', 'main_container',1, 200, Fx.Transitions.Cubic.easeOut);
	
	var TipsLinks = new Tips($$('.link_nav'),{ fixed: false, className:'linkInfo', showDelay: 0, hideDelay: 0, offsets: {'x': -55, 'y': -40} });
	
	var TipsCalendar = new Tips($$('.ontour'),{ fixed: false, className:'dateInfo', showDelay: 0, hideDelay: 0, offsets: {'x': -190, 'y': -20} });
	
	if(flash_can){
	
		activateMusicPlayer();
		
		activateSponsors();
	
		
		commonSWF		= new SWFObject('remoteplayer/badge.swf', 'LucienFoort Remote MusicPlayer', 285, 170, "9", "86A098");
		commonSWF.addParam('flashvars','appname=Lucienfoort%20Remote%20MusicPlayer&appurl=http://www.lucienfoort.com/remoteplayer/lucienfoortMusicPlayer.air&airversion=1.1&imageurl=remoteplayer/icon.jpg');
		commonSWF.addParam("wmode", "transparent"); 
		commonSWF.addParam("quality", "high"); 
		commonSWF.addParam("allowscriptaccess", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); 
		commonSWF.addParam("codebase", "all"); 
		commonSWF.useExpressInstall('expressinstall.swf');
		commonSWF.write('remoteplayer');
		
		$('flow_side_music_remoteplayer').addEvent('mouseenter', function(event){
				$('flow_side_music_remoteplayer').setStyle('z-index',100);											  
		});
		$('flow_side_music_remoteplayer').addEvent('mouseleave', function(event){
				$('flow_side_music_remoteplayer').setStyle('z-index',2);											  
		});

	}else{
		$('remoteplayer').innerHTML = flash_message;
		$('flow_side_music_content').innerHTML = flash_message;
	}
	
	fx_mouse_overs[active_current].start({'top': 20});
	
	if(active_current!=0){
		var temp_current = active_current;
		active_current 	= 0;
		processClick(temp_current, '?include_header=1&item='+active_item);
	}else{


	}
	/*
	if($('wk')){
	$('wk').setStyle('width' , innerWidth);
	$('wk_bg').setStyle('width' , innerWidth);
	$('wk_bg').setStyle('opacity' , 0.9);
	$('wk').setStyle('opacity' , 0);
	$('wk').setStyle('display' , 'block');
	wkAni		= MorpheItems('wk', 1000, Fx.Transitions.Cubic.easeOut);
		wkAni.start({'opacity':1});
	}*/
	
}

function openHeroes(){
	if($('heroes')){
	
		$('heroes').setStyle('width' , innerWidth);
		$('heroes_bg').setStyle('width' , innerWidth);
		$('heroes_bg').setStyle('opacity' , 0.9);
		$('heroes').setStyle('opacity' , 0);
		$('heroes').setStyle('display' , 'block');
		
		
		heroesAni		= MorpheItems('heroes', 1000, Fx.Transitions.Cubic.easeOut);
		heroesAni.onComplete = function(){ 
			var heroesSWF		= new SWFObject('video.swf', 'LucienFoort Heroes of Housemusic',645, 377, "9", "86A098");
			heroesSWF.addParam("scale", "noscale");
			heroesSWF.addParam("quality", "high"); 
			heroesSWF.addParam("allowscriptaccess", "all");
			heroesSWF.addParam("allowFullScreen", "true"); 
			heroesSWF.addParam("wmode", "window"); 
			heroesSWF.addParam("codebase", "all"); 
			heroesSWF.useExpressInstall('expressinstall.swf');
			heroesSWF.write('heroes_video');
		};
		heroesAni.start({'opacity':1});
	
	}
}

function calendarListing(){
	calendarlist 	= $$('#flow_side_agenda_content .ontour');
	calendarlist.each(function(element) {
		var marked_date = element.getProperty('name');
		
		element.addEvent('mouseenter', function(){
			element.addClass('overDate');
			
			if(calender_info_isset==false && active_current != 2){
				$('flow_side_agenda_content_shower').setStyle('display', 'block');
				processCalenderDataOver(element, false);
			}else if(active_current == 2){
				temp_date		= element.getProperty('id');
				if($('agenda_list_'+temp_date)){
					$('agenda_list_'+temp_date).highlight('#3b90b0', '#111111');
					$('agenda_isplaying_'+temp_date).highlight('#3b90b0', '#111111');
					
				}
				
			}
		});
		element.addEvent('mouseleave', function(){
			element.removeClass('overDate');
			if(calender_info_isset==false && active_current != 2){
				
				$('flow_side_agenda_content_shower').setStyle('display', 'none');
				
				for(var booking = 1; booking <= 5; booking++){
					$('flow_side_agenda_content_shower_'+(booking)).setStyle('display', 'none');
				}
				
			}
		});
		element.addEvent('click', function(event){
										   
			if(active_current != 2){
				mouseX = event.page.x;
				mouseY = event.page.y;
				
				processCalenderDataClick(element, true);
			}
			
		});
   	});
	
	allow_calender_click		= true;
}

var active_calender_swf 	= '';
var backup_calender_value	= '';

function processCalenderDataSWF(poststr, booking, temp_date){
	if(flash_can){
		active_calender_swf		= temp_date;
		var smallAgendaInfoSWF	= new SWFObject("small_agenda.swf", "Lucien Foort", "250", "100", "9", "86A098");
		smallAgendaInfoSWF.addParam('flashvars',poststr);
		smallAgendaInfoSWF.addParam("wmode", "transparent"); 
		smallAgendaInfoSWF.addParam("quality", "high"); 
		smallAgendaInfoSWF.useExpressInstall('expressinstall.swf');
		
		$('flow_side_agenda_content_shower_'+(booking+1)).setStyle('display', 'block');
		smallAgendaInfoSWF.write('flow_side_agenda_content_shower_swf_'+(booking+1));
	}else{
		$('flow_side_agenda_content_shower_'+(booking+1)).setStyle('display', 'block');
		$('flow_side_agenda_content_shower_swf_'+(booking+1)).addClass('noflash');
	}
}

function getCalenderData(element){
	temp_title		= element.getProperty('name').split('###');
	
	titles			= temp_title[0].split('@@@');
	locations		= temp_title[1].split('@@@');
	timetable		= temp_title[2].split('@@@');
	items_string	= temp_title[3];	
}

function processCalenderDataOver(element, clicked){
	temp_date		= element.getProperty('id');
	if(active_calender!=temp_date){
		getCalenderData(element)
		active_calender_count	= titles.length;
		for(var booking = 0; booking < active_calender_count; booking++){
	
			var booking_name		= titles[booking];
			var booking_location 	= locations[booking];
			var booking_time		= timetable[booking];
	
			var poststr				= 'title='+booking_name+'&date='+temp_date+'&time='+booking_time+'&locate='+booking_location;
			
			if(flash_can){
				processCalenderDataSWF(poststr, booking, temp_date)
			}
		}
		$('flow_side_agenda_content_shower').setStyle('height',active_calender_count*110);
	}
}

var mouseOverCal = true;

function processCalenderDataClick(element, clicked){
	
	if(mouseOverCal == true){
		mouseOverCal	= false;
		var TipRemove 	= $$('.dateInfo');
		TipRemove.each(function(element) {
			element.destroy();
		});	
	}
	
	temp_date		= element.getProperty('id');
	if(active_calender!=temp_date){
		getCalenderData(element)
		
		if(active_calender!=0){
			$(active_calender).innerHTML = backup_calender_value;
			$(active_calender).removeClass("clickedDate");
		}
		
		if(calender_info_isset==false){
			for(var booking = 1; booking <= 5; booking++){
				$('flow_side_agenda_content_shower_'+(booking)).addClass('info_open');
				$('flow_side_agenda_content_shower_info_'+(booking)).setStyle('display', 'block');
			}
			calender_info_isset 	= true;
		}
		
		element.addClass('clickedDate');
		backup_calender_value	= element.innerHTML;
		element.innerHTML 		= '';
		
		if(active_calender_count>titles.length){
			for(var close_booking = titles.length; close_booking <= active_calender_count; close_booking++){
				$('flow_side_agenda_content_shower_'+(close_booking)).setStyle('display', 'none');
			}
		}
		
		active_calender			= temp_date;
		active_calender_count	= titles.length;
		
		loadNshow('flow_agenda_item_detail.php?include_header=1&items='+items_string,'flow_side_agenda_content_shower_info_1', 'get', false);	
		fx_calender_info.cancel();
		fx_calender_info_close.cancel();
		fx_calender_info.start({
			'left' : mouseX - 600,
			'top' : mouseY,
			'width' : 550
		});
		
		if(temp_date != active_calender_swf){
			for(var booking = 0; booking < active_calender_count; booking++){
		
				var booking_name		= titles[booking];
				var booking_location 	= locations[booking];
				var booking_time		= timetable[booking];
		
				var poststr				= 'title='+booking_name+'&date='+temp_date+'&time='+booking_time+'&locate='+booking_location;
				
				processCalenderDataSWF(poststr, booking, temp_date);
			}
		}
	}else if(active_calender==temp_date){
		
		//close current
		closeCurrentCalendarItems();
	}	
}

function closeCurrentCalendarItems(){
	//alert('close');
	$(active_calender).innerHTML = backup_calender_value;
	$(active_calender).removeClass("clickedDate");
	
	for(var close_booking = 5; close_booking > active_calender_count; close_booking--){
		//$('flow_side_agenda_content_shower_'+(close_booking)).setStyle('display', 'none');
	}
	for(var booking = 1; booking <= 5; booking++){
		$('flow_side_agenda_content_shower_'+(booking)).removeClass('info_open');
		//$('flow_side_agenda_content_shower_info_'+(booking)).setStyle('diclickedDatesplay', 'none');
	}

	active_calender_count	= 0;
	
	fx_calender_info_close.cancel();
	fx_calender_info.cancel();
	fx_calender_info_close.start({
		'left' : mouseX - 270,
		'top' : mouseY,
		'width' : 250
	});	
}


function loadSongPlayer(){
	var oneSongSWF			= new SWFObject("onSong.swf", "LucienFoortMusic", "100", "40", "9", "86A098");
	oneSongSWF.addParam("wmode", "transparent"); 
	oneSongSWF.addParam("quality", "high"); 
	oneSongSWF.useExpressInstall('expressinstall.swf');
	oneSongSWF.write("song_player");
	if(active_item!=0){
		if(active_current==3){
			var loadListing = function() {
				var mp3_url	= $('mp3_url_'+active_item).value;
				loadSong(active_item,mp3_url);
				active_item	= 0;
			}.delay(900);
		}
	}
}

function activateMusicPlayer(){
	var musicSWF			= new SWFObject("music.swf", "LucienFoortMusicPlayer", "300", "270", "9", "86A098");
	musicSWF.addParam("wmode", "transparent"); 
	musicSWF.addParam("quality", "high"); 
	musicSWF.useExpressInstall('expressinstall.swf');
	musicSWF.write("flow_side_music_content");
}
function activateSponsors(){
	var musicSWF			= new SWFObject("slideshowSponsors.swf", "Powered By", "285", "65", "9", "86A098");
	musicSWF.addParam("wmode", "transparent"); 
	musicSWF.addParam("quality", "high"); 
	musicSWF.useExpressInstall('expressinstall.swf');
	musicSWF.write("flow_side_sponsor_content");
}

function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function makeCall(target,str) {
	thisMovie(target).asFunc(str);
}

var active_song = 0;
function loadSong(song, songMP3){
	if(active_song!=0){
		if($('pause_'+active_song)){
			$('pause_'+active_song).setStyle('display', 'none');
			$('play_'+active_song).setStyle('display', 'block');
		}
	}
	if(song!=0){
		active_song	= song;
		$('pause_'+active_song).setStyle('display', 'block');
		$('play_'+active_song).setStyle('display', 'none');
		makeCall("LucienFoortMusic",'http://www.lucienfoort.com/'+songMP3);
	}
	makeCall("LucienFoortMusicPlayer",song);
}

function pauseSong(song, songMP3){
	if(active_song==song){
		makeCall("LucienFoortMusic",'http://www.lucienfoort.com/'+songMP3);
		$('pause_'+active_song).setStyle('display', 'none');
		$('play_'+active_song).setStyle('display', 'block');
	}
}

function openItem(items_id,categories){
	
	for(var cat = 0; cat < categories_array.length; cat++){
		if(categories_array[cat] == categories && items_id>0){
			allow_click 		= false;
			var target 			= 'inner_content';
			var post_query		= '?include_header=1&item='+items_id;
			loadNshow(item_page_array[cat]+post_query, target, 'get', false);
		}
	}
}


function setPageListing(the_page, target){
	var page 	= the_page
	switch(target){
		case 'headlines':
			var target 	= 'listing_row_container';
			var url		= 'flow_headlines_listing.php?include_header=1&page='+page
			$(target).addClass('loading');
			var cat_list	= $$('#listing_row_container .listing_row');
			var counter		= 0;
			cat_list.each(function(element) {
				counter++;			   
				ChangeAnim('opacity', element, 0, counter * 200, Fx.Transitions.Cubic.easeOut);
			});
			
			var loadListing = function() {
				loadNshow(url, target, 'get', false);
			}.delay(800);
		break;
		case 'music':
			var target 	= 'listing_row_container';
			var url		= 'flow_music_listing.php?include_header=1&page='+page
			$(target).addClass('loading');
			ChangeAnim('opacity', $(target), 0, 700, Fx.Transitions.Cubic.easeOut);
			
			var loadListing = function() {
				loadNshow(url, target, 'get', false);
			}.delay(800);
		break;
	}
}

var post_query 		= ''
var allow_click 	= true;

function processDirectClick(categories, query, this_item){
	active_item = this_item;
	if(active_item!='' && active_item>0){
	   query += '&item='+active_item;
	}
	for(var cat = 0; cat < categories_array.length; cat++){
		if(categories_array[cat] == categories){
			processClick(cat, query);
			fx_mouse_overs[cat].cancel();
			fx_mouse_overs[cat].start({'top': 20});
		}
	}
}

function processClick(current, query){
	if(current!=active_current && allow_click == true){
		
		allow_click = false;
		
	//	if(active_current!=0){
			fx_mouse_overs[active_current].cancel();
			fx_mouse_overs[active_current].start({'top': 50});
	//	}
		
		
		ChangeAnim('top', 'flow_side_agenda_container', sidepositions_array[current][0], 500, Fx.Transitions.Cubic.easeOut);
		ChangeAnim('top', 'flow_side_music_container', sidepositions_array[current][1], 500, Fx.Transitions.Cubic.easeOut);
		ChangeAnim('top', 'flow_side_newsletter_container', sidepositions_array[current][2], 500, Fx.Transitions.Cubic.easeOut);
		ChangeAnim('top', 'flow_side_music_remoteplayer', sidepositions_array[current][3], 500, Fx.Transitions.Cubic.easeOut);
		ChangeAnim('top', 'flow_side_links', sidepositions_array[current][4], 500, Fx.Transitions.Cubic.easeOut);
		ChangeAnim('top', 'flow_side_sponsors', sidepositions_array[current][5], 500, Fx.Transitions.Cubic.easeOut);
	
		if(!browserIE6){
			$('inner_content_menu').removeClass(class_array[active_current]);
			$('inner_content').removeClass(class_array[active_current]);
			$('inner_content_menu').addClass('loading');
			$('inner_content_menu').innerHTML = '';
			$('inner_content').innerHTML = '';
		}else{
			$('inner_content_menu').innerHTML = 'loading....';
			$('inner_content').innerHTML = '';
		}
		
		/*if(mouseOverCal == true && active_current == 2){
			var TipsCalendar = new Tips($$('.ontour'),{ fixed: false, className:'dateInfo', showDelay: 0, hideDelay: 0, offsets: {'x': -190, 'y': -20} });
		}*/
		
		active_current = current;
		
		if(active_calender_count>0){
			closeCurrentCalendarItems();
			for(var booking = 1; booking <= 5; booking++){
				$('flow_side_agenda_content_shower_'+(booking)).setStyle('display', 'none');
			}
		}
		
		post_query = query;
		if(start_content[current]){
			loadNshow(start_content[current]+query, 'inner_content_menu', 'get', swfLoad[current]);
		}else{
			allow_click	= true;
		}
	}else{
		//alert(allow_click + ' - ' + active_current);	
	}
}

var currentTime 			= new Date();
var month 					= currentTime.getMonth() + 1;
var day 					= currentTime.getDate();
var year 					= currentTime.getFullYear();
var current_step_content	= 0;
var current_step_calendar	= 0;


var allow_calender_click 	= false;


//common var for al center swf's
var commonSWF;

function setAgenda(target,direction){
	if(target=='content'){
		//inner content reload
		
		$('agenda_listing').addClass('loading');
		
		var paging 	= parseInt($('paging').value)	+ parseInt(direction);
		var query 	= '?include_header=1&show_frame=0&page='+paging;
		loadNshow(start_content[2]+query, 'agenda_listing', 'get', false);
	}else{
		//calendar reload
		
		if(active_calender_count>0){
			closeCurrentCalendarItems();
			for(var booking = 1; booking <= 5; booking++){
				$('flow_side_agenda_content_shower_'+(booking)).setStyle('display', 'none');
			}
		}
		
		if(allow_calender_click==true){
			allow_calender_click = false;
			switch(direction){
				case -1:
					month-=1;
					if(month==0){
						month = 12;
						year-=1;
					}
				break;
				case 1:
					month+=1;
					if(month==13){
						month = 1;
						year+=1;
					}
				break;
			}
			$('flow_side_agenda_content').addClass('loading');
			$('flow_side_agenda_content').innerHTML = '';
			loadNshow('flow_calendar_content.php?include_header=1&month='+month+'&year='+year, 'flow_side_agenda_content', 'get', false);
		}
	}
}

function sendAlert(url,output) {
   pageTracker._trackPageview(rootdomain + '/' + url);
   //alert(rootdomain + '/' + url); 
}

function loadNshow(url, target, method, swfload){
	
	if(swfload == true){
		var request = new Request.JSON({
			url: url,
			onComplete: function(jsonObj) {
				var result = jsonObj.swfvar;
				
				result.each(function(swf) {
					
					var swf_src			= swf.source;
					var swf_title		= swf.titel;
					var swf_width		= swf.width;
					var swf_height		= swf.height;
					var swf_vars		= '?'+swf.vars;
					
					if(flash_can){
		
						commonSWF	= new SWFObject(swf_src, swf_title, swf_width, swf_height, "9", "86A098");
						commonSWF.addParam('flashvars',swf_vars);
						commonSWF.addParam("wmode", "transparent"); 
						commonSWF.addParam("quality", "high"); 
						commonSWF.addParam("allowscriptaccess", "all"); 
						commonSWF.addParam("codebase", "all"); 
						commonSWF.useExpressInstall('expressinstall.swf');
						
						$(target).removeClass('loading');
						$(target).addClass(class_array[active_current]);
						
						commonSWF.write(target);
						
						if(swf_title=="LUCIENFOORTVIDEO"){
							swfName = swf_title;
						}
					}else{
						$(target).removeClass('loading');
						$(target).addClass(class_array[active_current]);
						$(target).innerHTML = flash_message;	
					}
						
					allow_click = true;	
				});
				
			}
		}).send();
		
	}else{
	
		var req = new Request({url: url,
			method: method,
			onSuccess: function(responseText) {
				var output 	= req.response.text;
				
				if(!browserIE6){
					$(target).removeClass('loading');
				}
				
				switch(target){
					case 'inner_content':
						
						fx_inner_content.cancel();
						fx_inner_content.set({'opacity': 0});
						
						$(target).addClass(class_array[active_current]);
						$(target).innerHTML = output;
						
						$(target).addEvent('domready', function() {
							fx_inner_content.cancel();
							fx_inner_content.start({'opacity': 1});
							sendAlert(url,output);
						});	
						
						allow_click 	= true;
						
						active_item	= 0;
						
							
						
					break;
					case 'inner_content_menu':
						
						
						
						fx_inner_content_menu.cancel();
						fx_inner_content_menu.set({'opacity': 0});
						
						if(!browserIE6){
							$(target).addClass(class_array[active_current]);
						}
						$(target).innerHTML = output;
						
						
						$(target).addEvent('domready', function() {
							fx_inner_content_menu.cancel();
							fx_inner_content_menu.start({'opacity': 1});
							sendAlert(url,output)
						});	
						
						if(active_current==2){
							
							if(mouseOverCal == true){
								//alert(1);
								var TipRemove 	= $$('.dateInfo');
								TipRemove.each(function(element) {
									element.destroy();
								});	
							}
							
							var TipsInBasket = new Tips($$('.flyer_icon'),{ fixed: false, className:'FlyOver', showDelay: 0, hideDelay: 0, offsets: {'x': 55, 'y': -250} });
						}
						
						if(active_current==3){
							active_song		 = 0;
							if(flash_can){
								loadSongPlayer();
							}else{
								$("song_player").innerHTML = "You need <a href='http://www.adobe.com/products/flashplayer/' target='_blank'>flashplayer</a> to listen..";	
							}
						}
						
						if(active_current==5){
							if(active_item!=0){
								loadGalleryDirect(5, active_item);
								active_item	= 0;
							}else{
								active_category = 5;
								active_gallery 	= 0;
								setAlbumInterface();
							}
						}
						
						if(load_innercontent[active_current]==1){
							loadNshow(item_page_array[active_current]+post_query, 'inner_content', 'get', false);
						}else{
							allow_click = true;	
						}
					break;
					case 'flow_side_agenda_content':
						
						fx_calender.cancel();
						fx_calender.set({'opacity': 0});
						
						$(target).innerHTML 		= output;
						$('month_year').innerHTML	= months_array[month] + ', ' + year;
						
						calendarListing();
						fx_calender.start({'opacity': 1});
						
						sendAlert(url,output);
						
						if(mouseOverCal == true){
							var TipsCalendar = new Tips($$('.ontour'),{ fixed: false, className:'dateInfo', showDelay: 0, hideDelay: 0, offsets: {'x': -190, 'y': -20} });
						}
							
					break;
					case 'flow_side_agenda_content_shower_info_1':
						//split result voor agenda mouseovers....
						
						var output_output			= output;
						var output_array			= output.split('@@@');

						for(var booking = 0; booking <= output_array.length; booking++){
							$('flow_side_agenda_content_shower_info_'+(booking+1)).innerHTML = output_array[booking];
						}
						var TipsInBasket = new Tips($$('.flyer_icon'),{ fixed: false, className:'FlyOver', showDelay: 0, hideDelay: 0, offsets: {'x': -255, 'y': 40} });
						
						sendAlert(url,output_output);
						
					break;
					case 'listing_row_container':
						//split result voor agenda mouseovers....
						//alert(output);
						$(target).setStyle('opacity', 0);
						$(target).innerHTML 			= output;
						
						
						if(active_current==1){
							var counter		= 0;
							var cat_list	= $$('#listing_row_container .listing_row');
							cat_list.each(function(element) {
								element.setStyle('opacity', 0);
								counter++;			   
								ChangeAnim('opacity', element, 1, counter * 200, Fx.Transitions.Cubic.easeOut);
							});
							$(target).setStyle('opacity', 1);
						}
						if(active_current==3){		
							ChangeAnim('opacity', $(target), 1, 400, Fx.Transitions.Cubic.easeOut);
						}
						
						sendAlert(url,output);
						
					break;
					case 'agenda_listing':
						//alert(1);
						$(target).innerHTML 			= output;
						if($('limit').value > $('counter').value){
							if($('paging').value < 0){
								$('prv_month').setStyle('display', 'none');
							}else{
								$('nxt_month').setStyle('display', 'none');
							}
						}else{
							$('prv_month').setStyle('display', 'block');
							$('nxt_month').setStyle('display', 'block');
						}
						var TipsInBasket = new Tips($$('.flyer_icon'),{ fixed: false, className:'FlyOver', showDelay: 0, hideDelay: 0, offsets: {'x': 55, 'y': -250} });
						
						sendAlert(url,output);
						
					break;
					case 'flow_label_content_shower_content':
						//alert(1);
						$('flow_label_content_shower').removeClass('loading');
						$(target).innerHTML 			= output;
						
					break;
					default:
						//alert(1);
						$(target).innerHTML 			= output;
					break;
				}
			},
			onFailure: function() {
				$(target).set('innerHTML', 'The request failed.');
			}
		});
		req.send();
	}
}
//image vars

var active_category = 0;
var active_gallery 	= 0;
var active_option	= 0;

var thumb_count 	= 0;
var active_thumb 	= 0;
var active_image 	= 0;
var gallery_opened	= false;
var gallery_open	= false;
var thumb_list;

function setAlbumInterface(){
	
	var cat_list	= $$('#inner_content_menu .category_list');
	cat_list.each(function(element) {
		var current = parseInt(element.getProperty('id').substring(4));
			
		element.addEvent('mouseenter', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			if(current!=active_category){
				element.addClass('overAlbum');
			}
		});
		element.addEvent('mouseleave', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			if(current!=active_category){
				element.removeClass('overAlbum');
			}
		});
		element.addEvent('click', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			if(current!=active_category){
				if(active_category!=0){
					$('cat_' + active_category).removeClass('clickedAlbum');
				}
				active_category	= current;
				active_option	= 0;
				element.removeClass('overAlbum');
				element.addClass('clickedAlbum');
				openAlbumsIn(active_category, true);
			}
		});
   	});
	
	if(active_category != 0 || active_gallery != 0){
		if(active_gallery != 0 && active_category == 0){
			active_category	= $('active_category').value;
		}
		
		openAlbumsIn(active_category, false);
		
		if(active_gallery != 0){
			loadGallery(active_gallery, false)
		}
		
	}
}

function openAlbumsIn(the_category, loadData){
	if(loadData){
		$('albumsIn').innerHTML = '';
		$('albumsIn').addClass('loading');
		var req = new Request({url:'flow_get_albumsInCat.php?include_header=1&categories='+active_category+'&gallery='+active_gallery,
			method: 'get',
			onSuccess: function(responseText) {
				var output 	= req.response.text;
				$('albumsIn').removeClass('loading');
				$('albumsIn').innerHTML	= output;
				loadDropDownActions('search_optionGallery');
			},
			onFailure: function() {
				$('albumsIn').set('innerHTML', 'The request failed.');
			}
		});
		req.send();
	}else{
		loadDropDownActions('search_optionGallery');	
	}
}

function loadDropDownActions(element_name){
	var element_clicker = $(element_name);
	
	element_clicker.addEvent('click', function(){
		
		if(element_clicker.getProperty('name')!=active_option){
			
			if(active_option!=0){
				var valueTarget = $('search_option_values'+active_option);
				if(valueTarget){
					var clickTarget = $('search_option'+active_option);
					ChangeAnim('height', valueTarget, 0, 500, Fx.Transitions.Cubic.easeOut)
					clickTarget.setStyle('backgroundImage', 'url(img/assets/scroll/bg_options.gif)');
				}
			}
			
			active_option 	= element_clicker.getProperty('name');
			element_clicker.setStyle('backgroundImage', 'url(img/assets/scroll/bg_options_up.gif)');
			
			var nr_ofValues	= $('option_value_counter'+active_option).value;
			valueTarget 	= $('search_option_values'+active_option);
			var toMove		= nr_ofValues * 17;
			if(toMove>200){
				toMove = 200;
			}
			
			ChangeAnim('height', valueTarget, toMove, 300, Fx.Transitions.Cubic.easeOut)
			
			scroller = new Scroller('search_option_values'+active_option, {area: 20, velocity: 0.15});
			valueTarget.addEvent('mouseover', scroller.start.bind(scroller));
			valueTarget.addEvent('mouseout', scroller.stop.bind(scroller));		
		}else{
			closeCloset(active_option);
		}
	});

	var optionsValuelist = $$('.search_option_value');
	optionsValuelist.each(function(element) {
	 	
		if(active_gallery==parseInt(element.getProperty('id').substring(6))){
			var childof = element.getProperty('childof');
			$('search_option'+childof).innerHTML = element.innerHTML;
			element.addClass('selected');
			element.setStyle('background-color', '#111111');
		}
		
		var fxvalues = new Fx.Morph(element, {wait:false});
		element.addEvent('mouseenter', function(){
			if(element.getProperty('class')=='search_option_value'){									
			fxvalues.set({
				'background-color': '#3b90b0'
			});
			}
		});
	 
		element.addEvent('mouseleave', function(){
			if(element.getProperty('class')=='search_option_value'){									
			fxvalues.set({
				'background-color': '#dfdfdd'
			});
			}
		});

		element.addEvent('click', function(){
			var childof = element.getProperty('childof');
			var disablelist = $$('#search_option_values'+childof+' .search_option_value');
			disablelist.each(function(element) {
				element.setStyle('background-color', '#dfdfdd');
				element.removeClass('selected');
			});
			element.addClass('selected');
			fxvalues.start({
				'background-color': '#5a5a5a'
			});
			
			var tempval;
			switch(childof){
				case 'Gallery':
					tempval	= parseInt(element.getProperty('id').substring(6));
					if(active_gallery != tempval){
						active_gallery 	= tempval;
						$('search_option'+childof).innerHTML = element.innerHTML;
						closeCloset(childof);
						loadGallery(active_gallery, true);
					}
				break;
			}
			
		});
		
		
	});
}

function loadGalleryDirect(category, gallery){
	active_category = category;
	active_gallery 	= gallery;
	var target_album	= $('inner_content_menu');target_album
	
	
	if(active_current!=5){
		active_current = 5;
		fx_mouse_overs[5].cancel();
		fx_mouse_overs[5].start({'top': 20});
	}
	
	
	var url = 'flow_photo.php?include_header=1&gallery='+active_gallery ;
	var req = new Request({url:url,
		method: 'get',
		onSuccess: function(responseText) {
			
			var output 		= req.response.text;
			var counter_t	= 0
			
			target_album.setStyle('display','none');
			target_album.innerHTML	= output;
			
			setAlbumInterface()
			
			target_album.setStyle('display','block');
			
			sendAlert('flow_photo.php?include_header=1&categories='+active_category+'&gallery='+active_gallery,output);
			
		},
		onFailure: function() {
			target_album.set('innerHTML', 'The request failed.');
		}
	});
	req.send();
}


function loadGallery(active_gallery, loadData){
	if(loadData){
		$('thumb_container').addClass('loading');
		
		var url = 'flow_photo_item.php?include_header=1&gallery='+active_gallery ;

		var req = new Request({url:url,
			method: 'get',
			onSuccess: function(responseText) {
				
				var output 		= req.response.text;
				var counter_t	= 0
				
				$('thumb_container').removeClass('loading');
				$('thumb_container').setStyle('display','none');

				$('thumb_container').innerHTML	= output;
				thumb_count	= $('aantal_thumbs').value;
				
				thumb_list = $$('#thumb_container .thumbnail');
				thumb_list.each(function(element) {
					counter_t++;
					element.setStyle('opacity',0);
					ChangeAnim('opacity', element, 0.9, counter_t * 200, Fx.Transitions.Cubic.easeOut)
					
					element.addEvent('mouseenter', function(){
						element.setStyle('opacity',1);
						element.addClass('overThumb');
					});
	
					element.addEvent('mouseleave', function(){
						element.setStyle('opacity',0.9);
						element.removeClass('overThumb');
					});
				});
				aantal_images	= counter_t;
				
				$('thumb_container').setStyle('display','block');

				//var TipsInBasket = new Tips($$('.the_thumb'),{ fixed: false, className:'galleryInfo', showDelay: 0, hideDelay: 0, offsets: {'x': 55, 'y': -40} });
				
			},
			onFailure: function() {
				$('thumb_container').set('innerHTML', 'The request failed.');
			}
		});
		req.send();
	}else{
		var counter_t	= 0
				
		thumb_count	= $('aantal_thumbs').value;
		
		thumb_list = $$('#thumb_container .thumbnail');
		thumb_list.each(function(element) {
			counter_t++;
			element.setStyle('opacity',0);
			ChangeAnim('opacity', element, 0.9, counter_t * 50, Fx.Transitions.Cubic.easeOut)
			
			element.addEvent('mouseenter', function(){
				element.setStyle('opacity',1);
				element.addClass('overThumb');
			});

			element.addEvent('mouseleave', function(){
				element.setStyle('opacity',0.9);
				element.removeClass('overThumb');
			});
		});
		aantal_images	= counter_t;
	}
}

function closeCloset(childof){
	var valueTarget = $('search_option_values'+childof);
	ChangeAnim('height', valueTarget, 0, 300, Fx.Transitions.Cubic.easeOut);
	var clickTarget = $('search_option'+active_option);
	ChangeAnim('height', valueTarget, 0, 300, Fx.Transitions.Cubic.easeOut)
	clickTarget.setStyle('backgroundImage', 'url(img/assets/scroll/bg_options.gif)');
	active_option = 0;
}

var imageContainer;
var imageContainerBorder;
var imageContainerBackground;
var imageNxt;
var imagePrv;
var imageClose;
var imageTitle;
var imageAddon;
var max_breedte_image  	= 0;
var max_hoogte_image  	= 0;
var xPos_image  		= 0;
var yPos_image  		= 0;
var windowheight		= 0;
var windowwidth			= 0;

var this_breedte_image  = 0;
var this_hoogte_image	= 0;

var lefter_thumb		= middleX - 480;
var thumb_middle		= lefter_thumb + 300;

var fx_mouseGalleryAnim;
var fx_mouseGalleryAnimBorder;
var fx_mouseNxt;
var fx_mousePrv;

var mouseGallery		= 0;
var mouseGallery_Prev	= 0;

var currentImageIndex	= 0;
var currentFolder		= '';
var aantal_images		= 0;
var imageURLS;
var imageTitles;

function closeBigImage(){
	$('thumb_container').setStyle('display', 'block');
	imagePrv.setStyle('display' , 'none');
	imageNxt.setStyle('display' , 'none');
	imageClose.setStyle('display' , 'none');
	imageTitle.setStyle('display' , 'none');
	imageAddon.setStyle('display','none');
	imageAddon.innerHTML	= '';
	
	imageContainerBackground.setStyle('display' , 'none');
	imageContainerBorder.setStyle('display' , 'none');
	imageContainer.setStyle('display' , 'none');
	gallery_open = false;
}
		
function openBigImage(folder,value,index,description){
	if(!gallery_opened){
		
		if(!browserSAF){
			var windowDim 	= window.getScrollSize();
			windowheight	= windowDim.y;
			windowwidth		= windowDim.x;
		}else{
			windowheight 	= document.body.scrollHeight;
			windowwidth 	= document.body.scrollWidth;
		}
		
		gallery_opened				= true;
		imageContainer 				= $('imageContainer');
		imageContainerBackground 	= $('imageContainerBackground');
		imageContainerBorder 		= $('imageContainerBorder');

		imageURLS			 		= new Array();
		imageTitles			 		= new Array();
		
		imageClose 		= $('imageClose');
		imagePrv 		= $('imagePrev');
		imageNxt		= $('imageNext');
		imageTitle		= $('imageTitle');
		imageAddon		= $('AlbumAddon');
		
		fx_mouseGalleryAnim			= MorpheItems('imageContainer', 500, Fx.Transitions.Cubic.easeOut);
		fx_mouseGalleryAnimBorder	= MorpheItems('imageContainerBorder', 500, Fx.Transitions.Cubic.easeOut);
		fx_mouseNxt					= MorpheItems('imageNext', 500, Fx.Transitions.Cubic.easeOut);
		fx_mousePrv					= MorpheItems('imagePrev', 500, Fx.Transitions.Cubic.easeOut);
		
		imageClose.addEvent('click', function(event){
			if (!busyBig) {
				
				closeBigImage();
				
			}
		});
		
		imagePrv.addEvent('click', function(event){
			if (!busyBig) {
				
				openBigImage(currentFolder,imageURLS[currentImageIndex-2],currentImageIndex-1,imageTitles[currentImageIndex-2])
				
			}
		});
		
		imageNxt.addEvent('click', function(event){
			if (!busyBig) {
				
				openBigImage(currentFolder,imageURLS[currentImageIndex],currentImageIndex+1,imageTitles[currentImageIndex])
				
			}
		});
		
		//ChangeAnim('opacity', 'content', 0, 1000, Fx.Transitions.Sine.easeOut);
		//$('content').setStyle('opacity' , 0);
	
		
		
/*		
		var myElement 	= $(document.body);
		myElement.addEvent('mousemove', function(event){
			if (!busyBig) {
				mouseGallery		= thumb_middle - event.page.x;
				
				if(mouseGallery > 0){
					//muis links;
					if(mouseGallery_Prev==1){
						//mouseGallery	= thumb_middle - this_breedte_image - 100;
						mouseGallery	= (windowwidth - thumb_middle)/2 - this_breedte_image/2 + thumb_middle;
						fx_mouseGalleryAnim.cancel();
						fx_mouseGalleryAnim.start({'left': mouseGallery});
						fx_mouseGalleryAnimBorder.cancel();
						fx_mouseGalleryAnimBorder.start({'left': mouseGallery-20});
					}
					mouseGallery_Prev	= 0;
				}else{
					//muis rechts;
					if(mouseGallery_Prev==0){
						//mouseGallery	= thumb_middle + 100;
						mouseGallery	= thumb_middle/2 - this_breedte_image/2;
						fx_mouseGalleryAnim.cancel();
						fx_mouseGalleryAnim.start({'left': mouseGallery});
						fx_mouseGalleryAnimBorder.cancel();
						fx_mouseGalleryAnimBorder.start({'left': mouseGallery - 20});
					}
					mouseGallery_Prev	= 1;
				}
				
				imageContainerBorder.setStyles({
					'left': mouseGallery - 20
				});
			
				imageContainer.setStyles({
					'left': mouseGallery,
				});
			}
		});
	*/
	}
	
	if(!gallery_open){
		
		
		imageURLS			 		= ($('valuesURL').value).split(',');
		imageTitles			 		= ($('valuesTitles').value).split(',');
		
		
		var myElement = $(document.body);
		var myFx = new Fx.Scroll(myElement).start(0, 0);
	
		$('thumb_container').setStyle('display', 'none')
		
		currentFolder				= folder;
		
		gallery_open				= true;
		var breedte_hoogte			= ($('breedte_hoogte').value).split(',');
		max_breedte_image  			= parseInt(breedte_hoogte[0]);
		max_hoogte_image  			= parseInt(breedte_hoogte[1]);
		this_breedte_image  		= max_breedte_image;
		this_hoogte_image  			= max_hoogte_image;
		
		xPos_image  				= (innerWidth - max_breedte_image)/2;
		yPos_image  				= (innerHeight - max_hoogte_image)/2;
	
		imageContainerBackground.setStyles({
					'width': innerWidth,
					'height': windowheight,
					'top': -1 * windowheight,
					'opacity': 0.8,
					'display': 'block'
				});
		
		imageContainerBorder.setStyles({
					'width': max_breedte_image + 40,
					'height': max_hoogte_image + 40,
					'left': xPos_image - 20,
					'top': yPos_image - 20,
					'opacity': 0.4,
					'display': 'block'
				});
		
		imageContainer.setStyles({
					'width': max_breedte_image,
					'height': max_hoogte_image,
					'left': xPos_image,
					'top': yPos_image,
					'opacity': 0,
					'display': 'block'
				});
		
		imagePrv.setStyles({
					'left': xPos_image - 100,
					'top': yPos_image + max_hoogte_image/2 - 50,
					'opacity': 0.5,
					'display': 'block'
				});
		
		imageNxt.setStyles({
					'left': xPos_image + max_breedte_image + 60,
					'top': yPos_image + max_hoogte_image/2 - 50,
					'opacity': 0.5,
					'display': 'block'
				});
		
		imageTitle.setStyles({
					'left': middleX + -200,
					'top': yPos_image - 50,
					'display': 'block'
				});
		imageAddon.setStyles({
					'left': middleX + -200,
					'top': yPos_image + max_hoogte_image + 25,
					'display': 'block'
				});
		
		ChangeAnim('top', imageContainerBackground, 0, 500, Fx.Transitions.Cubic.easeOut);
		//ChangeAnim('top', imageContainer, yPos_image, 800, Fx.Transitions.Cubic.easeOut);
	
		var alphaContainer = function() {
			ChangeAnim('opacity', imageContainer, 1, 500, Fx.Transitions.Cubic.easeOut);
		}.delay(600);
	
		imageAddon.setStyle('display' , 'block');
		var addon_Album 	= $('addon_Album').value
		imageAddon.innerHTML = addon_Album;
		
	}
	
	
	imageClose.setStyle('display' , 'block');
	imageTitle.setStyle('display' , 'block');
	
	imageTitle.innerHTML = description;
	
	
	
	
	if(index==1){
		imagePrv.setStyle('display' , 'none');
		if(aantal_images==index){
			imageNxt.setStyle('display' , 'none');
		}
	}else if(aantal_images==index){
		imageNxt.setStyle('display' , 'none');
	}else{
		imageNxt.setStyle('display' , 'block');
		imagePrv.setStyle('display' , 'block');
	}
	currentImageIndex			= index;
	setBigImage(folder,value)
}

var imageB 		= new Array();
var loadedBig 	= new Array();
var busyBig		= false;

function setBigImage(folder,value){
	imageB = [
		folder + value
	];
	
	if (!busyBig) {
		var imageContainerImgs = $$('#imageContainer img');
		if (imageContainerImgs.length > 0){
			imageContainerImgs.each(function(image) {
				var RemoveImage = new Fx.Tween(image, {duration:400, 
					onComplete: function(){
					image.destroy();	
					loadNewImage();
				},
				transition: Fx.Transitions.linear});
				RemoveImage.start('opacity', 0);															
			});
			busyBig = true;
		}else{
			imageContainer.setStyle('display', 'block');
			loadNewImage();	
		}
	}
}

function loadNewImage(){
	new Asset.images(imageB, {
		onProgress: function(i) {
			this.setStyles({
				'position': 'absolute',
				'opacity': 0
			});
			loadedBig[i] = this;
			this_breedte_image = this.width;
			this_hoogte_image = this.height;
		},
		onComplete: function() {
			fx_mouseGalleryAnim.start({
				'left': xPos_image + (max_breedte_image-this_breedte_image)/2,
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/2,
				'width': this_breedte_image,
				'height': this_hoogte_image
			});
			
			ChangeAnim('top', imageTitle, yPos_image + (max_hoogte_image-this_hoogte_image)/2 - 50, 500, Fx.Transitions.Cubic.easeOut);
			ChangeAnim('top', imageAddon, yPos_image + (max_hoogte_image-this_hoogte_image)/2 + this_hoogte_image + 20, 500, Fx.Transitions.Cubic.easeOut);
			
			loadedBig[0].inject(imageContainer);
			var fxBG = new Fx.Morph(imageContainerBorder, {duration: 500, transition: Fx.Transitions.Cubic.easeOut,onComplete: function() {
				var showImage = new Fx.Tween(loadedBig[0], {duration:500, 
					onComplete: function(){
						busyBig  = false;
					},
					transition: Fx.Transitions.Cubic.easeOut});
				showImage.start('opacity', 1);
			}});
			fxBG.start({
				'left': xPos_image + (max_breedte_image-this_breedte_image)/2 - 20,
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/2 - 20,
				'width': this_breedte_image + 40,
				'height': this_hoogte_image + 40
			});
						
		}
	});
}

function ChangeAnim(prop, target, to, speed, trans){
	if(target){
		var myFx = new Fx.Tween(target,{duration:speed, transition: trans});
		myFx.start(prop, to );
	}
}

function MorpheItems(target, speed, trans){
	if(target){
		return new Fx.Morph(target, {duration: speed, transition: trans});
	}
}


//special init
function specialInit(occasion){
	switch(occasion){
		case 'newsletter':
			setSomeForm(occasion);
		break;
	}
}

//forms//
function setSomeForm(target_form){
	$(target_form).addEvent('submit', function(e){
		
		$('submit_newsletter').addClass('loading');
		new Event(e).stop();
		var emailCheck = checkEmail( $('email') , 0);
		if(emailCheck){
			this.set('send', {
				method: 'post',
				data: $(target_form),                                      
				onSuccess: function(responseText, responseXML) {
					$('submit_newsletter').removeClass('loading');
					var result = responseText;
					$('infobox').innerHTML = responseText;
				}
			});
			this.send(this.action); 
		}else{
			$('submit_newsletter').removeClass('loading');
			$('infobox').innerHTML = 'No valid e-mail address. Please try again.';	
		}		
	});		
}

function sendForm(target_form){
	$(target_form).set('send', {
		method: 'post',
		data: $(target_form),                                      
		onSuccess: function(responseText, responseXML) {
			$('submit_newsletter').removeClass('loading');
			var result = responseText;
			$('infobox').innerHTML = responseText;
			
		}
	});
	$(target_form).send($(target_form).action); 
}

//newsletter
function checkEmail( field , inside) {
	var emailCheck	= true;
	var objRegExp  	= /^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$/;
	if(field.value == null || field.value == ''){
		emailCheck 	= false;
	}else if( objRegExp.test(field.value)==false){
		emailCheck 	= false;
	}
		
	if(emailCheck == false){
		if(inside==1){
			$('infobox').innerHTML = 'No valid e-mail address. Please try again.';	
		}else{
			return false;
		}
	}else{
		if(inside==1){
			$('infobox').innerHTML = '';	
		}else{
			return true;
		}
	}
}

function SendSubscription(){
	$('submit_newsletter').addClass('loading');
	var emailCheck = 	checkEmail( $('email') , 0);
	if(emailCheck){
		sendForm('newsletter');
	}else{
		$('submit_newsletter').removeClass('loading');
		$('infobox').innerHTML = 'No valid e-mail address. Please try again.';	
	}
}

function bioMore(){
	$('bio_intro').fade(0);	
	$('bio_more').fade('hide');	
	$('bio_more').setStyle('display', 'block');	
	$('bio_more').fade(1);	
}
function bioIntro(){
	$('bio_intro').fade(1);	
	$('bio_more').fade(0);	
}