// JavaScript Document
var content_folder 		= new Array('','blog','portfolio','contact');
var page_content 		= new Array('','detail.php','detail.php','detail.php','detail.php','detail.php','detail.php');
var url_name 			= new Array('','blog','portfolio','contact');
var menu_name 			= new Array('','blog','portfolio','contact');

var root_short			= 'bekkum';
var has_scroll			= false;

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

var q_str_page			= '';
var q_str_item			= 0;
var active_current		= 1;
var active_menu			= 1;




var active_categories	= 0;
var active_parent		= 0;
var active_item			= 0;
var active_position		= 0;

var display_methods		= new Array('thumbs','rows','one');
var display_method		= 0;

var minimized			= true;
var left_pos			= 0;

var mySpinner;
var navigating			= false;

var url_to_load;
var allow_click			= true;

var swf_load_item		= false;
var swfOveruler			= false;

function LoadPageAll(basis_url, pagina, basis_item){
	$('main_container').setStyle('left' , 0);
	$('main_container').setStyle('top' , 0);
	
	hasFlash();
	
	menulist			= $$('.navigation_div_horizontal');
	menulist.each(function(element) {
		var current = parseInt(element.getProperty('id').substring(4));
		fx_mouse_overs[current] = MorpheItems(element.getProperty('id'), 500, Fx.Transitions.Cubic.easeOut);
		
		element.addEvent('mouseenter', function(event){ 
			var current = parseInt(element.getProperty('id').substring(4));
			if(active_current!=current){
				fx_mouse_overs[current].cancel();
				fx_mouse_overs[current].start({'padding-top':0});
			}
		});
		element.addEvent('mouseleave', function(){
			var current = parseInt(element.getProperty('id').substring(4));
			if(active_current!=current){
				fx_mouse_overs[current].cancel();
				fx_mouse_overs[current].start({'padding-top':0});
			}
		});
	});
	
	fx_inner_content 	 			= MorpheItems('inner_content', 800, Fx.Transitions.Cubic.easeOut);
	fx_inner_content_menu 			= MorpheItems('inner_content_menu', 800, Fx.Transitions.Cubic.easeOut);
	
	q_str_page			= pagina;
	q_str_item			= basis_item;
	
	for(var i=0;i<menu_name.length;i++){
		if(url_name[i] == q_str_page){
			active_current	= i;
			if(fx_mouse_overs[active_current]){
//				fx_mouse_overs[active_current].cancel();
//				fx_mouse_overs[active_current].start({'opacity':1});
			}
		}
		if(menu_name[i] == q_str_page){
			active_menu	= i;
		}
	}
	
	
	var imgswapCounter	= 0;
	$$('.imgswap').each(function(img) {
		imgswapCounter++;
		var src 		= img.getProperty('src');
		var extension 	= src.substring(src.lastIndexOf('.'),src.length)
		if(imgswapCounter==active_menu){
			img.setProperty('src',src.replace(extension,'-active' + extension));
		}else{
			img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'-active' + extension)); });
			img.addEvent('mouseleave', function() { img.setProperty('src',src); });
		}
	}); 
	
	switch(pagina){
		case 'portfolio':
//			maxHeight	= 720;	
		break;
	}
	
	firstResize();	
	
	if(basis_item>0){
		active_item 					= basis_item;
		fxcontentShower					= MorpheItems('inner_content_content', 250, Fx.Transitions.Cubic.easeOut);
		fxcontentShower.set({'display': 'none'});	
		
		listing_thumb_array				= new Array;				
		listing_thumb_list				= $$('#inner_content_content img');
		initItemFinalize();
	}
	switch(pagina){
		case 'portfolio':
			if($('listing_container')){
				
				$('formfilter').removeEvent('submit');
				$('formfilter').addEvent('submit', function(e){
					new Event(e).stop();
					if($('zoeknaam').value != ''){
						runTagFilter('zoeknaam');
					}
				});
				
				active_view					= $('viewoption').value;
			}else{
				//detail
			}
			if(!$('detail_image_navigation')){
				allow_auto_refresh = true;
				setSlideBase();
			}
		break;
		case 'contact':
			setSlideBase();
		break;
		case 'blog':
			setSlideBase();
			if($('active_item')){
				if(basis_item == 0){
					basis_item	= $('active_item').value
					if(basis_item>0){
						active_item 					= basis_item;
						fxcontentShower					= MorpheItems('inner_content_content', 250, Fx.Transitions.Cubic.easeOut);
						fxcontentShower.set({'display': 'none'});	
						
						listing_thumb_array				= new Array;				
						listing_thumb_list				= $$('#inner_content_content img');
						initItemFinalize();
					}
				}
			}
			
			if($('search_optionjaar')){
				loadDropDownActions('search_optionjaar','jaar');		
			}
			if($('search_optionmaand')){
				loadDropDownActions('search_optionmaand','maand');		
			}
			
		break;
	}
	
	//document.body.addEvent('contextmenu',function(e) {
	 // e.stop();
	//});

	window.onresize = function goResize(){resizing();}
}


var minWidth		= 990; //buffert of 20! basic width = 916 rounded gives 920 + 20
var minHeight		= 800; //buffert of 20! basic width = 916 rounded gives 920 + 20
function firstResize(){
	
	//if(q_str_page!='blog'){
		if(document.documentElement.clientWidth){
		
			if(!browserSAF){
				if(browserIE && browserIE8 == false){
					innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
				}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));
			}
			
			if(innerWidth<minWidth){
				innerWidth 	= minWidth;
			}
			if(innerHeight < minHeight){
				if(!browserIE){
					innerWidth 	= parseInt(innerWidth - 17);
				}
				innerHeight = minHeight;
				has_scroll	= true;
			}
		}else{
			innerWidth 	= minWidth;
			innerHeight = minHeight;
		}
	//}else{
	//	innerWidth 	= parseInt((document.documentElement.clientWidth * 1)) - 17;
	//	innerHeight = 0;
	//}
	positionAfterResize();
	
}

function resizing(){
	if(document.documentElement.clientWidth){
		if(!browserSAF){
			if(browserIE && browserIE8 == false){
				innerWidth 	= parseInt((document.documentElement.clientWidth * 1));
			}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));
		}
		if(innerWidth<minWidth){
			innerWidth 	= minWidth;
		}
		if(innerHeight < minHeight){
			if(innerHeight > minHeight){ 
				if(!browserIE){
					if(!browserSAF){
						innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 17);
					}else{
						innerWidth 	= parseInt((document.documentElement.clientWidth * 1) - 16);
					}
				}
			}
			innerHeight = minHeight;
			has_scroll	= true;
		}
	}else{
		innerWidth 	= minWidth;
		innerHeight = minHeight;
	}
	positionAfterResize();
					
}


var maxWidth 			= 0; //1080; //if 0 then innerwidth!
var av_width			= 0; //will be set
var maxHeight			= 0; //455; //if 0 then innerHeight!
var av_height			= 0; //will be set

function positionAfterResize(){
	
	middleX				= innerWidth / 2;
	middleY				= innerHeight / 2;
	
	$('footer').setStyles({'left' : middleX - 487,'top' : innerHeight - 65});
	$('header-bar').setStyles({'left' : middleX - 487});
	$('navigation').setStyles({'left': middleX - 487});
	$('main_container').setStyles({'width' : innerWidth, 'height' : innerHeight, 'top' : 0});
	
	if(maxWidth > 0){
		//work with maxWidth instead of innerWidth!
		if(innerWidth > maxWidth + 20 ){ //scrollbarbuffer..always
			av_width		= maxWidth;
		}else{
			av_width		= innerWidth-20;
		}
	}else{
		av_width	= innerWidth;
	}
	
	if(maxHeight > 0){ //fixed height
		av_height		= maxHeight;
	}else{
		av_height		= innerHeight - 41 - 215; //used for slideshows! - 90 - 170 means minus header and minus footer(+ info)
		av_height		= innerHeight; //used for slideshows! - 90 - 170 means minus header and minus footer(+ info)
	}
	
	$('big_logo').setStyles({'left' : middleX + 385 });
	
	proportions_site 		= av_height / av_width;  
	
	switch(q_str_page){
		case 'map':
			$('big_logo').setStyles({'display' : 'none' });
			$('inner_content').setStyles({'height' : av_height , 'width' : av_width, 'left' : 0});	
			$('inner_content_menu').setStyles({'height' : av_height , 'width' : av_width, 'left' : 0});	
				$('inner_content_menu').setStyles({'background-color' : '#000000'});
		
			$('mapembed').setStyles({'height' : av_height , 'width' : av_width});
			$('pano').setStyles({'height' : av_height , 'width' : av_width});
			
			//$('contactdiv').setStyles({'left' : middleX, 'top' : middleY - 150});
			initializeMaps();
			
		break;
		case 'portfolio':
			$('inner_content_menu').setStyles({'left' : middleX - 495});
			
			
			filterShower			= MorpheItems('filterform_background', 800, Fx.Transitions.Cubic.easeOut);
			filterContent			= MorpheItems('filterform', 800, Fx.Transitions.Cubic.easeOut);
			
			listingShower			= MorpheItems('listing_container_background', 800, Fx.Transitions.Cubic.easeOut);
			listingContent			= MorpheItems('listing_container_content', 800, Fx.Transitions.Cubic.easeOut);
			$('slides_container').setStyles({'width' : innerWidth, 'height' : innerHeight});
						
			if($('listing_container')){
				filter_status	= 0;
				listing_status	= 3;
				
				
				
				$('listing_container_background').setStyle('opacity',0.7);
				$('filterform_background').setStyle('opacity',0.7);
				initListingDivs();
			}
			
			if($('detail_image_navigation')){
				filter_status	= 1;
				listing_status	= 4;

				$('filter_opener').addClass('closed');
				$('selection_opener').addClass('closed');
				filterShower.set({'width':0});
				filterContent.set({'opacity':0});
				listingShower.set({'width':0});
				listingContent.set({'width':0,'opacity':0});
				
				
				if($('detail_loader')){
					$('detail_loader').setStyles({'opacity':0, 'display':'block', 'left':middleX ,'top':middleY - 18});
					$('detail_loader').fade('in');
				}
				$('inner_content_content').setStyles({'height' : av_height , 'width' : av_width, 'left' : 0});	
				$('detail_image_navigation').setStyles({'top' : av_height  / 2 - 25});			 
				$('detail_content_container').setStyles({'left' : middleX + 240});				 
				
				if(!BI){
				$('thumbs_container_background').setStyle('opacity',0.7);
				$('thumbs_container').setStyles({'left' : middleX - 425})	
				}else{
				$('thumbs_container').setStyles({'left':innerWidth - 160})	
				}
				
				$('blog_container_background').setStyle('opacity',0.7);
				$('blog_container').setStyles({'left' : middleX - 425});		
				
				$('detail_content_container_background').setStyles({'opacity' : 0.8});		
				
				
				fxItemsArchive 				= MorpheItems('listing_container_scrollable_content_archive', 1000, Fx.Transitions.Cubic.easeInOut);
				$('item_content').setStyles({'left' : middleX - 425});
				if($('item_content_background')){
					$('item_content_background').setStyle('opacity',0.9);
				}
				toScrollArchive		 		= 4;
				
				$('detail_image_container').setStyles({'height' : av_height , 'width' : av_width});	
				$('detail_image_content').setStyles({'height' : av_height , 'width' : av_width});	
				resizeImage(av_width, av_height);
			}
		break;
		case 'blog':
			$('slides_container').setStyles({'width' : innerWidth, 'height' : innerHeight});
			
			fxItems 		= MorpheItems('listing_container_scrollable_content', 1000, Fx.Transitions.Cubic.easeInOut);
			fxItemsArchive 	= MorpheItems('listing_container_scrollable_content_archive', 1000, Fx.Transitions.Cubic.easeInOut);
			
			$('inner_content_menu').setStyles({'left' : middleX - 495});
			if($('listing_container')){
				$('listing_container_background').setStyle('opacity',0.7);
				$('listing_container_background_archive').setStyle('opacity',0.7);
			}
			
			
			
			if($('post_content')){
				$('inner_content').setStyles({'height' : av_height , 'width' : av_width, 'left' : 0});	
				$('inner_content_content').setStyles({'height' : av_height , 'width' : av_width, 'left' : 0});	
				$('item_content').setStyles({'left' : middleX - 425});
				
				if(archive_status == 1){
				$('item_content').setStyles({'top' : 400});
				}
				
				$('item_content_background').setStyle('opacity',0.9);
				
//				$('detail_image_container').setStyles({'height' : av_height , 'width' : av_width});	
//				$('detail_image_content').setStyles({'height' : av_height , 'width' : av_width});
				$('detail_image_container').setStyles({'height' : 0 , 'width' : 0});	
				$('detail_image_content').setStyles({'height' :  0 , 'width' :  0});	
				resizeImage(av_width, av_height);
						
			}
		break;
		case 'contact':
			$('slides_container').setStyles({'width' : innerWidth, 'height' : innerHeight});
			$('inner_content_menu').setStyles({'height' : 400, 'width' : 960, 'left' : middleX - 495});
			$('inner_content').setStyles({'display' : 'none'});
			$('contact_container_background').setStyle('opacity',0.7);
			$('about_container_background').setStyle('opacity',0.7);
		break;
	}

	$('navigation').setStyle('display' , 'block');
	$('main_container').setStyle('display' , 'block');
}


function initPageItem(){
	fx_inner_content.set({'display': 'block'});
}

function initItemFinalize(){
	if(($('is_product') && $('is_product').value == 'yes' && $('product_id') && $('product_id').value != '')){
		product_id 		= $('product_id').value;
		initproduct();
	}else{
		initDetail(content_folder[active_current]);
		allow_click		= true;
	}
}

function initDetail(page){
	switch(page){
		case 'portfolio':
			listing_thumb_list.each(function(element){
				listing_thumb_array.push(element.src);
			});	
			
			if(listing_thumb_array.length > 0 ){
				var myImages = new Asset.images(listing_thumb_array, {
					onComplete: function(){
						if(mySpinner){
						   mySpinner.destroy();
						}
						if($('detail_loader')){
							$('detail_loader').setStyle('display','none');
						}
						finalizePortfolio();
					}
				});	
			}else{								
				if(mySpinner){
				   mySpinner.destroy();
				}
				finalizePortfolio();
			}
			fxcontentShower.set({'opacity': 1, 'display': 'block'});
		break;
		case 'blog':
			fxcontentShower.set({'opacity': 1, 'display': 'block'});
			
			finalizeBlog();
		break;
	}
}

function runFilter(){
	var jaar 			= $('active_jaar').value;
	var maand 			= $('active_maand').value;
	var page 			= $('page_nr_archive').value;
	
	var url_to_load		= root_domain + 'blog/archive-listing.php?include_header=1&maand='+maand+'&jaar='+jaar+'&page='+page;
	loadNshow(url_to_load, 'listing_container_scrollable_content_archive', 'get', false);
}

var disabledTags 		= new Array;
function runTagFilter(tag){
	
	if(tag == 'zoeknaam'){
		$('tagfilter').value			= '';
		disabledTags 					= new Array;
		var url_to_load					= root_domain + 'portfolio/listing-bekkum.php?include_header=1&zoeknaam='+ $(tag).value;
		loadNshow(url_to_load, 'listing_container_scrollable', 'get', false);
	}else if(tag == 0){
		$('tagfilter').value			= '';
		disabledTags 					= new Array;
		var url_to_load					= root_domain + 'portfolio/listing-bekkum.php?include_header=1';
		loadNshow(url_to_load, 'listing_container_scrollable', 'get', false);
	}else{
		if(!in_array(tag, disabledTags)){
			var current_tagfilter				= $('tagfilter').value;
			var current_tagfilter_array			= new Array;
			var current_tagfilter_array_temp	= new Array;
			var tagExistsInFilter				= false;
			
			if(current_tagfilter.length > 0){
				current_tagfilter_array = current_tagfilter.split(',');
				for (var i = 0; i < current_tagfilter_array.length; i++){
					if(current_tagfilter_array[i] != tag){
						current_tagfilter_array_temp.push(current_tagfilter_array[i]);
					}else{
						tagExistsInFilter = true;
					}
				}
				if(!tagExistsInFilter){
					current_tagfilter_array_temp.push(tag);
				}
				
				current_tagfilter_array		= current_tagfilter_array_temp;
				current_tagfilter 			= current_tagfilter_array.join();
				
			}else{
				current_tagfilter_array[0] 	= tag;
				current_tagfilter 			= tag;
			}
			
			$('tagfilter').value			= current_tagfilter;
			
			var url_to_load		= root_domain + 'portfolio/listing-bekkum.php?include_header=1&tagfilter='+current_tagfilter;
			loadNshow(url_to_load, 'listing_container_scrollable', 'get', false);
		}
	}
	
}

var open_full 			= false;
var detail_width		= 565;
var active_view			= 'thumbs';
var count_inlist		= 0;
var fx_list_items		= new Array;
var items_inlist		= new Array;
var categories_inlist	= new Array;

var imgHider;
var infoHider;
var navigateItemStarted	= false;
	
var currentPosition 	= 0;
var currentItemsCount 	= 0;	
var toScroll		 	= 5;	
var toScrollWidth	 	= -112;
var fxItems;	
function navigateList(direction){
	currentItemsCount	= $('count_inlist').value;
	switch(direction){
		case 1:
			//rechts // ouder bericht
			//we willen m uitvullen!
			if((currentPosition + toScroll + toScroll) <= currentItemsCount){
				currentPosition += toScroll;
			}else{
				var tempvalue = currentPosition + toScroll + toScroll - currentItemsCount
				currentPosition += toScroll - tempvalue;
			}
		break;
		case -1:
			//links // nieuwer bericht
			currentPosition -= toScroll;
			if(currentPosition<0){
				currentPosition = 0;
			}
		break;
	}
	fxItems.cancel();
	fxItems.start({'left': toScrollWidth * currentPosition});
}

var currentPositionArchive 		= 0;
var currentItemsCountArchive 	= 0;	
var toScrollArchive		 		= 5;	
var toScrollWidthArchive	 	= -112;
var fxItemsArchive;	
function navigateListArchive(direction){
	currentItemsCountArchive	= $('count_inlist_archive').value;
	switch(direction){
		case 1:
			//rechts // ouder bericht
			//we willen m uitvullen!
			if((currentPositionArchive + toScrollArchive + toScrollArchive) <= currentItemsCountArchive){
				currentPositionArchive += toScrollArchive;
			}else{
				var tempvalue = currentPositionArchive + toScrollArchive + toScrollArchive - currentItemsCountArchive
				currentPositionArchive += toScrollArchive - tempvalue;
			}
		break;
		case -1:
			//links // nieuwer bericht
			currentPositionArchive -= toScrollArchive;
			if(currentPositionArchive<0){
				currentPositionArchive = 0;
			}
		break;
	}
	fxItemsArchive.cancel();
	fxItemsArchive.start({'left': toScrollWidthArchive * currentPositionArchive});
}	

var currentPositionThumb 	= 0;
var currentItemsCountThumb	= 0;	
var toScrollThumb		 	= 2;	
var toScrollWidthThumb	 	= -92;
var fxItemsThumb;	
function navigateListThumb(direction){
	currentItemsCountThumb	= $('aantal_thumbs_2').value;
	switch(direction){
		case 1:
			//rechts // ouder bericht
			//we willen m uitvullen!
			if((currentPositionThumb + toScrollThumb + toScrollThumb) <= currentItemsCountThumb){
				currentPositionThumb += toScrollThumb;
			}else{
				var tempvalue = currentPositionThumb + toScrollThumb + toScrollThumb - currentItemsCountThumb
				currentPositionThumb += toScrollThumb - tempvalue;
			}
		break;
		case -1:
			//links // nieuwer bericht
			currentPositionThumb -= toScrollThumb;
			if(currentPositionThumb<0){
				currentPositionThumb = 0;
			}
		break;
	}
	fxItemsThumb.cancel();
	fxItemsThumb.start({'left': toScrollWidthThumb * currentPositionThumb});
}


function navigateItem(direction){
	if(allow_click == true){
		
		openCloseThumbs(3);
		openCloseThumbs(1);
		
		
		allow_click			= false;
		
		if(!navigateItemStarted){
			var items_inlist_str		= $('items_inlist').value;
			count_inlist				= $('count_inlist').value;
			var categories_inlist_str	= $('categories_inlist').value;
			items_inlist				= items_inlist_str.split(',');
			categories_inlist			= categories_inlist_str.split(',');
		}
		
		var current_active_item;
		if($('selected_article')){
			if($('articles_inlist')){
				var articles_inlist_str		= $('articles_inlist').value;
				var articles_inlist			= articles_inlist_str.split(',');
				current_active_item 		= $('selected_article').value;
				for(var i=0;i<count_inlist;i++){
					if(articles_inlist[i] == current_active_item){
						active_position	= i;
					}	
				}
			}else{
				current_active_item 		= active_item;
				for(var i=0;i<count_inlist;i++){
					if(items_inlist[i] == current_active_item){
						active_position	= i;
					}	
				}	
			}
		}else{
			current_active_item 		= active_item;
			for(var i=0;i<count_inlist;i++){
				if(items_inlist[i] == current_active_item){
					active_position	= i;
				}	
			}
		}
		
		//Log.log(active_position);
		
		switch(direction){
			case 1:
				//rechts // ouder bericht
				if(active_position < (count_inlist - 1) ){
					active_position++;
				}else{
					active_position	= 0;	
				}
			break;
			case -1:
				//links // nieuwer bericht
				if(active_position>0){
					active_position--;
				}else{
					active_position		= count_inlist - 1 ;
				}
			break;
		}
		
		var infoHider_target;
		var positionMove;
		
		
		if($('detail_image_container_sets')){
			if(navigateItemStarted){
				imgShower.cancel();
			}
			imgHider				= MorpheItems('detail_image_container_sets', 800, Fx.Transitions.Cubic.easeOut);
			imgHider.start({'opacity':0, 'top':0, 'left':0});	
			infoHider_target		= 'detail_content_container';
			positionMove			= true;
			
			if(navigateItemStarted){
				infoShower.cancel();
			}
		}else if($('detail_image_container')){
			
			//hideTabs();
			if(navigateItemStarted){
				imgShower.cancel();
			}
			imgHider				= MorpheItems('detail_image_content', 800, Fx.Transitions.Cubic.easeOut);
			imgHider.cancel();
			imgHider.start({'opacity':0});
			
			infoHider_target		= 'detail_info_text';
			positionMove			= true;
		
			if(navigateItemStarted){
				infoShower.cancel();
			}
		}else{
			infoHider_target		= 'inner_content_content';
			positionMove			= false;
		}
		
		infoHider		= new Fx.Morph(infoHider_target, {duration: 800, transition: Fx.Transitions.Cubic.easeOut, 
			onComplete: function(){
				gallery_opened_detail	= false;
				if($('detail_url_str')){
					
					var urls_string	= $('detail_url_str').value;
					var urls_array	= urls_string.split(',');
			
					var new_url		= urls_array[active_position];
					window.location = new_url;
				}else{
					openItem(items_inlist[active_position], categories_inlist[active_position], active_position, true);
				}
			}
		});
		
		navigateItemStarted		= true;	
			
		if(positionMove){
			infoHider.set({'opacity':0});
			infoHider.start({'opacity':0});		
		}else{
			infoHider.start({'opacity':0});	
		}
		
	}
}

function baseInitListingControls(loadImages){
	//Log.log('listing : config scroll & dropdown');
	fxcontentShower					= MorpheItems('listing_container', 400, Fx.Transitions.Cubic.easeOut);
	fxcontentShower.set({'opacity': 0, 'display': 'block'});									
	listing_thumb_array				= new Array;				
	listing_thumb_list				= $$('#inner_content_menu_listing img');
	initListLoadnShow(loadImages);
}

var fxcontentShower;
var listing_thumb
var listing_thumb_list;
var listing_thumb_array		= new Array;				
var fx_listing_thumb		= new Array;				
				
function processAfterClick(target, output){
	switch(target){
		case 'inner_content_content':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				fxcontentShower					= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
				listing_thumb_array				= new Array;				
				listing_thumb_list				= $$('#inner_content_content img');
				
				positionAfterResize();
				initItemFinalize();
			});
		break;
		case 'item_content':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				fxcontentShower					= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
				listing_thumb_array				= new Array;				
				listing_thumb_list				= $$('#item_content img');
				
				positionAfterResize();
				
			fxcontentShower.set({'opacity': 1, 'display': 'block'});
			
			finalizeBlog();
			});
		break;
		case 'login_area_content':
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				
				if($('form_account')){
					ChangeAnim('height', $('login_area'), 200, 400, Fx.Transitions.Cubic.easeOut);
					ChangeAnim('height', $('login_area_background'), 180, 400, Fx.Transitions.Cubic.easeOut);
					setSomeForm('form_account','account_form','account_form','info_creation', false, 'submit_btn');
					allow_click		= true;
					
									
				}
				
				basicShow(target, false, true);
			});
		break;
		case 'listing_container_scrollable_content_archive':
		
			currentPositionArchive	= 0;
			fxItemsArchive.set({'left': 0});
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				allow_click		= true;
				basicShow(target, false, true);
			});;
		break;
		case 'listing_container_scrollable':
		
			$(target).innerHTML = output;
			$(target).addEvent('domready', function() {
				allow_click		= true;
				disabledTags	= new Array;
				
				if($('allowed_filters')){
					var str_allowed = $('allowed_filters').value;
					var str_all		= $('all_filters').value;
					var str_used	= $('tagfilter').value;
					
					var array_allowed 	= str_allowed.split(',');
					var array_all 		= str_all.split(',');
					var array_used		= str_used.split(',');
					for (var i = 0; i < array_all.length; i++){
						var this_tag	= array_all[i];
						
						if($('tag_'+this_tag)){
							if(in_array(this_tag, array_allowed)){
								if(in_array(this_tag, array_used)){
									$('tag_'+this_tag).addClass('active');
									$('tag_'+this_tag).removeClass('disabled');
								}else{
									$('tag_'+this_tag).removeClass('disabled');
									$('tag_'+this_tag).removeClass('active');
								}
							}else{
								$('tag_'+this_tag).addClass('disabled');
								disabledTags.push(this_tag);
								$('tag_'+this_tag).removeClass('active');
							}
						}
					}
				}
				
				
				basicShow(target, false, true);
				allow_auto_refresh = true;
				setSlideBase();
				initListingDivs();
			});;
		break;
	};
}

function basicShow(target,animate,allowclick){
	fxcontentShower	= MorpheItems(target, 400, Fx.Transitions.Cubic.easeOut);
	if(animate){
		if(mySpinner){
		   mySpinner.hide();
		}
		fxcontentShower.start({'opacity': 1});
	}else{
		if(mySpinner){
		   mySpinner.destroy();
		}
		fxcontentShower.set({'opacity': 1});
	}
	
}


var basis_rows;
var row_height;
var loaded_rows;
var loaded_images;
var items_per_row;
var stepper			= 0;

var scroll_innited	= false;
var wanna_see		= 324;
var busyBig			= false;
var inside_image 	= false;



function initListLoadnShow(loadImages){
	if(loadImages){
		listing_thumb_list.each(function(element){
			listing_thumb_array.push(element.src);
		});	
		if(listing_thumb_array.length > 0){
			var myImages = new Asset.images(listing_thumb_array, {
				onComplete: function(){
					initListShow();
				}
			});
		}else{
			initListShow();
		}
	}else{
		initListShow();			
	}
}


function initListShow(){
	var music_list			= $$('.listing-music-holder');
	music_list.each(function(element) {
		var current_music				= parseInt(element.getProperty('id').substring(13));
		music_array[current_music]		= false;
		element.addEvent('click', function(){
			var this_music				= parseInt(element.getProperty('id').substring(13));
			openMusic(this_music);
		});
	});
	if(mySpinner){
	   mySpinner.destroy();
	}
	if(active_form_busy){
		active_form_busy	= false;
		$('listing_container').unspin();
	}
	
	var page_nr			= parseInt($('page_nr').value);
	var countertje		= parseInt($('count_inlist').value);
	var maxInList		= parseInt($('maxInList').value);
	if(countertje < page_nr * maxInList){
		$('olderposts').setStyle('opacity',0);
		//$('olderposts_footer').setStyle('opacity',0);
		if(countertje == 0){
			$('inner_content_menu_listing').setStyle('background-image','none');
		}
	}else{
		$('olderposts').setStyle('opacity',1);
		//$('olderposts_footer').setStyle('opacity',1);
	}
	var current_page 	= $('page_nr').value;
	if(current_page==1){
		$('newerposts').setStyle('opacity',0);
		//$('newerposts_footer').setStyle('opacity',0);
	}else{
		$('newerposts').setStyle('opacity',1);
		//$('newerposts_footer').setStyle('opacity',1);
	}
	
	if($('listing_loader')){
		$('listing_loader').setStyle('display','none');
	}
	fxcontentShower.cancel();									
	fxcontentShower.set({'opacity': 1});									
	
	allow_click		= true;
}

function makeCall(target,str) {
	thisMovie(target).asFunc(str);
}

function resetDetail(){
	active_item								= 0;
	$('inner_content_content').innerHTML 	= '';
	active_position							= 0;
	fx_inner_content.cancel();
	fx_inner_content.start({'left':0, 'width':0});	
	open_full 								= false; // resetten want item is gesloten!
}

var new_top;
function openItem(items_id, categories, position, overrule_allow_click){
	////Log.log('open item : meaning : zet de indicator op de juiste plek / scroll listing indien nodig / laad het item in!');
	if(allow_click || overrule_allow_click){
		allow_click 							= false;
		active_item								= items_id;
		var soort_listing						= $('page').value;
		switch(soort_listing){
			case 'blog': //blog
				url_to_load			= root_domain + 'blog/detail.php?include_header=1&item='+items_id+'&categories='+categories;
			break;
		}
		loadNshow(url_to_load, 'inner_content_content', 'get', false);
	}
}


function openItemLoad(url){
	loadNshow(url_to_load, 'inner_content_content', 'get', false);
}

var product_id;


var main_parent_name	= '';
var parent_name			= '';
var main_parent_id		= 0;
var parent_id			= 0;

function initFilter(){
	if($('filterform')){
		if($('search_optionfilter_0')){
			loadDropDownActions('search_optionfilter_0','filter_0');
		}
	}
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}
