 /*
    Document   : FUNCIONES y METODOS jQuery - JavaScript de --SAYARIY--
    Created on : 30/05/2011
    Description:
        Efectos y metodos destinados para el Website de --SAYARIY--
*/


/* ============================================================================
                                 GENERALES
============================================================================= */

//FUNCIONES Y EFECTOS GENERALES QUE SE APLICARAN EN TODA LA PAGINA
$(document).ready(function() {
  
    


    /* ============================================================================
                          MENU: SECCION - ACTIVA
    ============================================================================= */
    function zonaActiva(capa, head) {
        $(capa).addClass('mActived');
        $('.slide-home').css('display', 'none');
        
        $('#headImg').attr('src', '/images/head/'+head+'.jpg');

        if ($.browser.msie) {
            $('#headImg').css('display', 'block');
        } else {
            $('#headImg').load(function() {
                $('#headImg').fadeIn(580);
            });
        }
    }


    var ruta=$('#idem').text(); 

    switch (ruta) {
        case 'Home':		
            $('#mInicio').addClass('mActived');
        break;

        case 'Nosotros':
            $('#mNosotros').addClass('mActived');
        break;

        case 'Trabajos':
            $('#mTrabajos').addClass('mActived');
        break;

        case 'Descargas':
            $('#mDescargas').addClass('mActived');
        break;

        case 'Prensa':
            $('#mPrensa').addClass('mActived');
        break;
        
        case 'Ventas':
            $('#mVentas').addClass('mActived');
        break;

        case 'Contact':
            $('#mContacto').addClass('mActived');
        break;

        case 'Electro':
            $('.bRaymi').css('display','block');
        break;

        case 'Enjundia':
            $('.bEnjundia').css('display','block');
        break;

        case 'Wayna':
            $('.bWayna').css('display','block');
        break;

        case 'Quimba':
            $('.bQuimba').css('display','block');
        break;
    }


    /* Efecto Fade para Imagen de cabecera */
    
    

    $('.portrait:eq(4) img:last').css('height','55px');

    

});





/* =========================================================================  */

//FUNCIONES Y EFECTOS QUE SERAN APLICADOS SEGUN SEAN INVOCADOS
var functionSayariy = {
    main: {
        init: function() {
            
        }
    },


    /* ====================================================
        Funcion de Slider de Back Imagenes para el Home
  ===================================================== */
    backSlide: {
        init: function() {
            //$('.slide-home').css('display', 'block');
            $('#headImg').css('display', 'none');

            if ($.browser.msie) {
                $('.slide-home img:eq(0)').css('display', 'block');
            } else {
                $('.slide-home img:eq(0)').load(function() {//Mostramos la primera Imagen
                   // $(this).fadeIn(580);
                });
            }
            var number = $('.slide-home img').length - 1;            
            
            var count = 1; //Inicializamos el contador en 1;

            function sliderTimer() {
                $('.slide-home img').fadeOut(400);//Ocultamos las Imagenes
                $('.slide-home img:eq('+count+')').delay(400).fadeIn(1000, function(){                  
                    $('.slide-home').css('background', 'none');                  
                }); //Mostramos la Imagen Siguiente

                if (count < number) {
                      count+=1
                } else {
                      count=0;
                }
            }
            setInterval(sliderTimer, 10000);

        }
    },


    /* *******************************************************
      Funcion de Easy Slider y Carrusel para seccion Trabajos
    ******************************************************* */
    cdSlider: {
        init: function() {
            var userPlataform = navigator.platform;
            var userAgente = navigator.userAgent;
            var rChrome = /Chrome/g;
            var rMac = /Mac/;

            function slideSellos() {
                $('.boxTrabajos dd ul').slideUp(0);
                $('.boxTrabajos dd > a').toggle(
                    function() {
						$('.boxTrabajos dd .actSello').trigger('click');
						$('.boxTrabajos dd ul').slideUp(); //Subir
						$('.boxTrabajos dd > a').removeClass('actSello');
                        $(this).addClass('actSello');//activar el item
                        $(this).parent('dd').children('ul').slideDown(); //Bajar el Indicado
                        return false;
                    },

                    function() { 
                      $(this).removeClass('actSello');
					  $('.boxTrabajos dd ul').slideUp();
                        return false;
                    }
                );
				
                $('.boxTrabajos dd .actSello').trigger('click');
				$("#abre").show();

            }
            slideSellos();
                        
            if (rMac.test(userPlataform) ) {
              if (rChrome.test(userAgente)) {
                var cf = new ContentFlow('contentFlow', {
                  circularFlow: false, 
                  reflectionHeight: 0.0,
                  maxItemHeight: 155,
                  maxItemWidth: 174
                  /*, fixItemSize:true*/ 
                }); 
              }
              
            } else {
              var cf = new ContentFlow('contentFlow', {
                  circularFlow: false, 
                  reflectionHeight: 0.3,
                  reflectionColor: '#454545'
                  /*, fixItemSize:true*/ 
                });
            }


            
        }
   },

   /****** EFECTO COVERFLOW PARA LA SECCION TRABAJOS ******/
   coverFlow: {
        init: function() {

          var userPlataform = navigator.platform;
          var userAgente = navigator.userAgent;
          var rChrome = /Chrome/g;
          var rMac = /Mac/;
          
          if (rMac.test(userPlataform) ) {
              if (rChrome.test(userAgente)) {
                var cf = new ContentFlow('contentFlow', {
                  circularFlow: false, 
                  reflectionHeight: 0.0,
                  maxItemHeight: 155,
                  maxItemWidth: 174
                  /*, fixItemSize:true*/ 
                }); 
              }
              
          } else {
              var cf = new ContentFlow('contentFlow', {
                circularFlow: false, 
                reflectionHeight: 0.3,
                reflectionColor: '#454545'
                /*, fixItemSize:true*/ 
              });
          }
        }
   },

   /****** Form Validate ******/
   validateForm: {
        init: function() {
            $(':text, textarea').one('focus', function() {
                $(this).val('');
            });
            
            $('#frmContact').validate();

        }
   },


   /****** Puntaje Estrella ******/
   slideDisco: {
        init: function() {
           var contWidth = 0;
           
           $('#slide-disco .boxDisco').each(function() {
               contWidth+=$(this).innerWidth();
           });
           
           alert(contWidth);
        }
   },


   /****** SLIDER JCAROUSEL PARA SECCION SELLOS ******/ 
   selloSlider: {
        init: function() {
            var items = $('.producciones ul li').length;

            if (items > 3) {
                $('#mycarousel').jcarousel({
                    scroll: 3
                });
            }
        }
           
   },


   /****** Efecto Hover para la subseccion Artitas en la seccion Trabajos ******/
   artHover: {
        init: function() {
            var altura = new Array(); //Creamos el Array para almacenar las alturas
            
            $('.artista-item').each(function(i) {                
                altura[i] = $('.artista-bio', this).height(); //Asignamos la altura de cada parrafo
            });

            $('.artista-bio').height(0);//Reducimos la altura de todos los parrafos para el efecto

            $('.artista-item').hover(
                    function() {
                        var id = $(this).index();
                       // $('img', this).fadeTo(800, 1.0);                        
                        $('.artista-bio', this).animate({height: altura[id]+"px"},{easing: "easeOutBounce"}, 3500);
                    },
                    function() {
                      //  $('img', this).fadeTo(800, 0.7);
                        $('.artista-bio', this).animate({height: "0px"}, 800);
                    }
              
            );
                
            var items = $('.artista-item').length;            
            if (items > 3) {
                $('#mycarousel').jcarousel({
                    scroll: 3
                });
            }
            
        }
   },


   /****** Modal Lighbox para galeria de imagenes  ******/
   lightModal: {
        init: function() {
          //  $('.galeriaImg a img').fadeTo(0, 0.6);
            $('.galeriaImg a').hover(
                function() {
                   // $('img',this).fadeTo(750, 1.0)
                },
                function() {
                  //  $('img',this).fadeTo(650, 0.6)
                }
            );

            $('.galeriaImg a').lightBox();
        }
   },


   /****** Efectos Tabs para la seccion descargas ******/
   slideTabs: {
        init: function() {
            $('.tabs-download li a').click(function(e) {
                e.preventDefault();

                $('.tabs-download li a').removeClass('tabAct');
                $(this).addClass('tabAct');
                
                var tab = $(this).attr('href');
                $('.content-tabs dd').hide(0);
                $(tab).fadeIn(480);                
            });

            $('.image-item a').hover(
                function() {
                  //  $('img',this).fadeTo(750, 1.0)
                },
                function() {
                  //  $('img',this).fadeTo(650, 0.6)
                }
            );

           $('.image-item a').lightBox();

           $('.image-item:even').css('padding', '0px 40px');
        }
   }
}



