$(document).ready(function() {
	
	
	// detection IE	
	if ($.browser.msie) {
	    if($.browser.version == '6.0'){
	      fixIe();
 	    };
};
	
	$('a').click(function(){
		$(this).blur();
		
	});
	
	$('address strong').each(function(){
	 $(this).css({'font-weight': 'bold'});	
	});
	
	
	
	// style pour la premiere li de chaque ul sur la page villa sur plans
	$('ul.description').each(function(){
	$thisLi = $(this).find('li:first');
	$thisLi.css({'font-weight': 'bold', 'list-style-type':'none', 'margin-left': '8px', 'font-size': '1.5em' });	
	});
	
	// creation dynamique des balises title des liens
	$('#nav a, #resources a, #info p a, #credit p a').each(function(index){
	  $thisLink = $(this);
	  $thisLink.attr({'title': $thisLink.text()});	
	});
	
	// envoi du formulaire en ajax apres verification
	$('#contactForm').submit(function(){
	if(cForm() === true){
	   $('<p id ="envoi_ok"></p>').hide().prependTo('#contactForm');
	   $('#send').hide();
	   $('#loading').show();
	   var inputs = [];
	   $(':input', this).each(function(){
	   	inputs.push(this.name + '=' + escape(this.value));
	   });
	   
	   $.ajax({
	     url: "check.php",
	     type: "POST",
	     data: inputs.join('&'),
	   
	     success: function(msg) {
	       $('#loading').hide();
	       $('#send').show();
	       $('#envoi_ok').append(msg)
	                     .show('slow')
	                     .animate({'opacity': 1},3000)
	                     .hide('slow', function(){
	                     	$(this).remove();
                     });
	       document.forms.contactForm.reset();
      
	    },
	   
	     error: function() {
	       alert('impossible d\'envoyé le message');
	       $('#send').show();
            }
	   });
	   
	}
	$(this).blur();
	return false;
        });
	
	$('a.plan').hover(function(){
		$(this).children('.wide').fadeOut('slow');
	}, function(){
		$('.wide').fadeIn('slow');
	});
	
	
	// css du lien before after en bas de chaque page + ouverure d'une autre fenetre
	$('a[@href*="before-after-design"]').css({'color': '#B8C491', 'text-decoration': 'none', 'font-weight': 'bold' }).click(function(){
	   newWin($(this).attr('href'));	
	   return false;	
	}).hover(function(){
		$(this).css({'text-decoration': 'underline', 'color': '#DAE0C5' });
	},function(){
		$(this).css({'text-decoration': 'none', 'color': '#B8C491' });
	});
	
	$('a[@href^="mailto:"]').css({'color': '#8E9C50'}).hover(function(){
		$(this).css({'text-decoration': 'underline'});
	},function(){
	        $(this).css({'text-decoration': 'none'});	
	});	
	
	
	$('#resources li a').click(function(){
	  $thisExt = $(this);
	  newWin($thisExt.attr('href'));
	  return false;	
	});
	
	
 function fixIe(){
$('#logo').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/logo.png', sizingMethod='crop');" });
$('#c_accueil').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/accueil.png', sizingMethod='crop');" });
$('#c_toubab').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/toubad_dialaw.png', sizingMethod='crop');" });
$('#c_villas').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/villas_sur_plans.png', sizingMethod='crop');" }); 
$('#c_prest').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/prestations.png', sizingMethod=crop');" });  
$('#c_contact').css({'background': "none", 'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/contact.png', sizingMethod='crop');" });  
};	
	
});

function  newWin(url){
	window.open(url);
};





















