// JavaScript Document
/*Esta variable es la ruta de la carpeta raiz de Halconesxalapa*/
var ruta =  "/halconesxalapa/";

function menu_superior() {
var equipo = ruta + "equipo/"; 
var localidades = ruta + "localidades/"; 
var zonafan = ruta + "zona_fan/"; 
var historia = ruta + "historia/";
var calendario = ruta + "calendario/";
var estadisticas = ruta + "estadisticas/";
var noticias = ruta + "noticias/";
var club = ruta + "club/";
var academia = ruta + "academia/";

document.write("<ul id='menu'>");
document.write("<li><span><a href='"+ ruta +"index.html'>HOME</a></span></li>");

document.write("<li><span>EQUIPO</span>");
document.write("<!--[if lte IE 6]><a href='" + equipo + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + equipo + "index.html'>EQUIPO</a></dt>");
document.write("	<dd><a href='" + equipo + "index.html'>Roster</a></dd>");
document.write("	<dd><a href='" + historia + "index.html'>Historia</a></dd>");
document.write("	<dd><a href='http://www.lnbp.com.mx/web2/admin_lv2/estadisticas/alltables.php#gral' rel='external'>Tabla de posiciones</a></dd>");
document.write("	<dd><a href='" + equipo + "transmisiones.html'>Transmisiones</a></dd>");

document.write("</dl>");
document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");

document.write("<li><span><a href='"+ calendario +"index.html'>CALENDARIO</a></span></li>");

document.write("<li><span>ESTADISTICAS</span>");
document.write("<!--[if lte IE 6]><a href='" + ruta + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + estadisticas + "index.html'>ESTADISTICAS</a></dt>");
document.write("	<dd><a href='" + estadisticas + "resultados2011.html'>Ultimos Resultados</a></dd>");
document.write("	<dd><a href='" + estadisticas + "resultados2010.html'>Resultados 2010</a></dd>");
document.write("	<dd><a href='" + estadisticas + "index.html'>Temporada 2011-12</a></dd>");
document.write("	<dd><a href='" + estadisticas + "temporada2010-11.html'>Temporada 2010-11</a></dd>");
document.write("	<dd><a href='" + estadisticas + "temporada2009-10.html'>Temporada 2009-10</a></dd>");
document.write("	<dd><a href='" + estadisticas + "temporada2008-09.html'>Temporada 2008-09</a></dd>");  
document.write("	<dd><a href='" + estadisticas + "temporada2007-08.html'>Temporada 2007-08</a></dd>");    
document.write("	<dd><a href='" + estadisticas + "temporada2006-07.html'>Temporada 2006</a></dd>");
document.write("	<dd><a href='" + estadisticas + "temporada2005-06.html'>Temporada 2005</a></dd>"); 
document.write("	<dd><a href='" + estadisticas + "temporada2004-05.html'>Temporada 2004</a></dd>");
document.write("	<dd><a href='" + estadisticas + "temporada2003-04.html'>Temporada 2003</a></dd>");
document.write("</dl>");
document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");


document.write("<li><span>LOCALIDADES</span>");
document.write("<!--[if lte IE 6]><a href='" + localidades + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + localidades + "index.html'>LOCALIDADES</a></dt>");

document.write("	<dd><a href='" + localidades + "index.html'>Abonos</a></dd>");
document.write("	<dd><a href='" + localidades + "boletos.html'>Boletos individuales</a></dd>");
document.write("	<dd><a href='" + localidades + "promociones.html'>Boletos Promociones</a></dd>");
document.write("	<dd><a href='" + localidades + "gimnasiouniversitario.html'>Mapa del Gimnasio</a></dd>");
document.write("</dl>");
document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");

document.write("<li><span><a href='" + noticias + "index.html'>NOTICIAS</a></span></li>");

document.write("<li><span>ZONA FAN</span>");
document.write("<!--[if lte IE 6]><a href='" + zonafan + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + zonafan + "index.html'>ZONA FAN</a></dt>");

document.write("	<dd><a href='" + zonafan + "galeria-juegos.html'>Galer&iacute;a de juegos</a></dd>");
document.write("	<dd><a href='" + zonafan + "porra.html'>Porra oficial</a></dd>");
document.write("	<dd><a href='" + zonafan + "index.html'>Trivias</a></dd>");
document.write("	<dd><a href='" + zonafan + "cubihalcon.html'>Cubi halc&oacute;n</a></dd>");
document.write("	<dd><a href='" + zonafan + "encuentrosminifan.html'>Encuentros minifan</a></dd>");
document.write("	<dd><a href='" + ruta + "foros/index.php' rel='external'>Foro</a></dd>");

document.write("	<dd><a href='" + zonafan + "tapices.html'>Wallpapers</a></dd>");
document.write("</dl>");
document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");
document.write("<li><span>CLUB XALAPA</span>");
document.write("<!--[if lte IE 6]><a href='" + club + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + club + "index.html'>CLUB XALAPA</a></dt>");

document.write("	<dd><a href='" + club + "index.html'>Misi&oacute;n-visi&oacute;n</a></dd>");
document.write("	<dd><a href='" + club + "directorio.html'>Directorio</a></dd>"); 
document.write("	<dd><a href='" + ruta + "contacto/index.html'>Cont&aacute;ctanos</a></dd>"); 
document.write("</dl>");

document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");
document.write("<li><span>ACADEMIA</span>");
document.write("<!--[if lte IE 6]><a href='" + academia + "index.html'><table><tr><td><![endif]-->");
document.write("<dl>");
document.write("	<dt><a href='" + academia + "index.html'>ACADEMIA</a></dt>");

document.write("	<dd><a href='" + academia + "historia.html'>Historia</a></dd>");
document.write("	<dd><a href='" + academia + "index.html'>Objetivo</a></dd>");   
document.write("	<dd><a href='" + academia + "informes.html'>Informaci&oacute;n</a></dd>"); 
document.write("	<dd><a href='" + academia + "entrenadores.html'>Entrenadores</a></dd>"); 
document.write("	<dd><a href='" + academia + "materialdidactico.html'>Descargas</a></dd>");        
document.write("</dl>");
document.write("<!--[if lte IE 6]></td></tr></table></a><![endif]-->");
document.write("</li>");
document.write("</ul>");
}
/*Patrocinadores*/
function patrocinadores(){
	document.write(" <ul id='Patrocinadores'>");
	document.write("  <li id='Xalapa'><a href='http://www.hotelesenxalapa.com/' rel='external' title='BG Hoteles'>&nbsp;</a></li>");
	document.write("  <li id='Ado'><a href='http://www.keytalent.net/' rel='external' title='Key Talent'>&nbsp;</a></li>");
	document.write("  <li id='Key'><a href='http://www.gmodelo.com/' rel='external' title='Corona Extra'>&nbsp;</a></li>");
	document.write("  <li id='Corona'><a href='http://www.comex.com.mx/home' rel='external' title='Comex'>&nbsp;</a></li>");
	document.write("  <li id='Comex'><a href='http://www.wix.com/gpg2010/gpg1-1' rel='external' title='GPG Publicidad'>&nbsp;</a></li>");
	document.write("  <li id='Gpg'><a href='http://ferchegas.com.mx/' rel='external' title='FERCHE GAS'>&nbsp;</a></li>");
	document.write("  <li id='Ferche'><a href='http://www.adx.com.mx/' rel='external' title='ADX'>&nbsp;</a></li>");
	
	
	
	document.write("  <li id='Trevino' class='Bloque2'><a href='http://es-la.facebook.com/people/Chantres-Gym/100001028728246'rel='external' title='Chantres'>&nbsp;</a></li>");
	document.write("  <li id='Xallapan' class='Bloque2'><a href='http://ideasdeimpresion.com.mx/' rel='external' title='IDEAS'>&nbsp;</a></li>");
	document.write("  <li id='Total' class='Bloque2'><a href='http://www.trevicom.com.mx/' rel='external' title='Trevi&ntilde;o Computaci&oacute;n'>&nbsp;</a></li>");
	document.write("  <li id='Rtv' class='Bloque2'><a href='http://www.xallapan.com/' rel='external' title='xallapan'>&nbsp;</a></li>");
	document.write("  <li id='Molten' class='Bloque2'><a href='http://www.electrolit.com/#' rel='external' title='Total'>&nbsp;</a></li>");
	document.write("  <li id='Acontecer' class='Bloque2'><a href='http://www.rtv.org.mx/' rel='external' title='RTV Radio Televisi&oacute;n de Veracruz'>&nbsp;</a></li>");	
	document.write("  <li id='Gatorede' class='Bloque2'><a href='#' rel='external' title='Acontecer'>&nbsp;</a></li>");

	/*document.write("  <li id='Twitter' class='Bloque3'><a href='http://twitter.com/halconesxalapa' rel='external' title='Siguenos en Twitter'>&nbsp;</a></li>");
	document.write("  <li id='Facebook' class='Bloque3'><a href='http://www.facebook.com/?sk=2361831622#!/groups/174398712626043' rel='external' title='Siguenos en Facebook'>&nbsp;</a></li>");
	document.write("  <li id='Youtube' class='Bloque3'><a href='#' title='Siguenos en Youtube'>&nbsp;</a></li>");	
	document.write(" </ul>"); */
}


/*Esto es para mostrar plecas aleatorias*/
var total_img = 2; //total de imágenes
var url_img =  ruta + "images/Home/caratula/caratula-"; //url de las imagenes aleatorias
function FondoPleca(){
 var img_aleatoria= "url("+url_img+Math.floor( Math.random() * total_img + 1)+ ".jpg" + ")";
   $("#PlecaHalcones").css('background-image', img_aleatoria);
}

function AgregaFondo(){
	if ($("#ContentTitulos.Fondo-Roster").length > 0) { //#some element exists 
		$("#FondoDerecha").addClass('FVerde');
		$("#Titulo span").addClass('slash-FVerde');
	}
	if ($("#ContentTitulos.Fondo-Calendario").length > 0) { //#some element exists 
		$("#FondoDerecha").addClass('FPlata1');
		$("#Titulo span").addClass('slash-FPlata1');		
	}
	if ($("#ContentTitulos.Fondo-Localidades").length > 0) { //#some element exists 
	    $("#FondoDerecha").addClass('FAzul2');
		$("#Titulo span").addClass('slash-FAzul2');
	}
	if ($("#ContentTitulos.Fondo-Academia").length > 0) { //#some element exists 
  	    $("#FondoDerecha").addClass('FVerde2');	
		$("#Titulo span").addClass('slash-FVerde2');
	}
	if ($("#ContentTitulos.Fondo-Zona").length > 0) { //#some element exists 
  	    $("#FondoDerecha").addClass('FAzul');
		$("#Titulo span").addClass('slash-FAzul');
	}
	if ($("#ContentTitulos.Fondo-Club").length > 0) { //#some element exists 
  	    $("#FondoDerecha").addClass('FAzulClub');
		$("#Titulo span").addClass('slash-FAzulClub');
	}
	if ($("#ContentTitulos.Fondo-Mapa").length > 0) { //#some element exists 
  	    $("#FondoDerecha").addClass('FVerde2');	;
	}

		  
}
/*Esto es para mostrar los jugadores de fondo aleatorio*/
var total_jugadores = 7; //total de iágenes
var url_jugador = ruta + "images/Home/fondo/"; //url de las imagenes aleatorias
function FondoPagina(){
 var img_aleatoria= "url("+url_jugador+Math.floor( Math.random() * total_jugadores + 1)+ ".jpg" + ")";
   $("#MasterPage").css('background-image', img_aleatoria);
}

/*Administrador de onload para html*/
function addLoadEvent (func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
			window.onload = func; 
		
		} 
		else { 
			window.onload = function() { 
				if (oldonload) { 
					oldonload(); 
				} 
					func(); 
			} 
	} 
}


function Links(){
	//para la opacidad en el Menu
	$('#MenuSuperior dd').css('opacity',0.9);
	
	$('a[rel="external"]').click( function() {
			  this.target = "_blank";
	});
	
	$('a[class="tblank"]').click( function() {
			  this.target = "_blank";
	});
}

//para la galeria de fotos
function Galeria(){
 $('.gallery_demo_unstyled').addClass('gallery_demo'); // Añade el nombre de nueva clase para mantener la degradabilidad
		
		$('ul.gallery_demo').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // ayuda para la toma de la imagen puede hacer clic
			insert    : '#main_image', // que contiene el selector para nuestra imagen principal
			onImage   : function(image,caption,thumb) { // añadir algunos efectos de imagen con fines de demostración
				
				// se desvanecen en la imagen
				image.css('display','none').fadeIn(1000);
				caption.css('display','none').fadeIn(1000);
				
				// recoger el contenedor en miniatura
				var _li = thumb.parents('li');
				
				// fade out miniatura inactivos
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// se desvanecen en miniatura activa
				thumb.fadeTo('fast',1).addClass('selected');
				
				// añadir un título para la imagen puede hacer clic
				image.attr('title','Imagen Siguiente >>');
			},
			onThumb : function(thumb) { // efectos miniatura va aquí
				
				// recoger el contenedor en miniatura
				var _li = thumb.parents('li');
				
				// miniatura si está activo, se desvanecen hasta el final.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// se desvanecen en la imagen cuando se carga finnished
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// efectos hover
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // no se borran si el padre está activo
				)
			}
		});
  
}


/* *********** Funciones para validar la forma (busqueda) de Google */
function trim(cadena) {
			for(i=0; i<cadena.length; )	{
				if(cadena.charAt(i)==" ")
				cadena=cadena.substring(i+1, cadena.length);
				else
					break;
			}
			for(i=cadena.length-1; i>=0; i=cadena.length-1)	{
				if(cadena.charAt(i)==" ")
					cadena=cadena.substring(0,i);
				else
					break;
			}
			document.forms[0].q.value = cadena;
			return cadena;
}

// JavaScript Document
function validar(form) {
	var forma = document.forms['FormaBusqueda'];
		document.forms['FormaBusqueda'].action = "" + ruta + "resultados-buscar.html";

	if (document.forms['FormaBusqueda'].q.value=="Búsqueda...")
		return false;
	if( trim(document.forms["FormaBusqueda"].q.value)=="" || document.forms["FormaBusqueda"].q.value==null || document.forms["FormaBusqueda"].q.value=="B&uacute;squeda..." )
		return false;	
	return true;
}

var cadena;
var pf = 0;

function getParams() {
	var url = new String( document.location );
	var idx = url.indexOf('?');
	var params = new Array();
	if (idx != -1) {
		var pairs = url.substring(idx+1, url.length).split('&');
		for (var i=0; i<pairs.length; i++) {
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
			if (nameVal[0] == 'q')
				pf = 1;
  		}
	}
	return params;
}

function findDone(result) {
//<![CDATA[
  // Make sure we didn't get an error.
  if (!result.error) {
    // Get content div
    var content = document.getElementById('ContentFeeds');
    var html = '';

    // Loop through the results and print out the title of the feed and link to
    // the url.
    html += '<p>&nbsp;&nbsp;<\/p><ul>';
    for (var i = 0; i < result.entries.length; i++) {
      var entry = result.entries[i];
	  var num = i+1;
      html += '<li> ' + num +'.- <a href="' + entry.url + '" target="_blank" title="' +  entry.title + '">' + entry.title + '<\/a><br \/><span> ' + entry.url + '<\/span><\/li>';
      }
    html += '<\/ul>';  
    content.innerHTML = html;
  }
//]]>
}



// the se class encapsulates a left and right search control
// both controls are driven by a shared search form
function se() {
	var sFormDiv = document.getElementById("searchForm");
	var leftScDiv = document.getElementById("leftSearchControl");
	var rightScDiv = document.getElementById("rightSearchControl");

	// create a left, right search control
	// create a custom search form
	this.leftControl = new google.search.SearchControl();
	this.rightControl = new google.search.SearchControl();
	google.search.Search.getBranding(document.getElementById("branding"));
	this.searchForm = new google.search.SearchForm(true, sFormDiv);
	
	// bind clear and submit functions
	this.searchForm.setOnSubmitCallback(this, se.prototype.onSubmit);
	this.searchForm.setOnClearCallback(this, se.prototype.onClear);
	
	// set up for large result sets
	this.leftControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	this.rightControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	
	var searcher;
	var options;
	
	// configure left control
	// vertical layout, image and blog
	// iamgen search, 
	var options = new google.search.SearcherOptions();
	options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	
	 // Create an ImageSearch.
	var imageSearch = new google.search.ImageSearch();
	imageSearch.setUserDefinedLabel("Imagenes");
	// Set a site restriction to the desired web site.
	imageSearch.setSiteRestriction('uv.mx/halconesxalapa');		
	this.rightControl.addSearcher(imageSearch, options);
	
	// configure right control
	// tabbed layout image, web, news
		var options = new google.search.SearcherOptions();
	options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	
	// Create an ImageSearch.
	var siteSearch = new google.search.WebSearch();
	siteSearch.setUserDefinedLabel("Web");
	// Set a site restriction to the desired web site.
	siteSearch.setSiteRestriction('uv.mx/halconesxalapa');
	// Add the searcher to the SearchControl.
	this.leftControl.addSearcher(siteSearch, options);
	

	var drawOptions = new google.search.DrawOptions();
	drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
	
	this.leftControl.setNoResultsString(GSearchControl.NO_RESULTS_DEFAULT_STRING);
	this.leftControl.draw(leftScDiv, drawOptions);
	
	this.rightControl.setNoResultsString(GSearchControl.NO_RESULTS_DEFAULT_STRING);
	this.rightControl.draw(rightScDiv);

		params = getParams();
			if (pf == 1 ) {
				cadena = unescape(params["q"]);
				this.searchForm.execute(cadena);  
			}else{
				// execute a starter search
					this.searchForm.execute("Halcones UV Xalapa");
				}
}
	
	// when the form fires a submit, grab its
	// value and call the left and right control
	se.prototype.onSubmit = function(form) {
	var q = form.input.value;
    var queryDiv = document.getElementById('ResultadoCadena');
	queryDiv.innerHTML = q.replace(/\+/gi, " ");
	
	if (q && q!= "") {
	  this.leftControl.execute(q);
	  this.rightControl.execute(q);
	}
	return false;
	}
	
	// when the form fires a clear, call the left and right control
	se.prototype.onClear = function(form) {
		this.leftControl.clearAllResults();
		this.rightControl.clearAllResults();
		form.input.value = "";
		return false;
	}

/*   *********** Fin funciones de Google  ************* */
 
