window.lastUrl = '';

/* funcion que */
function launchGallery() {

    $("#slideshow").slideshow({
        pauseSeconds: 7,
        height: 300,
        width: 742,
        caption: true
    });

    $("#slideshow img").show();

    var target = $("#slideshow");
    var j = 0;
    var text = '';
    var newContent = '';
    $("#slideshow ol").children("li").each(function() {
        text = $(this).text();
        newContent = "<a href='" + $("#" + $(target).attr("id") + " img:nth(" + j+++")").attr("longdesc") + "'>" + text + "</a>";
        $(this).text('');
        $(this).append(newContent);
    });
    $("#slideshow ul li").children("a").each(function() {
        $(this).attr('href', 'javascript:;');
    });
}

/* Esta funcion crea el componente que permite alternar los enlaces legales*/
function launchLegalLinksSlideshow() {
    $('#s2').cycle({
        fx: 'fade',
        timeout: 3000,
        pause: 1,
        pager: '#s2nav',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"></a>';
        },
        next:   '#next2',
        prev:   '#prev2'
    });


}

function setupNavigationMenu() {

   
    $("ul.css-tabs").tabs("div.css-panes > div", {

        // enable the history feature
        history: false ,

        // just before tabs are clicked, we load the contents
        
        onBeforeClick: function(ev,tabIndex) {
           
            i = tabIndex;
            // get the pane to be opened
            var pane = this.getPanes().eq(i);
            // load contents only the first time it's opened
            //			alert(i);
            if (true) {
                // transform anchor links to page URL's
                if (i > 0 && i != 12) {
                    // var url = this.getTabs().eq(i).attr("href").substring(1) + ".php";
                    var url = this.getTabs().eq(i).attr("href");
                    // load the page (ajax1.html)
                    // if(url != //window.lastUrl){
                    
                    try {
                        showMenuThrobber(tabIndex);
                        pane.load(url,function() {
                            _gaq.push(['_trackPageview', url]);                            
                            loadTabResponse(tabIndex);
                        });
                    } catch(e) {
                        alert(e);
                    }
                    
                //window.lastUrl= url;
                }

            }
            if (i != 12) {

                hideAccessForms();
                $("#serviceTabsContainer").removeClass("allBackGroundColor");
                $("#serviceTabsContainer > div").removeClass("littleTabServiceActive");

            }

            if (i == 12) {
        // $("ul.css-tabs li a").removeClass("current");
        // return false;
        }
            
        },

        onClick: function(ev,i) {
            
            if (i == 0) {
                $("#leftCol").height($("#main-content").height() + 30);
            }
        }
        
    });
}

function showMenuThrobber(tabIndex){
    $($("ul.css-tabs li a")[tabIndex]).append("<img class='menuThrobber' src='/imagenes/spinner.gif'/>");
}

function removeMainMenuClass(service, divId) {
    if (service) {
        hideAccessForms();
    }   
    $('#dummyTab').click();
    $('#dummyPane').hide();
    $("#" + divId + "_content").show();
}

function loadTabResponse(tabIndex) {
    $("ul.css-tabs li a img.menuThrobber").remove();
    i = tabIndex;
    /*
		i = Indice de la Pesta?�a de menu principal seleccionada.
     */
    if ($("#accordion" + i)) {

        var api = $("#accordion" + i).tabs("#accordion" + i + " div.pane", {
            history: false,
            tabs: 'h2',
            effect: 'fade',
            initialIndex: 0,
            api : true
        });

        $('#accordion' + i + ' > h2 ').bind('click', function(e) {
            loadAccordionSection(tabIndex, this, api);
        });

        setSecondNavigationHistory('#accordion' + i + ' h2 a');
        $('#accordion' + i + '  h2:first a').click();
    }
}

function loadAccordionSection(tabIndex, actualAccordion,api) {

    i = tabIndex;
    $('#accordion' + i + ' > h2').addClass("accordionTab").removeClass("current");

    $('#accordion' + i + ' > h2:last').addClass("ultimate");
    $(actualAccordion).addClass("current");

    //var totalIndice = $('#accordion' + i + ' > h2').length;

    /* Indice del Accordeon Seleccionado en el menu secundario*/
    var indice = $('#accordion' + i + ' > h2').index(actualAccordion);

    /* se le quita el margen derecho al h2 del acordeon que se le dio click */
    $($('#accordion' + i + ' > h2').get(indice)).addClass("current");
    //$('#accordion'+i+' > h2').get(indice).style.marginRight= '';
    var pane = api.getPanes().eq(indice);

    var url = $(actualAccordion).children("a:first").attr('href');
    //alert("solicitando " + url);
    if( !(url == "#"  || url == "javascript:;") ){

        $(pane).load(url, {
            nombre: url,
            hf: 1
        },
        function(responseText, textStatus, XMLHttpRequest) {
            _gaq.push(['_trackPageview', url]);
            accordionPaneContent = pane;
            handleAccordionSectionSuccess(url,responseText, textStatus, XMLHttpRequest,actualAccordion,tabIndex, accordionPaneContent,  indice, pane);

        });
    }
}

function handleAccordionSectionSuccess(url,responseText, textStatus, XMLHttpRequest,actualAccordion,tabIndex, accordionPaneContent, indice, pane){

    if(tabIndex == 3 || tabIndex == 4 || tabIndex == 5 || tabIndex == 10 ||tabIndex == 6 ||tabIndex == 1){
        guideServiceTabs(tabIndex, indice, false);
    }

    if(tabIndex == 2 && indice == 0 ){
        setFacultyCorners();
    }

    if(tabIndex == 8 && indice == 0){
        initDependencyPager();
    }
    if((tabIndex== 2 && (indice == 1 || indice == 2) ) || (tabIndex== 7 && (indice == 1 || indice ==2) ) ){
        initGenericListPager();
    }
    if(tabIndex == 9){

        if(indice == 1){
            initSimpleAcordionSection();
            $("div.pane:visible h4").corner("3px");
        }
        if(indice == 2){
            $("#contratosRealizadosWrapper").tabs("#contratosRealizadosWrapper > ul",{
                initialIndex: "null",
                tabs: 'h4',
                onClick: function(ev,wichTab){
                    setLayoutHeight();
                }
            });
            $("div.pane:visible h4").corner("3px");
        }

    }
    if(tabIndex == 2){

        if(indice == 4){
            $("#monitoriasPasantiasWrapper").tabs("#monitoriasPasantiasWrapper .innerpane",{
                initialIndex: "null",
                tabs: 'h4',
                onClick: function(){
                    setLayoutHeight();
                }
            });
            $("div.pane:visible h4").corner("3px");
            $("#monitoriasPasantiasWrapper ul li").corner("7px");

        }
    }
    if(tabIndex == 10 && indice == 2){
        if($("div.pane:visible div").hasClass("secundaryContent")){
            clearHtml();
        }
    }
    
    if(tabIndex == 11){
        $(".helpBoxes .block").corner("7px");        
    }    
    if(tabIndex == 203){
        publiSelect(indice);
    }

    if(tabIndex == 8 && indice ==1){
        var jqzoom_options_organigrama = {
            zoomType: 'drag',
            lens:true,
            preloadImages: true,
            alwaysOn:true,
            zoomWidth: 320,
            zoomHeight: 420,
            xOffset:90,
            yOffset:30,
            position: 'left',
            map: 'true',
            mapName: '#Organigrama'
        //...MORE OPTIONS
        };

        $('.jqzoom_org').jqzoom(jqzoom_options_organigrama);
    }

    setLayoutHeight();
}

function clearHtml(){
    var cleared = $("div.pane:visible .secundaryContent").html();
    $("div.pane:visible .secundaryContent").before(cleared);
    $("div.pane:visible .secundaryContent").remove();
}

function initSimpleAcordionSection(){
    $("#ciudadelaPorvenirWrapper").tabs("#ciudadelaPorvenirWrapper .contenido",{
        tabs: 'h4',
        onClick: function(wichTab){
            setLayoutHeight();
        }
    });
}

function initGenericListPager(){
    var howMany = 15;
    for(i=-1;i<=($("div.InternContent:visible ul.borderBacgroundGray li").length)+1/howMany;i++){
        $("div.InternContent:visible ul.borderBacgroundGray").before($("div.InternContent:visible ul.borderBacgroundGray li:lt("+howMany+")").remove());
        $("div.InternContent:visible > li").wrapAll('<ul class="new listStyleNne listPagerBorderBacgroundGray" />');
    }
    $("div.InternContent:visible ul.borderBacgroundGray").remove();
    $("div.InternContent:visible").pager("ul",{
        navId : 'pagerControl',
        navAttach: 'prepend'
    });
    $("#pagerControl.nav a").corner("3px ");
    setLayoutHeight();

}

function initDependencyPager(){
    $("#adminDependencyList").pager("ul",{
        navId : 'pagerControl',
        navAttach: 'prepend'
    });
    $("#pagerControl.nav a").corner("3px");
    $('#adminDependencyList #pagerControl').after('<div id="pagerContact"></div>');
    initDependencyGetContact();
    $("#adminDependencyList ul.borderBacgroundGray:visible li a:first").click();
    $("#adminDependencyList ul.borderBacgroundGray").append("<li class='clearfloat'></li>")
    setLayoutHeight();

}

function initDependencyGetContact(){
    $("#adminDependencyList ul.borderBacgroundGray li a").bind("click", function(e){
        var tittle = $(this).html();
        $(this).append("<img class='menuThrobber' src='/imagenes/spinner.gif'/>")
        e.preventDefault();
        var href = $(this).attr("href");
        var id = href.replace(/[^0-9]+/, "");
        $("#pagerContact").load("/getContentTipica.php?m=contactInformation&id="+id, function(){
            $("#adminDependencyList ul.borderBacgroundGray li a img.menuThrobber").remove();
            $("#pagerContact .image, #pagerContact hr").remove();
            $("#pagerContact .contactExtra").append('<span class="contactCenter verMasLink"><a class="webPage boxArrow" href="'+ href +'">M&aacute;s Informaci&oacute;n</a></span>');
            $("#pagerContact").prepend("<h5>"+tittle+"</h5>");
            setLayoutHeight();
        });

        $("#adminDependencyList ul.borderBacgroundGray li a").removeClass("current");
        $(this).addClass("current");
    });

    $("#adminDependencyList #pagerControl a").bind("click", function(){
        $("#adminDependencyList ul.borderBacgroundGray:visible li a:first").click();
    });
}

function setLayoutHeight(){
    setTimeout("setLayoutHeight_();",200);
}

function setLayoutHeight_(){
    var lc = $("#leftCol").children(":not(area, base, basefont, head, meta, script, style, title, noembed, param )");
    var minHeight = 0;
    for(i=0;i<lc.length;i++){
        minHeight+=$(lc[i]).outerHeight(true);
    }
    var e = $("div.pane:visible").children(":not(area, base, basefont, head, meta, script, style, title, noembed, param, br.clearfloat )");
    var h=0;
    for(i=0;i<e.length;i++){
        h+=$(e[i]).outerHeight(true);        
    }   
    h = (h<minHeight) ? minHeight: h;
    $("div.pane:visible").height(h);
    $("#leftCol").height($("#rightCol").outerHeight(true));    
}

function loadProjectListing(url,responseText, textStatus, XMLHttpRequest,actualAccordion,tabIndex, accordionPaneContent){

}

function getLayoutHeight(fromMenu, params) {

    //contentMinHeight = 527;
    contentMinHeight = 437;

    switch (fromMenu) {
        case 0:

            paneHeight = params[0];
            if(paneHeight > contentMinHeight){
                LeftColHeight = paneHeight + 90;
                AccordionNewHeight = paneHeight;
            }else{
                LeftColHeight = contentMinHeight+90;
                AccordionNewHeight = contentMinHeight;
            }

            return [AccordionNewHeight, LeftColHeight];
            break;
        case 1:
            paneHeight = params[0];

            if(paneHeight > contentMinHeight+60){
                LeftColHeight = paneHeight + 30;
                ContainerNewHeight = paneHeight;
            }else{
                LeftColHeight = contentMinHeight+90;
                ContainerNewHeight = contentMinHeight+60;
            }

            return [ContainerNewHeight, LeftColHeight];

            break;
        case 2:

            paneHeight = params[0];

            if(paneHeight > contentMinHeight+60){
                LeftColHeight = paneHeight + 30;
                ContainerNewHeight = paneHeight;
            }else{
                LeftColHeight = contentMinHeight+186;
                ContainerNewHeight = contentMinHeight+156;
            }

            return [ContainerNewHeight, LeftColHeight];
            break;
        case 3:
            paneHeight = params[0];
            paneHeight = paneHeight  + 50;

            if(paneHeight > contentMinHeight+60){
                LeftColHeight = paneHeight + 90;
                ContainerNewHeight = paneHeight;
            }else{
                LeftColHeight = contentMinHeight + 90;
                ContainerNewHeight = contentMinHeight;
            }

            return [ContainerNewHeight, LeftColHeight];
            break;
    }

    return null;

}

//funcion para el cambio de los nombres de los formularios
function cambiarNombres() {

    var domain = document.getElementById('dominio-correo').value;

    if (domain == "@correo.udistrital.edu.co") {
        document.getElementById("mailAccessLink_username").name = "Email";
        document.getElementById("login-mail").action = "http://mail.google.com/a/correo.udistrital.edu.co/";
        document.getElementById("passwd").disabled = true;
        $("#passwd,#passwd_label").hide();


    } else if(domain == "@egresado.udistrital.edu.co"){
        $("#passwd,#passwd_label").show();
        document.getElementById("mailAccessLink_username").name = "login_username";
        document.getElementById("login-mail").action = "http://egresado.udistrital.edu.co/webmail/src/redirect.php";
        document.getElementById("passwd").disabled = false;
    } else {
        $("#passwd,#passwd_label").show();
        document.getElementById("mailAccessLink_username").name = "login_username";
        document.getElementById("login-mail").action = "http://mail.udistrital.edu.co/webmail/src/redirect.php";
        document.getElementById("passwd").disabled = false;
    }

}

//funcion para realizar el submit del formulario
function cambiarActionUrl() {
    var domain = document.getElementById('dominio-correo').value;
    var username = document.getElementById("mailAccessLink_username").value;
    if(domain == "false"){
        alert("Seleccione el dominio al que pertenece su Cuenta de Corrreo. El usuario no debe incluir @ ni el dominio.");
        return false;
    }

    if (domain != "@correo.udistrital.edu.co") {
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(!(username.match(emailExp))){
            document.getElementById("mailAccessLink_username").value = document.getElementById("mailAccessLink_username").value + domain;
        }
    }
    document.getElementById("login-mail").submit();

}

function cleanDefaultFieldValue(fieldObj) {
    if (fieldObj.defaultValue && typeof(fieldObj.defaultValue) == "undefined")
        fieldObj.defaultValue = fieldObj.value;
    ///////////////////////////////////////////////////
    if (fieldObj.value == fieldObj.defaultValue)
        fieldObj.value = "";
}

function restoreFieldValue(fieldObj) {
    if (fieldObj.value == "") {
        fieldObj.value = fieldObj.defaultValue;
    }
}

function hideAccessForms() {
    $("#formularios_registro").hide();
    $("#accessIcons div a.iconAnchor").removeClass("accessIconActive");
    $("#accessIcons div a.iconAnchor").removeClass("allBackGroundColor");
}

function pager() {
    $('#accordion' + i + ' > h2 a').remove();
    var scrollableDiv = urlOld.replace(/ /g, '_');
    // alert($("#"+scrollableDiv).height() +"  "+ $("#"+scrollableDiv)[0].scrollHeight);
    if ($("#" + scrollableDiv).height() < $("#" + scrollableDiv)[0].scrollHeight || indice == 0) {

        var scrollNextId = scrollableDiv + '_scrollerNext';
        var scrollPrevId = scrollableDiv + '_scrollerPrev';
        var scrollNextLink = "<a href='javascript:;' id='" + scrollNextId + "' class='paginador'>&gt;&gt;<!--Next--></a>";
        var scrollPrevLink = "<a href='javascript:;' id='" + scrollPrevId + "' class='paginador'>&lt;&lt;<!--Prev--></a>";
        var scrollEvent = "<script>$('#" + scrollNextId + "').click(function(){$('#" + scrollableDiv + "').scrollTo( '+=" + 2 * AccordionNewHeight + "');});$('#" + scrollPrevId + "').click(function(){$('#" + scrollableDiv + "').scrollTo( '-=" + 2 * AccordionNewHeight + "');});<\/script>";
        var htmlH2 = $('#accordion' + i + ' > h2').get(indice).innerHTML;

        $('#accordion' + i + ' > h2').get(indice).innerHTML = htmlH2 + scrollNextLink + scrollPrevLink;
        $('#' + scrollableDiv).append(scrollEvent);
    }
}


function checkBrowserCompatibility(){
    if (jQuery.browser.msie) {
        if(parseInt(jQuery.browser.version)==0){
            $("<div/>")
            .attr("id","IE6Overlay")
            .css({
                "position" : "absolute",
                "width"	: "100%",
                "height"	: $(window).height(),
                "top"		: "0px",
                "left"		: "0px",
                "z-index"	: "1000",
                "background-color" : "#333",
                "opacity"	: "0.8",
                "color"    : "white",
                "font-size": "42px",
                "font-weight": "bolder",
                "text-align" : "center"
            })
            .append($("<div/>").css({
                "opacity":"1.0",
                "z-index":"2000"
            }).text("Su navegador es demasiado antig�o y en el momento esta versi&oacute;n del portal no podr&aacute; ser accedida por completo. Por favor ingrese usando un navegador m&aacute;s moderno. Tambien podr&aacute; ingresar en los proximos dias cuando se le haya adicionado el soporte a su navegador."))
            .appendTo("body");
        }
    }

    $("<div/>")
    .attr("id","BetaOverlay")
    .css({
        "position" : "absolute",
        "width"	: "100%",
        "height"	: $(document).height(),
        "top"		: "0px",
        "left"		: "0px",
        "z-index"	: "1000",
        "background-color" : "#333",
        "opacity"	: "0.8",
        "color"    : "white",
        "font-size": "42px",
        "font-weight": "bolder",
        "text-align" : "center"
    })
    .append($("<div/>").css({
        "opacity":"1.0",
        "z-index":"2000"
    }).text("Esta es la versi&oacute;n Beta del Nuevo Portal Web Institucional. La informaci&oacute;n que pueda ser accedida a continuaci&oacute;n no corresponde a informaci&oacute;n oficial de la Universidad y solo se muestra para fines de demostraci&oacute;n. El sitio se encuentra en constante desarrollo por lo cual es posible que algunas secciones no se comporten como usted lo esperar&iacute;a y que muestren contenidos a&uacute;n en proceso de construcci&oacute;n. Nos gustaria contar con sus comentarios. Para ello puede escribirnos al correo nuevoportalud@udistrital.edu.co").append("<br/>").append($("<input/>").attr("type","button").attr("value","Entiendo que Ingresar� a un sitio de Demostraci�n y deseo Continuar.").click(function(){
        $("#BetaOverlay").hide();
    })))
    .appendTo("body");

}

function activateServiceTab(actualDiv){
    $("#main-content > div").hide();
    $("#" + actualDiv.id + "_content").show();
    $("#serviceTabsContainer > div").removeClass("littleTabServiceActive");
    $(actualDiv).addClass("littleTabServiceActive");
    $("#serviceTabsContainer").addClass("allBackGroundColor");
}

function setupServiceArea(){

    $("#serviceTabsContainer div a").each(function(item){
        this.href2 = this.href;
    });

    $("#serviceTabsContainer div a").bind("click",
        function(e){
            if($(this).parent().hasClass("littleTabServiceActive")){
                e.preventDefault();
                return;
            }
                  
            var id = this.id;
            var url = this.href2;
            var divId = id.replace("_anchor","_content");
            that = this;
            
            $("#"+divId+" div.lastServiceContent").load(url,{
                nombre: url,
                hf: 1
            },function(){
                _gaq.push(['_trackPageview', url]);
                serviceAreaSetHeight(id);
                if($(that).hasClass("tabLauncher")){
                    guideServiceTabs(20, 1, false);
                }
                if($(that).hasClass("publication")){
                    loadTabResponse(203);                    
                }
                if($(that).hasClass("directoty")){
                    loadDirectoryResult();
                }

            });
            e.preventDefault();
        });
    /*
    $('#serviceTabsContainer').bind('click', function() {
        
    });
*/
    $("#serviceTabsContainer > div").bind("click", function(e) {       
        activateServiceTab(this);
        removeMainMenuClass(true, this.id);
    });

    
}

function loadDirectoryResult(){
    $("#searchForm").bind("submit",function(e){
        e.preventDefault();
        var search = document.getElementById("buscar").value;
        $("#searchResultDirectyory").load("/oldpwi/directorio.php #directoryResult", {
            buscar: search
        },function(){
            setLayoutHeight()
            var numRows = $("#numRowsMake").html();
            $("#numRowsFind").html(numRows);
        });

    });
}

function serviceAreaSetHeight(id){
    setLayoutHeight();
//var serviceAreaHeight = $("#"+id+"_content").height();
/*params = [serviceAreaHeight];
    var layoutHeight = getLayoutHeight(1, params);
    ContainerNewHeight = layoutHeight[0];
    LeftColHeight = layoutHeight[1];
    $("#"+id+"_content").height(ContainerNewHeight);
    $("#leftCol").height(LeftColHeight);*/

}

function setupPwiServices(){
    $("#accessIcons div a").bind(
        "click",function(e){  
            if($(this).hasClass("accessIconActive")){
                e.preventDefault(e);
                return;
            }        
            var url = $(this).attr("href");
            var id = this.id;
            
            $("#"+this.id+"_content div").load(url,
                function(){
                    _gaq.push(['_trackPageview', url]);                    
                    handlePwiService(id);
                    if($.browser.msie && $.browser.version < 8){

                    }else{
                        setCorners();
                    }
                });
            //solucion para corregir el problema de condor en explorer
            /* if($.browser.msie && this.id == "condorAccessLink"){
                    $("#condorAccessLink_form").html("<ul class='css-tabs'><li><h5><a class='inTextLink current' href='http://www.udistrital.edu.co/condor.php'>Ingrese al Sistema C&oacute;ndor</a></h5></li></ul>");
                }*/
            $("#"+this.id+"_username").focus();
            e.preventDefault(e);
        });
}

function handlePwiService(id){
    //var pwiServiceHeight = $("#"+id+"_content").height();
    /*params = [pwiServiceHeight];
    var layoutHeight = getLayoutHeight(2, params);
    ContainerNewHeight = layoutHeight[0];
    LeftColHeight = layoutHeight[1];
    $("#" + id + "_content").height(ContainerNewHeight);
    $("#leftCol").height(LeftColHeight);*/
    setLayoutHeight();

}

function activateAccessFormIcon(actualAnchor){     
    $("#formularios_registro").show();
    $("#accessIcons div a.iconAnchor").removeClass("accessIconActive");
    $("#accessIcons div a.iconAnchor").removeClass("allBackGroundColor");
    $(actualAnchor).addClass("accessIconActive");
    $(actualAnchor).addClass("allBackGroundColor");
    $("#main-content > div").hide();   
    $("#" + actualAnchor.id + "_content").show();      
    $("#formularios_registro > div").hide();
    $("#" + actualAnchor.id + "_form").show();
    $("#serviceTabsContainer").removeClass("allBackGroundColor");
    $("#serviceTabsContainer > div").removeClass("littleTabServiceActive");
    setLayoutHeight();
}

function setupAccessFormsArea(){

    $("#accessIcons div a.iconAnchor").bind("click", function(e) {
        activateAccessFormIcon(this);
        removeMainMenuClass(false, this.id)
    });

    $("#accessIconsWrapper div.iconWrapper").bt({
        positions: 'top',
        left:'100px'
    });

/*
    $('#pwiLinks, #formularios_registro').bind('click', function() {
        //removeMainMenuClass(false);
        $('#formularios_registro div form').removeClass('inactiveForm');
    });
*/
}

function setupLastMinuteLinksSection(){

    $("#lastMinuteLinks a.ajaxAnchor").bind("click", function(e){
        var url = $(this).attr('href');
        var idDivDestino = $(this).attr('rel');       
        $("#" + idDivDestino).load(url,{
            getAbstract: true
        }, function(){
            _gaq.push(['_trackPageview', url]);
        });
        e.preventDefault(e);
       
    // setLayoutHeight();
    });
    $("#lastMinuteLinks li a:first").click();
}

function footerLinksAction(){

    $("#homeFooter a").bind("mouseenter", function(){
        $(this).addClass('footerActive');
    });
    $("#homeFooter a").bind("mouseout", function(){
        $(this).removeClass('footerActive');
    });
}

function setCorners(){
    $("#main-content").corner("tr br 7px");
    $("#leftCol").corner("tl bl 7px");
    $("#header-home").corner("br bl 7px");
    $(".slideshowlite ul li a").corner("3px keep");
    $("div.block").corner("7px");
    $("#streamHomeVideo").corner("7px");
    if($.browser.msie && $.browser.version < 9.0){
      
  }else{
    $("#s2nav a").corner("2px");
  }
}

function setCornersBackGroundGray(){
    $(".borderBacgroundGray").corner("7px");
}

function setFacultyCorners(){
    $("h3.facultadesTitulo").corner("tr tl 7px");
    $("div.facultadesColabsable").corner("br bl 7px keep");
}

function searchFormActions(){
    $("#buscarFormDiv form #q").bind("click", function(){

        $("#buscarFormDiv form #q").addClass("searching");
    });

    $("#buscarFormDiv form #q").bind("blur", function(){
        $("#buscarFormDiv form #q").removeClass("searching");
    });
}

function setMainNavigationHistory(){
    setHistory("ul.css-tabs li a , .iconWrapper a , .serviceTabPadding  a");
}

function setSecondNavigationHistory(selector){
//setHistory(selector);
}

function setHistory(selector){
    $(selector).history(
        function(event, hash) {
            //alert(hash);
            var href = hash.replace("#","");
            $("a[href="+href+"]").click();
        });
}

$(document).ready(function() {

    // checkBrowserCompatibility();

    //cambiarNombres();
    //$.fx.off = true;

    launchLegalLinksSlideshow();

    launchGallery();

    setupNavigationMenu();  

    setupServiceArea();

    setupPwiServices();
    
    setupAccessFormsArea();

    setupLastMinuteLinksSection();

    footerLinksAction();

    setCorners();

    searchFormActions();

    setMainNavigationHistory();

});

String.prototype.unescapeHtml = function () {
    var temp = document.createElement("div");
    temp.innerHTML = this;
    var result = temp.childNodes[0].nodeValue;
    temp.removeChild(temp.firstChild);
    return result;
} 

// configuration for snow efect script (snowstorm-min.js)
/*
snowStorm.flakesMaxActive = 1000;
snowStorm.freezeOnBlur = false;
*/

