var geenParams={};(function(){var a,b=/\+/g,c=/([^&=]+)=?([^&]*)/g,d=function(a){return decodeURIComponent(a.replace(b," "))},e=window.location.search.substring(1);while(a=c.exec(e))geenParams[d(a[1])]=d(a[2])})()

//	Mobile detection
var donkey = geenParams["visitor"]
if (donkey == 'mobile') {
	//	Visitor with mobile phone who clicked.
} else if (screen.width < 600) {
	window.location = "http://m.bandbreed.com";
};

$(document).ready(function(){	
	caseexpand();
	//fade_in();
	//images();
	anchors();
	slidert();
	muisovers();
});

function caseexpand() {

		
	 //klik op plaatsen #expandable expand
	$('.plaatsen').click(function() { //als je waar op klikt
		var casekeuze = $(this).attr('postid');		
		var selected = $('.cases[postid='+casekeuze+']');
		var oud = $('.cases:visible').not(selected);

		
		if(oud.length == 0){ // Als waar je op klikt de eerste klik is:
			TopOfCase();
     		$('#case_deel_titel').delay(200).animate({"opacity": "hide"}, { duration: 200 });
     		selected.delay(390).animate({"height": "show"}, { duration: 600 });
     		     		
     	} else {
     	 	TopOfCase();
			oud.animate({"opacity" : "hide"}, 100, function() {
			selected.animate({"opacity" : "show"},{ duration: 100 }); //en de geselecteerde binnenkomen
			});
		
		}
		//klik op sluiten #expandable sluit
		$('.sluit').click(function() { //als je waar op klikt
			TopOfCase();
			selected.delay(200).animate({"height": "hide"}, 200 );
			$('#case_deel_titel').delay(300).animate({"opacity": "show"}, { duration: 400 });
		});
	
	});
	    
};

// doe een standaard klik, altijd.
	$('.plaatsen').click();

function TopOfCase() {

    $('html, body').animate({ scrollTop: $('#cases').offset().top-4 }, 'fast');

};


function anchors() {	
	 //klik op menulink en ga naar item
	$('.menulink').click(function() { 
		var target = $(this).attr('link');		

		  $('html, body').animate({ scrollTop: $('#'+target).offset().top-4 }, 'slow');
	});
	
	$('.back_top').click(function() { 

		  	$('html, body').stop().animate({ scrollTop: $('body').offset().top-0 }, 'slow');

	});
	
};

// wordt nog niet gebruikt, fade foto's in als ze worden geladen
function fade() {
	var i = 0;
	$('.foto img').clone().appendTo($('.foto'));
	$('.foto img').each(function(){
		var me = this;
		$(this).hide()
		var j = i;
		setTimeout(function(){
			$(me).fadeIn(500);
			}, i)
		i += 20
	});
};

function slidert() {

	$(document).ready(function(){	
		$("#slider1").easySlider({
			continuous: true,
			nextId: "slidernext_1",
			prevId: "sliderprev_1"
		});
		$("#slider2").easySlider({
			continuous: true,
			nextId: "slidernext_2",
			prevId: "sliderprev_2"
		});
		$("#slider3").easySlider({
				continuous: true,
				nextId: "slidernext_3",
				prevId: "sliderprev_3"
		});
		$("#slider4").easySlider({
			continuous: true,
			nextId: "slidernext_4",
			prevId: "sliderprev_4"
		});
		$("#slider5").easySlider({
			continuous: true,
			nextId: "slidernext_5",
			prevId: "sliderprev_5"
		});
		$("#slider6").easySlider({
			continuous: true,
			nextId: "slidernext_6",
			prevId: "sliderprev_6"
		});
		$("#slider7").easySlider({
			continuous: true,
			nextId: "slidernext_7",
			prevId: "sliderprev_7"
		});
		$("#slider8").easySlider({
			continuous: true,
			nextId: "slidernext_8",
			prevId: "sliderprev_8"
		});
	});
};

function muisovers() {

	$(".sluit").mouseover(function(){
    	$(this).animate({color: "#191E2C" }, 100);
    	$('.sluitkruisje').css({backgroundPosition: '-20px 0px'});
    })
    
    $(".sluit").mouseout(function(){
    	$(this).animate({color: "#444652" }, 100);
    	$('.sluitkruisje').css({backgroundPosition: '0px 0px'});
    })
    
    $(".slidercontrols span a").mouseover(function(){
    	$(this).css({backgroundPosition: '-20px 0px'});
    })
    
    $(".slidercontrols span a").mouseout(function(){
    	$(this).css({backgroundPosition: '0px 0px'});
    })
      
	$("#menuwrapper div.menulink").mouseover(function(){
    	$(this).animate({color: "#B8B3B0" }, 100);
    })
    
    $("#menuwrapper div.menulink").mouseout(function(){
    	$(this).animate({color: "#191E2C" }, 100);
    })
    
    $("#footer_menuwrapper div.menulink").mouseover(function(){
    	$(this).animate({color: "#ffffff" }, 100);
    })
    
    $("#footer_menuwrapper div.menulink").mouseout(function(){
    	$(this).animate({color: "#B8B3B0" }, 100);
    })
	
	$(".plaatsen").animate({opacity:0.4 }, 100);
		
	 //mouseover een case button naar opacity 80%
	$(".plaatsen").mouseover(function(){
    	$(this).animate({opacity:1 }, 100);
    });
   
   //mouseout een case button terug naar opacity 100%
    $(".plaatsen").mouseout(function(){
    	$(this).animate({opacity:0.4 }, 100);	
    });

};

function initialize() {
				var map;
				var bandbreed = new google.maps.LatLng(52.088971,5.124683);
				var latlng = new google.maps.LatLng(52.088971,5.124683);
				var settings = {
					zoom: 15,
					center: latlng,
					mapTypeControl: true,
					mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
					navigationControl: true,
					navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
					mapTypeId: google.maps.MapTypeId.ROADMAP};
 
				 var stylez = [ 	
					{
						featureType: "water",
						elementType: "all",
						stylers: [
							{ hue: "#c1deec" },
							{ saturation: 30 },
							{ lightness: 47 }
						]
					},{
						featureType: "landscape.man_made",
						elementType: "all",
						stylers: [
							{ hue: "#cbc6c2" },
							{ saturation: -71 },
							{ lightness: -13 }
						]
					},{
						featureType: "landscape.natural",
						elementType: "all",
						stylers: [
							{ hue: "#b8b3b0" },
							{ saturation: -79 },
							{ lightness: -24 }
						]
					},{
						featureType: "road.highway",
						elementType: "all",
						stylers: [
							{ hue: "#444651" },
							{ saturation: -91 },
							{ lightness: -54 }
						]
					},{
						featureType: "road.arterial",
						elementType: "all",
						stylers: [
							{ hue: "#908c89" },
							{ saturation: -97 },
							{ lightness: -28 }
						]
					},{
						featureType: "road.local",
						elementType: "all",
						stylers: [
							{ hue: "#f8f7f7" },
							{ saturation: -93 },
							{ lightness: -3 }
						]
					},{
						featureType: "poi.park",
						elementType: "all",
						stylers: [
							{ hue: "#908c89" },
							{ saturation: -92 },
							{ lightness: -23 }
						]
					}
				];
				
				 
				 var mapOptions = {
				 zoom: 16,
				 center: bandbreed
				 };
				 
				 map = new google.maps.Map(document.getElementById("map_canvas"),
				 mapOptions);
				 
				 var styledMapOptions = {
				 map: map,
				 name: "BandbreedHip-Hop"
				 }
				 
				 var testmap =  new google.maps.StyledMapType(stylez,styledMapOptions);
				 
				 map.mapTypes.set('Bandbreed', testmap);
				 map.setMapTypeId('Bandbreed');
 
				
				var companyImage = new google.maps.MarkerImage('/wp-content/themes/bandbreed/images/logo.png',
					new google.maps.Size(200,120),
					new google.maps.Point(0,0),
					new google.maps.Point(60,60)
				);


				var companyPos = new google.maps.LatLng(52.088971,5.124683);

				var companyMarker = new google.maps.Marker({
					position: companyPos,
					map: map,
					icon: companyImage,
					title:"Bandbreed",
					zIndex: 3});
				
				var parkingImage = new google.maps.MarkerImage('/wp-content/themes/bandbreed/images/parking.png',
					new google.maps.Size(50,50),
					new google.maps.Point(0,0),
					new google.maps.Point(5,40)
				);


				var parkingPos = new google.maps.LatLng(52.088575,5.11943);

				var parkingMarker = new google.maps.Marker({
					position: parkingPos,
					map: map,
					icon: parkingImage,
					title:"Springhaver parkeergarage",
					zIndex: 1
				});
				
			
};


function images() {

};




function fade_in() {	

	$('#header').fadeIn(100);
    $('#nieuws1').delay(100).fadeIn(100);
    $('#cases').delay(200).fadeIn(100);
    $('#nieuws2').delay(300).fadeIn(100);
    $('#merken').delay(400).fadeIn(100);
    $('#nieuws3').delay(500).fadeIn(100);
	$('#watwijdoen').delay(600).fadeIn(100);
	$('#nieuws4').delay(700).fadeIn(100);
	$('#mensen').delay(800).fadeIn(100);
	$('#nieuws6').delay(900).fadeIn(100);
	$('#contact').delay(1000).fadeIn(100);
	$('#nieuws7').delay(1100).fadeIn(100);
	$('#footer').delay(1200).fadeIn(100);
	
};


//	Local storage
	function createCookie(a,b){if ("localStorage"in window&&window["localStorage"]!=null)localStorage.setItem(a,b);else{var c=new Date;c.setTime(c.getTime()+31104e6);var d="; expires="+c.toGMTString();document.cookie=a+"="+b+d+"; path=/"}}
	function clearCookie(a,b){if ("localStorage"in window&&window["localStorage"]!=null)localStorage.setItem(a,null);else{var c="; expires=Thu, 01-Jan-70 00:00:01 GMT";document.cookie=a+"="+c+"; path=/"}}
	function readCookie(a){var b=null;if ("localStorage"in window&&window["localStorage"]!=null)b=localStorage.getItem(a);else{var c=a+"=",d=document.cookie.split(";");for(var e=0;e<d.length;e++){var f=d[e];while(f.charAt(0)==" ")f=f.substring(1,f.length);f.indexOf(c)==0&&(b=f.substring(c.length,f.length))}}if (b!=null){if (b.toLowerCase()=="true")return!0;if (b.toLowerCase()=="false")return!1}return b}

