/*
 * js para generalidades de VIVE ICA . Hecho por: karmi / 8 de abril del 2011
 */

var irASeccion = function(idSeccion)
{
    $('a#linkBottomMenu'+idSeccion).click();
}

$(document).ready(function(){
	$("#arrowLeft").css("display","none");
    $("#hiddenSliderImages").val(0);
    $("#hiddenFlagMenu").val(0);
    $("#hiddenSliderImagesReturn").val(3);
    $('#linkTopMenu1').bind({
        click: function() {
            alert("Llevar a Aviso Legal");
        },
        mouseover: function() {
            $('#imgTopMenu1').attr("src","recursos/img/imgUpLegal.png");
        },
        mouseout: function(){
             $('#imgTopMenu1').attr("src","recursos/img/imgDownLegal.png");
        }
 
    });


    $('#linkTopMenu2').bind({
        click: function() {
            alert("Llevar a Copyright");
        },
        mouseover: function() {
            $('#imgTopMenu2').attr("src","recursos/img/imgUpCopy.png");
        },
        mouseout: function(){

       $('#imgTopMenu2').attr("src","recursos/img/imgDownCopy.png");


        }

    });

    $('#linkTopMenu3').bind({
        click: function() {
            alert("Llevar a Contacto");
        },
        mouseover: function() {
            $('#imgTopMenu3').attr("src","recursos/img/imgUpContact.png");
        },
        mouseout: function(){
            $('#imgTopMenu3').attr("src","recursos/img/imgDownContact.png");

        }

    });

    $('#linkTopMenu4').bind({
        click: function() {
            alert("Llevar a Bolsa de Trabajo");
        },
        mouseover: function() {
            $('#imgTopMenu4').attr("src","recursos/img/imgUpBolsa.png");
        },
        mouseout: function(){
         $('#imgTopMenu4').attr("src","recursos/img/imgDownBolsa.png");

        }

    });

    ///MENU INFERIOR

    //////////////////////////////////// ACCIONES DEL HOME ////////////////////////////////

    //LINK A
    $("#divA").live({
		
		
		
		click: function(){
           // $("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(2);
            $("#hiddenFlag").val(3);
            $("#divArrowRight").css('display','block');
            $("#divArrowLeft").css('display','block');
           // $("#sliderOver").fadeOut(1000);


        }

      


    })

  


    //LINK B
    $("#divB").live({

        click: function(){
            //$("#sliderOver").css( 'height','145px');
            $("div#divContainerCenter input#hiddenLink1").attr("value","80");
            $("div#divWrapper input#flagState").attr("value","79");
            $("#hiddenFlagMenu").val(1);
            $("#hiddenFlag").val(2);
            $("#divArrowRight").css('display','block');
            $("#divArrowLeft").css('display','block');
            //$("#sliderOver").fadeIn(1000);


        }


    })

    



    //LINK C
    $("#divC").live({

       click: function(){
            //$("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(3);
            $("#hiddenFlag").val(4);
            $("#divArrowRight").css('display','none');
            $("#divArrowLeft").css('display','block');
            //$("#sliderOver").fadeOut(1000);


        }


    })

    


 //LINK D
    $("#divD").live({

       click: function(){
            url="index.php?id=92";
            window.location = url; 
        }


    })



 //LINK E
    $("#divE").live({

       click: function(){
            url="index.php?id=98";
            window.location = url; 
        }


    })

    

    // TERMINA MENU DEL HOME
    $('#linkBottomMenu1').live({




        click: function() {
           // $("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(0);
            $("#hiddenFlag").val(1);
            $("#divArrowLeft").css('display','none');
            $("#divArrowRight").css('display','block');
            //$("#sliderOver").fadeOut(1000);
            $(".botonFooterActions").removeClass('active');
            $(this).parent().addClass('active');
            
        }


    });

    $('#linkBottomMenu2').live({

        click: function() {
           // $("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(1);
            $("#hiddenFlag").val(2);
            $("#divArrowRight").css('display','block');
            $("#divArrowLeft").css('display','block');
            $("#divDittos ul li:first a").click();
           // $("#sliderOver").fadeIn(1000);
            $(".botonFooterActions").removeClass('active');
            $(this).parent().addClass('active');

        }

    });


    $('#linkBottomMenu3').live({

        click: function() {
           // $("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(2);
            $("#hiddenFlag").val(3);
            $("#divArrowRight").css('display','block');
            $("#divArrowLeft").css('display','block');
           // $("#sliderOver").fadeOut(1000);
            $(".botonFooterActions").removeClass('active');
            $(this).parent().addClass('active');
        }

    });

    $('#linkBottomMenu4').live({

        click: function() {
            //$("#sliderOver").css( 'height','145px');
            $("#hiddenFlagMenu").val(3);
            $("#hiddenFlag").val(4);
            $("#divArrowRight").css('display','none');
            $("#divArrowLeft").css('display','block');
           // $("#sliderOver").fadeOut(1000);
            $(".botonFooterActions").removeClass('active');
            $(this).parent().addClass('active');
        }

    });

    $('#linkBottomMenu5').live({

        click: function(e) {
          e.preventDefault();
        	url="index.php?id=13";
        	window.location = url;   
      }

    });


    $('.bottomMenuLinks').live({
        click: function(e){
                    
            var currentFlag= $("#hiddenFlagMenu").val();
           
            firstLayer=(-12*currentFlag);
            var firstLayerLabel=firstLayer+"%";
            secondLayer=(-65*currentFlag);
            var secondLayerLabel=secondLayer+"%";
            thirdLayer=(-65*currentFlag);
            var thirdLayerLabel=thirdLayer+"%";
            fourthLayer=(-1092+(currentFlag*-1453));
            var fourthLayerLabel=fourthLayer+"px";
            boxesContainer=(-100*currentFlag);
            var boxesContainerLabel=boxesContainer+"%";

            e.preventDefault();
            $("#divBackFirst").animate({
                'margin-left': firstLayerLabel
            },2100);

            $("#divBackSecond").animate({
                'margin-left': secondLayerLabel
            },2200);
            $("#divBackThird").animate({
                'margin-left': thirdLayerLabel
            },2200);

            $("#divBackFourth").animate({
                'margin-left': fourthLayerLabel
            },2000);
            $("#divBoxesContainer").animate({
                'margin-left': boxesContainerLabel
            },2000);

        }
        

    });
    //SLIDER PEQUEÑO (DESARROLLOS POR ESTADO)

    $("#arrowRight").live({

        click: function(e){
            $("#arrowLeft").css("display","block");
            var countClicks= $("#hiddenSliderImages").val();
            countClicks=parseInt(countClicks)+1;
            $("#hiddenSliderImages").val(countClicks);

            var countClicksBacking= $("#hiddenSliderImagesReturn").val();
            countClicksBacking=parseInt(countClicksBacking)-1;
            $("#hiddenSliderImagesReturn").val(countClicksBacking);
          
            var newMargin=(-509)+((-128)*countClicks);
            if(newMargin==(-893)){
                $("#arrowRight").css("display","none");

            }
            $("#divImages").animate({
                'margin-left': newMargin
            },1200);


        }

    })

    $("#arrowLeft").live({

        click: function(e){
            $("#arrowRight").css("display","block");
            var countClicks=$("#hiddenSliderImagesReturn").val();
            
            countClicks=parseInt(countClicks)+1;
           
            $("#hiddenSliderImagesReturn").val(countClicks);

         
            var countClicksGoing= $("#hiddenSliderImages").val();
            countClicksGoing=parseInt(countClicksGoing)-1;
            $("#hiddenSliderImages").val(countClicksGoing);

       

            var newMargin=(-893)+((128)*countClicks);
            if(newMargin==(-509)){
                $("#arrowLeft").css("display","none");

            }
            $("#divImages").animate({
                'margin-left': newMargin
            },1200);


        }

    })


   /* $("#sliderOver").live({

        mouseover: function(){
            $("#popUpMenu2").attr("id","popUpMenu2");


        }

    })
*/
    $("#linkPopUpA").live({

	 click:function(e){

            e.preventDefault();
            url="index.php?id=92";
            window.location = url;    

    }

     });

	

 /*   $("#linkPopUpB").live({

    mouseout: function(){
	$(this).attr("id","linkPopUpA");
	},
   
 
   })*/
   
   $("#divCRight").live({
   		click:function(e){
   			e.preventDefault();
        url="index.php?id=16";
        window.location = url;   
   		}
   	}
   );
   
   $("#divARight").live({
   		click:function(e){
   			e.preventDefault();
        url="index.php?id=93";
        window.location = url;   
   		}
   	}
   );

})



