// JavaScript Document
var navi 			= navigator.appVersion;
var browserIE 		= false;
var browserIE6 		= false;
var browserIE8		= 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);
	browserIE8 = (parseFloat(navAr[1].split(" ")[2])>7.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;

if(!browserSAF){
	if(browserIE && browserIE8 == false){
		innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 17);
	}else{
		innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
	}
	innerHeight	= parseInt((document.documentElement.clientHeight * 1));
}else{
	innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
	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.";
}


var fx_mouse_overs	= new Array;
var fx_inner_content_menu;
var fx_inner_content;

var menulist;
var mouseY,mouseX;

var item_page_array 		= new Array();
var start_content 			= new Array();

var load_innercontent		= new Array();
var swfLoad					= new Array();
var class_array 			= new Array();
var class_array 			= new Array();
var categories_array 		= new Array();
var content_folder 			= new Array();
var gallery_type			= new Array();

//side positions
var sidepositions_array 	= new Array();

var months_array			= new Array('','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var active_current		  	= 0;	

function LoadInit(){
	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 to comm between flash n js
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function makeCall(target,str) {
	thisMovie(target).asFunc(str);
	//makeCall("ID?NAME SWF OBJECT",string);
}

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(content_folder[cat]+'/'+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;
	}
}

var post_query 		= ''
var allow_click 	= true;

function processDirectClick(categories, query){
	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(gallery_open){
			closeBigImage();
		}
		
		//$('inner_content_menu').innerHTML 	= '';
		$('inner_content').innerHTML 		= '';
		active_current 						= current;
		//fx_mouse_overs[active_current].set({'background-image': 'url(../img/assets/btns/active_' + class_array[active_current] + '.png)'});
		
		post_query = query;
		if(start_content[current]){
			loadNshow(content_folder[current]+'/'+start_content[current]+query, 'inner_content_menu', 'get', swfLoad[current]);
		}else{
			allow_click	= true;
		}
}

var currentTime 			= new Date();
var month 					= currentTime.getMonth() + 1;
var day 					= currentTime.getDate();
var year 					= currentTime.getFullYear();


//common var for al center swf's
var commonSWF;

function setSomeSWF(swf_src, swf_title, swf_width, swf_height, target, swf_vars){
	var someSWF	= new SWFObject(swf_src, swf_title, swf_width, swf_height, "9", "86A098");
	someSWF.addParam('flashvars',swf_vars);
	someSWF.addParam("wmode", "transparent"); 
	someSWF.addParam("quality", "high"); 
	someSWF.addParam("allowscriptaccess", "all"); 
	someSWF.addParam("codebase", "all"); 
	someSWF.useExpressInstall('expressinstall.swf');
	someSWF.write(target);
}

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);
					}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;
				
			//	$(target).removeClass('loading_content');
				
				switch(target){
					case 'inner_content':
						
						fx_inner_content.cancel();
						fx_inner_content.set({'opacity': 0});
						
						//$(target).addClass(class_array[active_current]);
						//$(target).setProperty('class',class_array[active_current]);
						$(target).innerHTML = output;
						
						$(target).addEvent('domready', function() {
							fx_inner_content.cancel();
							fx_inner_content.start({'opacity': 1});
						});	
						
						allow_click = true;

						
					break;
					case 'inner_content_menu':
						//fx_inner_content_menu.cancel();
						//fx_inner_content_menu.set({'opacity': 0});
						
						//$(target).innerHTML = output;
						
	/*					
						if(gallery_type[active_current]==1){
							active_category = 0;
							active_gallery 	= 0;
							setAlbumInterface();
						}else if(gallery_type[active_current]==2){
							setGalleryVars(active_current);
						}else if(gallery_type[active_current]==3){
							$$('.the_thumbnail').each(function(element,index) {
								var content = element.get('title').split('::');
								element.store('tip:title', content[0]);
								element.store('tip:text', content[1]);
							});
							 
							//create the tooltips
							var tipz = new Tips('.the_thumbnail',{
								className: 'type'+active_current,
								fixed: false,
								hideDelay: 50,
								showDelay: 50
							});	
						}
	*/					
							
						if(load_innercontent[active_current]==1){
							//alert(content_folder[active_current]+'/'+item_page_array[active_current]+post_query);
							loadNshow(content_folder[active_current]+'/'+item_page_array[active_current]+post_query, 'inner_content', 'get', false);
						}else{
							processAfterClick(target,output);
							allow_click = true;	
						}
					break;
					case 'stad_container':
						$(target).innerHTML 			= output;
						loadDropDownActions('search_optionstad');
						$('stad_container').setStyle('opacity', 1);
					break;
					case 'dealer_results':
						$(target).innerHTML 			= output;
						
						var breedte_dealers	= Math.abs(innerWidth * 4/5);
						
						if(breedte_dealers < 900){
							breedte_dealers = 900
						}
			
						$('dealer_div_header').setStyle('width', breedte_dealers);
						$('dealer_div_content').setStyle('width', breedte_dealers);
						
						$('dealer_results').setStyle('opacity', 1);
					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, 'flow_photo_item.php?include_header=1&gallery='+active_gallery)
		}
		
	}
}

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.png)');
				}
			}
			
			active_option 	= element_clicker.getProperty('name');
			element_clicker.setStyle('backgroundImage', 'url(img/assets/scroll/bg_options_up.png)');
			var nr_ofValues	= $('option_value_counter'+active_option).value;
			valueTarget 	= $('search_option_values'+active_option);
			var toMove		= nr_ofValues * 16;
			if(toMove>200){
				toMove = 200;
			}
			
			ChangeAnim('height', valueTarget, toMove, 300, Fx.Transitions.Cubic.easeOut)
			
			scroller = new Scroller('search_option_values'+active_option, {area: 55, velocity: 0.2});
			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', '#cccccc');
		}
		
		var fxvalues = new Fx.Morph(element, {wait:false});
		element.addEvent('mouseenter', function(){
			if(element.getProperty('class')=='search_option_value'){									
			fxvalues.set({
				'background-color': '#dadada'
			});
			}
		});
	 
		element.addEvent('mouseleave', function(){
			if(element.getProperty('class')=='search_option_value'){									
			fxvalues.set({
				'background-color': '#ededed'
			});
			}
		});

		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', '#ededed');
				element.removeClass('selected');
			});
			element.addClass('selected');
			fxvalues.start({
				'background-color': '#cccccc'
			});
			
			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, 'flow_photo_item.php?include_header=1&gallery='+active_gallery);
					}
				break;
				case 'GalleryV2':
					tempval	= parseInt(element.getProperty('id').substring(6));
					if(active_gallery != tempval){
						active_gallery 	= tempval;
						$('search_optionGallery').innerHTML = element.innerHTML;
						closeCloset(childof);
						//alert(content_folder[active_current]+'/'+start_content[active_current]+'?include_header=1&gallery='+active_gallery);
						loadGallery(active_gallery, true, content_folder[active_current]+'/'+start_content[active_current]+'?include_header=1&gallery='+active_gallery);
					}
				break;
				default:
					tempval	= element.getProperty('id').substring(6);
					if(active_gallery != tempval){
						//active_gallery 	= tempval;
						$('search_option'+childof).innerHTML = element.innerHTML;
						closeCloset(childof);
						
						//alert(tempval)
						
						processAfterClickDropdown(childof, tempval);
						
						//loadNshow(content_folder[active_current]+'/flow_details.php?include_header=1&item='+tempval, 'contact_details', 'get', false);	
					}
					//closeCloset(childof);						
				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&categories='+active_category+'&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');

		},
		onFailure: function() {
			target_album.set('innerHTML', 'The request failed.');
		}
	});
	req.send();
}


function loadGallery(active_gallery, loadData, url){
	if(loadData){
		$('thumb_container').addClass('loading');
		
		var url = url;

		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);
	
	if(gallery_type[active_current]==1){
		var clickTarget = $('search_option'+active_option);
	}else if(gallery_type[active_current]==2){
		var clickTarget = $('search_optionGallery');
	}else{
		var clickTarget = $('search_option'+childof);
	}
	
	ChangeAnim('height', valueTarget, 0, 300, Fx.Transitions.Cubic.easeOut)
	clickTarget.setStyle('backgroundImage', 'url(img/assets/scroll/bg_options.png)');
	active_option = 0;
}

var imageContainer;
var imageContainerBorder;
var imageContainerBackground;
var imageNxt;
var imagePrv;
var imageClose;
var imageCorner;
var imageInfoBG;
var imageInfo;
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 currentAlbum		= 0;
var currentImageIndex	= 0;
var currentFolder		= '';
var aantal_images		= 0;
var imageURLS;
var imageTTLS;

function closeBigImage(){
	//$('thumb_container').setStyle('display', 'block');
	
	//$('page_navigation_click').innerHTML = $('imageNavigator').innerHTML;
	//$('imageNavigator').innerHTML = '';
	$('scroll_top').setStyle('display','block');
	$('scroll_bottom').setStyle('display','block');
	//$('imageNavigator').setStyle('display' , 'none');
	
	$('page_navigation_click').setStyles({
		'left': 340,
		'width': innerWidth - 350 - 120,
		'top': middleY + 20
	});
	minHeight	= 650;
	resizing();

	
	imagePrv.setStyle('display' , 'none');
	imageNxt.setStyle('display' , 'none');
	imageClose.setStyle('display' , 'none');
	imageCorner.setStyle('display' , 'none');
	imageInfoBG.setStyle('display' , 'none');
	imageInfo.setStyle('display' , 'none');
	//imageContainerBackground.setStyle('display' , 'none');
					ChangeAnim('opacity', imageContainerBackground, 0, 500, Fx.Transitions.Cubic.easeOut)
	imageContainerBorder.setStyle('display' , 'none');
	imageContainer.setStyle('display' , 'none');
	imageCorner.setStyle('display' , 'none');
	gallery_open 	= false;
	gallery_opened	= false;
}
		
function openBigImage(folder,value,index,title,album){
	
	var detail_link 		= '<a href="'+$('js_link_'+album).value+'" target="_blank" class="visit_site">'+$('js_link_name_'+album).value+'</a>';			
	
	if(!gallery_opened){
		
		
		
		if(!browserSAF){
			var windowDim 	= window.getScrollSize();
			windowheight	= windowDim.y;
			windowwidth		= windowDim.x;
		}else{
			windowheight 	= document.body.scrollHeight;
			windowwidth 	= document.body.scrollWidth;
		}
		aantal_images				= $('aantal_thumbs_'+album).value;
		
		gallery_opened				= true;
		imageContainer 				= $('imageContainer');
		imageContainerBackground 	= $('imageContainerBackground');
		imageContainerBorder 		= $('imageContainerBorder');

		imageURLS			 		= new Array();
		imageURLS			 		= ($('valuesURL_'+album).value).split(',');
		imageTTLS			 		= new Array();
		imageTTLS			 		= ($('valuesTitles_'+album).value).split(',');
		
		imageClose 		= $('imageClose');
		imageCorner		= $('imageCorner');
		imageInfoBG		= $('imageInfoBG');
		imageInfo 		= $('imageInfo');
		
		imagePrv 		= $('imagePrev');
		imageNxt		= $('imageNext');
		
		fx_mouseGalleryAnim			= MorpheItems('imageContainer', 300, 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) {
			//alert(currentImageIndex);
			openBigImage(currentFolder,imageURLS[currentImageIndex-2],currentImageIndex-1,imageTTLS[currentImageIndex-2],currentAlbum)
			//moveBar(-1)
		}
	});
	
	imageNxt.addEvent('click', function(event){
		if (!busyBig) {
			/*alert(currentFolder);
			alert(currentImageIndex);
			alert(currentImageIndex);
			*///moveBar(1)
			
			openBigImage(currentFolder,imageURLS[currentImageIndex],currentImageIndex+1,imageTTLS[currentImageIndex],currentAlbum)
			
		}
	});
	}
	
	if(!gallery_open){
		
		
		
		//$('imageNavigator').setStyle('display','block');
		$('scroll_top').setStyle('display','none');
		$('scroll_bottom').setStyle('display','none');
		//$('page_navigation_click').setStyle('display','none');
		
		minHeight	= 760;
		resizing();

		//$('thumb_container').setStyle('display', 'none')
		
		gallery_open				= true;
		var breedte_hoogte			= ($('breedte_hoogte_'+album).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  				= middleX - max_breedte_image / 2;

		yPos_image  				= 50;

		
		imageContainerBackground.setStyles({
					'width': innerWidth,
					'height': windowheight - 70,
					'top': 50,
					'opacity': 0,
					'display': 'block'
				});
		
		imageContainerBorder.setStyles({
					'width': max_breedte_image + 4,
					'height': max_hoogte_image + 2,
					'left': xPos_image - 2,
					'top': yPos_image,
					'opacity': 1,
					'display': 'block'
				});
		imageClose.setStyles({
					'left': xPos_image - 22,
					'top': yPos_image - 22,
					'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': max_hoogte_image/2  +  yPos_image,
					'opacity': 1,
					'display': 'block'
				});
		
		
		imageNxt.setStyles({
					'left': xPos_image + max_breedte_image + 60,
					'top': max_hoogte_image/2  +  yPos_image,
					'opacity': 1,
					'display': 'block'
				});
		
		imageCorner.setStyles({
					'left': middleX + (475-90),
					'top': yPos_image + 570 - 90,
					'display': 'none'
				});
		imageInfoBG.setStyles({
					'left': middleX,
					'width': 450,
					'top': yPos_image - 25,
					'opacity': 1,
					'display': 'block'
				});
		imageInfo.setStyles({
					'left': xPos_image + 20,
					'width': 440,
					'top': yPos_image - 25,
					'display': 'block'
				});
		
		
		$('page_navigation_click').setStyles({
					'left': middleX - max_breedte_image / 2 + 30,
					'width': max_breedte_image - 60,
					'top': max_hoogte_image + 55
				});
		
		
		ChangeAnim('opacity', imageContainerBackground, 0.9, 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);
	
	
	}
	
	currentFolder				= folder;
		
	imageClose.setStyle('display' , 'block');
	imageInfoBG.setStyle('display' , 'block');
	imageInfo.setStyle('display' , 'block');

	imageInfo.innerHTML 		= detail_link + title;
	
	aantal_images				= $('aantal_thumbs_'+album).value;
		
	imageURLS			 		= new Array();
	imageURLS			 		= ($('valuesURL_'+album).value).split(',');
	imageTTLS			 		= new Array();
	imageTTLS			 		= ($('valuesTitles_'+album).value).split(',');
	
	currentImageIndex			= index;
	currentAlbum				= album;		
					

	
		
	
	
	//alert(aantal_images);
	
	if(index==1){
		imagePrv.setStyle('display' , 'none');
		if(aantal_images==index){
			imageNxt.setStyle('display' , 'none');
		}else{
			imageNxt.setStyle('display' , 'block');
		}
	}else if(aantal_images==index){
		imageNxt.setStyle('display' , 'none');
	}else{
		imageNxt.setStyle('display' , 'block');
		imagePrv.setStyle('display' , 'block');
	}
	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() {
			
			loadedBig[0].inject(imageContainer);
			
			fx_mouseGalleryAnim = new Fx.Morph(imageContainer, {duration: 400, transition: Fx.Transitions.Cubic.easeOut,onComplete: function() {
				var showImage = new Fx.Tween(loadedBig[0], {duration:400, 
				onComplete: function(){
					busyBig  = false;
				},
				transition: Fx.Transitions.Cubic.easeOut});
				showImage.start('opacity', 1);
			}});
			
			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
			});
			//MorpheItems('imageContainer', 300, Fx.Transitions.Cubic.easeOut);
//			
			//ChangeAnim('opacity', 'imageContainer', 1, 500, Fx.Transitions.Cubic.easeOut);
			
			var fxBG = new Fx.Morph(imageContainerBorder, {duration: 500, transition: Fx.Transitions.Cubic.easeOut});
			fxBG.start({
				'left': xPos_image + (max_breedte_image-this_breedte_image)/2 - 2,
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/20,
				'width': this_breedte_image + 4,
				'height': this_hoogte_image + 2
			});
			var fxClose = new Fx.Morph(imageClose, {duration: 500, transition: Fx.Transitions.Cubic.easeOut});
			fxClose.start({
				'left': xPos_image + (max_breedte_image-this_breedte_image)/2 - 22,
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/2 - 22
			});
			/*var fxInfoBg = new Fx.Morph(imageInfoBG, {duration: 500, transition: Fx.Transitions.Cubic.easeOut});
			fxInfoBg.start({
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/2 - 25
			});*/
			/*var fxInfo = new Fx.Morph(imageInfo, {duration: 500, transition: Fx.Transitions.Cubic.easeOut});
			fxInfo.start({
				'top': yPos_image + (max_hoogte_image-this_hoogte_image)/2 - 25
			});*/
						
		}
	});
}

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});
	}
}

//forms//
function setSomeForm(target_form, target_loading, target_output){
	$(target_form).addEvent('submit', function(e){
		
		$(target_loading).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) {
					$(target_loading).removeClass('loading');
					var result = responseText;
					$(target_output).innerHTML = responseText;
				}
			});
			this.send(this.action); 
		}else{
			$(target_loading).removeClass('loading');
			$(target_output).innerHTML = 'No valid e-mail address. Please try again.';	
		}		
	});		
}

function sendForm(target_form, target_loading, target_output){
	$(target_form).set('send', {
		method: 'post',
		data: $(target_form),                                      
		onSuccess: function(responseText, responseXML) {
			$(target_loading).removeClass('loading');
			var result = responseText;
			$(target_output).innerHTML = responseText;
			
		}
	});
	$(target_form).send($(target_form).action); 
}

//newsletter
function checkEmail( field , inside, target_output) {
	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){
			$(target_output).innerHTML = 'No valid e-mail address. Please try again.';	
		}else{
			return false;
		}
	}else{
		if(inside==1){
			$(target_output).innerHTML = '';	
		}else{
			return true;
		}
	}
}