$(function(){
	$('.folderTree').each(function(index){
		$(this).fileTree({  
			root: $(this).attr("rel"),  
			script: '/admin/js/jqueryFileTree/connectors/jqueryFileTree.asp',  
			expandSpeed: 300,  
			collapseSpeed: 300,  
			multiFolder: true 
		}, function(file) {  
			window.open(file,'Download');  
		});
	});
});

function loadGallery(galleryId,menuId,websiteId){
	if(galleryId){		
		$.ajax({
			url: '/templates/thuez/includes/fotoboek.asp',
			data:{galleryId:galleryId,menuId:menuId,websiteId:websiteId},
			//ajaxStart:showBusyOverlay(),
			success: function(data) {
				//hideBusyOverlay();
				$("#main").html(data);
			},
			dataType: "html"
		});
	}
};
function processZoomImages(path){
	$("a.zoomImage").each(
		function(){
			var obj=$(this);
			var thumbsize = obj.attr("rel");
			var thumbsizeArr = obj.attr("rel").split("x");
			var thumbwidth = thumbsizeArr[0];
			var thumbheight = thumbsizeArr[1];
			var urlParts = /^(https?:\/\/.+?)?(\/.+?)(\?.*?)?$/.exec(obj.attr("href")); 
			var server = urlParts[1]; // maybe be '' depending on the browser 
			var relpath = urlParts[2]; 
			var query = urlParts[3]; 
			$.ajax({
				  url: path,
				  data : {
				  	  file : relpath,
					  width : thumbwidth,
					  height : thumbheight
				  },
				  success: function(data) {
					obj.html("<img src='"  + data.thumb + "' alt='' />");
				  },
				  dataType:"json"
			});
			obj.fancybox({
				'transitionIn'	:	'elastic',
				'transitionOut'	:	'elastic',
				'speedIn'		:	200, 
				'speedOut'		:	200, 
				'overlayShow'	:	false
			});
		}
	)
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
