// JavaScript Document

var ultimaActualizacion = "02/03/2010";

var KeyID = 0;
document.onkeydown = KeyCheck;
document.onkeyup = KeyUp;
var botonID = 0;

//
// muestra pie de página
//
function piePagina()
{
	var text = "<p>"
	 	+ "Última actualización " + ultimaActualizacion + "<br />"
		+ "CasinosonlinePT.com &copy; 2009 - 2010 All rights reserved."
	 	+ "</p>";
	
	document.write(text);
}

//
// obtiene nombre de la página
//
function getURL()
{
	var url = document.location.href; 
	var partes = url.split('/'); 
	return(partes[partes.length-1]);
}

//
// crea sitemap
//
function onClickLogo()
{   
    if (KeyID == 15)
		{
        window.location.href = "./crearsitemap.php";
		}
        
    KeyID = 0;
}

function KeyCheck()
{
    if (getURL() == "index.html" || getURL() == "")
    {
        //alert(event.keyCode);
        if (event.keyCode == 16) KeyID = KeyID | 1;
        if (event.keyCode == 17) KeyID = KeyID | 2;
        if (event.keyCode == 84) KeyID = KeyID | 4;
        if (event.keyCode == 67) KeyID = KeyID | 8;
    }
    else
    {
        KeyID = 0;
    }
}

function KeyUp()
{
    KeyID = 0;
}

//
// expande o contrae un control div
//
function toggleVisibility(control, divObjName)
{
	divObj = document.getElementById(divObjName);
	
	if (divObj.className == 'Oculta')
	{
		control.innerHTML = (control.lang == 'en') ? 'Close' : 'Cerrar';
		divObj.className = 'Visible';
	}
	else 
	{
		control.innerHTML = (control.lang == 'en') ? 'Read more' : 'Leer más';
		divObj.className = 'Oculta';
	}
}

function toggleVisibility2(divObjName, divObjName2)
{
	divObj = document.getElementById(divObjName);
	divObj2 = document.getElementById(divObjName2);
	
	if (divObj.className == 'Oculta')
	{
		divObj.className = 'Visible';
		divObj2.className = 'Oculta';
	}
	else 
	{
		divObj.className = 'Oculta';
		divObj2.className = 'Visible';
	}
}

function toggleVisibility3(control, divObjName, text1, text2)
{
	divObj = document.getElementById(divObjName);
	
	if (divObj.className == 'Oculta')
	{
		control.innerHTML = text2;
		divObj.className = 'Visible';
	}
	else 
	{
		control.innerHTML = text1;
		divObj.className = 'Oculta';
	}
}

//
// validar dirección de contacto
//
function validarContacto(form)
{
    var nombre = form.NombreContacto.value;
    if (nombre.length < 4)
    {
        alert("Por favor introduce tú nombre.");
        form.NombreContacto.focus();
        return false;
    }
    
    var email = form.EmailContacto.value;
    apos = email.indexOf("@")
    dotpos = email.lastIndexOf(".")
    if (apos < 1 || dotpos - apos < 2)
    {
        alert("Por favor introduce tú dirección de correo electrónico.");
        form.EmailContacto.focus();
        return false;
    }
    
    var asunto = form.AsuntoContacto.value;
    if (asunto.length < 4)
    {
    	alert("Por favor introduce un asunto un poco más largo.");
    	form.AsuntoContacto.focus();
    	return false;
    }
    
    var comentario = form.ComentarioContacto.value;
    if (comentario.length < 10)
    {
        alert("Por favor introduce algún comentario un poco más largo.");
        form.ComentarioContacto.focus();
        return false;
    }
    
    return true;
}
