/* *****************************************************************************
   *                           js/main.js                                      *
   * ========================================================================= *
   * Software                 :  eurocamping.es                                *
   *                          :  infocamping.es                                *
   *                          :  ecamping.es                                   *
   *                          :  e-camping.es                                  *
   *                          :  mundocaravaning.com                           *
   * Software Version         :  5.0                                           *
   * Software by              :  JacSoft                                       *
   * Copyright 2005-2008 by   :  (c) 2008 José Antonio Cabetas Aliaga          *
   * E-Mail                   :  admin@cabetas.org                             *
   * ------------------------------------------------------------------------- *
   * Descripción              |  Funciones JavaScript                          *
   * ------------------------------------------------------------------------- *
   * Fecha:                      1 de Agosto de 2008                           *
   ***************************************************************************** */



/******************************************************************************
* Abrir una ventana popup                                                     *
******************************************************************************/

newWin = null;


function checkWin() {
	if (newWin && newWin.open && !newWin.closed) { newWin.close(); }
}


function showWin(url,name,bar,loc,menu,scroll,width,height,posx,posy) {
	if (newWin && newWin.open && !newWin.closed) { newWin.close(); }
    	var str = "'toolbar=" + bar + ",location=" + loc + ",directories=0,status=1,menubar=" + menu + ",scrollbars="
		+ scroll + ",resizable=1,copyhistory=0,width=" + width + ",height=" + height + ",left"
		+ posx + ",top=" + posy + "'\"";
    	newWin = window.open(url,name,str);
}

/******************************************************************************
* Leer la fecha del cliente                                                   *
******************************************************************************/
hoy     = new Date();
dia     = hoy.getDay();
dd      = hoy.getDate();
mm      = hoy.getMonth();
aa      = hoy.getYear();
dias    = new Array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado');
meses   = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');

if (aa < 200)
  aa = aa + 1900;

/******************************************************************************
* Calcular días que faltan hasta la expo: 14/06/2008                          *
******************************************************************************/

hoyz    = new Date(aa,mm+1,dd)
hasta   = new Date(2008,06,14)

if (hasta.getTime() < hoyz.getTime()) {
  hasta.setYear(hasta.getFullYear()+1)
}

function convierteaDias(inTime) {
  return (Math.floor(inTime.getTime() / (1000 * 60 * 60 * 24)))
}
function calcularDiasHasta(inDate) {
  return convierteaDias(inDate) - convierteaDias(hoyz)
}
numdias = calcularDiasHasta(hasta)

/******************************************************************************
* Escribe la barra de estado del cliente                                      *
******************************************************************************/
var current = 0;
var posx = 0;
var speed = 100;
var back = 20;
var speed2 = 2000;
var back2 = 1500;

function initArray(n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = " ";
  }
}

msg = new initArray(3);
msg[0]="Bienvenido a nuestro Portal Campista";
msg[1]="Queremos ayudarte a conocer todas las posibilidades que ofrece el mundo del camping y del caravaning";
msg[2]="Gracias por visitar nuestro portal";

function writeStatus() {
  var m = msg[current];
  window.status = m.substring(0, posx++);
  if (posx == m.length + 1) {
    setTimeout("erase()", back2);
  }
  else {
    setTimeout("writeStatus()", speed);
  }
}

function erase() {
  var m = msg[current];
  window.status = m.substring(0, posx--);
  if (posx < 0) {
    current++;
    setTimeout("writeStatus()", speed2);
    if (current > msg.length - 1) {
      current = 0;
    }
  }
  else {
    setTimeout("erase()", back);
  }
}

writeStatus();
