// Funciones Comunes en el Portal de Bossdport Spa

// Set slideShowSpeed (milliseconds)
var SlideShowSpeed = 3000

// Duration of crossfade (seconds)
var crossFadeDuration = 4

// Especifica las imágenes a rotar
var Pic = new Array() 

Pic[0] = '../imagenes/fotospa.jpg'
Pic[1] = '../imagenes/recepcion.jpg'
Pic[2] = '../imagenes/fotocardio.jpg'
Pic[3] = '../imagenes/fotospa.jpg'
Pic[4] = '../imagenes/fotomusculacion.jpg'
Pic[5] = '../imagenes/fotospa.jpg'
Pic[6] = '../imagenes/fotospa.jpg'

function ventanaSecundaria (URL){ 
window.open(URL,"ventana1","width=400, height=500, scrollbars=no, menubar=no, location=no, resizable=no") 
} 
function ventanapromo (URL){ 
window.open(URL,"ventana1","width=400, height=200, scrollbars=no, menubar=no, location=no, resizable=no") 
} 
/*
function ventanapromo2 (URL){ 
window.open(URL,"ventana1","width=300, height=300, scrollbars=no, menubar=no, location=no, resizable=no") 
} */
function anuncio (URL){ 
window.open(URL,"ventana1","width=500, height=350, scrollbars=no, menubar=no, location=no, resizable=no") 
} 
function ventanapromo2 (URL){ 
window.open(URL,"ventanapromo","width=250, height=300, scrollbars=no, menubar=no, location=no, resizable=no") 
} 
function mapa (URL){ 
window.open(URL,"ventana1","width=550, height=450, scrollbars=no, menubar=no, location=no, resizable=no") 
} 

function Abrir_ventana (pagina) {
var opciones="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=100,height=220,top=5,left=10";
window.open(pagina,"",opciones);
}
/*
function mapa (pagina) {
var opciones="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=550,height=425,top=5,left=10";
window.open(pagina,"donde estamos",opciones);
}
*/

var t
var j = 0
var p = Pic.length


var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}



function runSlideShow(z){
   if (document.all){
      eval('document.images.SlideShow' + z + '.style.filter="blendTrans(duration=1)"');
      eval('document.images.SlideShow' + z + '.style.filter="blendTrans(duration=crossFadeDuration)"');
      eval('document.images.SlideShow' + z + '.filters.blendTrans.Apply()');      
   }
   eval('document.images.SlideShow' + z + '.src = preLoad[j].src');
   if (document.all){
      eval('document.images.SlideShow' + z + '.filters.blendTrans.Play()');
   }
   //eval('document.getElementById("link0").href = alink[' + j +']');
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow('+z+')', SlideShowSpeed);
}

function runSlideShow2(s){
   if (document.all){
      eval('document.images.SlideShow' + s + '.style.filter="blendTrans(duration=1)"');
      eval('document.images.SlideShow' + s + '.style.filter="blendTrans(duration=crossFadeDuration)"');
      eval('document.images.SlideShow' + s + '.filters.blendTrans.Apply()');      
   }
   eval('document.images.SlideShow' + s + '.src = preLoad[j].src');
   if (document.all){
      eval('document.images.SlideShow' + s + '.filters.blendTrans.Play()');
   }
   //eval('document.getElementById("link0").href = alink[' + j +']');
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow('+s+')', SlideShowSpeed);
}


//Site wide javascript

//is the browser IE5.5 or IE6?
IE5_6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.5")!=-1)) || ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;


imgCounter = 0
pageImages = new Array(12);
pageImages[0] = "http://www.bossdportspa.com/talavera/home/images/img_01.jpg"
pageImages[1] = "http://www.bossdportspa.com/talavera/home/images/img_02.jpg"
pageImages[2] = "http://www.bossdportspa.com/talavera/home/images/img_03.jpg"
pageImages[3] = "http://www.bossdportspa.com/talavera/home/images/img_04.jpg"
pageImages[4] = "http://www.bossdportspa.com/talavera/home/images/img_05.jpg"
pageImages[5] = "http://www.bossdportspa.com/talavera/home/images/img_06.jpg"
pageImages[6] = "http://www.bossdportspa.com/talavera/home/images/img_07.jpg"
pageImages[7] = "http://www.bossdportspa.com/talavera/home/images/img_08.jpg"
pageImages[8] = "http://www.bossdportspa.com/talavera/home/images/img_09.jpg"
pageImages[9] = "http://www.bossdportspa.com/talavera/home/images/img_10.jpg"
pageImages[10] = "http://www.bossdportspa.com/talavera/home/images/img_11.jpg"
pageImages[11] = "http://www.bossdportspa.com/talavera/home/images/img_12.jpg"

function rollFeatImg(i) {
	//reset counter if neccessary
	if (i >= pageImages.length) {
		currentImg = 0
	}else{
		currentImg = i
	}
	
	//apply the filter if IE5/6
	if(IE5_6) {
		document.images["featImg"].filters[0].Apply()
	}
	
	//flip the image
	document.images["featImg"].src = pageImages[currentImg]
	
	//play the filter if IE5/6
	if(IE5_6) {
		document.images["featImg"].filters[0].Play()
	}
	//call self with time delay
	setTimeout("rollFeatImg(currentImg+1)", 3000)
}

//var currentimg = 1;
var imgcount = 4;
var imgpath = "http://www.bossdportspa.com/talavera/home/images/index.html";
var imgext = ".jpg";
var imgCounter1 = 1;
var imgCounter2 = 1;
var imgCounter3 = 1;
var minTime = 2000;
var maxTime = 5000;
if (typeof(iList) == "undefined") var iList = "";
if (typeof(iDir) == "undefined") var iDir = "http://www.bossdportspa.com/talavera/home/images/index.html";
if (typeof(iExt) == "undefined") var iExt = "gif";
	
function rand() {
	delay = Math.round(Math.random() * maxTime) + minTime;
	return delay;
}


function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function countChars(caller, reciever) {
	caller = eval('document.form.' + caller);
	reciever = eval('document.form.' + reciever);
	reciever.value = caller.value.length;
	if (reciever.value > 500) {
		alert("Too long!");
	}
}

var d = document;
var iA = iList.split(',');
if 	(d.images) { 
	var iO = new Array();
	for	(j = 0; j < iA.length; j++) {
		iO[j] = new Image();
		iO[j].src = iDir + iA[j] + "b." + iExt;
	 	}
	}
	
function 	out(iName,newDir,newType) { 
			i = eval("d." + iName);
			i.src = iDir + iName + "a." + iExt;
			}
			
function 	over(iName,newDir,newType) { 
			i = eval("d." + iName);
			i.src = iDir + iName + "b." + iExt;
			}
			
/* Cambia la imagen a restaurar	 */
	function swapImgRestore() { 
		var i;
		var x;
		var a=document.sr; 
		for (i=0; a && i < a.length && (x=a[i]) && x.oSrc; i++) {
			x.src=x.oSrc;
		}
	}

	
	function preloadImages() { 
		var d=document; 
		if (d.images) { 
			if (!d.p) {
				d.p=new Array();
			}
			var i;
			var j=d.p.length;
			var a=preloadImages.arguments; 
			for(i=0; i<a.length; i++) {
				if ( a[i].indexOf("#")!=0) { 
					d.p[j]=new Image; 
					d.p[j++].src=a[i];
				}
			}
		}
	}

	

	function swapImage() {
		var i;
		var j=0;
		var x;
		var a=swapImage.arguments; 
		document.sr = new Array; 
		for (i=0; i<(a.length-2); i+=3) {
			if ((x=findObj(a[i]))!=null) {
				document.sr[j++]=x; 
				if(!x.oSrc) {
					x.oSrc=x.src; 
				}
				x.src=a[i+2];
			}
		}
	}
	
function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
	function showVisi(id) {
		var all = document.getElementsByTagName("ul");
		for (var loop=0; loop < all.length; loop++) {
			all[loop].style.display = "none";
		}
		document.getElementById(id).style.display = "block";
	}

	

function swapType(type){
	iExt = type;
}



	function Item(){
  this.length = Item.arguments.length 
  for (var i = 0; i < this.length; i++)
    this[i] = Item.arguments[i];
}



function Fecha() {
  var ndia  = new Item('Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado')
  var nmes  = new Item('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 
                          'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
  var ahora
  var fecha = new Date()
  var anno   = fecha.getYear()
  var mes   = fecha.getMonth()
  var dia   = fecha.getDay()
  var aux   = "" + fecha
  
  if (anno<10) {
    anno2 = "200" + eval(anno)
  }
  else if (anno<80) {                // anno tiene 2 dígitos 19xx (más de 80)
    anno2 = "20" + anno
  } 
  else if (anno<=99) {               // anno tiene 2 dígitos 20xx (menor de 80)
    anno2 = "19" + anno
  }
  else if (anno<1000) {              // anno tiene 3 dígitos (100 es 2000)
    anno2 = eval(anno) + eval(1900)
  }
  else {
    anno2 = anno                      // anno tiene 4 dígitos
  }
  ahora = ndia[dia] + ", " + eval(aux.substring(7, 10)) + " " + nmes[mes] + " " + anno2
  return ahora
}
/////////////////////////////////////////////////////////////////

function movstar(a,time){
	movx=setInterval("mov("+a+")",1)
	}
function movover(){
	clearInterval(movx)
	}
function mov(a){
	scrollx=win1.document.body.scrollLeft
	scrolly=win1.document.body.scrollTop
	scrolly=scrolly+a
	win1.window.scroll(scrollx,scrolly)
	}
function o_down(theobject){
object=theobject
	while(object.filters.alpha.opacity>60){
		object.filters.alpha.opacity+=-10}
		}
function o_up(theobject){
object=theobject
	while(object.filters.alpha.opacity<100){
		object.filters.alpha.opacity+=10}
		}
function wback(){
	if(new_date.history.length==0){window.history.back()}
	else{new_date.history.back()}
	}
	

function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="index.html"; 
      var titulo="bossdport Spa: Centro Deportivo Talavera";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Favoritos"); 
   }
} 


function Validar(form)
{
  if (form.nombre.value == "")
  { alert("Por favor introduce tu nombre"); form.nombre.focus(); return; }

  if (form.apellidos.value == "")
  { alert("Por favor introduce tus apellidos"); form.apellidos.focus(); return; }
 
  if (form.email.value == "")
  { alert("Por favor introduce tu dirección de e-mail"); form.email.focus(); return; }

  if (form.email.value.indexOf('@', 0) == -1 ||
      form.email.value.indexOf('.', 0) == -1)
  { alert("Dirección de e-mail inválida"); form.email.focus(); return; }

  if (form.telefono.value == "")
  { alert("Por favor introduce tu número de teléfono"); form.telefono.focus(); return; }
  
  var er_telefono = /^([0-9\s\+\-])+$/
  //comprueba campos de telefonos (permite campos vacios y guiones)
	if( !er_telefono.test(form.telefono.value) ) {
		alert('El Telefono no es válido.')
		form.telefono.focus(); return;
	}

  
  form.submit();
}
function Validar2(form)
{
  if (form.nombre.value == "")
  { alert("Por favor introduce tu nombre"); form.nombre.focus(); return; }

  if (form.apellidos.value == "")
  { alert("Por favor introduce tus apellidos"); form.apellidos.focus(); return; }
 
  if (form.email.value == "")
  { alert("Por favor introduce tu dirección de e-mail"); form.email.focus(); return; }

  if (form.email.value.indexOf('@', 0) == -1 ||
      form.email.value.indexOf('.', 0) == -1)
  { alert("Dirección de e-mail inválida"); form.email.focus(); return; }

  if (form.telefono.value == "")
  { alert("Por favor introduce tu número de teléfono"); form.telefono.focus(); return; }
    if (form.archivo.value == "")
  { 
  alert("Por favor introduce tu curriculum");  form.archivo.focus();   return;   }

  var er_telefono = /^([0-9\s\+\-])+$/
  //comprueba campos de telefonos (permite campos vacios y guiones)
	if( !er_telefono.test(form.telefono.value) ) {
		alert('El Telefono no es válido.');
		form.telefono.focus(); return;
	}

  
  form.submit();
}

function ValidarNumerico(cadena) {
var numeros="0123456789";
for (var i=0;i<cadena.length;i++) {
	if (numeros.indexOf(cadena.substring(i,i+1))==-1){
		alert("El campo seleccionado no es correcto");
		return false;
		}
	}
alert("El campo seleccionado es correcto");
return true;
}

