(function ($) {
 Drupal.behaviors.language = { attach: function (context, settings) {
	$(".i18n-fr label[for='edit-field-status-value-coming-soon']").text('A venir');
	$(".i18n-fr label[for='edit-field-status-value-ongoing']").text('En cours');
	$(".i18n-fr label[for='edit-field-status-value-built']").text('Réalisé');
	
	$(".i18n-fr label[for='edit-submitted-category-1']").text('Résidentiel');
	$(".i18n-fr label[for='edit-submitted-category-2']").text('Bureaux');
	$(".i18n-fr label[for='edit-submitted-category-3']").text('Loisirs');
	
	
	if($('.i18n-fr li.pager-current').length>0){
		$('.i18n-fr li.pager-current').html($('.i18n-fr li.pager-current').html().replace(/of/g,'sur'));
	}
	
	
	
}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.field_remove_colon = { attach: function (context, settings) {
	
	var labels = jQuery(".field-label");
	jQuery.each(labels, function() {
	this.innerHTML = this.innerHTML.replace(":", "");
	
});}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.form_input = { attach: function (context, settings) {	
	
	$('.form-item input').each(function() {
		
		if ($(this).parent().find('.description').length==0) return 0;
		var _description = '<div class="description">'+$(this).parent().find('.description').html()+'</div>';
		$(this).parent().find('.description').remove();
		$(_description).insertBefore($(this));
		
		if ($(this).val() != ''){
			$(this).parent().find('.description').hide();
		}
		
		
	});
	
	$('.form-item .description').click(function(){
		$(this).parent().find('input').focus();
	});
	
	$('.form-item textarea').each(function() {
		
		var _description = '<div class="description">'+$(this).parent().parent().find('.description').html()+'</div>';
		$(this).parent().parent().find('.description').remove();
		$(_description).insertBefore($(this));
		
		if ($(this).val() != ''){
			$(this).parent().parent().find('.description').hide();
		}
	});
	
	
	$('.form-item input').keyup(function() {
		if ($(this).val() != ''){
			$(this).parent().find('.description').hide();
		}else{
			$(this).parent().find('.description').fadeTo('fast',0.5);
		}
	});
	
	$('.form-item textarea').keyup(function() {
		if ($(this).val() != ''){
			$(this).parent().parent().find('.description').hide();
		}else{
			$(this).parent().parent().find('.description').fadeTo('fast',0.5);
		}
	});
	
	
	$('.form-item input').focus(function() {
		if ($(this).val() == ''){
			$(this).parent().find('.description').fadeTo('fast',0.5);
		}
	});
	
	$('.form-item textarea').focus(function() {
		if ($(this).val() == ''){
			$(this).parent().parent().find('.description').fadeTo('fast',0.5);
		}
	});
	
	$('.form-item input').blur(function() {
		if ($(this).val() == ''){
			$(this).parent().find('.description').fadeTo('fast',1);
		}
	});
	
	$('.form-item textarea').blur(function() {
		if ($(this).val() == ''){
			$(this).parent().parent().find('.description').fadeTo('fast',1);
		}
	});
	
	//http://envisioninteractive.com/drupal/add-ajax-to-a-webform-in-drupal-7/

}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.rollover = { attach: function (context, settings) {	
	
			jQuery('.views-row').each(function(index) {
		//jQuery(this).prepend('<div class="under">&nbsp;</div></a>');
			if (jQuery(this).find('a').length > 0){
				if (!jQuery(this).find('.over').length > 0){
				if (jQuery(this).find('a').attr('class') == 'active'){ jQuery(this).addClass("on"); }
				jQuery(this).prepend('<a href="'+jQuery(this).find('a').attr('href')+'"><div class="over">&nbsp;</div></a>');
				jQuery(this).find('.over').height(jQuery(this).height());
				jQuery(this).find('.over').width(jQuery(this).width());	
			}
			
			//jQuery(this).find('.under').height(jQuery(this).height());
			//jQuery(this).find('.under').width(jQuery(this).width());
		}
  	});
	
	jQuery('.over').mouseover(function() {
		//jQuery(this).parent().parent().find('.under').fadeIn();
		jQuery(this).parent().parent().addClass('active');
	});
	
	jQuery('.over').mouseout(function() {
		//jQuery(this).parent().parent().find('.under').fadeIn();
		jQuery(this).parent().parent().removeClass('active');
	});

}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.back_button = { attach: function (context, settings) {	
 		var _path_array = window.location.href.split('/');
		_path_array.pop();
		
		if ($.inArray('node',_path_array) == -1){
			$('.back-button a').attr('href',_path_array.join('/'));
		}else{
			$('.back-button').remove();
		}
		
		
}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.style = { attach: function (context, settings) {
	
	var _news_back_button = $('#block-block-3 div.content').html();
	$('.node-type-news #block-block-3').remove();
	$('.node-type-news .content-node').append(_news_back_button);
	
	$('.form-radio').each(function(){
		if ($(this).hasClass('error')){ 
			$(this).parent().parent().parent().find('label').addClass('red'); 
		}
	});
	
	$('.view-project .views-row, .view-news .views-row').each(function(){
		$(this).append('<div class="arrow">Arrow</div>');
	});
	
	function display_or_hide_logo(){
		
		if($('input[name="submitted[category]"]:checked').val() == 'info@kurt.lu'){
			$('#webform-component-logos').show();
		}else{
			$('#webform-component-logos').hide();
		}
	}
	
	$('input[name="submitted[category]"]').change(function(){
		display_or_hide_logo();
	});
	display_or_hide_logo();
	
	$('.content-node .field .field-item').each(function(){
		$(this).html($(this).html().replace(/m2/g,'m²'));
	});
	
	
	
}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.form_asterisk = { attach: function (context, settings) {
	$('input.required, textarea.required').each(function(){
		if ($(this).parent().find('label').length == 0){
			$(this).parent().append('<span class="required asterisk">*</span>');
		}
	});
}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.animation = { attach: function (context, settings) {
	
	$('#footer').hide();
	
	$('.view-project .views-row').each(function(i){
		display_element($(this),200*i);
	});
	
	$('#block-views-news-block .view-news .views-row').each(function(i){
		display_element($(this),200*(i+1));
	});
	
	display_element($('.view-slideshow'),300);
	display_element($('.images'),300);
	display_element($('.node-page .field-name-field-image'),300);
	display_element($('.node-page .field-name-body'),500);
	display_element($('.content-node'),500);
	display_element($('.back-button'),800);
	$('#footer').delay(500).fadeIn(400);
	
	function display_element(element, delay){
		
		delay = delay / 3;
		element.delay(delay).fadeIn(400).css('display','none').css('visibility','visible')
	}
	
}}
}(jQuery));







;
(function ($) {
 Drupal.behaviors.navigation = { attach: function (context, settings) {
	
	var id_news = 0;
	$('#block-views-news-block-1 .views-row').each(function(i){
		if ($(this).find('.views-field-view-node a').hasClass('active')) id_news = i;	
	});
	
	if($('#block-views-news-block-1 .views-row:nth-child('+(id_news)+')').length > 0){
		$('#news-navigation .next').show();
		$('#news-navigation .next').attr('href',$('#block-views-news-block-1 .views-row:nth-child('+(id_news)+') .views-field-view-node a').attr('href'));
	}
	
	if($('#block-views-news-block-1 .views-row:nth-child('+(id_news+2)+')').length > 0){
		$('#news-navigation .prev').show();
		$('#news-navigation .prev').attr('href',$('#block-views-news-block-1 .views-row:nth-child('+(id_news+2)+') .views-field-view-node a').attr('href'));
	}
	
}}
}(jQuery));;
(function ($) {
 Drupal.behaviors.a_target = { attach: function (context, settings) {	
 		$('a').each(function(index) {
		
		if ($(this).attr('href')){
		if ($(this).attr('href').indexOf('http://')>-1 && ($(this).attr('href').indexOf('.jpg')>-1 || $(this).attr('href').indexOf('.pdf')>-1 || $(this).attr('href').indexOf('prodomos')<0)){
			$(this).attr('target','blank');
		}
		}
		});
}}
}(jQuery));;

