$(document).ready(function(){			   
	$("#menu li.submenu,#menuOther li.submenu").hover(
		function() {
			$("ul", this).show();
			$(this).find("span").addClass("active");
			$("ul", this).css("z-index","545");
			},
		function() {
			$("ul", this).hide();
			$(this).find("span").removeClass();
			}
	);
	remplaceFonts();
	$(".list-hover-nice li").hover(
		function() {
			if ($.browser.msie) {$(this).find("div").show();}else{$(this).find("div").fadeIn(200);}
			var title = $(this).find("a").attr("title");
			$(this).append("<p>"+title+"</p>");
			$(this).find("h2").addClass("active");
			},
		function() {
			if ($.browser.msie) {$(this).find("div").hide();}else{$(this).find("div").fadeOut(200);}
			$(this).find("p").remove();
			$(this).find("h2").removeClass("active");
			}
	);
	$(".list-hover-nice li.icoNew,.list-product li.icoNew").each(function(){
		$(this).prepend("<img class=\"icoNewimg\" src=\""+ROOT_DIR+"imagenes/icons/new.png\" />");
	});
	$(".tootip-colors li.icoNew").each(function(){
		$(this).prepend("<img class=\"icoNewimg2\" src=\""+ROOT_DIR+"imagenes/icons/new.gif\" />");
	});
	$(".list-hover-nice li,#bloque-home-3").click(function() {
		var url = $(this).find("a:first").attr("href");
		window.location = url;
	    return false;
	});
	$(".ultimLi:last,#listproductos li:last,#bloque-home-1 p:last,#caracteristicas-links ul li:last,.marca-modelo li:last,.marca-ano li:last,#paginacion li:last,#listproductos2 li:last").addClass("last");
	$("#caracteristicas-links ul li:first").hover(
		function() {
			$(this).parent().addClass("active");
			},
		function() {
			$(this).parent().removeClass("active");
			}
	);
	$("#caracteristicas-links ul li:last").hover(
		function() {
			$("#caracteristicas-links").addClass("active");
			},
		function() {
			$("#caracteristicas-links").removeClass("active");
			}
	);
	$("#caracteristicas-links ul li:first,#paginacion li:first,.escoderImg img:first,.esconderVideos img:first").addClass("first");
	$("#featuresAllTool .tooltip-target").ezpz_tooltip({
		contentPosition:'aboveStatic',
		stayOnContent:true,
		offset:-31
	});
	$("#marcas .tooltip-target").ezpz_tooltip({
		contentPosition:'belowStatic',
		stayOnContent:true,
		offset:-170
	});
	$('#other-colors').jcarousel({
		start:1,
		scroll:4
	});
	$('#listado-distribuidores').jcarousel({
		start:1,
		scroll:1
	});
	$("#marcas .tooltip-content ul li a").click(function() {
		$(this).addClass("active");
	});
	$("body").append("<p id='tooltip'></p>");
	tooltip();
	submitCSS();
	$("#aviso-legal").colorbox();
	setTimeout ('equalHeight($("#faqTop ul li,.contentDistribCaro"))', 500);
	imagen_on_1 = new Image()
	imagen_on_1.src = ROOT_DIR+"imagenes/"+LANG+"/download_hover.png"
	imagen_off_1 = new Image()
	imagen_off_1.src = ROOT_DIR+"imagenes/"+LANG+"/download.png"
});
this.tooltip = function(){	
	xOffset = -20;
	yOffset = 20;
	$("a.tooltip").hover(function(e){
		this.t = this.rel;
		$("#tooltip").html(this.t);
		$("#tooltip").show();
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(e){
		this.title = this.t;		
		$("#tooltip").hide();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
};
function formDefaultValue (elemento, defaultValue) {
	if (elemento.value==defaultValue) {
		elemento.value = "";
	}
	return true;
}
function formDefaultValueCheck (elemento,defaultValue) {
	if(elemento.value == "") {
		elemento.value = defaultValue;
	}
}
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
function remplaceFonts() {
	Cufon.replace('.DINPro-Bold', {fontFamily:'DINPro-Bold',hover: true});
	Cufon.replace('.DINPro-Black', {fontFamily:'DINPro-Black',hover: true});
}