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

$(document).ready(function(){
	
	window.onload = function(){
		var cookie_starterbzbox = jQuery('.popup_cookie');
//		alert(cookie_starterbzbox.html());
		if(cookie_starterbzbox.html() == '0')
		{
			Shadowbox.open({
	            content: '<img src="/tinnemanskeukens.nl/img/beste-keuken-zaak.jpg" alt="Tinnemans Keukens Ittervoort - Limburg is genomineerd voor de beste keukendetaillist 2011" style="float: left; margin: 0px 0px"/>',
			    player: 'html', 
			    width: 527, 
			    height: 339, 
			    title: 'Beste KEUKENZAAK van NEDERLAND',
			    options: 
			       { 
			           onClose: function()
			           {                       	
			                  set_cookie_one_hour();
			           }
			       }
	          });
	    
		}
	};
	
	selectboxForms();
	
	$('#container-3').tabs({fxSlide:true}); 
	
	$(".blank_link").attr("target","_blank");

	$(".single_image").fancybox({'titlePosition':'inside'});
	$(".single_image2").fancybox({'titlePosition':'inside'});
	
	jQuery('.more-information').click(function(){
		var taf_id = jQuery(this).attr('id');
		var taf_id_split = taf_id.split('_');
		
		show_mi(taf_id_split['1']);
	});
	
	jQuery('.tell_a_friend').click(function()
	{
		var taf_id = jQuery(this).attr('id');
		var taf_id_split = taf_id.split('_');		
		
		show_taf(taf_id_split['1']);
	
	});
	
	$('#view_commercial').click(function(){
		Shadowbox.open({
           content:    'http://www.youtube.com/v/dueAFUdPaUw&rel=1&autoplay=1',
           player:     "swf",
           title:      "Tinnemans Keukens Commercial",
           height:     390,
           width:      640           
       });
	});

	
	$(function() {
	    $('.icon').tipsy();
	});
	
	$(function() {
	    $('.back').tipsy();
	});


	$(function () {

      function formatText(index, panel) {
  		  return index + "";
  	  };
    
      $(function () {
      
          $('.anythingSlider').anythingSlider({
            easing: "easeInOutQuad",        // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 6500,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 1500,             // 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);
          });
          
      });
	
});

function selectboxForms(){
	$('div.form div.select select').selectbox();
	var zIndex = 9999;
	$('div.form div.entry').each(function(){
		$(this).css('z-index',zIndex);
		zIndex--;
	});
}


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: 12,
//	      		center: latlng,
//	      		mapTypeId: google.maps.MapTypeId.ROADMAP
//	    		};
			var myOptions = {
			zoom:      12,
			center:    latlng,
			disableDefaultUI: true,
			streetViewControl: false,
			navigationControl: true,
			scrollwheel: false,
			navigationControlOptions: {
			        style: google.maps.NavigationControlStyle.SMALL,
			        position: google.maps.ControlPosition.TOP_RIGHT
			        },
			mapTypeId: google.maps.MapTypeId.ROADMAP
			
			};

	    	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  		} 		

		initialize();			
   		codeAddress();  
   		
   		
}


function codeAddress() 
{
    var address = 'Wethouder v. Caldenborghlaan, Maastricht';
    var image = new google.maps.MarkerImage('/keukenontwerpers-maastricht.nl/img/beachflag.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(27, 43),
      // 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(0, 30));
  	var shadow = new google.maps.MarkerImage('/keukenontwerpers-maastricht.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(40, 15),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 0));

    
    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);
        	}
      	});
    }
}
	
	});			  
	
	
	function show_mi(product_id)
	{
		//AJAX connectie voor zetten van Sessie e.d. daarna doorzetten naar search page.
		
		jQuery.ajax({
			type: "POST",
			url: "/keukenontwerpers-maastricht.nl/ajax/ajax_helper.php",
			data: 'product_id='+product_id+'&action=show_mi',
			dataType: "html",
			success: function(result)
			{
				if(result != '')
				{
				   	Shadowbox.open({
	                   content:    result,
	                   player:     "html",
	                   title:      "Meer informatie",
	                   height:     310,
	                   width:      520,
	                   options: 
	                   { 
	                       onFinish: function()
	                       {                       	
	                              
	                       }
	                   }
	               });
	   			}
			}
	
	    });
	}
	
	function show_taf(product_id)
	{
		//AJAX connectie voor zetten van Sessie e.d. daarna doorzetten naar search page.
		
		jQuery.ajax({
			type: "POST",
			url: "/keukenontwerpers-maastricht.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:      "Tip een vriend",
	                   height:     340,
	                   width:      520,
	                   options: 
	                   { 
	                       onFinish: function()
	                       {                       	
	                              
	                       }
	                   }
	               });
	   			}
			}
	
	    });
	}
	
	function set_cookie_one_hour()
	{
		jQuery.ajax({
	       type: "POST",
	       url: "/keukenontwerpers-maastricht.nl/ajax/ajax_helper.php",
	       data: 'action=set_cookie_one_hour',
	       dataType: "html",
	       success: function(result)
	       {
	       		//doe niets... is alleen maar irritant.	       		
	       }
	    });
	}
