var language = 'nl';

function translate(){

	

}

var __ = translate;


$(document).ready(function () {

	// determine language
	language = $('meta[name$=language]').attr('content');
	language = language ? language.toLowerCase() : 'nl';
	
	$('.open-tab').click(function(){
	
		var me = this;
		$('.tabs a').each(function(){
			
			if (me.href==this.href){
				$(this).trigger('click');
			}
			
		});
	
		return false;
	});

	
	
	$(".header ul li:last-child a, .process-steps li:last-child, , .process dd:last-child, .doormat-folio:last-child").css("margin-right","0");
	$(".column-320:last-child").css("width","320px");
	$(".process dd:nth-child(6n+6) a").css("margin-right","0")
	$(".teamlist li:nth-child(3n+3), .logos li:nth-child(3n+3)").css("margin-right","0")
	$("#footer li:last-child").css("background","none");
	$(".still-video span a").prepend("<img src='/images/sprites/play-buttons.png' alt='' class='play-buttons' />");
	$(".video-small a, .video-small-right a").prepend("<img src='/images/sprites/play-buttons-small.png' alt='' class='play-buttons-small' />");
	$(".content-block span, .news-block span").prepend("<img src='/images/globals/border-170.gif' alt='' class='border-170' />");
	$(".usp-video").append("<img src='/images/globals/teaser-papier_"+language+".png' alt='' class='teaser-papier' />");
	$(".title-login").prepend("<a href='#'><img src='/images/globals/close-icon.gif' alt='Sluit het inloggen' class='close-login showhide-login' /></a>");
	$(".process-bar p").append("<img src='/images/globals/hoe-films_"+language+".png' alt='Hoe maakt FourCorners films?' class='how' />");
	$(".still-video span a").prepend("<img src='/images/globals/play-arrow.gif' alt='' class='play-attention' />");
	$(".video-small a, .video-small-right a").prepend("<img src='/images/globals/play-arrow.gif' alt='' class='play-attention-small' />");
	$(".bottom-service").prepend("<a href='#myAnchor' class='camera-doormat anchorLink' href='#myAnchor'>Naar bovenkant website</a>");
	$("#sidebar").prepend("<img src='/images/globals/nietje.png' alt='' id='nietje' />");
	$("#nofaux .wrap-content").prepend("<img src='/images/globals/nietje.png' alt='' id='nietje-nofaux' />");
	$(".process dd a, .content-block-small span, .team dd span").prepend("<img src='/images/globals/border-wit.gif' alt='' class='border' />");
	$(".pasfoto").prepend("<img src='/images/globals/border-wit-s.gif' alt='' class='border' />");
	$("blockquote").prepend("<img src='/images/globals/quote-papier_"+language+".png' alt='' class='quote-papier' />");
	$(".thumb-team li.current a").prepend("<img src='/images/globals/current-team.png' alt='' class='current-team' />");
	$(".thumb-team li a").prepend("<img src='/images/globals/border-hover.gif' alt='' class='border-hover' />");
	$(".teamlist li a span, .logos li a span").prepend("<img src='/images/globals/border-team.gif' alt='' class='border' />");
	
	// Open link in new window
	$(".external").attr("target","_blank");
	
	// Make entire block clickable
	//$(".still-video, .content-block-small, .has-link, .folio-strip li a, .news-block, .folio-big").click(function(){
	$(".still-video, .content-block-small, .has-link, .folio-strip li, .news-block, .folio-big").click(function(){ // <- Fili
		window.location=$(this).find("a").attr("href");return false; // href attribute value
	});
	
	$(".content-block-small, .content-block, .news-block").hover(function(){
		$(this).addClass('over-pointer'); // Plaats een class op een hover
	},function(){
		$(this).removeClass('over-pointer'); // Verwijder de class op een mouseout
	});
	
	// Slide button over video
	$('.video-small, .video-small-right').hover(function(){
		$(this).find('.play-attention-small').animate({left:'132px'},{queue:false,duration:500});
	}, function(){
		$(this).find('.play-attention-small').animate({left:'-59px'},{queue:false,duration:500});
	});
	
	// Slide button over video
	$('.still-video').hover(function(){
		$(this).find('.play-attention').animate({left:'262px'},{queue:false,duration:500});
	}, function(){
		$(this).find('.play-attention').animate({left:'-59px'},{queue:false,duration:500});
	});
	
	// Slide border on team
	$('.thumb-team li').hover(function(){
		$(this).find('.border-hover').animate({left:'0'},{queue:false,duration:300});
	}, function(){
		$(this).find('.border-hover').animate({left:'-53px'},{queue:false,duration:300});
	});
	
	// Slide Login
	$(".showhide-login").click(function() {
		$("#wrap-login").slideToggle("slow");
		return false; // <- Fili
	});
	
	// Clear inputs on blur
	$("input.clear-on-focus").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});

	// Load PrettyPhoto when js is included
	if ($(document).prettyPhoto)
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// Write print link when javascript is enabled
  	$('.page-options').prepend('<li class="print"><a href="#print">Print deze pagina</a></li>');
	$('.page-options li.print a').click(function() {
		window.print();
		return false;
	});
				
	// Set the scroll to anchor
	anchor.init()

	if (el = document.getElementById('google-maps')){
		load_google_maps(el);
	}
	
});



anchor = {
	init : function()  {
		$("a.anchorLink").click(function () {	
			elementClick = $(this).attr("href")
			destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
		  	return false;
		})
	}
}

var map = false;

function load_google_maps(map_element){
	map = new GMap2(map_element);
	map.setCenter(new GLatLng(51.98116653620794, 5.915064811706543), 14);

	
	$('#frm-googlemaps').submit(function(){
	
		postalcode = $('#naam').val();
	
		directionsPanel = document.createElement('div');
		directions = new GDirections(map, directionsPanel);
		directions.load("from: " + postalcode + " to: Eusebiusbuitensingel 3 Arnhem");
		
	
		return false;
	
	});
}

