﻿// Scripts de comportamiento del Sitio
// VHDM - 26Feb2008
	$(document).ready(function(){		
		// Inicializaciones
		
		// Behavior
		// Mostramos Navegador
		$(".navSection").show("slow");
		$(".ViveMex").show("slow");
		// Over de Menu Home
		$("#mHom").hover(function(){
			$(".sMenu").hide();
			$("#smHom").show("fast");
			},
			function(){
			//$("#sMenu").hide("slow");
			}
		);
		// Over de Menu Directorio
		$("#mDir").hover(function(){
			$(".sMenu").hide();
			$("#smDir").show("fast");
			},
			function(){
			//$("#sMenu").hide("slow");
			}
		);
		// Ocultamos si pasamos por otra opcion
		$(".opt").hover(function(){
			$(".sMenu").hide();
			},
			function(){
			}
		);
		
	});
	
	// Funciones
	// Actualiza el indice seleccionado de los listados
	function UpPgNum(page){
		$("#pageNumber")[0].value = page;
	}
	
	// Banner		-------------------------------------------------------------------------------
	// Declaramos 
	var actCurrentBann;
	var eventHandlerBann;
	
	function ActInitBann() {
		//actCurrentBann=1;   // Inicio Default
		
		var d = new Date();
		rnd = Math.abs(d.getMilliseconds()%6)+1;	
		actCurrentBann = rnd;   // Inicio Aleatorio
	}	
	function ActStartBann() {
		ActInitBann();
		ActPlayBann();
	}
	
	function ActPlayBann() { ActPlayTimeBann(10000); }
	function ActPlayTimeBann(t) {
		// Reporte de estatus
		//if (stsShow) $('#stsDisplay').text = '>>> ' + actCurrent;
		$(".banner img").hide();
		$(".bann" + actCurrentBann).animate( { "opacity": "toggle" }, { "duration": "slow"} );
		//$(".display").find('.100' + actCurrent).show("slow");
	
		// Inscribe siguiente Rotacion
		eventHandlerBann = window.setTimeout('ActMoveBann(' + (actCurrentBann + 1) +')', t);
	}
	
	function ActMoveBann(n) {
		actCurrentBann = n;
		// Ciclo Rotatorio
		if (actCurrentBann >= 7) actCurrentBann = 1;		
		// Hace Rotacion
		ActPlayBann();
	}
	
	function ActStopBann() { if (eventHandlerBann != null) window.clearTimeout(eventHandlerBann);}


	//------------------------------------------------------------------------------------------------
	//Nota Principal
	//Declaramos
	var actCurrent;
	var actTop;
	var ctrl;
	var eventHandler;

	function ActInit(n, name) { actCurrent = 1; actTop = n;ctrl = name; }	
	function ActStart(n, name) {
	    ActInit(n, name);
		ActPlay();
	}
	
	function ActPlay() { ActPlayTime(8000); }
	function ActPlayTime(t) {
		// Reporte de estatus
		$("." + ctrl + " img, ." + ctrl + " div").hide();
		$("." + ctrl + "").find('.100' + actCurrent).animate( { "opacity": "toggle" }, { "duration": "fast"} );
	
		// Inscribe siguiente Rotacion
		eventHandler = window.setTimeout('ActMove(' + (actCurrent + 1) +')', t);
	}
	
	function ActMove(n) {
		actCurrent = n;
		// Ciclo Rotatorio
		if (actCurrent > actTop) actCurrent = 1;		
		// Hace Rotacion
		ActPlay();		
	}
	
	function ActStop() { if (eventHandler!= null) window.clearTimeout(eventHandler);}	



