/************************************************/
//   Java Script							    //
/*************************************************

--------------------------------------------------
funcion esconder(div)
	Esconde la capa que se le pasa por paramentros
--------------------------------------------------
funcion mostrar(div)
	Muestra la capa que se le pasa por paramentros
--------------------------------------------------
funcion esconder(div)
	Esconde la capa que se le pasa por paramentros
--------------------------------------------------
funcion cambiabg(div,imagen)
    Establece la imagen pasada por parametros como 
	el fondo del div que tambien de le pasa
--------------------------------------------------
función anima(Dinlayer,xfin,yfin,pasos)
	Mueve un dynlayer a la posición (xfin,yfin) en 
	n pasos. Esta función genera un retardo en los 
	pasos finales para dar una sensación de frenado
	Es necesario el onjeto dynlayer de Dan Steinman
--------------------------------------------------
función precarga_imagenes()
	Precarga todas y cada una de las imágenes que
	se pasan por parámetros entre comillas y 
	separadas por comas. Llamar a la función dentro
	del HEAD de la página
--------------------------------------------------
función ValidarEmail()
	Precarga todas y cada una de las imágenes que
	se pasan por parámetros entre comillas y 
	separadas por comas. Llamar a la función dentro
	del HEAD de la página
--------------------------------------------------
función AddFavoritos()
	Permite incorporar la página actual a la lista
	de favoritos del Navegador empleado.
--------------------------------------------------

*/


function ValidarEmail(email)
{
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (email.length == 0 )
	 return false;
 if (filter.test(email))
      return true;
 else
     alert("Entre una direccion de correo válida.\nFormato: nombre@servidor.dom");
 return false;
}
//=====================================================
// esconder(elemento)
//=====================================================
function esconder(elemento){
	if (is.ns) 
		eval('document.'+elemento+'.visibility = "hide"')
   	else 
		eval(elemento+'.style.visibility = "hidden"')
}
//=====================================================


function cambiaimg(id,nombre){
		document.images[id].src = nombre;
	}

function mostrar(elemento){
	if (is.ns) 
		eval('document.'+elemento+'.visibility = "show"')
   	else 
		eval(elemento+'.style.visibility = "visible"')
}

function cambiabg(div,imagen){
	if (is.ns) 
		eval('document.'+div+'.background.src = '+imagen)
   	else 
		eval(div+'.style.background = "url('+imagen+')"')
}
var xf,yf,div,pas,incx,incy,fin;
var xf2,yf2,div2,pas2,incx2,incy2,fin2;

function anima(Dinlayer,xfin,yfin,pasos){
	fin=false;
	div=Dinlayer
	xf=xfin;
	yf=yfin;
	pas=pasos;
	x=eval(div+'.x')
	y=eval(div+'.y')
	incx=(xf-x)/pas
    incy=(yf-y)/pas
	movimiento()
}

function anima2(Dinlayer,xfin,yfin,pasos){
	fin2=false;
	div2=Dinlayer
	xf2=xfin;
	yf2=yfin;
	pas2=pasos;
	x=eval(div2+'.x')
	y=eval(div2+'.y')
	incx2=(xf2-x)/pas2
    incy2=(yf2-y)/pas2
	movimiento2()
}

function movimiento(){
	x=eval(div+'.x')
	y=eval(div+'.y')
	dist=Math.sqrt(((xf-x)*(xf-x))+((yf-y)*(yf-y)))
	if(dist > 30) {
	  eval(div+'.moveBy('+incx+','+incy+')')
      setTimeout(movimiento, 5);
   }else if (dist > 1) {
      eval(div+'.moveBy('+incx/5+','+incy/5+')')
      setTimeout(movimiento, 5);
   }else{
	fin=true;
   }
}

function movimiento2(){
	x=eval(div2+'.x')
	y=eval(div2+'.y')
	dist=Math.sqrt(((xf2-x)*(xf2-x))+((yf2-y)*(yf2-y)))
	if(dist > 30) {
	  eval(div2+'.moveBy('+incx2+','+incy2+')')
      setTimeout(movimiento2, 5);
   }else if (dist > 1) {
      eval(div2+'.moveBy('+incx2/5+','+incy2/5+')')
      setTimeout(movimiento2, 5);
   }else{
	fin2=true;
   }
}

var precargaimg=new Array();

function precarga_imagenes() {
	for(i=0; i<precarga_imagenes.arguments.length; i++) {
		precargaimg[i] = new Image();
		precargaimg[i].src = precarga_imagenes.arguments[i];
	}
}


function CambiaColor(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // fin cambia color fila

function ventana(nombre) {

		ventana=window.open(nombre, "Ventana", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=400");

	}

function addFavoritos()
	{
		if ((navigator.appVersion>=4)||(navigator.appName=='Microsoft Internet Explorer'))
			window.external.AddFavorite('http://www.clubdesalsa.com','Club de Salsa - Versión Beta 1.0.');
	}
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MostrarPopUp(img,ancho,alto,numFiesta) {
	if(location.href=="http://www.clubdesalsa.com/")
	{	wpopup=window.open("../php/popup.php?imagen="+img+"&ancho="+ancho+"&alto="+alto+"&numFiesta="+numFiesta, "wpopup", "height="+alto+",width="+ancho);
	}

}