$(document).ready(function(){	
	$(".scrollable").scrollable();
	$('.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');  
		    });
	});
	$('.slideshow').cycle({
		fx: 'fade', 
		random:1
	});	
	$('.slideshow_intro').cycle({
		fx: 'fade', 
		random:0
	});	
	$("a.zoomLink").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	$(".youtube").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
	
});

function loadVerkaveling(flashId,websiteLoft,websiteAppartement,websiteWoning,websiteHandelsruimte,websiteUniekmonument,websiteParking,websiteExtra,websiteTerug){
	var flashV = {	
		id: flashId,
		websiteLanguage:websiteLanguage,
		templateXml:'/templates/wilma/includes/mapsXml.asp?websiteId='+websiteId+'&websiteLanguage='+websiteLanguage+'&',
		aText: websiteLoft,
		aColor: 'FF9900',
		bText: websiteAppartement,
		bColor: 'DBA5A5',
		cText: websiteWoning,
		cColor: 'C299FF',
		dText: websiteHandelsruimte,
		dColor: '6EDA4B',
		eText: websiteUniekmonument,
		eColor: '4CB7FF',
		fText: websiteParking,
		fColor: '8EAA72',
		gText: websiteExtra,
		gColor: 'CC3366',
		backText: websiteTerug,
		unHighlightAlpha:'0',
		highlightAlpha:'1'
	};
	var att = { 
		data:'templates/wilma/swf/verkaveling.swf', 
		width:598, 
		height:406, 
		bgcolor:'#FFFFFF', 
		menu:'false',
		wmode:'transparent'
	};
	var par = {flashvars:jQuery.param(flashV),wmode:'transparent'};
	var id = 'verkaveling';
	var myObject = swfobject.createSWF(att, par,id);
}

function processZoomImages(path){

	$("a[class^=zoomImage][zoomok!=true]").each(
		function(){
			var obj=$(this);
			obj.attr("zoomok","true");
			var thumbsizeArr,thumbwidth,thumbheight,urlParts,server,relpath,query			
			if(obj.attr("rel").indexOf("x")>1){
				thumbsize = obj.attr("rel");
				thumbsizeArr = thumbsize.split("x");
			}else{
				thumbsize = obj.attr("class").split("_")[1];
				thumbsizeArr = thumbsize.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 loadGallery(galleryId){

	if(galleryId){		
		$.ajax({
			url: '/templates/wilma/includes/fotoboek.asp',
			data:{galleryId:galleryId,menuId:menuId,websiteId:websiteId},
			//ajaxStart:showBusyOverlay(),
			success: function(data) {
				//hideBusyOverlay();
				$("#gallerycontent").html(data);
			},
			dataType: "html"
		});
	}
};

/*****************************
/* algemene functies
/****************************/

function showInfo(mapAlias,websiteLanguage) {
	$.ajax({
		url: '/templates/wilma/includes/includeMapInfo.asp',
		data:{mapAlias:mapAlias,websiteLanguage:websiteLanguage},
		success: function(data) {
			$("#info").html(data);
			$("#info").fadeIn("slow");
		},
		dataType: "html"
	});
}

