/* SACD 2008 */
/* COMMON JAVASCRIPT FUNCTIONS */

/* ENABLE ROLLOVER ON TARGETED IMAGES (ALL BROWSERS) */
function imgRollover(elt) {
    jQuery(elt).each( function() {
		jQuery(this).hover(
			function() {
				jQuery(this).attr("src", jQuery(this).attr("src").replace("-off","-on"));
			},
			function () {
				jQuery(this).attr("src", jQuery(this).attr("src").replace("-on","-off"));
			}
		);
	});
}

/* ENABLE "+" ROLLOVER ON MODULE IMAGES LINKS (ALL BROWSERS) */
function moduleLinkRollover(elt) {
    jQuery(elt).each( function() {
		jQuery(this).hover(
			function() {
				jQuery(this).addClass("onLink");
			},
			function () {
				jQuery(this).removeClass("onLink");
			}
		);
	});
}

/* NUANCES MODULE */
function nuancesModule(elt) {
    jQuery("#moduleNuancierDeux").addClass('offLeft');
	jQuery(elt+" a").click(function(){
		if (!jQuery(this).hasClass("buttonNuancier")) {
			jQuery(".bigNuancier img").attr("src",jQuery(this).attr("href")).attr("alt",jQuery(this).attr("title"));
			jQuery(".bigNuancier span").text(jQuery(this).attr("title"));
			return false;
		} else {
			jQuery(".moduleNuancier li").removeClass('offLeft');
			jQuery(this).parent().parent().parent().addClass('offLeft');
			return false;
		}
	});
}

/* SAME HEIGHT FOR SAME CLASS ELEMENTS */
function sameHeight(elt) {
	var heightBlockMax=0;
	jQuery(elt).each(function(){ if( jQuery(this).height() > heightBlockMax ) heightBlockMax = jQuery(this).height(); }); // get max height
	if (jQuery.browser.msie) {
		if (parseInt(jQuery.browser.version) <= "6") {
			jQuery(elt).each(function(){ jQuery(this).css("height",heightBlockMax); }); // assign max height
		} else {
			jQuery(elt).each(function(){ jQuery(this).css("min-height",heightBlockMax); }); // assign max height
		}
	} else {
		jQuery(elt).each(function(){ jQuery(this).css("min-height",heightBlockMax); }); // assign max height
	}
	heightBlockMax=0;
}

// verif formulaire de contact
function validationContact(elt) {
	jQuery(elt).validationAideEnable(null,{summaryMessage: "<h3>Attention, vous devez remplir ou corriger le(s) champs suivant(s) :</h3>"});
}

/* TABS IN AUTHOR STUDIO */
function tabs(elt) {
	jQuery(elt).tabs();
}

/* LIGHTBOX FUNCTION */
function myLightbox(elt) {
    jQuery(elt).lightBox({
		imageLoading:'img/lightbox-ico-loading.gif',
		imageBtnClose:'img/lightbox-btn-close.gif',
		imageBtnNext:'img/lightbox-btn-next.gif',
		imageBtnPrev:'img/lightbox-btn-prev.gif',
		overlayBgColor:'#1D1713',
		overlayOpacity:0.5,
		containerBorderSize:0,
		txtOf:'de'
	});
}

jQuery(document).ready(function() {

    /* ADD hasJS CLASS TO BODY FOR ABS/REL POSITIONNING */
	jQuery("body").addClass("hasJS");

    /* HIDE QUICK LINKS */
	jQuery('#quickAccess').addClass('offLeft');

    /* ENABLE ROLLOVER ON FORM BUTTONS (ALL BROWSERS) */
	if (jQuery('input.inputImage').size() > 0) { initImgRollover = imgRollover('input.inputImage'); }

    /* ENABLE "+" ROLLOVER ON MODULE IMAGES LINKS (ALL BROWSERS) */
	if (jQuery('.moduleAmbiances li a').size() > 0 || jQuery('.moduleNuancier li a').size() > 0 || jQuery('.tabs li').size() > 0) { initModuleLinkRollover = moduleLinkRollover('.moduleAmbiances li a, .moduleNuancier li a, .tabs li'); }

	/* SAME HEIGHT FOR HOME BLOCKS */
	if (jQuery('#homeTextContent .homeText').size() > 1) { initSameHeight = sameHeight('#homeTextContent .homeText'); }

    /* TABS IN AUTHOR STUDIO DETAIL */
    if (jQuery('.tabs').size() > 0) { initTabs = tabs('.tabs'); }

    /* CONTACT FORM VALIDATION */
	if (jQuery('#contactForm').size() > 0) { initValidationContact = validationContact('#contactForm'); }

    /* ESTIMATE FORM VALIDATION */
	if (jQuery('#estimateForm').size() > 0) { initValidationContact = validationContact('#estimateForm'); }

    /* NUANCES MODULE */
	if (jQuery('.moduleNuancier').size() > 0) { initNuancesModule = nuancesModule('.moduleNuancier'); }

	/* LIGHTBOX */
	//if (jQuery('a.lightbox').size() > 0) { initMyLightbox = myLightbox('a.lightbox'); }

	/* COMBOBOX */
	if (jQuery('select.niceSelect').size() > 0) {
		var adeplacer = jQuery('#redirectMenu').children('p').html();
		jQuery('<div class="clearfix"></div>').appendTo(jQuery("#redirectMenu")).html(adeplacer);
		jQuery('#redirectMenu').children('p').remove();
		jQuery('select.niceSelect').combobox({ animationType: "none" });
	}
	
	/* COMBOBOX */
	if (jQuery('a.printTool').size() > 0) {
  
		jQuery('a.printTool').click(function(e){
			
			
			e.preventDefault();
			
			window.print();
			
		});
	
	}


});

if(typeof(window.console) == 'undefined') {
	
	window.console = function() {};
	window.console.log = function(msg) {};
		
}























/* END */