if (!WAX) { var WAX = new Object() }

WAX = {
		
	province_selected	:	'',
	gemeente_selected	:	'',

	goCufon			:	function() {					
		Cufon.replace('#tabmenu a', 
				{ 
				fontFamily: 'tahoma',
				hover:true,
				textShadow: '1px 1px #f5f5f5'			
				}
		)('h1,h2,#searchform label', 
				{ 
				fontFamily: 'impact'			
				}
		)('.button', 
				{ 
				fontFamily: 'trebuchet',
				hover:true,
				textShadow: '-1px -1px #409da7'
				}
		);
	},

	goFancyBox		:	function() {
		$(".fancybox").fancybox(); 
	},

	goTableRows		:	function() {
		$("#detail_specs tr:even").addClass('even');
	},
	
	
	
	goCycle			:	function() {

		$('#referenties .slidecontainer').cycle({
					fx:'scrollHorz',
					speed:1000, 
					timeout:5000,
					pause:1,
					prev:'#referenties .prev',
					next:'#referenties .next'
		});
		
		$('#verkaveling_verkoop .slidecontainer').cycle({
					fx:'scrollHorz',
					speed:1000, 
					timeout:5000,
					pause:1,
					prev:'#verkaveling_verkoop .prev',
					next:'#verkaveling_verkoop .next'
		});
		
		$('#verkaveling_uitvoering .slidecontainer').cycle({
					fx:'scrollHorz',
					speed:1000, 
					timeout:5000,
					pause:1,
					prev:'#verkaveling_uitvoering .prev',
					next:'#verkaveling_uitvoering .next'
		});
	},
	

	highLightProvince	:	function(province) {
				
				switch (province) {
					case 'westvlaanderen':
					$('#map').css({'background-position':'-297px 0px'});
					break;
					case 'oostvlaanderen':
					$('#map').css({'background-position':'-594px 0px'});
					break;
					case 'antwerpen':
					$('#map').css({'background-position':'0px -250px'});
					break;
					case 'limburg':
					$('#map').css({'background-position':'-297px -250px'});
					break;
					case 'vlaamsbrabant':
					$('#map').css({'background-position':'-594px -250px'});
					break;
					case 'brussel':
					$('#map').css({'background-position':'0px -500px'});
					break;
					case 'waalsbrabant':
					$('#map').css({'background-position':'-297px -500px'});
					break;
					case 'henegouwen':
					$('#map').css({'background-position':'-594px -500px'});
					break;
					case 'namen':
					$('#map').css({'background-position':'0px -750px'});
					break;
					case 'luxemburg':
					$('#map').css({'background-position':'-297px -750px'});
					break;
					case 'luik':
					$('#map').css({'background-position':'-594px -750px'});
					break;
					default:
					$('#map').css({'background-position':'0px 0px'});
				}
	},
	
	goGemeentes	:	function() {
		$('#gemeente').empty();
		$.each(eval(WAX.province_selected), function(key,value) {
			$('#gemeente').append('<option value="'+key.replace(/p/,'')+'">'+value+'</option>');
		});
	},
			
	goBelgium : function(objData) {
	
		if(objData.province_selected!=null)	{
			
			WAX.province_selected = objData.province_selected;
			WAX.gemeente_selected = objData.gemeente_selected;
			
			// set map and box via php var
			WAX.highLightProvince(WAX.province_selected);
			$("#provincie").val(WAX.province_selected);
			WAX.goGemeentes();
			$("#gemeente").val(WAX.gemeente_selected);
		}
		
		// animate map
		$("#belgium_map area").bind('click',function(){
			WAX.province_selected = $(this).attr("id");
			$("#provincie").val(WAX.province_selected);
			WAX.highLightProvince(WAX.province_selected);
			WAX.goGemeentes();
		});
		
		$("#provincie").bind('change',function (){
			WAX.province_selected = $("#provincie").val();
			WAX.highLightProvince(WAX.province_selected);
			WAX.goGemeentes();
		});
		
		$("#belgium_map area").bind('mouseover',function(){
			WAX.highLightProvince($(this).attr("id"));
		});
			
		$("#belgium_map area").bind('mouseout',function(){
			WAX.highLightProvince(WAX.province_selected);	
		});
	},
	
	
	goGallery	:	function(){
	
	
		$('.gallery_demo_unstyled').addClass('gallery'); // adds new class name to maintain degradability
		
		$('ul.gallery').galleria({
			history   : false, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				
				image.css('display','none').fadeIn(500);
				
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
	}
}


