﻿/* 
Funciones JavaScript

Matriz de Modificaciones
Fecha           Autor           Descripción
13MAY2011       mmendoza        Creación de Archivo

*/

/* MyCarousel*/
    function mycarousel_initCallback(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });
     
        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });
     
        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();            
        });
    };
     
    jQuery(document).ready(function() {
        jQuery('#mycarousel').jcarousel({
            visible: 7,
            auto: 2,
            scroll: 1,
            wrap: 'last',
            initCallback: mycarousel_initCallback
        });
    });
/* MyCarousel*/

/* Anything Slider */

    $(function(){
	    // External Link with callback function
	    $("#slide-jump").click(function(){
		    $('#slider2').anythingSlider(4, function(slider){ /* alert('Now on page ' + slider.currentPage); */ });
		    return false;
	    });

	    // External Link
	    $("a.muppet").click(function(){
		    $('#slider1').anythingSlider(5);
		    $(document).scrollTop(0);
		    return false;
	    });

	    // Report Events to console & features list
	    $('#slider1').bind('before_initialize initialized swf_completed slideshow_start slideshow_stop slideshow_paused slideshow_unpaused slide_init slide_begin slide_complete', function(e, slider){
		    // show object ID + event (e.g. "slider1: slide_begin")
		    var txt = slider.$el[0].id + ': ' + e.type + ', now on panel #' + slider.currentPage;
		    $('#status').text(txt);
		    if (window.console && window.console.firebug){ console.debug(txt); } // added window.console.firebug to make this work in Opera
	    });

    });

    // Set up Sliders
    $(function(){

	    $('#slider1')
	    .anythingSlider({
		    startStopped    : false, // If autoPlay is on, this can force it to start stopped
		    width           : 900,   // Override the default CSS width
		    height          : 230,   // if resizeContent is false, this is the default height if panel size is not defined
		    resizeContents  : true, // If true, solitary images/objects in the panel will expand to fit the viewport
		    theme           : 'Default',
		    easing          : 'easeInOutBack',
		    autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
		    resumeDelay     : 1000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
		    delay           : 12000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
            animationTime   : 500,  // How long the slideshow transition takes (in milliseconds)		
            toggleControls  : false,				
            buildArrows     : false,
            buildNavigation : true,
            startText       : "",
            stopText        : "",
            stopAtEnd       : false,
		    stopAtEnd : true				
	    })		
    });
    
/* Anything Slider */

/*Menu*/

var menu=function(){
	var t=15,z=50,s=2,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

//  mmnedoza    MenuColores 24MAY2011
//    $(document).ready(function(){
//	    //Fix Errors - http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup/
//	    //Remove outline from links
//	    $("ul.menu a").click(function(){
//		    $(this).blur();
//	    });
//    	
//	    //When mouse rolls over
//	    $("ul.menu li").mouseover(function(){
//		    $(this).stop().animate({height:'150px'},{queue:false, duration:600, easing: 'easeOutBounce'})
//	    });
//    	
//	    //When mouse is removed
//	    $("ul.menu li").mouseout(function(){
//		    $(this).stop().animate({height:'50px'},{queue:false, duration:600, easing: 'easeOutBounce'})
//	    });
//    	
//    });

//	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
//	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//	try {
//	    var pageTracker = _gat._getTracker("UA-6444047-1");
//	    pageTracker._trackPageview();
//	} catch(err) {}

/*Menu*/


