function wc()
{
	if(window.console)
	{
		for(var i = 0; i < arguments.length; i++)
		{
			window.console.log(arguments[i]);
		}
	}
	else
	{
		//alert(msg);
	}
}

/* 
	Shadowbox 3.0 Beta
	- buiten de jQuery ready houden
*/
var ShadowboxOptions = {

	language:				'nl',
	counterType:			'skip',//'default',//'skip',
	
	overlayColor:			'#fff',
	
	overlayOpacity:	   		'0.4',
	
	initialWidth:			'550',//'320',
	initialHeight:			'450',//'160',
	
	resizeDuration:			'0.2',//'0.55',
	
	fadeDuration:			'0.15',//'0.35',
	
	animSequence:			'sync',//'wh',
	
	//handleOversize:			'resize',//'drag',
		
	//enableKeys:				false,
	
	keysClose:				['c', 27], // c or esc
	
	players:				["iframe","html","img","swf","flv","qt","wmp"],
	
	autoDimensions:			true,
	continuous:				true,
	
	ZZZonOpen:	function(el) {
	
		wc('Shadowbox onOpen');
		
		wc(el);
		
		$('a', $(el.content)).click(function()
		{
			wc(this);
			return false;
		}
		);
	},
	
	onFinish: function() {
		
		wc('Shadowbox onFinish');
		
		var image_zoomer = $('div.zoomed-image', '#sb-content.html');
		var jqlmap = $('div.google-map-large', '#sb-content.html');
		
		$('a.close-shadowbox', '#sb-content.html').click(function()
		{
			Shadowbox.close();
			
			return false;
		});
		
		$('a.image', '#sb-content.html').click(function()
		{
			wc(this);
			
			jqlmap.hide();
			
			$('img', image_zoomer).attr('src', $(this).attr('href'));
			
			image_zoomer.show();
			
			return false;
		});
		
		// google map
		var map_wrapper = $('div.google-map', '#sb-content.html').get(0);
		
		if(map_wrapper)
		{			
			// de lat-long waarden staan in de title
			// van de map-wrapper
			var tmp 	= $(map_wrapper).attr('title');
			var latlong = tmp.split(',');
			var lat		= parseFloat(latlong[0]);
			var long	= parseFloat(latlong[1]);
			
			wc(latlong, lat, long);
			
			// centreer de map en markeer
			if( ! isNaN(lat) && ! isNaN(long))
			{
				var map = new GMap2(map_wrapper);
				
				map.disableDoubleClickZoom();
				map.disableDragging();
				
				var point = new GLatLng(lat, long);
						
				var marker = new GMarker(point);
			
				map.addOverlay(marker);
			
				map.setCenter(point, 10);
								
				// GEvent.addListener(marker, 'click', function() {
				GEvent.addListener(map, 'click', function() {
				
					wc('user clicked the map');
					
					jqlmap.show(10, function()
					{
						wc('large map now visible');
						
						var large_map = new GMap2(jqlmap.get(0));
						
						large_map.addControl(new GSmallZoomControl());
						
						large_map.addOverlay(new GMarker(point));
			
						large_map.setCenter(point, 15);
						
						image_zoomer.hide();
					});
					
					return false;
				});
				
			}
			else
			{
				$(map_wrapper).remove();
			}
		}
	}
};

Shadowbox.init(ShadowboxOptions);

/* 
	
*/
function openPopup(href, title)
{
	//var href = $(this).attr('href');
	
	//var title = $(this).attr('title');
		
	$.post(
		
		href,
		
		{
			// detail:"popup",
			// time:"2pm"
		},
		
		function(sHtml)
		{				
			Shadowbox.open({
				
				player:     'html',

				content:    sHtml,
									
				//title:      title,
				
				width:      740,
				
				height:     470,
				
				
				bla: 'foo'
			});
		}
	);
}

/* 
	Maarsen Groep JS
*/
$(document).ready(function()
{
	/* 
		Shadowbox voor projecten detailed information links
	*/
	$('#page a.projectdata-detailed-information').click(function()
	{
		openPopup($(this).attr('href'), $(this).attr('title'));
				
		return false;
	});
	
	
	/* 
		Shadowbox for playing movies.
	*/	
	Shadowbox.setup("a.video", {
      

		width: '400',
		height: '295',
		player: 'flv',
		autoplayMovies: true
    
    });

	
	$('form input, form textarea').removeAttr('placeholder');
	
	
	
	
	 /* 
	 	var player = $f("player", "gui/swf/flowplayer-3.1.5.swf");
	 			
	 	//alert($(this).attr('href'));
	 	// setup button action. it will fire our overlay 
	 	
	 	$("a[rel]").overlay({ 
	 			 
	 		// when overlay is opened, load our player 
	 		onLoad: function() { 
	 			
	 					
	 			player.load(); 
	 			player.play(this.getTrigger().attr("href")); 
	 			
	 			
	 		}, 
	 	 
	 		// when overlay is closed, unload our player 
	 		onClose: function() { 
	 			player.unload(); 
	 		} 
	 	});
	 	
	 */
	 
	
	
	/* 
		TEMP
	
	//var url = 'http://www.keyweb.nl/MA/maarsengroep.nl.rev2/index.php/project/projectdata/popup.html';
	var url = 'http://www.keyweb.nl/MA/maarsengroep.nl.rev2/index.php/project/projectdata-8/popup.html';
	
	$.post(
		
		url,
		
		{ },
		
		function(sHtml)
		{
	
			Shadowbox.open({
				
				player:     'html',

				content:    sHtml,
									
				title:      'TESTEN VAN DE POPUP',
				
				width:      740,
				
				height:     470
			});
		}
	);*/
	
	/* 
		border weghalen bij nav
	*/
	$('#page div.frame1 div.navigationobject > ul > li:last > a').css({ border: 0 });
	$('#page div.footerframe div.navigationobject > ul > li:last > a').css({ border: 0 });
	
	/* 
		hover fix voor IE6
	*/
	$('#page.projectpage div.projectweergave div.project').hover(
		
		function(){
			$('p.navigation a', this).show();
		},
		
		function(){
			$('p.navigation a', this).hide();
		}
	);
	
	/* 
		outbound links moeten openen in een nieuw venster
	*/
	$('a.outbound').live('click', function(event)
	{
		var href = this.href;
		
		wc('outbound: ' + href);
		
		event.preventDefault();
		
		//event.stopPropagation();
		
		window.open(href);
		
		return false;		
	});
	
	/* 
		print links moeten content laten printen
	*/
	$('a.print').live('click', function(event)
	{
		var href = this.href;
		
		wc('print: ' + href);
		
		event.preventDefault();
		
		//event.stopPropagation();
		
		//window.open(href);
		
		var iframe = '<iframe class="printable" src="'+href+'" />';
		
		$('#page').after(iframe);
		
		return false;		
	});
	
	/* 
		projecten in het geheel klikbaar maken
		- opent shadowbox popup
	*/
	$('#page.homepage div.project-image-frame div.datarecord div.information').css({ opacity: 0.8 });
	
	$('#page div.projectdata-banner-large, #page div.projectdata-banner-small').each(function()
	{
		var href = $('a.projectdata-detailed-information', this).attr('href');
		
		var title = $('a.projectdata-detailed-information', this).attr('title');
		
		// wc(href, title, this);
		
		$(this).css({cursor: 'pointer'}).attr('title', title);

		$(this).click(function() {
			
			openPopup(href, title);
			
			return false;
		});
		
	});
	
	/* 
		persberichten clickable
		
	*/
	$('#page div.bannerframe div.pressrelease-list, #page div.sidebarframe div.pressrelease-list').each(function()
	{
		var href = $('p.navigation-readmore a', this).attr('href');
		
		var title = $('p.navigation-readmore a', this).attr('title');
		
		// wc(href, title, this);
		
		$(this).css({cursor: 'pointer'}).attr('title', title);
		

		$(this).click(function() {
			
			document.location = href;
						
			return false;
		});
		
	});
	
	/* 
		Cycle... rouleren van banners
	*/
	var cycle_options = {

		fx: 'fade',
		//fx: 'scrollLeft',
	
		slideExpr: 'div.datarecord',
		
		cleartype: false,
		cleartypeNoBg: true,
		
		//before: slideUpInformation(),
		//after: slideUpInformation(),
		
		pause: true,
		
		timeout: 5000,
		speed: 800
	};
	
	// projecten op de homepage rouleren
	$('#page.homepage div.project-image-frame div.object1').cycle($.extend({random: true}, cycle_options));
	
	// sidebar sponsorbanners
	$('#page.textpage div.sponsorbanners div.banners').cycle($.extend({random: true}, cycle_options));
	
	// homepage corporate advertisement's
	$('#page.homepage div.corporate-adverts div.adverts').cycle($.extend({random: true}, cycle_options));
		
	/* 
		Fix voor plaatje in heading
	*/
	// $('#page.homepage div.tekstruimte .content-dataobject .datarecord1 h3').wrapInner("<span></span>");	
	
	
	/* 
		dropdown menu
	
	$("#page div.headerframe div.navigationobject ul li").hover(
		function(){ $("#page div.headerframe div.navigationobject ul li ul", this).show(); }, 
		function() { } 
	);
	
	// IE... ?
	if (document.all) {
		$("#page div.headerframe div.navigationobject ul li").hoverClass("sfHover");
	} */
	
		
	
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};


