// JavaScript Document
function colorear_celdas(){
	// seleccionamos las filas y asignamos clase segun corresponda
	var filas_array = document.getElementsByTagName("tr")
	var swt = true;
	var primer = true;
	for (var i = 1; i < filas_array.length; i++)
	{		
		var element = filas_array[i]
		var hijo = element.firstChild;
		if (element.style.display != "none")
		{
			if (primer)
			{
				element.style.backgroundColor		= "White";
				primer = false
				continue;
			}
			if (swt)
			{
				element.style.backgroundImage="none";
				element.style.backgroundColor= "#f9f9f9";
				swt = false;
			}
			else
			{
				element.style.backgroundImage="none";
				element.style.backgroundColor= "White";
				swt = true;
			}
			
		}
	}	
	primer = true;
}
// Aņadimos elemtos de carga en el onLoad;

function addLoadEvent(func) {
	var oldonload = window.onload;
		if (typeof window.onload != 'function') {
		window.onload = func;
		} else {
		window.onload = function() {
		oldonload ();
		func();
		}	
	}
}
// Aņade o modifica la clase de un tag;
function addClass(element, value){
	if (!element.className){
		element.className = value;	
	}else{
		newClassName = element.className;
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}
// Abrimos ventanaFlotante a secas.
function abrirVentana(url,nombre,parametros) {
 	 window.open(url,nombre,parametros);
}
// Acciones para el editor de textos.
//--
function check_link(objectID,bVisible){
		var object = document.getElementById(objectID);
		object.style.display = bVisible
}
function introducir_link(formulario,campo){
	var txtArea = document[formulario][campo]
	var texto = document[formulario].texto_link.value
	var ruta = document[formulario].ruta_link.value
	txtArea.value = txtArea.value + "<a href='"+ruta+"' target='_blank'>"+texto+"</a>"
}
function add_tag(formulario,campo,tag){
		init_edit()
		var txtArea = document[formulario][campo]
		var txtSeleccionado
		var original
		var aSplit
		if (window.getSelection)
		{
			//MOZILLA - NETSCAPE
			var startPos = txtArea.selectionStart;
			var endPos = txtArea.selectionEnd;

			var texto_base = txtArea.value.substring(startPos,endPos)
			original = txtArea.value
			aSplit = original.split (texto_base)
			if (aSplit.length > 1)
			{
			txtSeleccionado = "<"+tag+">"+texto_base+"</"+tag+">";
			txtArea.value = txtArea.value.substring(0, startPos)+txtSeleccionado+txtArea.value.substring(endPos, txtArea.value.length);
			}
		}
		else if (document.selection && document.selection.createRange().text != "" )
		{
			// IE
			txtSeleccionado = document.selection.createRange().text;
			original = txtArea.value
			aSplit = original.split (txtSeleccionado)

			if (aSplit.length > 1)
			{
				document.selection.createRange().text = "<"+tag+">"+txtSeleccionado+"</"+tag+">";
			}
		}
		else
		{
			return
		};
}
//--
// Confirmacion de envio de link.
function confirm_accion(texto){
	var confirmacion = confirm(texto)
	if (confirmacion){
		return true
	}else{
		return false
	}
}
//--
// Imprimimos el contenido de un id por js si las css no son validas
function printDiv(id ,css) 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById(id).innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write(' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'); 
	   winprint.document.write('<html xmlns="http://www.w3.org/1999/xhtml">'); 
	   winprint.document.write('<head>'); 
	   winprint.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />'); 
	   winprint.document.write('<link href='+css+' rel="stylesheet" type="text/css" />'); 
	   winprint.document.write('</head></body>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
	   //--
	   winprint.print();
	   //--
       winprint.document.close(); 
       winprint.close(); 
	   
	   return true
}
// imprimir a secar combicar con css de impresion.
function imprimir(){
	window.print()
}
//PopUp CSS
function abrirPopup(pid)
   {
      document.getElementById(pid).style.display = 'block';      
   }

function cerrarPopup(pid)
   {
      document.getElementById(pid).style.display = 'none';      
   }



//Numero de Jugadores
function jugador() { 
    var selec = document.reservas_frm.jugadores.options[document.reservas_frm.jugadores.selectedIndex].value;
    var jugador1  = document.getElementById('jugador1'); 
    var jugador2  = document.getElementById('jugador2'); 
	var jugador3  = document.getElementById('jugador3'); 
    var jugador4  = document.getElementById('jugador4'); 
	
	if (selec=='1')
	{
	jugador1.style.display = 'block';
	jugador2.style.display = 'none';
	jugador3.style.display = 'none';
	jugador4.style.display = 'none';
	}
	if (selec=='2')
	{
	jugador1.style.display = 'block';
	jugador2.style.display = 'block';
	jugador3.style.display = 'none';
	jugador4.style.display = 'none';
	}
	if (selec=='3')
	{
	jugador1.style.display = 'block';
	jugador2.style.display = 'block';
	jugador3.style.display = 'block';
	jugador4.style.display = 'none';
	}
	if (selec=='4')
	{
	jugador1.style.display = 'block';
	jugador2.style.display = 'block';
	jugador3.style.display = 'block';
	jugador4.style.display = 'block';
	}
	if (selec=='nj') {
	jugador1.style.display = 'none';
	jugador2.style.display = 'none';
	jugador3.style.display = 'none';
	jugador4.style.display = 'none';
	}
 } 		
	
/*Ampliar Imagen*/
function ampliarImagen(nombreImagen)
{
	//alert (nombreImagen);
	flashLightbox('../../media/imagenes/cabeceraVisor/'+nombreImagen)
	return false;
	
}
/*Ampliar Imagen*/
function ampliarImagenCampos(nombreImagen)
{
	//alert (nombreImagen);
	flashLightbox('../../media/imagenes/campos/'+nombreImagen)
	return false;
	
}
/*Crea y/o destruye un div tipo POP UP*/

function ocultarPopUpVideo()
{
	document.getElementById('contVideoHoyo').style.display="none"; 
}

function mostrarPopUpVideo()
{
	document.getElementById('contVideoHoyo').style.display="block"; 
}	

function ocultarPopUpVR()
{
	document.getElementById('contVR').style.display="none"; 
}

function mostrarPopUpVR()
{
	document.getElementById('contVR').style.display="block"; 
}	
	
