﻿/*** START Full Screen Alignment ***/
function FullScreenSmoothShow()
{
	$(function () {
	var $pxs_container = $('.pxs_container');	
	$pxs_container.fadeIn(1000,function(){
			//
		});
	});  	
}

function FullScreenBackground(theItem) {
	var winWidth=$(window).width();
	var winHeight=$(window).height();
	var imageWidth=$(theItem).width();
	var imageHeight=$(theItem).height();
	var picHeight = imageHeight / imageWidth;
	var picWidth = imageWidth / imageHeight;

	if ((winHeight / winWidth) < picHeight) {
		$(theItem).css("width",winWidth);
		$(theItem).css("height",picHeight*winWidth);
	} else {
		$(theItem).css("height",winHeight);
		$(theItem).css("width",picWidth*winHeight - 51);
	};

	$(theItem).css("margin-left",winWidth / 2 - $(theItem).width() / 2);
	$(theItem).css("margin-top",winHeight / 2 - $(theItem).height() / 2);	
		
	FullScreenSmoothShow();
};

function FullScreenBackgroundOnLoad() {    
	/*** Indica a la imagen del fondo que se comportara como Slide ***/
	$('.compania .pxs_containerSWBackground img').addClass('slide');
	$('.compania .pxs_container img').addClass('slide');
	$('.diversidad .pxs_container img').addClass('slide');
	$('.servicios .pxs_container img').addClass('slide');
	$('.trabajar-int .pxs_container img').addClass('slide');
	FullScreenBackground('.slide');	
}

_spBodyOnLoadFunctionNames.push("FullScreenBackgroundOnLoad");

$(window).load(function(){
	
	FullScreenBackground('.slide');
})

$(window).resize(function () {
    FullScreenBackground('.slide');

	$('.destacado').vAlign();
});

/*** END Full Screen Alignment ***/


(function ($) {
    /*** VERTICALLY ALIGN FUNCTION **/
    $.fn.vAlign = function () {
        return this.each(function (i) {
            var ah = $(this).height();
            var ph = $(window).height();
            var mh = (ph - ah) / 2;

            if (mh > 100) {
                $(this).css('padding-top', mh);
            } else {
                $(this).css('padding-top', 120); //130
            }

        });
    };

    $.fn.vAlignHoy = function () {
        return this.each(function (i) {
            var ah = $(this).height();
            var ph = $(window).height();
            var mh = Math.ceil((ph - ah) / 2);

            $(this).css('padding-top', mh - 114); // 114 = header height // 7-6 cambie valores
            $(this).css('padding-bottom', mh - 50); // // 50 = footer height //7-6 cambie valores
        });
    };
})(jQuery);


// BEGIN DOM READY
$(document).ready(function () {

    /*** Manejador de los fancybox ***/
    $("a.fancybox").fancybox({
        overlayColor: '#0063be',
        overlayOpacity: 0.8,
        overlayMargin: 10,
        margin: 0,
        padding: 0

    });


  
    $("a.fancybox1").fancybox({
        overlayColor: 'none',
        margin: 0,
        padding: 0,
        width: 996,
        height: 446,
        closeOut: false,
        autoDimensions: false,
        onComplete: function () {
            $('#fancybox-content #pane1').jScrollPane();
        },
        onClosed: function () {
            $("#link1").parent().css({ 'overflow': 'hidden' });
        }
    });

    $("a.fancybox2").fancybox({
        overlayColor: 'none',
        margin: 0,
        padding: 0,
        width: 996,
        height: 446,
        closeOut: false,
        autoDimensions: false,
        onComplete: function () {
            $('#fancybox-content #pane2').jScrollPane();
        },
        onClosed: function () {
            $("#link2").parent().css({ 'overflow': 'hidden' });
        }
    });

    $("a.fancybox3").fancybox({
        overlayColor: 'none',
        margin: 0,
        padding: 0,
        width: 996,
        height: 446,
        closeOut: false,
        autoDimensions: false,
        onComplete: function () {
            $('#fancybox-content #pane3').jScrollPane();
        },
        onClosed: function () {
            $("#link3").parent().css({ 'overflow': 'hidden' });
        }
    });
   
    $("a.fancybox4").fancybox({
        overlayColor: 'none',
        margin: 0,
        padding: 0,
        width: 996,
        height: 446,
        closeOut: false,
        autoDimensions: false,
        onComplete: function () {
            $('#fancybox-content #pane4').jScrollPane();
        },
        onClosed: function () {
            $("#link4").parent().css({ 'overflow': 'hidden' });
        }
    });	
    /*** Manejador de los fancybox ***/

 

    $('#box-search').hide();

    $('#slick-toggle').click(function () {
        $('#box-search').fadeToggle(500, "linear"); /*slick-toggle-station*/
        $('#box-search-station').hide();
        $('#box-info').hide();
        return false;
    });

    $('#box-search-station').hide();

    $('#box-info').hide();

    $('#slick-show').click(function () {
        $('#box-info').toggle('fast');
        $('#box-search').hide();
        $('#box-search-station').hide();
        return false;
    });

    $('#slick-hide').click(function () {
        $('#box-info').hide('fast');
        return false;
    });


    $('.tab a ').click(function () {
        $('.box-information').css("zIndex", "1000");

        $('.box-information').css("position", "relative");

        if ($(this).parent().hasClass('tab2')) {
            $('.subnav').slideUp();
            $('.run').animate({ "marginLeft": "0px" }, 'slow');
            $('.tab').removeClass('tab2');
        }
        else {
            $('.run').animate({ "marginLeft": "-803px" }, 'slow', function () {
                $('.content-secondary').css('zIndex', '80');
            });
            $('.tab').addClass('tab2');
        }
        $('.menu').removeClass('select');
    });

    /*ACCENTURE*/
    //El despliege del menu de navegacion se maneja directamente desde el control que lo soporta. MenuUc.ASCX
    /*ACCENTURE*/

    /*** Manejador del selector de Idioma ***/
    $('.idioma-list').hide();
    $('#country').click(function () {
        $('.idioma-list').slideToggle(100, "linear");
        if ($(this).hasClass('over')) {
            $(this).removeClass('over');

        } else {
            $(this).addClass('over');
        }
        return false;
    });

    $('.idioma-list .subnav-idioma').hide();

    $('.idioma-list a.arg').click(function () {
        $(this).parent().find('.subnav-idioma').slideToggle(500, "swing"); //swing
        if ($(this).hasClass('selected-idioma')) {
            $(this).removeClass();
        } else {
            $(this).addClass('selected-idioma');
        }
    });
    /******/

    /*** Selector para form customizar ***/
    $('.advanced').jqTransform({ imgPath: '/JQuery/' });

    $('.resultados-search').jqTransform({ imgPath: '/JQuery/' });
    /******/

    /*** Buscador General Lupa ***/
    $('input:text').addClass("idleField");

    $('#box-search input:text').focusin(function () {
        $(this).removeClass("idleField").addClass("focusField");
        $('.go.header').css({ 'display': 'block' })
        $('.lupa.header').css({ 'display': 'none' })
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    
    $('#box-search input:text').blur(function () {
        if ($(this).val() == '') {
            $('.lupa.header').css({ 'display': 'block' })
            $('.go.header').css({ 'display': 'none' })
            $(this).removeClass("focusField").addClass("idleField");
            if ($.trim(this.value) == '') {
                this.value = (this.defaultValue ? this.defaultValue : '');
            }
        }
    });
    /******/

    /*** Alineacion vertical ***/
    $('.destacado').vAlign();
    /******/

    /*** Manejador del Menu lateral de as paginas de contenido ***/
    $('div.accordionButton').click(function () {
        if ($('div.accordionButton').find('.selected')) {
            $('#wrapper').find('.selected').removeClass('selected')
        }
        if ($(this).next().is(':visible')) {
            $(this).removeClass('selected');
            $('div.accordionContent').slideUp('normal');
        } else {
            $('div.accordionContent').slideUp('normal');
            $(this).next().slideDown('normal');
            $(this).addClass('selected')
        }
    });

    $("div.accordionContent").hide();
    
    $('div.accordionButton').mouseover(function () {
        $(this).addClass('over');
    }).mouseout(function () {
        $(this).removeClass('over');
    });

    //// sidebar prensa items ocultos ////
    $('#search-content-prensa').hide();
    $('.multimedia-items').hide();
    $('.prensa-items').hide();
    //// sidebar prensa items ocultos ////

    $('.overflownav, ul.menu').bind('mouseover', function () {
        $('.overflownav').css('height', '300px');
    });

    //Esto tiene que ir para que el area overflow despues no tape todo en una resolucion menor
    $('.overflownav, ul.menu').bind('mouseleave', function () {
        $('.overflownav').css('height', '110px');
    });
    //Esto tiene que ir para que el area overflow despues no tape todo en una resolucion menor	 

    //implementacion de tooltip levantando el atributo title de los elementos con clase .tooltip 27-10-2011
    if ($('.tooltip').length > 0) {
        $('.tooltip').tipTip();
    }
}); 
//END READY

