var opened = 1;
	var openfooter = false;
    var curvyCornersVerbose = false;
	var form_id = false;
    jQuery(document).ready(function(){
        jQuery("#sub_client").click(function(event){
            event.preventDefault();
            //pass = $.md5($("#login_pass").val().toUpperCase());
            //$("#login_pass").val(pass);
            jQuery("#form_cli").submit();
        });
        
        $("#sub_jira").click(function(event){
            event.preventDefault();
            //pass = $.md5($("#login_pass").val().toUpperCase());
            //$("#login_pass").val(pass);
            $("#form_jira").submit();
        });
    
        $("#menu ul li").click(function(){
            $("#menu ul li").removeClass('active');
            $(this).addClass('active');
        });
        
        $("#linea").click(function(){
            $(this).addClass('active');
            $("#sect").removeClass('active');
            $("#linea-negocio").show();
            $("#sectores").hide();
            return false;
        });
        
        $("#sect").click(function(){
            $(this).addClass('active');
            $("#linea").removeClass('active');
            $("#linea-negocio").hide();
            $("#sectores").show();
            return false;
        });
        
        $("#mapMad").click(function(){
            $(this).addClass('active');
            $("#mapVal").removeClass('active');
            $("#mapLon").removeClass('active');
            initialize_map(40.487565,-3.688468);
            $("#dirs").html("<h2><!--#I_I_I_sections[I6,I6I1,I6I1I1,1]/--><!--#I_I_I_section[I6,I6I1,I6I1I1,I6I1S1]/-->"+
            "<!--#I_I_I_section_tit[I6,I6I1,I6I1I1,I6I1S1,dónde encontrarnos en madrid]/-->Dónde encontrarnos</h2>"+
            "<p><!--#I_I_I_section_content[I6,I6I1,I6I1I1,I6I1S1]-->Fco. Sancha 22 Bajo G, 28034<!--/#I_I_I_section_content[I6,I6I1,I6I1I1,I6I1S1]--></p>");
            return false;
        });
        
        $("#mapVal").click(function(){
            $(this).addClass('active');
            $("#mapMad").removeClass('active');
            $("#mapLon").removeClass('active');
            initialize_map(39.480999, -0.362847);
            $("#dirs").html("<h2><!--#I_I_I_sections[I6,I6I1,I6I1I0,1]/--><!--#I_I_I_section[I6,I6I1,I6I1I0,I6I1S0]/-->"+
            "<!--#I_I_I_section_tit[I6,I6I1,I6I1I0,I6I1S0,dónde encontrarnos valencia]/-->Dónde encontrarnos</h2><p>"+
            "<!--#I_I_I_section_content[I6,I6I1,I6I1I0,I6I1S0]-->C/Alvaro de Bazán 10 - 12, 46010 Valencia<!--/#I_I_I_section_content[I6,I6I1,I6I1I0,I6I1S0]--></p>");
            return false;
        });
        
        $("#mapLon").click(function(){
            $(this).addClass('active');
            $("#mapVal").removeClass('active');
            $("#mapMad").removeClass('active');
            initialize_map(51.515227, -0.134852);
            $("#dirs").html("<h2><!--#I_I_I_sections[I6,I6I1,I6I1I2,1]/--><!--#I_I_I_section[I6,I6I1,I6I1I2,I6I1S2]/-->"+
            "<!--#I_I_I_section_tit[I6,I6I1,I6I1I2,I6I1S2,dónde encontrarnos en londres]/-->Dónde encontrarnos</h2>"+
            "<p><!--#I_I_I_section_content[I6,I6I1,I6I1I2,I6I1S2]-->Medius House LG 12</p><p>Sheraton St, W1F8BH Londres<!--/#I_I_I_section_content[I6,I6I1,I6I1I2,I6I1S2]--></p>");
            return false;
        });
        
        $("#ctl00_placeHold_DDL_boletines").change(function(){
            window.open($(this).val(),"","target=_blank,scrollbars=YES");
        });
        
        jQuery("#login_btn").click(function(event){       
            event.preventDefault();
            pass = jQuery.md5(jQuery("#login_pass").val().toUpperCase());
            jQuery("#login_pass").val(pass);
             jQuery("#login_form").submit();
        });
        $("#login_form").keypress(function(event){ 
			if(event.which == 13)
			{
				pass = $.md5($("#login_pass").val().toUpperCase());
				$("#login_pass").val(pass);
				 $("#login_form").submit();
			}
        }); 
		$("#login_pass").focus(function(event){       
            $("#login_pass").val('');
        });
		$("#login_name").focus(function(event){       
            $("#login_name").val('');
        }); 
//        $("#login input").click(function(event){
//            SelectAll(this);
//        });
        
        $(".text img").each(function(index){
            id = $(this).attr('id').substring($(this).attr('id').length-20,$(this).attr('id').length);
            if(id != "" && $.cookie("CSD_"+id)!=null){
                aux = $(this).attr('src').substring(0,$(this).attr('src').length-4)+"_off.gif"
                $(this).attr('src',aux);
                $(this).parent().attr('href',"");
            }
        });
        
        $(".thumb").each(function(index){
            $(this).mouseenter(function(event){
                $(this).find("div").show();
            });
            $(this).mouseleave(function(event){
                $(this).find("div").hide();
            });
        });
		$("#login1").click(function()
		{
			showLogin();
		});
		$("#login2, .btn_area").click(function()
		{
			showLogin2();
			return false;
		});
		$("#submDesc").click(function(event)
		{
			event.preventDefault();
			if(form_id=="SIGESCON")
			{
				//alert('Enviando id:'+form_id);
				$("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
				$("#form_down").attr("action","seguridad/identificacion_sica.asp?ruta=descargas/descargas_sigescon.aspx");
				//alert("hello!");
				$("#form_down").submit();
			}
			else if(form_id == "SICA")
			{
			    $("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
    		    $("#form_down").attr("action","seguridad/identificacion_sica.asp?ruta=../descargas/descargas_sica.aspx");
    		    $("#form_down").submit();
			}
            else if(form_id == "F_E_VISADO")
            {
                $("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
    		    $("#form_down").attr("action","seguridad/identificacion_sica.asp?ruta=../descargas/descargas_visared.aspx");
    		    $("#form_down").submit();
            }else if(form_id == "B_E_VISADO")
            {
                $("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
    		    $("#form_down").attr("action","seguridad/identificacion_sica.asp?ruta=../descargas/descargas_visared_back.aspx");
    		    $("#form_down").submit();
            }else if(form_id == "CLECE")
            {
                $("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
    		    $("#form_down").attr("action","seguridad/identificacion_sica.asp?ruta=../descargas/descargas_clece.aspx");
    		    $("#form_down").submit();
            }else
            {
                $("#TextDesc").attr("name","login");
				$("#PasswordDesc").attr("name","password");
    		    $("#form_down").attr("action","seguridad/seguridad.asp?ruta=../descargas/descargas_giga.aspx");
    		    $("#form_down").submit();
            }
		});
		$(".downld li").click(function()
		{
			form_id= $(this).attr("id");
			$(".downld").hide();
			$(".desc").addClass('end');
			$(".hiddform").show();
			$("#back_down").show();
			$("#downl_area").html('Descarga: '+form_id);
		});
		$("#back_down").click(function()
		{
			$(".hiddform").hide();
			$("#back_down").hide();
			$(".desc").removeClass('end');
			$(".downld").show();
			$("#downl_area").html('Descargas');
		});
    });
    
    function tagContact(mapa){
        if(mapa == "mapMad"){
            $("#mapMad").addClass('active');
            $("#mapVal").removeClass('active');
            $("#mapLon").removeClass('active');
			$("#map_val").hide();
			$("#map_lon").hide();
			$("#map_mad").show();
			$("#img_val").hide();
			$("#img_lon").hide();
			$("#img_mad").show();
            //initialize_map(40.487565,-3.688468);
           }
          else if(mapa == "mapVal"){
            $("#mapVal").addClass('active');
			$("#mapMad").removeClass('active');
			$("#mapLon").removeClass('active');
			$("#map_mad").hide();
			$("#map_lon").hide();
			$("#map_val").show();
			$("#img_mad").hide();
			$("#img_lon").hide();
			$("#img_val").show();
            //initialize_map(39.480999, -0.362847);
          }
          else if(mapa == "mapLon"){
            $("#mapLon").addClass('active');
            $("#mapVal").removeClass('active');
            $("#mapMad").removeClass('active');
			$("#map_mad").hide();
			$("#map_lon").show();
			$("#map_val").hide();
			$("#img_mad").hide();
			$("#img_lon").show();
			$("#img_val").hide();
            //initialize_map(51.515227, -0.134852);           
          }  
    }
    
    function tagWeDo(weDo){
        if(weDo == "linea"){
             $("#linea").addClass('active');
            $("#sect").removeClass('active');
            $("#linea-negocio").show();
            $("#sectores").hide(); 
        }else if(weDo == "sect"){
            $("#sect").addClass('active');
            $("#linea").removeClass('active');
            $("#linea-negocio").hide();
            $("#sectores").show();
        }
    }
    
    function SelectAll(id)
    {
        id.focus();
        id.select();
    }
    
    function Abrir_ventana (pagina, height) {
			var opciones="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=460,height="+height+",top=0,left=0";
			window.open(pagina,"",opciones);
		}
    
	function showSectionInclusite(sect){
        $('#contenido_'+sect).slideToggle('slow');
        $('#contenido_'+sect).css('height','');       
        if($('#link_'+sect).html() == 'Reducir'){
            $('#link_'+sect).html('Leer más');
            $("#lupa_blog_"+sect).attr("src","images/lupa.gif");
        }else{
            if(opened != sect){
                $('#contenido_'+opened).slideUp('slow');
                $('#contenido_'+opened).css('height','1px'); 
                $('#link_'+opened).html('Leer más');
                $("#lupa_blog_"+opened).attr("src","images/lupa.gif");
                opened = sect;
            }
            $('#link_'+sect).html('Reducir');
            $("#lupa_blog_"+sect).attr("src","images/lupa_min.gif");
        }
    }
	
    function showSection(sect){
        $('#contenido_'+sect).slideToggle('slow');
        if($('#link_'+sect).html() == 'Reducir'){
            $('#link_'+sect).html('Leer más');
            $("#lupa_blog_"+sect).attr("src","images/lupa.gif");
        }else{
            if(opened != sect){
                $('#contenido_'+opened).slideUp('slow');
                $('#link_'+opened).html('Leer más');
                $("#lupa_blog_"+opened).attr("src","images/lupa.gif");
                opened = sect;
            }
            $('#link_'+sect).html('Reducir');
            $("#lupa_blog_"+sect).attr("src","images/lupa_min.gif");
        }
    }
    
    function rate(mod, art){
        $.post("actions/rating_insert.aspx", { mod: mod, id: art}, 
            function(data){
                $.cookie('CSD_'+art, mod ,{path: '/', expires: 30});
                alert("Su voto ha sido contabilizado de forma correcta, muchas gracias.");
                location.reload(true);
            });
    }    
    function showLogin(){
        parent.scrollTo(0,0);
        $('#login').slideToggle('slow');
    }
    function showLogin2(){
		if(openfooter)
		{
			$('#client_area').animate(
			{
				height: '1px'
			}, 1000, function()
			{
				$('#client_area').css('display', 'none');
				$('#footer').animate(
				{
					height: '100px'
				}, 800, function()
				{
					openfooter = false;
					$('.tit').hide();
				})
			});		
		}
		else
		{
			$('#footer').animate(
			{
				height: '250px'
			}, 800, function()
			{
				$('#client_area').animate(
				{
					height: '160px'
				}, 1000, function()
				{
					openfooter = true;
					$('.tit').fadeIn('slow');
				});	
				$.scrollTo( '#login2', 1000, {easing:'linear'} );
			});			
		}
    }
