Shadowbox.init({
    skipSetup: true,
    players: ["html"]
});




jQuery(document).ready(function()
{
	function formatText(index, panel) {
		  return index + "";
	    }
    
	$(function () {
	        
	            $('.anythingSlider').anythingSlider({
	                easing: "easeInOutCubic",        // Anything other than "linear" or "swing" requires the easing plugin
	                autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
	                delay: 3000,                    // How long between slide transitions in AutoPlay mode
	                startStopped: false,            // If autoPlay is on, this can force it to start stopped
	                animationTime: 1000,             // How long the slide transition takes
	                hashTags: true,                 // Should links change the hashtag in the URL?
	                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
	        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
	        		startText: "Go",             // Start text
			        stopText: "Stop",               // Stop text
			        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	            });
	            
	            $("#slide-jump").click(function(){
	                $('.anythingSlider').anythingSlider(6);
	            });
	            
	});

	if(jQuery("#map_canvas").length != 0)
	{
			var geocoder;
	  		var map;
	  		
	  		function initialize() {
		    	geocoder = new google.maps.Geocoder();
		    	var latlng = new google.maps.LatLng(-34.397, 150.644);
		    	var myOptions = {
		      		zoom: 15,
		      		center: latlng,
		      		mapTypeId: google.maps.MapTypeId.ROADMAP
		    		}
		    	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	  		} 		
	
			initialize();			
	   		codeAddress();  
	   		
	   		
	}


	function codeAddress() 
	{
	    var address = 'Neerkantseweg, Liessel';
	    var image = new google.maps.MarkerImage('/agri-horse.nl/img/beachflag.png',
	      // This marker is 20 pixels wide by 32 pixels tall.
	      new google.maps.Size(50, 44),
	      // The origin for this image is 0,0.
	      new google.maps.Point(0,0),
	      // The anchor for this image is the base of the flagpole at 0,32.
	      new google.maps.Point(25, 55));
	  	var shadow = new google.maps.MarkerImage('/agri-horse.nl/img/beachflag_shadow.png',
	      // The shadow image is larger in the horizontal dimension
	      // while the position and offset are the same as for the main image.
	      new google.maps.Size(65, 28),
	      new google.maps.Point(0,0),
	      new google.maps.Point(20, 35));
	
	    
	    if (geocoder) 
	    {
	      	geocoder.geocode( { 'address': address}, function(results, status) 
	      	{
	        	if (status == google.maps.GeocoderStatus.OK) 
	        	{
	          		map.setCenter(results[0].geometry.location);
	          		var marker = new google.maps.Marker({
	              		map: map, 
	              		position: results[0].geometry.location,
	              		shadow: shadow,
	              		icon: image
	          		});
	        	} 
	        	else 
	        	{
	          		alert("Geocode was not successful for the following reason: " + status);
	        	}
	      	});
	    }
	}

	jQuery("a.single_image").fancybox({
				'titleShow'		: false
			});

	jQuery("a.group").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});


	jQuery('.more-information').click(function(){
			var taf_id = jQuery(this).attr('id');
			var taf_id_split = taf_id.split('_');
			
			show_taf(taf_id_split['1']);
	});

	jQuery(function() {
	    $('.icon').tipsy();
	});
	
	jQuery(function() {
	    $('.terug').tipsy();
	});

});

function show_taf(product_id)
{
	//AJAX connectie voor zetten van Sessie e.d. daarna doorzetten naar search page.
	
	jQuery.ajax({
		type: "POST",
		url: "/agri-horse.nl/ajax/ajax_helper.php",
		data: 'product_id='+product_id+'&action=show_taf',
		dataType: "html",
		success: function(result)
		{
			if(result != '')
			{
			   	Shadowbox.open({
                   content:    result,
                   player:     "html",
                   title:      "Meer informatie",
                   height:     300,
                   width:      520,
                   options: 
                   { 
                       onFinish: function()
                       {                       	
                              
                       }
                   }
               });
   			}
		}

    });
}
