var IE=document.all?true:false;
if(IE)
{
	var AltoPantalla = screen.Height / 2;
	var AnchoPantalla = screen.Width / 2;
}
else
{
	var AltoPantalla=screen.height / 2;
	var AnchoPantalla=screen.width / 2;
}
var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;

function AbrePopup(Ruta, Nombre, Ancho, Alto) {
	var AltoMostrar = AltoPantalla - (Alto / 2);
	var AnchoMostrar = AnchoPantalla - (Ancho / 2);
	var PopUpW = window.open(Ruta, Nombre, "width=" + Ancho + ", height=" + Alto + ", top=" + AltoMostrar + ", left=" + AnchoMostrar + ", scrollbars=yes, titlebar=no, menubar=no, directories=no, status=no, location=no");
	PopUpW.focus();
	return false;
}
function cargaPagina(url,div,parametros)
{
	//$(div).innerHTML = '';
	//clearTimeout(cambio);
	parametros += '&Ajax=1';
	//new Ajax(url,{method: 'post', postBody:parametros, update:div}).request();
	
	new Request(
	{
		method: 'post',
		url: url,
		onSuccess: function(texto){
		$(div).innerHTML = texto;}
	}).send(parametros);	
}
function mail_valido(cadena)
{
	var b=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;	
	if (!b.test(cadena))
		return false;
	return true;
}
function telefono_valido(numero)
{
	var tfno= parseInt(numero);
	var error = "";
	if ( isNaN(tfno) )
		error="q";
	else
	{
		if ( !( (tfno >= 900000000) && (tfno < 1000000000) || (tfno >= 600000000) && (tfno < 700000000) ) )  
			error="q";
	}
	if(error == "")
		return true;
	return false;
}
function validaCodigoPostal(CP)
{
	if(CP == "" || isNaN(CP) || CP < 1000 || CP > 52999)
		return false;
	return true;
}
function iluminaMenuSup(cual, tipo)
{
	var menuSel = $('menuSel').value;
	var total = $('menuTotal').value;
	for(var i = 0; i<= total; i++)
	{
		switch(tipo)
		{
			case 0: //mouseout
				if(i == menuSel)
					$('menuSup_' + i).className = 'div_caja_menu_sup_click';
				else
					$('menuSup_' + i).className = 'div_caja_menu_sup';
				break;
			case 1: //mouseover
				if(i == cual)
					$('menuSup_' + i).className = 'div_caja_menu_sup_over';
				else if(i == menuSel)
					$('menuSup_' + i).className = 'div_caja_menu_sup_click';
				else
					$('menuSup_' + i).className = 'div_caja_menu_sup';
				break;
			case 2:
				if(i == cual)
				{
					$('menuSel').value = cual;
					$('menuSup_' + i).className = 'div_caja_menu_sup_click';
					if(cual == 0 || cual == 5 || cual == 6)
					{
						$('div_central').innerHTML = '';
						$('menu_lateral').style.display = 'none';
						$('div_central').style.width = '1100px';
					}
					else
					{
						$('menu_lateral').style.display = 'inline';
						$('div_central').style.width = '880px';
						cargaPagina('/includes/menu.php', 'menu_lateral', 'menuSeleccionado=' + cual)
					}
				}
				else
					$('menuSup_' + i).className = 'div_caja_menu_sup';
				break;
		}
	}
}

var toggleActual = '';
var	mySlideEquipo;
var	mySlideNoticias;
function abreSubMenu(a,e)
{
	$(a).setStyle("display","block");
	
	if(toggleActual!="" && toggleActual!=a)
	{
		ocultaSubMenu();
		toggleActual=a
	}
	else if(toggleActual==a)
		toggleActual="";
	else
		toggleActual=a;
	eval("mySlide"+a+".toggle();")
	var o = document.getElementById(a);
	o.parentNode.setStyles({ float : 'left', width : 220});

}
function ocultaSubMenu()
{
	eval("mySlide"+toggleActual+".slideOut();")
}

var mySlideArray = new Array(10);
for(i = 0; i<= 10; i++)
{
	mySlideArray[i] = new Array(20);
	for(j=-1; j<=20; j++)
	{
		mySlideArray[i][j] = '';
	}
}
		
var	indiceActual = '';
var	subindiceActual = '';
var toggleActualDin = '';
function abreSubMenuDinamico(i,j,e)
{
	var a = 'div_T' + i
	if(j != -1)
		a += '_C_' + j;
	if($(a))
		$(a).setStyle("display","block");	
	if(toggleActualDin!="" && toggleActualDin!=a)
	{
		if(i != indiceActual)
			ocultaSubMenuDinamico(0);
		else if(subindiceActual != -1)
			ocultaSubMenuDinamico(1);
		indiceActual = i;
		subindiceActual = j;
		toggleActualDin=a
	}
	else if(indiceActual == i && subindiceActual == j)
	{
		if(j == -1)
		{
			indiceActual = "";
			subindiceActual = "";
			toggleActualDin = '';
		}
		else
		{
			subindiceActual = -1;
			toggleActualDin = 'div_T' + i;
		}
	}
	else
	{
		indiceActual = i;
		subindiceActual = j;
		toggleActualDin=a
	}
	if(mySlideArray[i][j] != '')
		eval("mySlideArray["+i+"]["+j+"].toggle();")
	if($(a))
	{
		var o = document.getElementById(a);
		o.parentNode.setStyles({ float : 'left', width : 220});
	}
	if(j != -1)
	{
		//eval("mySlideArray["+i+"][-1].show();")
		var o = document.getElementById('div_T' + i);
		o.parentNode.setStyles({ height: 'auto' });
	}
}

function ocultaSubMenuDinamico(tipo)
{
	if(indiceActual != '')
	{
		if(tipo == 1)
			eval("mySlideArray["+indiceActual+"]["+subindiceActual+"].slideOut();")
		else
		{
			for(j=-1; j<=20; j++)
			{
				if(mySlideArray[indiceActual][j] != '')
				eval("mySlideArray["+indiceActual+"]["+j+"].slideOut();")	
			}
		}
	}
}

function cierraMenu()
{
	toggleActual = 'Trayectoria';
	ocultaSubMenu();
	toggleActual = 'InstitutoBelleza';
	ocultaSubMenu();
	toggleActual = 'InstitutoMedicina';
	ocultaSubMenu();
	toggleActual = 'Comunicacion';
	ocultaSubMenu();
	toggleActual = 'ParaEl';
	ocultaSubMenu();
}
function iluminaSubmenu(id)
{
	$(id).style.backgroundColor='#a2734b';
	$(id).style.color='#000000';
}
function apagaSubmenu(id)
{
	$(id).style.backgroundColor='#000000';
	$(id).style.color='#a2734b';
}
function iluminaTexto(id)
{
	$(id).style.color='#996c46';
}
function apagaTexto(id)
{
	$(id).style.color='#FFFFFF';
}
function enviaContacto()
{
	if($('nombre').value == '')	
	{
		alert('Indique el nombre');
		$('nombre').focus();
		return false;
	}
	if($('apellidos').value == '')	
	{
		alert('Indique los apellidos');
		$('apellidos').focus();
		return false;
	}
	if($('email').value == '' || !mail_valido($('email').value))	
	{
		alert('La dirección de e-mail introducida no es válida');
		$('email').focus();
		return false;
	}
	if($('telefono').value == '' || !telefono_valido($('telefono').value))	
	{
		alert('El teléfono introducido no es válido');
		$('telefono').focus();
		return false;
	}
	if($('ciudad').value == '')	
	{
		alert('Indique la ciudad.');
		$('ciudad').focus();
		return false;
	}
	if($('comentarios').value == '')	
	{
		alert('Indique sus cometarios');
		$('comentarios').focus();
		return false;
	}	
	if(!$('chbox').checked)	
	{
		alert('Debe aceptar la política de privacidad del servicio y el aviso legal. ');
		$('chbox').focus();
		return false;
	}	
	//if(confirm('¿Desea enviar esta consulta?'))
	//cargaPagina('/envia_contacto.php', 'div_envio', 'nombre=' + $('nombre').value + '&apellidos=' + $('apellidos').value + '&mail=' + $('mail').value + '&telefono=' + $('telefono').value + '&comentarios=' + $('comentarios').value + '&ruta=' + $('ruta').value);
	document.form_contacto.submit();
}
function enviaTrabaja()
{
	if($('nombre').value == '')	
	{
		alert('Indique el nombre');
		$('nombre').focus();
		return false;
	}
	if($('edad').value == '')	
	{
		alert('Indique la edad');
		$('edad').focus();
		return false;
	}
	if($('telefono').value == '' || !telefono_valido($('telefono').value))	
	{
		alert('El teléfono introducido no es válido');
		$('telefono').focus();
		return false;
	}
	if($('email').value == '' || !mail_valido($('email').value))	
	{
		alert('La dirección de e-mail introducida no es válida');
		$('email').focus();
		return false;
	}
	if($('trabajos').value == '')	
	{
		alert('Indique sus trabajos');
		$('trabajos').focus();
		return false;
	}

	//alert(cadena[max]);
	if($('doc_adjunto').value != '')
	{
		corte = $('doc_adjunto').value;
		cadena = corte.split('.');
		if(cadena[1] != 'doc' && cadena[1] != 'docx' && cadena[1] != 'pdf')
		{
			alert('El archivo que intenta adjuntar no es válido.');
			$('doc_adjunto').focus();
			return false;
		}
	}

	if(!$('chbox').checked)
	{
		alert('Debe aceptar la política de privacidad del servicio y el aviso legal. ');
		$('chbox').focus();
		return false;
	}
	//if(confirm('¿Desea enviar esta consulta?'))
	//cargaPagina('/envia_contacto.php', 'div_envio', 'nombre=' + $('nombre').value + '&apellidos=' + $('apellidos').value + '&mail=' + $('mail').value + '&telefono=' + $('telefono').value + '&comentarios=' + $('comentarios').value + '&ruta=' + $('ruta').value);
	document.form_trabaja.submit();
}
function AbrePopupConScroll(Ruta, Nombre, Ancho, Alto) 
{
	var AltoMostrar = AltoPantalla - (Alto / 2);
	var AnchoMostrar = AnchoPantalla - (Ancho / 2);	
	var PopUpW = window.open(Ruta, Nombre, "width=" + Ancho + ", height=" + Alto + ", top=" + AltoMostrar + ", left=" + AnchoMostrar + ", scrollbars=yes, titlebar=no, menubar=no, location=no");
	PopUpW.focus();
	return false;
}

var cambio;
var homeActual = 1;
function cargaHome()
{
	/*for(i = 2; i<= 5; i++)
	{
		//$('home' + i).fade(0);
	}
	cambio = setTimeout("cambiaHome()", 6000);*/
}
function cambiaHome()
{
	clearTimeout(cambio);
	var nuevaHome = homeActual + 1;
	if(nuevaHome > 5)
		nuevaHome = 1;
	
	//var myFx1 = new Fx.Tween($('home' + nuevaHome), [, options]);
	//var myFx2 = new Fx.Tween($('home' + homeActual), [, options]);
	//myFx1.set('opacity', {duration: 2000}).start(0);
    //myFx2.set('opacity', {duration: 2000}).start(1);
	$('home' + nuevaHome).style.visibility = 'visible';
	$('home' + homeActual).fade(0);
	$('home' + nuevaHome).fade(1);	
	
	homeActual = nuevaHome;
	cambio = setTimeout("cambiaHome()", 6000);
}
function calculaIfr()
{
	if($('ifr_blog'))	
	{
		var alto = parseInt(window.getHeight()) - 115 - 30;
		var ancho = parseInt(window.getWidth());
		//alert(alto)	
		$('ifr_blog').style.height = alto + 'px';
		$('ifr_blog').style.width = ancho + 'px';
	}
}

function ComprobarForm()
{
	error = "";

	if($('nombre').value == '')	
	{
		alert('Indique el nombre');
		$('nombre').focus();
		return false;
	}
	if($('email').value == '' || !mail_valido($('email').value))	
	{
		alert('La dirección de e-mail introducida no es válida');
		$('email').focus();
		return false;
	}
	if($('telefono').value == '' || !telefono_valido($('telefono').value))	
	{
		alert('El teléfono introducido no es válido');
		$('telefono').focus();
		return false;
	}
	if($('ciudad').value == '')	
	{
		alert('Indique la ciudad.');
		$('ciudad').focus();
		return false;
	}
	if($('comentarios').value == '')	
	{
		alert('Indique sus cometarios');
		$('comentarios').focus();
		return false;
	}
	if(!$('condiciones').checked)	
	{
		alert('Debe aceptar la política de privacidad del servicio y el aviso legal. ');
		$('condiciones').focus();
		return false;
	}

	document.form_peq.submit();
		//cargaPagina('/envia_contacto.php', 'div_envio', 'nombre=' + $('nombre').value + '&email=' + $('email').value + '&telefono=' + $('telefono').value + '&comentarios=' + $('comentarios').value + '&ruta=' + $('ruta').value);
}

function cargaMapa() {
	if (GBrowserIsCompatible()) {
	  var map = new GMap2(document.getElementById("map"));
	var geocoder = new GClientGeocoder();
	//var address = $('direccion').value;
	var address = "Paseo de la Castellana 114 28046 Madrid";
	var texto = "Institutos Maribel Yébenes";
	var LatLng = new GLatLng(geocoder.getLatLng(
		address,
		function(point) {
		  if (!point) {
			alert(address + " not found");
		  } else {
			map.setCenter(point, 15);
			var blueIcon = new GIcon(G_DEFAULT_ICON);
			//blueIcon.image = "http://";
			markerOptions = { icon:blueIcon }
			var marker = new GMarker(point, markerOptions);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(address);
			//var myHtml = "<center><font style='font-size: 14px;'>" + texto + "</font></center>";
			//map.openInfoWindowHtml(point, myHtml);
		  }
		}
	  )
	);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	//map.setCenter(LatLng);
	}
}

//--------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------//
var cambioFoto;
var fotoActual = 1;
function cargaFotos()
{
	for (var i = 2; i<=2; i++)
	{
		//$('foto' + i).fade(0);
		//$('foto' + i).style.visibility = 'hidden';
	}
	cambioFoto = setTimeout("cambiaFoto()", 5000);
}
//--------------------------------------------------------------------------------------------//
function cambiaFoto()
{
	clearTimeout(cambioFoto);
	var nuevaFoto = fotoActual + 1;
	if(nuevaFoto > 2)
		nuevaFoto = 1;
	
	//var myFx1 = new Fx.Tween($('texto' + nuevaFoto), [, options]);
	//var myFx2 = new Fx.Tween($('texto' + fotoActual), [, options]);
	//myFx1.set('opacity', {duration: 2000}).start(0);
    //myFx2.set('opacity', {duration: 2000}).start(1);
	//$('foto' + nuevaFoto).style.visibility = 'visible';
	$('foto' + fotoActual).fade(0);
	$('foto' + nuevaFoto).fade(1);	
	
	fotoActual = nuevaFoto;
	cambioFoto = setTimeout("cambiaFoto()", 5000);
}
//--------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------//
