﻿
 $$(document).ready(function() {
    /* Soporte para PNG IE6 */

    // $$(document).pngFix();

 /* Rollers */
    $$('.tour_options li').bind("mouseenter", function() {
     //$$('.tour_options li').mouseenter(function() {
        img =  $$(this).attr('id');
         $$(this).parents('.roller').css('background-image', 'url(/_lib/Partners/_prodigy/' + img + '.jpg)');
    });

    $$('.temas_options li').bind("mouseenter", function() {
     //$$('.temas_options li').mouseenter(function() {
        img =  $$(this).attr('id');
         $$(this).parents('.roller').css('background-image', 'url(/_lib/Partners/_prodigy/' + img + '.jpg)');
    });

    //Editorial
    cssOn = { 'display': 'block', 'opacity': '0' }
    cssOff = { 'display': 'none' }
    edElm = 0;

    editorialRoller = function(elm) {
        mostrar =  $$('.intro_editorial:eq(' + elm + ')');
        grupo =  $$('.intro_editorial');
        grupo.css(cssOff);
        mostrar.css(cssOn);
        mostrar.animate({ opacity: 1 }, 300);
         $$('.tit_art').removeClass('selected_art');
         $$('.tit_art:eq(' + elm + ')').addClass('selected_art');
        if (edElm <  $$('.tit_art').length - 1) { edElm++; } else { edElm = 0; }
    }

    $$('.tit_art').bind("mouseenter", function() {
     //$$('.tit_art').mouseenter(function() {
        edInt = window.clearInterval(edInt);
        edElm =  $$('.tit_art').index(this);
        editorialRoller(edElm);
        edInt = self.setInterval("editorialRoller(edElm)", 8000);
    });

    editorialRoller(edElm);
    var edInt = self.setInterval("editorialRoller(edElm)", 8000);

    //Destinos

     $$('.dest_tab').click(function() {
        nuevoTitulo =  $$(this).text();
         $$('.pd').text('Principales Destinos en ' + nuevoTitulo);
        i =  $$('.dest_tab').index(this);
        mostrar =  $$('.destRoll:eq(' + i + ')');
        grupo =  $$('.destRoll');
        grupo.css(cssOff);
        mostrar.css(cssOn);
        mostrar.animate({
            opacity: 1
        }, 300);
         $$('.dest_tab').removeClass('selected_tab');
         $$(this).addClass('selected_tab');
    });

     $$('.pd').click(function() {
         $$('.dest_tab').removeClass('selected_tab');
        tdStr =  $$(this).text();
        if (tdStr.indexOf('México') != -1) {
             $$(this).text('Principales Destinos en Estados Unidos y Canadá');
            mostrar =  $$('.destRoll:eq(1)');
             $$('.dest_tab:eq(1)').addClass('selected_tab');
        } else {
             $$(this).text('Principales Destinos en México');
            mostrar =  $$('.destRoll:eq(0)');
             $$('.dest_tab:eq(0)').addClass('selected_tab');
        }

        grupo =  $$('.destRoll');
        grupo.css(cssOff);
        mostrar.css(cssOn);
        mostrar.animate({ opacity: 1 }, 300);
    });

     $$('.destRoll:first').css('display', 'block');

    /*
    Inician Scrolls
    **/

    toursTopLimit = (parseInt( $$('.tour_options ul').height()) - parseInt( $$('.scroll').height())) * (-1);
    toursAbajo =  $$('.tour_arrows .arrow_abajo');
    toursArriba =  $$('.tour_arrows .arrow_arriba');
    toursUl =  $$('.tour_options ul');

    temasTopLimit = (parseInt( $$('.temas_options ul').height()) - parseInt( $$('.scroll').height())) * (-1);
    temasAbajo =  $$('.temas_arrows .arrow_abajo');
    temasArriba =  $$('.temas_arrows .arrow_arriba');
    temasUl =  $$('.temas_options ul');

    scrl = 35;
    prvErrScrl = 0;

    //Tours
    toursAbajo.click(function() {
        actualScrollTours = parseInt(toursUl.css('margin-top'));
        if (actualScrollTours > toursTopLimit && prvErrScrl == 0) {
            prvErrScrl = 1;
            toursUl.animate({
                marginTop: parseInt(toursUl.css('margin-top')) - scrl
            }, 200, function() {
                prvErrScrl = 0;
            });
        }
    });

    toursArriba.click(function() {
        actualScrollTours = parseInt(toursUl.css('margin-top'));
        if (actualScrollTours < 0 && prvErrScrl == 0 && actualScrollTours - scrl < 0) {
            prvErrScrl = 1;
            toursUl.animate({
                marginTop: parseInt(toursUl.css('margin-top')) + scrl
            }, 300, function() {
                prvErrScrl = 0;
            });
        }
    });

    //Temas
    temasAbajo.click(function() {
        actualScrollTemas = parseInt(temasUl.css('margin-top'));
        if (actualScrollTemas > toursTopLimit && prvErrScrl == 0) {
            prvErrScrl = 1;
            temasUl.animate({
                marginTop: parseInt(temasUl.css('margin-top')) - scrl
            }, 200, function() {
                prvErrScrl = 0;
            });
        }
    });

    temasArriba.click(function() {
        actualScrollTemas = parseInt(temasUl.css('margin-top'));
        if (actualScrollTemas < 0 && prvErrScrl == 0 && actualScrollTemas - scrl < 0) {
            prvErrScrl = 1;
            temasUl.animate({
                marginTop: parseInt(temasUl.css('margin-top')) + scrl
            }, 200, function() {
                prvErrScrl = 0;
            });
        }
    });

    /*
    Fondo Lista de Artículos
    **/
     $$('.listArt_item:odd').addClass('alt');

    /*
    Incrementar tamaño de texto
    **/

     $$('.inc_font').click(function() {
        actualFS = parseInt( $$('.articulo_completo p').css('font-size'));
        actualLH = parseInt( $$('.articulo_completo p').css('line-height'));
        if (actualFS != 15) {
             $$('.articulo_completo p').css('font-size', actualFS + 1 + 'px');
             $$('.articulo_completo p').css('line-height', actualLH + 2 + 'px');
        } else {
             $$('.articulo_completo p').css('font-size', '11px');
             $$('.articulo_completo p').css('line-height', '18px');
        }
        return false;
    });


    //Galería				
    var len =  $$('input[name=num_images]').val();
    var path =  $$('input[name=path_images]').val();
    var last = len;
    var ind = 1;
    var mxr = '0';

     $$('.galeria_art_img').html('<img src="' + path + mxr + ind + '.jpg" />');

    displayGal = function() {
         $$('.galeria_art_img').css('opacity', '0');
         $$('.galeria_art_img').animate({
            opacity: 1
        }, 300);
    }

     $$('.imgant').click(function() {
        ind = (ind != 1) ? ind - 1 : last;
        mxr = (ind > 9) ? '' : '0';
         $$('.galeria_art_img').html('<img src="' + path + mxr + ind + '.jpg" />');
        displayGal();
        return false;
    });

     $$('.imgsig').click(function() {
        ind = (ind == last) ? 1 : ind + 1;
        mxr = (ind > 9) ? '' : '0';
         $$('.galeria_art_img').html('<img src="' + path + mxr + ind + '.jpg" />');
        displayGal();
        return false;
    });


    $$('#ddlItems').change(function() {
        $$('#List').submit();
    });
    
   
});

