/* jQuery corner plugin v1.7 */
jQuery.fn.corner=function(F){function K(N){var N=parseInt(N).toString(16);return(N.length<2)?"0"+N:N}function D(O){for(;O&&O.nodeName.toLowerCase()!="html";O=O.parentNode){var N=jQuery.css(O,"backgroundColor");if(N.indexOf("rgb")>=0){rgb=N.match(/\d+/g);return"#"+K(rgb[0])+K(rgb[1])+K(rgb[2])}if(N&&N!="transparent"){return N}}return"#ffffff"}function M(N){switch(H){case"round":return Math.round(E*(1-Math.cos(Math.asin(N/E))));case"cool":return Math.round(E*(1+Math.cos(Math.asin(N/E))));case"sharp":return Math.round(E*(1-Math.cos(Math.acos(N/E))));case"bite":return Math.round(E*(Math.cos(Math.asin((E-N-1)/E))));case"slide":return Math.round(E*(Math.atan2(N,E/N)));case"jut":return Math.round(E*(Math.atan2(E,(E-N-1))));case"curl":return Math.round(E*(Math.atan(N)));case"tear":return Math.round(E*(Math.cos(N)));case"wicked":return Math.round(E*(Math.tan(N)));case"long":return Math.round(E*(Math.sqrt(N)));case"sculpt":return Math.round(E*(Math.log((E-N-1),E)));case"dog":return(N&1)?(N+1):E;case"dog2":return(N&2)?(N+1):E;case"dog3":return(N&3)?(N+1):E;case"fray":return(N%2)*E;case"notch":return E;case"bevel":return N+1}}F=(F||"").toLowerCase();var B=/keep/.test(F);var G=((F.match(/cc:(#[0-9a-f]+)/)||[])[1]);var J=((F.match(/sc:(#[0-9a-f]+)/)||[])[1]);var E=parseInt((F.match(/(\d+)px/)||[])[1])||10;var L=/round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;var H=((F.match(L)||["round"])[0]);var I={T:0,B:1};var A={TL:/top|tl/.test(F),TR:/top|tr/.test(F),BL:/bottom|bl/.test(F),BR:/bottom|br/.test(F)};if(!A.TL&&!A.TR&&!A.BL&&!A.BR){A={TL:1,TR:1,BL:1,BR:1}}var C=document.createElement("div");C.style.overflow="hidden";C.style.height="1px";C.style.backgroundColor=J||"transparent";C.style.borderStyle="solid";return this.each(function(R){var O={T:parseInt(jQuery.css(this,"paddingTop"))||0,R:parseInt(jQuery.css(this,"paddingRight"))||0,B:parseInt(jQuery.css(this,"paddingBottom"))||0,L:parseInt(jQuery.css(this,"paddingLeft"))||0};if(jQuery.browser.msie){this.style.zoom=1}if(!B){this.style.border="none"}C.style.borderColor=G||D(this.parentNode);var T=jQuery.curCSS(this,"height");for(var P in I){var U=I[P];C.style.borderStyle="none "+(A[P+"R"]?"solid":"none")+" none "+(A[P+"L"]?"solid":"none");var V=document.createElement("div");var N=V.style;U?this.appendChild(V):this.insertBefore(V,this.firstChild);if(U&&T!="auto"){if(jQuery.css(this,"position")=="static"){this.style.position="relative"}N.position="absolute";N.bottom=N.left=N.padding=N.margin="0";if(jQuery.browser.msie){N.setExpression("width","this.parentNode.offsetWidth")}else{N.width="100%"}}else{N.margin=!U?"-"+O.T+"px -"+O.R+"px "+(O.T-E)+"px -"+O.L+"px":(O.B-E)+"px -"+O.R+"px -"+O.B+"px -"+O.L+"px"}for(var Q=0;Q<E;Q++){var W=Math.max(0,M(Q));var S=C.cloneNode(false);S.style.borderWidth="0 "+(A[P+"R"]?W:0)+"px 0 "+(A[P+"L"]?W:0)+"px";U?V.appendChild(S):V.insertBefore(S,V.firstChild)}}})};


/*  Fonctions communes  */
(function($) {
$(document).ready(function(){

	function Init() {
		$(".expand").css({'display':'none'});
		$(".expand").prev().css({'background':'url(/css/images/h5plus.gif) left top no-repeat', 'cursor':'pointer', 'border-bottom':'1px solid #1CA7A3', 'margin':'20px auto 0 auto' });
		$(".selected").css({'display':'block'});
		$(".selected").prev().css({'background':'url(/css/images/h5bas.gif) left top no-repeat' });
	}
	
	function collapseAll() {
		$(".expand").slideUp();
		$(".expand").attr('class','expand');
		$(".expand").prev().css('background','url(/css/images/h5plus.gif) left top no-repeat');
	}
	
	function collapseOne(object) {
		object.next().slideUp();
		object.next().attr('class','expand');
		object.css('background','url(/css/images/h5plus.gif) left top no-repeat');
	}
	
	function showOne(object) {
		collapseAll();
		object.next().slideDown();
		object.next().attr('class','expand');
		object.css('background','url(/css/images/h5bas.gif) left top no-repeat');
	}
  	
	Init();
	
	/*sliding actions*/
	$(".expand").prev().toggle(
	   function(){
			showOne($(this));
		},
	   function(){
			collapseOne($(this));
		}
	);
	
	/* uniquement pour la page avec formulaire de candidature*/
	if($(".formcand").attr('class')=='expand formcand selected'){
		showOne($(".formcand").prev());
	}

	/* envoyer à un ami */
	$("#envoyer form").corner("15px cc:#fff tr");
	$("#envoyer h5").css({"cursor":"pointer"});
	$("#envoyer h5").next().css({"display":"none"});
	$("#envoyer h5").toggle(
	   function(){$(this).next().fadeIn();},
	   function(){$(this).next().fadeOut();}
	);
	
	/* "idee deco" et "textiles coordonnes" detail chambre */
	$(".expand_chambre").corner("15px cc:#fff tr");
	$(".expand_chambre").prev().css({"cursor":"pointer"});
	$(".expand_chambre").css({"display":"none"});
	$(".expand_chambre").prev().toggle(
	   function(){$(this).next().fadeIn();},
	   function(){$(this).next().fadeOut();}
	);
	
	
	if (document.getElementById('pub'))
	{
		$("#pub").wrap("<div id='ombre'></div>");
    $("#pub").prepend("<a href='#'>fermer</a>");
		$("#pub").css({'top':'-5px', 'left':'-3px'});
		$("#pub a").click(function() {
			$("#ombre").css({'display':'none'});
		} )
	}


	if(document.getElementById("flash_shop")){
		var flashvars = false;
		var params = {
			menu: "false",
			swliveconnect: true,
			bgcolor: "#FFFFFF",
			wmode: "transparent"
		};
		var attributes = {
			id: "flash_shop",
			name: "flash_shop"
		};
		swfobject.embedSWF("/flash/lienShop.swf", "flash_shop", "132", "142", "8","expressInstall.swf", flashvars, params, attributes);
		
	};
	
	
	$('#page .tooltip a').tooltip({
		track: true,
		showURL: false, 
		showBody: " - "
	});
  $('#page .tooltip a img').removeAttr('alt');
	
  
  
  $("a.catalogue")
    .removeAttr("rel")
    .removeAttr("href")
    .css("cursor", "pointer")
    .click(function(){window.open('/catalogue/virtuel/appli.htm','Catalogue','width=1000,height=670');return false;});
	
  
	/* lien externes dans une nouvelle fenetre */
	$("a[@rel='external']").each(function(){
		$(this).attr({ title: $(this).attr("title")+" (nouvelle fenĂȘtre)" });
		$(this).click(function() {
			window.open($(this).attr('href'));
			return false;
		});
	});
	
	
  
    
    

});
})(jQuery);