
//=============================================================
//==== marquesina de imagenes
//=============================================================
//specify interval between slide (in mili seconds)
var slidespeed=300

//specify images
var slideimages=new Array("../images/1-marq-main.jpg","../images/2-marq-main.jpg","../images/3-marq-main.jpg","../images/4-marq-main.jpg","../images/5-marq-main.jpg","../images/6-marq-main.jpg","../images/7-marq-main.jpg")

//specify corresponding links
var slidelinks=new Array("galeria.asp?cocina_1=1","galeria.asp?salon_1=1","galeria.asp?maternal_1=1","galeria.asp?bano_1=1","galeria.asp?salon_1=1","galeria.asp?area_recreacion_1=1","galeria.asp?salon_computacion_1=1")

var newwindow=1 //open links in new window? 1=yes, 0=no

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}
//=============================================================
//==== efecto de nieve en la pagina
//=============================================================
// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax=38

// Set the colors for the snow. Add as many colors as you like
var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD")

// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS")

// Set the letter that creates your snowflake (recommended:*)
var snowletter="*"

// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=0.9

// Set the maximal-size of your snowflaxes
var snowmaxsize=22

// Set the minimal-size of your snowflaxes
var snowminsize=8

// Set the snowing-zone
// Set 1 for all-over-snowing, set 2 for left-side-snowing 
// Set 3 for center-snowing, set 4 for right-side-snowing
var snowingzone=3

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////


// Do not edit below this line
var snow=new Array()
var marginbottom
var marginright
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var browserinfos=navigator.userAgent 
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var ns6=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/)  
var browserok=ie5||ns6||opera

function randommaker(range) {		
	rand=Math.floor(range*Math.random())
    return rand
}

function initsnow() {
	if (ie5 || opera) {
		marginbottom = document.body.clientHeight
		marginright = document.body.clientWidth
	}
	else if (ns6) {
		marginbottom = window.innerHeight
		marginright = window.innerWidth
	}
	var snowsizerange=snowmaxsize-snowminsize
	for (i=0;i<=snowmax;i++) {
		crds[i] = 0;                      
    	lftrght[i] = Math.random()*15;         
    	x_mv[i] = 0.03 + Math.random()/10;
		snow[i]=document.getElementById("s"+i)
		snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
		snow[i].size=randommaker(snowsizerange)+snowminsize
		snow[i].style.fontSize=snow[i].size
		snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
		snow[i].sink=sinkspeed*snow[i].size/5
		if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
		if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
		if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
		if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
		snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size)
		snow[i].style.left=snow[i].posx
		snow[i].style.top=snow[i].posy
	}
	movesnow()
}

function movesnow() {
	for (i=0;i<=snowmax;i++) {
		crds[i] += x_mv[i];
		snow[i].posy+=snow[i].sink
		snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
		snow[i].style.top=snow[i].posy
		
		if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
			if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
			if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
			if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
			if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
			snow[i].posy=0
		}
	}
	var timer=setTimeout("movesnow()",50)
}

for (i=0;i<=snowmax;i++) {
	document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
}
//=============================================================
//==== abre popup
//=============================================================
function abrir_popup (url, ancho, alto)
{
	var WinWidth=ancho;
	var WinHeight=alto;
	var winLeft = 350;
	var winUp = 150;
	var WinOptions="menubar=no,location=no,status=yes,toolbar=no,scrollbars=yes,titlebar=no,resizable=yes,width="+WinWidth+",height="+WinHeight+",top="+winUp+",left="+winLeft;
	winUpDetalle = window.open(url,"winUpDetalle",WinOptions);
	try
	{
	if (winUpDetalle.target)
	{}
	}catch (e) {alert('Se esta intentando mostrar contenido por medio de una\nventana emergente y su navegador no lo permite.\nPor favor deshabilite su bloqueador de Pop-Pup')}
}
//=============================================================
//==== 
//=============================================================
function mostrar_msn (mensaje,x,y)
{
	mensaje = "<div COLOR='#000000' style='BACKGROUND-COLOR: #9BED8F;FONT-SIZE: 11px;BORDER-TOP: black 1px dotted;BORDER-RIGHT: black 1px dotted;BORDER-LEFT: black 1px dotted;BORDER-BOTTOM: black 1px dotted;'>&nbsp;" + mensaje
	mensaje = mensaje + "&nbsp;</div>"
	document.getElementById("mensaje_dinamico").innerHTML = mensaje
	mensaje_dinamico.style.display = 'inline'
	if (x==0 || y==0)
	{
		mensaje_dinamico.style.left=document.body.scrollLeft+event.clientX+15
		mensaje_dinamico.style.top=document.body.scrollTop+event.clientY-20
	}
	else
	{
		mensaje_dinamico.style.left=document.body.scrollLeft+event.clientX+(x)
		mensaje_dinamico.style.top=document.body.scrollTop+event.clientY+(y)
	}
}
//=====================================================
// =====
//=====================================================
function ocultar_msn ()
{
	mensaje_dinamico.style.display = 'none'
}
//=============================================================
//==== 
//=============================================================
function comp_mail(texto)
{
	//expresion regular
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
	
	//lanza ventana de cofirmacion y devuelve a pagina anterior		
	if ( (b.test(texto.value))==false)
	{
		//alert('E-mail no válido. Introduzca uno válido.')
		return false
	}
	else
		return true
}
//=============================================================
//==== 
//=============================================================
function verificar_longitud (campo, tamano)
{
	if (campo.value.length >= tamano)
	{
		alert('Ha llegado el límite de Caracteres')
		return false;
	}
	else
		window.status = "Has escrito = "+(campo.value.length+1)+" caracteres de "+tamano+" disponibles"
	return true;
}
//=============================================================
//==== 
//=============================================================
function borrar_formulario ()
{
	document.forma.nombre.value=""
	document.forma.mail_cont.value=""
	document.forma.mensaje.value=""
}
//=============================================================
//==== 
//=============================================================
function expandir_contraer(sec)
{
     thisSec = eval(sec);

     if (thisSec != null){
          if (thisSec.length){
               if (thisSec[0].style.display != 'none'){
                    for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'none'}
               }
               else{
                    for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'inline'}
               }
          }
          else{
                         if (thisSec.style.display != 'none')     {thisSec.style.display = 'none'}
               else{thisSec.style.display = 'inline'}
          }
     }
}
//=============================================================
//==== valida sucripcion de mail
//=============================================================
function suscribir ()
{
	if (document.forma_susc.nombre.value=="")
		alert('Para suscribirse debe llenar el campo de nombre.')
	else if (document.forma_susc.mail.value=="")
		alert('Para suscribirse debe llenar el campo de e-mail.')
	else if (comp_mail(document.forma_susc.mail)==false)
		{}
	else
		document.forma_susc.submit();
}
//=============================================================
//==== 
//=============================================================
function eliminar_usuario (id)
{
	if (confirm ('Esta seguro de eliminar el usuario seleccionado?')) 
		document.location = '../include/ejecutar.asp?accion=eliminar_usuario&id='+id+'&regresar=usuario.asp'
}
//=============================================================
//==== 
//=============================================================
function comprobar_lleno ()
{
	if (document.forma_crear_usuario.login.value=="" || document.forma_crear_usuario.password.value=="")
	{	
		alert('Debe llenar el Login y Password para crear un usuario')
		return false
	}
}
//=============================================================
//==== previsualiza la marquesina
//=============================================================
function previsualizar ()
{
/*
editableAreaName = 'texto'
valor='fer'
	if (document.designMode) {
		// Explorer reformats HTML during document.write() removing quotes on element ID names
		// so we need to address Explorer elements as window[elementID]
		if (window[editableAreaName])
			window[editableAreaName].document.body.innerHTML = valor;
		else
			document.getElementById(editableAreaName).contentWindow.document.body.innerHTML = valor;
	} else {
		// return the value from the <textarea> if document.designMode does not exist
		document.getElementById(editableAreaName).value = valor;
	}
*/	
	
	
	ieslider1.innerHTML = LTrim (editableAreaContents('texto'))
	alert ('Recuerde que podrá observar lo escrito en la marquesina que se encuentra en la derecha.\npara volver a mostrarlo presione previsualizar')
}
//=============================================================
//==== 
//=============================================================
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}
//=============================================================
//==== 
//=============================================================
function enviar_marquesina ()
{
	document.forma_marquesina.action = "../include/ejecutar.asp?accion=crear_marquesina"
	document.forma_marquesina.texto_enviar.value = LTrim (editableAreaContents('texto'))
	document.forma_marquesina.submit();
}
//=============================================================
//==== 
//=============================================================
function Asc(CHARACTER){

var charac = eval ("'"+ CHARACTER + "'");

//alert(charac);
return eval(charac.charCodeAt(0));

}
//=============================================================
//==== accesa a la pagina ade administracion
//=============================================================
function accesar ()
{
	if (document.forma_login.login.value=="")
		alert('Para accesar rellene el campo de Login')
	else if (document.forma_login.password.value=="")
		alert('Para accesar rellene el campo de Password')
	else
		document.forma_login.submit();
}
//=============================================================
//==== previsualiza texto de eventos
//=============================================================
function previsualizar_evento ()
{
	document.forma_evento.texto_enviar.value=leer_area('textarea_evento')
	if (document.forma_evento.texto_enviar.value=='' || document.forma_evento.titulo.value=='')
	{
		alert('No puede previsualizar textos ni títulos en blanco')
		return false;
	}
	var WinWidth=700;
	var WinHeight=400;
	var winLeft = 350;
	var winUp = 150;
	var WinOptions="menubar=no,location=no,status=yes,toolbar=no,scrollbars=yes,titlebar=no,resizable=yes,width="+WinWidth+",height="+WinHeight+",top="+winUp+",left="+winLeft;
	winUpDetalle = window.open("about:blank","test_evento",WinOptions);
	document.forma_evento.texto_enviar.value=leer_area('textarea_evento')
	document.forma_evento.action="preview.asp"
	document.forma_evento.target="test_evento"
	document.forma_evento.submit();
}
//=============================================================
//==== envia a guardar el texto de tabla insertado
//=============================================================
function enviar_texto_tablas ()
{
	document.forma_evento.texto_enviar.value=leer_area('textarea_evento')
	if (document.forma_evento.texto_enviar.value=='' || document.forma_evento.titulo.value=='')
	{
		alert('No puede insertar textos ni títulos en blanco')
		return false;
	}
	document.forma_evento.action="../include/ejecutar.asp?accion=insertar_texto_tabla"
	document.forma_evento.target="_self"
	document.forma_evento.submit();
}
//=============================================================
//==== 
//=============================================================
function eliminar_mensaje (id)
{
	if (confirm('Esta seguro de eliminar este mensaje?'))
		document.location = '../include/ejecutar.asp?accion=eliminar_mensaje&regresar=tabla.asp&id='+id
}
//=============================================================
//==== 
//=============================================================
function modificar_texto_tablas ()
{
	document.forma_evento.texto_enviar.value=leer_area('textarea_evento')
	if (document.forma_evento.texto_enviar.value=='' || document.forma_evento.titulo.value=='')
	{
		alert('No puede insertar textos ni títulos en blanco')
		return false;
	}
	document.forma_evento.action="../include/ejecutar.asp?accion=modificar_texto_tabla"
	document.forma_evento.target="_self"
	document.forma_evento.submit();
}
//=============================================================
//==== 
//=============================================================
function Solo_numeros(fld, milSep, decSep, e, longitud_max)
{
	
	if ( (fld.value.length) == (longitud_max) )
		return false;
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	len = fld.value.length;
		for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
			aux = '';
		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
			aux += key;
	len = aux.length;
	if (len == 0) fld.value = '';
	if (len == 1) fld.value = decSep + aux;
	if (len == 2) fld.value = decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
	}
	fld.value = '';
	len2 = aux2.length;
	for (i = len2 - 1; i >= 0; i--)
	fld.value += aux2.charAt(i);
	fld.value += decSep + aux.substr(len - 2, len);
	}
	return false;
}
//=============================================================
//==== 
//=============================================================
function crear_encuesta ()
{
	if (document.forma_encuesta.pregunta.value=="")
	{
		alert('No puede crear una encuesta sin colocar la pregunta')
		return false;
	}

	
	var campo; opci_macadas = 0
	for (i=1; i!=9; i++)
	{
		campo = eval ("document.forma_encuesta.opci_"+i)
		if (campo.value!="")
			opci_macadas++
	}
	if (opci_macadas==0)
	{
		alert('No puede crear una encuesta sin colocar respuesta')
		return false;
	}

	if (confirm('Esta usted seguro de crear la encuesta?\nUsted a ingresado '+opci_macadas+' posibles respuestas.'))
		document.forma_encuesta.submit();
}
//=============================================================
//==== 
//=============================================================
function enviar_contacto ()
{
	if (document.forma.nombre.value=="")
		alert('Ingrese su nombre')
	else if (comp_mail(document.forma.mail_cont)==false)
		alert('Ingrese un correo electronico válido')
	else if (document.forma.mensaje.value=="")
		alert('Ingrese el mensaje que desea comunicarnos')
	else
		document.forma.submit();
}
//=============================================================
//==== 
//=============================================================
function responder_encuesta ()
{
	var campo, respondio = false;
	for (i=0;i!=document.forma_responder_encuesta.opcion_encuesta.length;i++ )
	{
		if (document.forma_responder_encuesta.opcion_encuesta[i].checked==true)
			respondio = true
	}

	if (respondio)
		document.forma_responder_encuesta.submit();
	else
		alert('Para realizar la Votación debe seleccionar alguna de las respuesta.')
}
//=============================================================
//==== 
//=============================================================
function crear_evento ()
{
	if (document.forma_evento.nombre.value=="" || document.forma_evento.descripcion.value=="" || document.forma_evento.orde.value=="")
		alert('Para crear/modificar un evento debe rellenar los campos de Nombre,Descipcion y Orden')
	else
		document.forma_evento.submit();
}
//=============================================================
//==== enviar mail
//=============================================================
function enviar_mail ()
{
	document.forma_envio_mail.cuerpo.value=leer_area('textarea_mensaje')
	document.forma_envio_mail.submit();
}
//=============================================================
//==== 
//=============================================================


//=============================================================
//==== 
//=============================================================
