
/***** l_unitpngfix *****/
/* <PENTALOG-MA> */
if ($("#tabs-container").length) {
	;
} 
/* </PENTALOG-MA> */
else {
var clear="/images/clear.gif"; //path to clear.gif
pngfix=function(){var els=document.getElementsByTagName('*');var ip=/\.png/i;var i=els.length;while(i-- >0){var el=els[i];var es=el.style;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";el.src=clear;}else{var elb=el.currentStyle.backgroundImage;if(elb.match(ip)){var path=elb.split('"');var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';var elkids=el.getElementsByTagName('*');if (elkids){var j=elkids.length;if(el.currentStyle.position!="absolute")es.position='static';while (j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}}
if(typeof(window.attachEvent)=='object'){window.attachEvent('onload',pngfix);}
}
/***** l_jquery_corner *****/
/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 1.98 (02-JUN-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 *  corners: one or more of: top, bottom, tr, tl, br, or bl. 
 *           by default, all four corners are adorned. 
 *  width:   width of the effect; in the case of rounded corners this is the radius. 
 *           specify this value using the px suffix such as 10px (and yes, it must be pixels).
 *
 * @name corner
 * @type jQuery
 * @param String options Options which control the corner style
 * @cat Plugins/Corner
 * @return jQuery
 * @author Dave Methvin (http://methvin.com/jquery/jq-corner.html)
 * @author Mike Alsup   (http://jquery.malsup.com/corner/)
 */
;(function($) { 

var expr = (function() {
	if (! $.browser.msie) return false;
    var div = document.createElement('div');
    try { div.style.setExpression('width','0+0'); }
    catch(e) { return false; }
    return true;
})();
    
function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
        var v = $.css(node,'backgroundColor');
        if (v == 'rgba(0, 0, 0, 0)')
            continue; // webkit
        if (v.indexOf('rgb') >= 0) { 
            var rgb = v.match(/\d+/g); 
            return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
        }
        if ( v && v != 'transparent' )
            return v;
    }
    return '#ffffff';
};

function getWidth(fx, i, width) {
    switch(fx) {
    case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl':   return Math.round(width*(Math.atan(i)));
    case 'tear':   return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long':   return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
    case 'dog':    return (i&1) ? (i+1) : width;
    case 'dog2':   return (i&2) ? (i+1) : width;
    case 'dog3':   return (i&3) ? (i+1) : width;
    case 'fray':   return (i%2)*width;
    case 'notch':  return width; 
    case 'bevel':  return i+1;
    }
};

$.fn.corner = function(o) {
    // in 1.3+ we can fix mistakes with the ready state
	if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(o);
            });
        }
        return this;
	}

    o = (o||"").toLowerCase();
    var keep = /keep/.test(o);                       // keep borders?
    var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
    var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
    var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
    var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
    var fx = ((o.match(re)||['round'])[0]);
    var edges = { T:0, B:1 };
    var opts = {
        TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
        BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
    };
    if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
        opts = { TL:1, TR:1, BL:1, BR:1 };
    var strip = document.createElement('div');
    strip.style.overflow = 'hidden';
    strip.style.height = '1px';
    strip.style.backgroundColor = sc || 'transparent';
    strip.style.borderStyle = 'solid';
    return this.each(function(index){
        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    //if (expr)
					if ((($.browser.msie) && ($.browser.version < 8.0)) && expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    //if (expr) {
					if ((($.browser.msie) && ($.browser.version < 8.0)) && expr) {
                        var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
                }

                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getWidth(fx,i, width));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
            }
        }
    });
};

$.fn.uncorner = function() { 
	$('div.jquery-corner', this).remove();
	return this;
};
    
})(jQuery);

/***** v_tp_result_search_index *****/
function show(myId) {
	killShow();
	
	$("#box_desc").html($('#'+myId).text());
	$("#box_desc").css("display","none");
	$("#"+myId).css("text-align","justify");
	$('#'+myId).html($('#'+myId).attr('cond'));
}
function killShow() {
	$("p[name='conditioning']").unbind("mouseover");
}

function initShow() {
	$("p[name='conditioning']").mouseover(function(){
        show(this.id);
	});
}

$(document).ready(function(){

    $(".pane-list li").click(function(){
        window.location=$(this).find("a").attr("href");return false;
	});

	$("#all_vign").corner("bevel tl bl");
	
	//Ouverture de la box pour la description
	$("p[name='conditioning']").mouseover(function(){
		show(this.id);
	});	
	// fermeture
	$("p[name='conditioning']").mouseout(function(){		
            $("#"+this.id).html($("#box_desc").text());
            $("#box_desc").html("");
            initShow();
	});

    if($('#listPromAct').length){
        setTimeout(function(){
            $('#listPromAct').slideUp();
        }, 5000);
    }
});
/***** v_tp_news_letter_index *****/
$(document).ready(function() {
	$("#forget").corner("bevel bl tl 10px");

	$("#box_cp_cross > a").click(function() {
		$("#box_cp").hide("normal");
	});
	
	//creation de la box pour le code postal 
	$("a[name='box_cat']").click(function(e) {			
            $("#valid_cp").append("<input type='hidden' name='sous_cat_id' value='" + this.id + "'/>");
	});			
	
	// focus sur un champ newsletter qui disparait
	//ou reapparait si on y pointe la souris
	$("#mail").focus(function() {
		if( $(this).val() == "Votre Email" ) $(this).val("");
	});
	$("#mail").blur(function() {
		if( $(this).val() == "" ) $(this).val("Votre Email");
	});

});
/***** v_tp_header_result *****/
$(document).ready(function() {
	/* <PENTALOG-MA> */
	if ($("#tabs-container").length || $("#usr_phone_type").length) {
		;
	}
	/* </PENTALOG-MA> */
	else {
		$("#txt").corner("bevel top 30px");
		$("#txtlogo").corner("bevel 8px");
		$("#footer").corner("bevel tl tr cc:#F2F2F2");
	}
});
/***** v_tp_search_promo_result *****/
/**
* fichier javascript pour la gestion de l auto completion
**/
$(document).ready(function() {

	//traitements pour affinage des resultats

	/*$("#search_ou").focus(function() {
		if( $(this).val(""));
	});
	
	$("#search_quoi").focus(function() {
		if( $(this).val(""));
	});*/
	
	$("#promo_result").corner("bevel bottom cc:#F389B7");
	$("#promo_result").corner("bevel top cc:#FFF");
	$(".boxActionOk").corner("bevel tl tr cc:#FFF");
    
    $("#refinement_search_ou").keydown().autocomplete('tp_search_promo/getcompletionresults/?q='+this.val, {
        minChars: 2,
        width: 350,
        //matchContains: true,
        highlight : false,
        matchSubset : false,
        scrollHeight: 180,
        scroll: false,
        dataType: "json",
        parse: function(data) {
			return $.map(data, function(row) {
				return {
					data: row,
					value: row.results,
					result: row.title
				}
			});
		},
        formatItem: function(data){
            return formatTab(data);
        }
    });
});

function formatTab(data){
	var max = data.results.length;
    var html = ''

    if(max != 0){
        html = '<span class="title">' + data.title + '</span>';

        for(var i = 0; i < max; i++){
            //alert(data.results[i][0].toSource());
            html = html + '<li class="'+(i%2 == 0 ? "ac_even" : "ac_odd") + '" name="' + data.results[i][0] + '">' + data.results[i][1] + '</li>';
        }
    }
	return html;
}
/***** v_tp_result_index *****/
function mailpage() {
    chaine_mail = "mailto:?subject= : " + document.title;
    chaine_mail+= "&body= Je recommande cette page : " + document.title;
    chaine_mail+= ". Consultable à l'adresse : " + location.href; location.href = chaine_mail;
}

function stylise() {
	//corners de la liste promo
	$(".header_liste_promo_gauche").corner("bevel tl bl");
	$(".newsletter").corner("bevel tl bl");
	$("#content_liste_promo").corner("bevel bl 10px").parent().css('padding-left', '1px').corner("bevel bl 10px");
	$("#logoPrint").corner("bevel tl bl 5px");

	//accordeon de la liste des promos
	$(".header_liste_promo_droite").toggle(
		function(){
			//$(".contenuListePromo").animate({ height: 'hide', opacity: 'hide' }, 'slow');
			$(".contenuListePromo").slideUp("normal", function(){
                $("#showClik").show();
            });
			
			if( $("#accordionPromoMsn").size() ) {
				$("#promoListSlider").attr({src: "/images/topPromo/bas-msn.gif"});
			}
			else{
				$("#promoListSlider").attr({src: "/images/topPromo/bas.gif"});
			}
		},
		function(){
            $("#showClik").hide();
			$(".contenuListePromo").slideDown();
            //$(".contenuListePromo").animate({ height: 'show', opacity: 'show' }, 'slow');
			
			if( $("#accordionPromoMsn").size() ) {
				$("#promoListSlider").attr({src: "/images/topPromo/haut-msn.gif"});
			}
			else{	
				$("#promoListSlider").attr({src: "/images/topPromo/haut.gif"});
			}

		}
	);
}

$(document).ready(function(){
	//: Appel de la liste de promo ssi le bloc existe (Pas sur Mobile)
	if( $("#promoListAjax").size() ) {
		$.ajax({
		  url: $('#promoListAjax').attr('name'),
		  cache: false,
		  success: function(html){
			$("#promoListAjax").append(html);
			stylise();
		  }
		});
	}
	
	//actions sur la box de validation d un action (reussite et echec) 
	//(utilise par le contactadv pour la confirmation de creation)
	$('.boxActionOk').click(function() {
		$(this).fadeOut();
	});
	$('.boxActionKo').click(function() {
		$(this).fadeOut("slow").slideUp("slow");
	});	
	$("#all_vign").corner("bevel tl bl");
    $("#accroche_alerte").corner('bevel');

    /***** AUTOCOMPLETION ****/
    //Echap cache les suggestions
    /*$('#refinement_search_ou').bind('keydown.searchlight', function(evt) {
        if (evt.which == 27) {
            $("div.searchlight-balloon").css('display', 'none');
        }
    }
    );
    //click en dehors des suggestions cache les suggestions
    $("html").click(function(e){
        if(typeof(e.target._rowId)=='undefined') {
            $("div.searchlight-balloon").css('display', 'none');
        }
    });

    jQuery(function() {
        try {
            $('#refinement_search_ou').searchlight('tp_search_promo/getcompletionresults/',
            {
                searchDelay: 300,
                limitPerCategory: 10,
                minimumCharacters: 2,
                width: '340px',
                showIcons: false,
                actionFunction: function(val) {
                    this._previousQuery = val;
                    $('#refinement_search_ou').focus();
                    $('#refinement_search_ou').val(val);
                    this.hide();
                }
            });
        } catch(err){
            //le plugin searchlight n'est pas chargé
        }
    });*/
});



function print_url(url)
{
 location=url;
 print();

 }