//Limpiar el value de los inputs
function formDefaultValue (elemento, defaultValue) {
	if (elemento.value==defaultValue) {
		elemento.value = "";
	}
	return true;
}
function formDefaultValueCheck (elemento,defaultValue) {
	if(elemento.value == "") {
		elemento.value = defaultValue;
	}
}

// Rollover imagenes accesos superiores
function rolloverAccesosImg (name,imagen){
	document.images[name].src = imagen;
}

//Eventos de las IMG
cambiaIMG = {};      
  cambiaIMG.rollover =
  {
     init: function()
     {
        this.preload();
        $(".imgHover").hover(
           function () { $(this).attr( 'src', cambiaIMG.rollover.newimage($(this).attr('src')) ); },
           function () { $(this).attr( 'src', cambiaIMG.rollover.oldimage($(this).attr('src')) ); }
        );
     },
     preload: function()
     {
        $(window).bind('load', function() {
           $('.imgHover').each( function( key, elm ) { $('<img>').attr( 'src', cambiaIMG.rollover.newimage( $(this).attr('src') ) ); });
        });
     },
     newimage: function( src ) { return src.substring( 0, src.search(/(\.[a-z]+)/) ) + '_hover' + src.match(/(\.[a-z]+)/)[0]; },
     oldimage: function( src ){ return src.replace(/_hover/, ''); }
  };
  
//Igualar altura
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

// Capas de coste - entrega en mano
function entrega_en_mano(){
	if ((document.forms['paso1'].terminal[0].checked) || (document.forms['paso1'].terminal[2].checked)){
		$("#coste_documentacion_en_mano").show();
		$("#coste_documentacion_normal").hide();
		document.forms['paso1'].documentacion[2].checked=true;
	} else {
		$("#coste_documentacion_en_mano").hide();
		$("#coste_documentacion_normal").show();
		if (document.forms['paso1'].documentacion[1].checked) {
			document.forms['paso1'].documentacion[1].checked=true;
		} else {
			document.forms['paso1'].documentacion[0].checked=true;
		}
	}
}

//Fuentes
Cufon.replace('#menu li, #link-header li, #linksDirectos-2 li, #linksDirectos-3 li', {fontFamily:'Helvetica67-CondensedMedium'});
Cufon.replace('#accesosDirectos h3', {fontFamily:'Helvetica57-Condensed'});
Cufon.replace('#logistica h2, h1', {fontFamily:'Helvetica-CondensedLight'});
	
$(document).ready(function(){					   
	if ($("#content-left").outerHeight()>$("#content-right").outerHeight()){var altura=$("#content-left").outerHeight(); $("#content-right").height(altura);}	
    $("#primerFot li:last, #segunFot li:last, #footer .fright li:last, #submenu li:last, #linksDirectos-3 li:last, #linksDirectos-2 li:last").addClass("last");
    $("#primerFot li:first #segunFot li:first, #footer .fright li:first").addClass("first");
	$("#list-iconos li:even").addClass("even");
	$("#list-iconos li:odd").addClass("odd");
	
	fecha_envio = new Date();
	dia = fecha_envio.getDay();
	if (dia==0) {fecha_envio.addDays(5); } //es domingo, sumamos 5 dias
	if (dia==1) {fecha_envio.addDays(4); } //es lunes, sumamos 4 dias
	if (dia==2) {fecha_envio.addDays(3); } //es martes, sumamos 3 dias
	if (dia==3) {fecha_envio.addDays(2); } //es miercoles, sumasmos 2 dias
	if (dia==4) {fecha_envio.addDays(1); } // es jueves, sumamos 1 dia
	if (dia==5) {fecha_envio.addDays(7); } // es miercoles, sumamos 7 dias
	if (dia==6) {fecha_envio.addDays(6); } // es jueves, sumamos 6 dias
	
	$('.inputEnvio').datePicker().val(fecha_envio.asString()).trigger('change');
	
	
	$("#icoHelp").mouseover(function(event) {$("#tootltip").show();});
	$("#icoHelp").mouseout(function(event) {$("#tootltip").hide();});
	$("#icoHelp_dest").mouseover(function(event) {$("#tootltip_dest").show();});
	$("#icoHelp_dest").mouseout(function(event) {$("#tootltip_dest").hide();});
	$("#icoHelp_acomp").mouseover(function(event) {$("#tootltip_acomp").show();});
	$("#icoHelp_acomp").mouseout(function(event) {$("#tootltip_acomp").hide();});
	$("#icoHelp_recog").mouseover(function(event) {$("#tootltip_recog").show();});
	$("#icoHelp_recog").mouseout(function(event) {$("#tootltip_recog").hide();});
	$("#icoHelp_fecha").mouseover(function(event) {$("#tootltip_fecha").show();});
	$("#icoHelp_fecha").mouseout(function(event) {$("#tootltip_fecha").hide();});
	
	$("#lang li").click(function(event) { 
		$("#lang li").toggleClass("active");
		$("#lang-list").slideToggle();
	});
	$("#cerrarLang").click(function(event) {$("#lang-list").hide();});
});