
/************************************************************************
 * Rollover des éléments avec les images passées en paremètres
 ************************************************************************/
jQuery.fn.rollover = function(imgOver, imgOut) {
  return this.each(function(){
	$(this).hover(function(){
		$(this).attr('src', imgOver);
	}, function(){
		$(this).attr('src', imgOut);
	});
  });
};
/************************************************************************
 * Rollover des images qui ont les attributs onmouseover et onmouseout 
 * qui retournent les paths d'images
 ************************************************************************/
jQuery.fn.rolloverImage = function() {
  return this.each(function(){
	$(this).hover(function(){
		var img = getImageUrl($(this), 'onmouseover');
		$(this).attr('src', img);
	}, function(){ 
		var img = getImageUrl($(this), 'onmouseout');
		$(this).attr('src', img);
	});
  });
};

/************************************************************************
 * Rollover des images dans les liens quand les liens ont les attributs
 * onmouseover et onmouseout qui retournent les paths d'images
 ************************************************************************/
jQuery.fn.rolloverLink = function() {
  return this.each(function(){
	$(this).hover(function(){
		var img = getImageUrl($(this), 'onmouseover');
		$(this).children('img').attr('src', img);
	}, function(){ 
		var img = getImageUrl($(this), 'onmouseout');
		$(this).children('img').attr('src', img);
	});
  });
};

jQuery.fn.preloadImages = function(){
    return this.each(function(){
		var img = getImageUrl($(this), 'onmouseover');
		var over = newImage(img);
    });
};

jQuery.fn.equalizeCols = function() {
    var el, height = 0, h;
    this.each(function() {
        el = jQuery(this).css('height', 'auto');
        h = el.outerHeight();
        height = (h > height) ? h : height;
    });
    return this.each(function() {
        if ($.browser.msie){
            if($.browser.version.substring(0, 1) < 7 )
                $(this).css('height', height + 'px');
            else
                $(this).css('min-height', height + 'px');
        }else{
            $(this).css('min-height', height + 'px');
        }
    });
}; 

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function getImageUrl(imgObj, tag){
	var img = imgObj.attr(tag);
	if(img != null){
		if(!$.browser.msie)
			img = img.replace(/return \'/, '').replace(/\'/, '').replace(/;/, ''); 
	}else{
		img = imgObj.attr("src");
	}
	return img;
}

// Products Details > Tabs
$(document).ready(function() {
    if ($("ul.Tabs a").length > 0) {
        $("div.TabContent").css("display", "none");
        $("div.TabContent:first").css("display", "block");
        
        $("div.HeaderContent").css("display", "none");
        $("div.HeaderContent:first").css("display", "block");
        
        $("ul.Tabs a:first").addClass("On");

        $("ul.Tabs a,a.NextTab").each(function() {
            var currentTabId = $(this).attr("href");
            var headerTabId = currentTabId.replace(/Tab/, "Head")
            var liTabId = currentTabId.replace(/Tab/,"li")
            $(this).attr("href", "javascript:void(0);");
            $(this).click(function() {
                $("div.TabContent").css("display", "none");
                $("div.HeaderContent").css("display", "none");
                $("ul.Tabs li").removeClass("On");
                $(currentTabId).css("display", "block");
                $(headerTabId).css("display", "block");
                $(liTabId).addClass("On");
            });
        });
    }
});



