var flashvars = {};
flashvars.height = "234";
flashvars.width = "195";
flashvars.showstop = "true";
flashvars.allowSciptAccess = "always";
//flashvars.controlbar='over'; asi para sin controles

var params = {};
params.menu = "false";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "internal";
//params.allownetworking = "all"; asi para llamar shadowbox desde flash

params.wmode = "transparent";
var attributes = {};

$(document).ready(function() {


    if ($('#accordion_01').length > 0) { jQuery('#accordion_01').accordion({ header: 'a.head', alwaysOpen: false, autoheight: false, active: false }); }
    if ($('#accordion_02').length > 0) { jQuery('#accordion_02').accordion({ header: 'a.head', alwaysOpen: false, autoheight: false, active: false }); }
    if ($('#accordion_03').length > 0) { jQuery('#accordion_03').accordion({ header: 'a.head', alwaysOpen: false, autoheight: false, active: false }); }
    if ($('#accordion_04').length > 0) { jQuery('#accordion_04').accordion({ header: 'a.head', alwaysOpen: false, autoheight: false, active: false }); }

    jQuery('#carousel_01c').jcarousel({ scroll: 5, visible: 5, wrap: 'both', initCallback: mycarousel_initCallback });

    $('.link_abrir').click(function() {
        $(".dContacta").show();
        return false;
    });
    $('.link_cerrar').click(function() {
        $(".dContacta").hide();
        return false;
    });
  /*Udem cambio 25 Octubre*/

    $('.link_abrir3').click(function() {
        $(".dContacta").show();
        return false;
    });
    /**/

    $(".dLink").mouseover(function() {
        var x = $(this.parentNode).find(".dTool");
        $(x).show();
    }).mouseout(function() {
        var x = $(this.parentNode).find(".dTool");
        $(x).hide();
    });


    $(".dLink02").mouseover(function() {
        var x = $(this.parentNode).find(".dTool02");
        $(x).show();
    }).mouseout(function() {
        var x = $(this.parentNode).find(".dTool02");
        $(x).hide();
    });




    $(".Linktoggle").click(function() {
        $(".dtoggle").hide();
        $(".Linktoggle").css("color", "#000");
        x = $(this.parentNode).find(".dtoggle");
        $(this).css("color", "#666");
        $(x).show();
        return false;
    });
    $(".btncerrar").click(function() {
        $(".dtoggle").hide();
        $(".Linktoggle").css("color", "#000");
    });

    $('.jcarousel-skin-01c a').click(function() {
        $("#dStage img").attr("src", this.href);
        $("#dStagetext").text(this.rel);
        return false;
    });



    $(".alterno li:even").addClass("alt1");
    $('.tablasort tr:even').addClass('altertab');
    $('.tablasort2 tr:even').addClass('alternoc');


    $.tabs("tab_01");
    $.tabs("tab_02");
    $.tabs("tab_03");

    $(".tab_det_carre span").mouseover(function() {
        $(this).addClass("spanover");
    }).mouseout(function() {
        $(this).removeClass("spanover");
    });
    $(".tab_det_carre2 span").mouseover(function() {
        $(this).addClass("spanover");
    }).mouseout(function() {
        $(this).removeClass("spanover");
    });


    $('.tabla_especial tr.parent')
		.css("cursor", "pointer")
    $(".parent").click(function() {
        $(this).siblings('.child-' + this.id).toggle();
        x = $(this).find(".link_colap");
        $(x).toggleClass("link_a");
    });
    //$(".tabla_especial tr[@class^=child-]").hide().children('td');


    $('.link_abrir2').click(function() {
        $(".dEnviar").hide();
        K = $(this.parentNode).find(".dEnviar");
        $(K).show();
        return false;
    });
    $('.link_cerrar2').click(function() {
        $(".dEnviar").hide();
        return false;
    });



    var tip;
    $(".tooltip").hover(function() {

        tip = $(this).find('.tip').remove();
        $('body').append(tip);

        tip.show();

    }, function() {

        tip.hide().remove();
        $(this).append(tip);

    }).mousemove(function(e) {

        var mousex = e.pageX + 20;
        var mousey = e.pageY + 20;
        var tipWidth = tip.width();
        var tipHeight = tip.height();

        var tipVisX = $(window).width() - (mousex + tipWidth);
        var tipVisY = $(window).height() - (mousey + tipHeight);

        if (tipVisX < 20) {
            mousex = e.pageX - tipWidth - 20;
            $(this).find('.tip').css({ top: mousey, left: mousex });
        } if (tipVisY < 20) {
            mousey = e.pageY - tipHeight - 20;
            tip.css({ top: mousey, left: mousex });
        } else {
            tip.css({ top: mousey, left: mousex });
        }

    });

    /*shadowbox*/
    Shadowbox.init();


});

function mycarousel_initCallback(carousel)
{
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};



Shadowbox.loadSkin('classic', '../js/src/skin');
Shadowbox.loadLanguage('es', '../js/src/lang');
Shadowbox.loadPlayer([], '../js/src/player');

function setLigasEnglish() {

    $("a[href]").each(function() {
        try {
            if ($(this).text().toLowerCase().indexOf("espa") < 0) {  //no se modifica la liga a espanol, valido por texto
                if ($(this).text().toLowerCase().indexOf("versi") != 0) { //no se modifica la liga a espanol, valido por texto
                    if ($(this).attr("id").toLowerCase().indexOf("ctrlsacsmenu") < 0) {
                        if ($(this).attr("id").toLowerCase().indexOf("cambioidioma") < 0) {
                            var href = this.href;
                            if (href.toLowerCase().indexOf("/cms/") < 0) {
                                if (href.toLowerCase().indexOf("winpopup") < 0) {
                                    if (href.toLowerCase().indexOf("#") < 0) {
                                        if (href.toLowerCase().indexOf("simulador.aspx") < 0) {
                                            if (href.toLowerCase().substring(0, 3) != "/eng" || href.toLowerCase().substring(0, 2) != "eng" || href.toLowerCase().indexOf("acercadeespanol") < 0 || href.toLowerCase().substring(0, 10) != "/eng/acerca")  {
                                                if (href.toLowerCase().indexOf("xstatic/udem/template") >= 0) {
                                                    href = href.replace("&sl=1", "");
                                                    href = href.replace("?sl=1", "");

                                                    if (href.indexOf("?") >= 0)
                                                        href = href + "&sl=2";
                                                    else
                                                        href = href + "?sl=2";
                                                } else if (href.toLowerCase().indexOf(document.domain) >= 0 || href.toLowerCase().indexOf("www.udem.edu.mx") >= 0) {
                                                    href = href.replace("http://www.udem.edu.mx/", "");
                                                    href = href.replace("http://www.udem.edu.mx", "");
                                                    href = href.replace("http://" + document.domain + "/", "");
                                                    href = href.replace("http://" + document.domain, "");
                                                    if (href.length > 0) {
                                                        if (href.toLowerCase().indexOf(".xml") < 0 && href.toLowerCase().indexOf("english") != 0 && href.toLowerCase().indexOf(".pdf") < 0 && href.toLowerCase().indexOf(".doc") < 0) {
                                                            if (href.substring(href.length, href.length - 1) == "/") {
                                                                href = "http://" + document.domain + "/" + "eng/" + href;
                                                            }
                                                            else {
                                                                href = "http://" + document.domain + "/" + "eng/" + href;
                                                            }
                                                        }
                                                        else {
                                                            href = "http://" + document.domain + "/" + href;
                                                        }
                                                    } else {
                                                        if (href.indexOf("www.udem.edu.mx") >= 0) {
                                                            href = "http://www.udem.edu.mx";
                                                        }
                                                        else {
                                                            href = "http://" + document.domain;
                                                        }
                                                    }
                                                }
                                                this.href = href;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (err) { }
    });

} 
