function buscaaereos(servidoraereo) {

var idavuelta = document.getElementsByName("aidavuelta");
var i;
var vidavuelta ;
for (var i = 0; i < idavuelta.length; i++) {
	if (idavuelta[i].checked == true) {
		vidavuelta  = (idavuelta[i].value);
	}    
}


	if (document.getElementById('aorigen').value=='') {
		alert("Debe especificar el origen.");
		document.getElementById('aorigen').focus();
		return false;			
	}
	if (document.getElementById('adestino').value=='') {
		alert("Debe especificar el destino.");
		document.getElementById('adestino').focus();
		return false;			
	}

	if (document.getElementById('afechaSalida').value=='') {
		alert("Debe especificar la fecha de salida.");
		document.getElementById('afechaSalida').focus();
		return false;			
	}

	if (vidavuelta=='RT') {
		if (document.getElementById('afechaRegreso').value=='') {
			alert("Debe especificar la fecha de regreso.");
			document.getElementById('afechaRegreso').focus();
			return false;			
		}
	}

	parametro ='origen='+document.getElementById('aorigen').value;
	parametro = parametro + '&destino='+document.getElementById('adestino').value;
	vdia = (document.getElementById('afechaSalida').value).substr(0,2)
	vmes = (document.getElementById('afechaSalida').value).substr(3,2);
	vano = (document.getElementById('afechaSalida').value).substr(6,4);
	parametro = parametro + '&diaFechaSalida='+vdia;
	parametro = parametro + '&mesFechaSalida='+vmes+vano;
	vdia = (document.getElementById('afechaRegreso').value).substr(0,2)
	vmes = (document.getElementById('afechaRegreso').value).substr(3,2);
	vano = (document.getElementById('afechaRegreso').value).substr(6,4);
	parametro = parametro + '&diaFechaRegreso='+vdia;
	parametro = parametro + '&mesFechaRegreso='+vmes+vano;
	parametro = parametro + '&journeyType='+vidavuelta;
	parametro = parametro + '&adultos='+document.getElementById('aadultos').value;
	parametro = parametro + '&ninos='+document.getElementById('aninos').value;
	parametro = parametro + '&bebes='+document.getElementById('abebes').value;
	//parametro ='origen=MADRID&destino=SEVILLA&diaFechaSalida=01&mesFechaSalida=042010&diaFechaRegreso=04&mesFechaRegreso=042010&journeyType=RT&adultos=1&ninos=0&bebes=0';
	muestraagencia('busquedaaereo',parametro, servidoraereo);
	return true;
}


function iFrameHeight(nombreframe) {
if(document.getElementById && !(document.all)) {
		h = document.getElementById(nombreframe.id).contentDocument.body.scrollHeight;
		document.getElementById(nombreframe.id).height = h + 0; // + 100
	}
	else if(document.all) {
		h = document.frames(nombreframe.id).document.body.scrollHeight;

//		document.all.iframename.style.height = h;
		document.getElementById(nombreframe.id).height = h + 0;		// + 50
	}
}

function muestraagencia(quemuestro, parametro, servidoraereo) {
	var vdiv='principal';
	var muestro = 'agencias/principalsuc.php';
	var ajustedealto = ' onLoad="iFrameHeight(this);"  scrolling="no" ';

	(quemuestro == "principal")			? muestro ='agencias/principalsuc.php' 	: null;	
	(quemuestro == "contacta")			? muestro ='agencias/contacta.php' 		: null;	
	(quemuestro == "boletines")			? muestro ='agencias/boletines.php' 		: null;	
	(quemuestro == "boletin")			? muestro ='agencias/boletin.php' 		: null;	
	(quemuestro == "servicios")			? muestro ='zonapublica/servicios.php' 		: null;	
	(quemuestro == "informacionoferta") ? muestro ='agencias/informacionoferta.php'		: null;	
	(quemuestro == "masofertas") 		? muestro ='agencias/masofertas.php'		: null;	
	(quemuestro == "masbuscados") 		? muestro ='agencias/masbuscados.php'		: null;	
	(quemuestro == "masbuscados") 		? muestro ='agencias/masbuscados.php'		: null;	
	(quemuestro == "ventaonline") 		? muestro ='agencias/ventaonline.php'		: null;	
	(quemuestro == "quemuestro ")		? muestro ='../boletin/enviamuestroboletin.php' :null;
	(quemuestro == "pidepassword")		? muestro ='agencias/pidepassword.php' 		:null;
	(quemuestro == "paquetes")			? muestro ='agencias/productospaquetes.php'	:null;
	(quemuestro == "vuelos")			? muestro ='agencias/vuelos.php'	:null;
	(quemuestro == "iberojet")			? muestro ='private/be/iberojet.php' 		:null;
	(quemuestro == "iberojet")			? ajustedealto =' height="850px"' 			:null;
	(quemuestro == "panelcontrol")		? muestro ='zonapublica/accesozonaprivada.php':null;
	(quemuestro == "hotelbds")			? muestro ='hoteles/index.php':null;
	(quemuestro == "hotelbds")			? muestro ='hoteles/index.php':null;
	(quemuestro == "aereosgi")			? muestro ='agencias/aereosgi.php':null;
	(quemuestro == "agencia")			? muestro ='zonapublica/accesozonaprivada.php'	:null;
if (quemuestro=="busquedaaereo") {
//origen=MADRID&destino=SEVILLA&diaFechaSalida=01&mesFechaSalida=042010&diaFechaRegreso=04&mesFechaRegreso=042010&journeyType=RT&adultos=1&ninos=0&bebes=0
	muestro = servidoraereo;
	ajustedealto =' height=800px ';
}

	// por si paso parametros
	(parametro)? muestro = muestro + parametro		: null;

//	parent.document.getElementById(vdiv).innerHTML ='<iframe id="iii'+vdiv+'" src="'+muestro+'" frameborder="0" marginheight="0" width="940px" '+ajustedealto+'></iframe>';
parent.document.getElementById(vdiv).innerHTML ='<iframe id="iii" src="'+muestro+'" frameborder="0" marginheight="0"  width="940px" '+ajustedealto+'></iframe>';

}

function reSizesucursal()
{
	try{	
	    var oBody	=	document.body;
	    var oFrame	=	document.getElementById("iii");


	    if(document.getElementById && !(document.all)) {
		h = oFrame.contentDocument.body.scrollHeight;
	    } else {
		h = document.frames('iii').document.body.scrollHeight;
	    }

	    oFrame.height = h;

	    w = oBody.scrollWidth - (oBody.scrollWidth - oBody.clientWidth);
	    
	    if (w < 940) {
		w = 940;
	    }
	    oFrame.width = w;

	}
	//An error is raised if the IFrame domain != its container's domain
	catch(e)
	{
	window.status =	'Error: ' + e.number + '; ' + e.description;
	}
}

function abrefichero (quemuestro){
var nombreframe = 'principal';
parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe id="ufprincipal"  src="'+quemuestro+'" width="95%"   height="800"  frameborder="0" scrolling="no" marginheight="0px" style="margin-left:15px" ></iframe>';

}

function abrezonaprivada (quemuestro, parametro){

var nombreframe ='crossbooking';
parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe width="0" frameborder="0" scrolling="no" marginheight="0px" height="0px" style="margin-left:0px" ></iframe>';
nombreframe = 'principal';

if (quemuestro == "Crosstour") {
	muestro = 'http://194.143.194.152:5849/forms/frmservlet?config=democross';
	(parametro)? muestro = parametro		: null;
	parent.document.getElementById('ifCrosstour').src = muestro;	
	return false;
}
if (quemuestro == "crossbooking") {
	nombreframe ='crossbooking';
	parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe id="ufprincipal"  src="crossbooking.php" width="100%" height="2500px" frameborder="0" scrolling="no" marginheight="0px" style="margin-left:0px" ></iframe>';
	nombreframe = 'principal';
	parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe width="100%" frameborder="0" scrolling="no" marginheight="0px" height="0px" style="margin-left:0px" ></iframe> ';
	return false;

}
var muestro='principal.php';
comandoalto = 'onLoad="iFrameHeight(this);"';
(quemuestro == "gestioneventos")	? comandoalto = '' : null;
(quemuestro == "mntomicrosite")	? comandoalto = '' : null;

(quemuestro == "actaccesoproveedor")? muestro ='../private/actualizaaccesoproveedor.php' 	: null;
(quemuestro == "buscaproveedores")	? muestro ='../lib/buscaproveedores.php'				: null;
(quemuestro == "fichaproveedor")	? muestro ='../lib/fichaproveedor.php'					: null;
(quemuestro == "bookingproveedor")	? muestro ='../lib/buscabookingfaxproveedor.php'		: null;
(quemuestro == "mntomicrosite")		? muestro ='../lib/presentaciondelegacion.php'			: null;
(quemuestro == "confgusuario")		? muestro ='configuracionusuario.php'					: null;
(quemuestro == "noticias")			? muestro ='../cpanel/listadonoticia.php'				: null;
(quemuestro == "editanoticia")		? muestro ='../cpanel/editanoticia.php'					: null;
(quemuestro == "ofertas")			? muestro ='../cpanel/listadooferta.php'				: null;
(quemuestro == "editaoferta")		? muestro ='../cpanel/editaoferta.php'					: null;
(quemuestro == "agencias")			? muestro ='../cpanel/listadoagencia.php'				: null;
(quemuestro == "editaagencia")		? muestro ='../cpanel/editaagencia.php'					: null;
(quemuestro == "proveedores")		? muestro ='../cpanel/listadoproveedor.php'				: null;
(quemuestro == "editaproveedor")	? muestro ='../cpanel/editaproveedor.php'				: null;
(quemuestro == "editacondicion")	? muestro ='../cpanel/editacondicion.php'				: null;
(quemuestro == "newsletter")		? muestro ='../cpanel/listadoboletines.php'				: null;
(quemuestro == "editanewsletter")	? muestro ='../cpanel/editaboletin.php'					: null;
(quemuestro == "clientenewsletter")	? muestro ='../cpanel/listadomailing.php'				: null;
(quemuestro == "editaclientenewsletter")	? muestro ='../cpanel/editaclientenews.php'		: null;
(quemuestro == "seccion")			? muestro ='../cpanel/listadoseccion.php'				: null;
(quemuestro == "editaseccion")		? muestro ='../cpanel/editaseccion.php'			 		: null;
(quemuestro == "editasubseccion")	? muestro ='../cpanel/editasubseccion.php'		 		: null;

(quemuestro == "actoftaconf")		? muestro ='../agencias/actualizaofertasconf.php'		: null;
(quemuestro == "actoftaimg")		? muestro ='../agencias/actualizaofertasimagen.php'		: null;

(quemuestro == "eventos")			? muestro ='eventos.php'								: null;
(quemuestro == "comunicados")		? muestro ='comunicados.php'							: null;
(quemuestro == "vermasnoticias")	? muestro ='noticias.php'								: null;
(quemuestro == "foro")				? muestro ='../lib/iraforo.php'							: null;
(quemuestro == "utilidades")		? muestro ='servicios.php'								: null;
(quemuestro == "crossbooking")		? muestro ='crossbooking.php'							: null;
(quemuestro == "ofertasproveedor")	? muestro ='ofertasproveedor.php'						: null;
(quemuestro == "listadoaccesos")	? muestro ='../private/listadoaccesos.php'				: null;
(quemuestro == "listadoconexiones")	? muestro ='../private/listadoconexiones.php'			: null;
(quemuestro == "gestioneventos")	? muestro ='gestioneventos.php'							: null;
(quemuestro == "seccion")			? muestro ='../cpanel/listadoseccion.php'				: null;


(quemuestro == "claveunica")		? muestro ='../private/iraproveedor.php'				: null;
(quemuestro == "listadirectorio")	? muestro ='../lib/explorer/listadirectorio.php'		: null;
(quemuestro == "ofertasgrupo")		? muestro ='ofertasgrupo.php'							: null;
(quemuestro == "vuelosbaratos")		? muestro ='vuelosbaratos.php'							: null;
(quemuestro == "multiofertas")		? muestro ='multiofertas.php'							: null;
(quemuestro == "bookingfax")		? muestro ='bookingfax.php'								: null;
(quemuestro == "articulosregalo")	? muestro ='pedido.php'									: null;
(quemuestro == "sms")				? muestro ='sms.php	'									: null;
(quemuestro == "ofertasparaagencias")?muestro='ofertasparaagencia.php'						:
null;
(quemuestro == "enviaboletin")		? muestro ='../boletin/enviamuestroboletin.php' :null;

ponscroll	= 'no'
alto = '800px';
(quemuestro == "principal") ? muestro ='../zonaprivada/principal.php'	:	null;

(parametro)? muestro = muestro + parametro		: null;

<!--parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe id="ufprincipal" ' + comandoalto + ' src="'+muestro+'" width="95%" height="'+alto+'" frameborder="0" scrolling="'+ponscroll+'" marginheight="0px" style="margin-left:15px" ></iframe>';-->

parent.parent.document.getElementById(nombreframe).innerHTML = '<iframe id="ufprincipal" ' + comandoalto + ' src="'+muestro+'" width="100%" height="'+alto+'" frameborder="0" scrolling="'+ponscroll+'" marginheight="0px" style="margin-left:15px" ></iframe>';
}

function calendarioverevento(mostrar, parametro) {
if (mostrar	=='calendario') {
		document.getElementById('calendar').innerHTML ='<iframe style="padding:0px 0px 0px 0px;height:166px;width:175px;" src="calendario.php"> </iframe> ';
	} else if (mostrar	=='calendarioparent') {
		parent.document.getElementById('calendar').innerHTML ='<iframe style="padding:0px 0px 0px 0px;height:166px;width:175px;" src="calendario.php"> </iframe> ';
	} else if (mostrar ='evento') {
		parent.document.getElementById('calendar').innerHTML ='<iframe style="padding:0px 0px 0px 0px;height:166px;width:175px;"  src="muestroevento.php'+parametro+'"> </iframe> ';
	}
}


function AbreImagen(param, ancho, alto)
{
vpropi = "height="+alto+", width="+ancho+",toolbar=no,scrollbars=no,menubar=no,status=no,titlebar=no,location=no";

OpenWindow=window.open("", "Foto", vpropi);
OpenWindow.document.write("<TITLE>Foto</TITLE>")
	OpenWindow.document.write("<BODY BGCOLOR=#055076>")
	OpenWindow.document.write("<img src=" + param + " height="+alto+" width="+ancho+">")
	OpenWindow.document.write("</BODY>")
	OpenWindow.document.write("</HTML>")
}


function confirmar(tipomensaje,lienzo,parametro) {
var irpantalla = 	lienzo+'.php'+parametro;

	if (tipomensaje== 'BORRAR') 
		textomensaje = '\277Esta seguro de borrar el registro?';

	if (confirm (textomensaje )) {
		window.location.href=irpantalla;
        return true;
    } else {
        //No env�a el formulario
       return false;
    }
}


function cambiatamanofoto(valor,ancho,alto)
{
document.getElementById(valor).width  = ancho;
document.getElementById(valor).height  = alto;

}

function BuscaFicheroIntranet(s) 
{
			ancho=550; alto=445;

			anchoPantalla = screen.availWidth;
			altoPantalla = screen.availHeight;
	
	
			posX = Math.round((anchoPantalla - ancho)/2);
			posY = Math.round((altoPantalla - alto)/2);
	
			opciones = "width=" + ancho + ",height=" + alto + ",top=" + posY + ",left=" + posX + ",scrollbars=no, resizable=no";		
			nueva=open('../lib/explorer/listadirectorioparaasignar.php');
			nueva.focus();
	    	if (nueva.opener == null) { nueva.opener = self; }

}


function BuscaFichero(s, directoriobusca, tipo, rutaynombrefichero, idagencia) {

ancho=550; alto=445;
			anchoPantalla = screen.availWidth;
			altoPantalla = screen.availHeight;
	
	
			posX = Math.round((anchoPantalla - ancho)/2);
			posY = Math.round((altoPantalla - alto)/2);
	
			opciones = "width=" + ancho + ",height=" + alto + ",top=" + posY + ",left=" + posX + ",scrollbars=no, resizable=no";		
			var buscaen		= '';
			var rutafichero	= '';
			if (directoriobusca != ''){
				buscaen='&buscadirectorio='+directoriobusca;
			}

if (tipo){
				tipof='&tipofichero='+tipo;
			}
			if (rutaynombrefichero){
				rutafichero='&rutaynombreimagen='+rutaynombrefichero;
			}
			agencia = '';
			if (idagencia){
				agencia='&idagencia='+idagencia;
			}

			nueva=open('../cpanel/cambiafichero.php?cambia='+s+buscaen+tipof+rutafichero+agencia,'myname',opciones);
			//nueva=open('cambiaimagen.php?cambia='+s,'myname',opciones);
			nueva.focus();
	    	if (nueva.opener == null) nueva.opener = self;		
}

function abrecalculadora(cal) {
			ancho=550; alto=445;
			anchoPantalla = screen.availWidth;
			altoPantalla = screen.availHeight;
	
	
			posX = Math.round((anchoPantalla - ancho)/2);
			posY = Math.round((altoPantalla - alto)/2);
	
			opciones = "width=" + ancho + ",height=" + alto + ",top=" + posY + ",left=" + posX + ",scrollbars=no, resizable=no";		

			nueva=open('../lib/calculadore.php','myname',opciones);
			//nueva=open('cambiaimagen.php?cambia='+s,'myname',opciones);
			nueva.focus();
	    	if (nueva.opener == null) nueva.opener = self;		
}



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

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

Navegador = navigator.appName;
Version  = parseInt(navigator.appVersion);
if (Navegador == "Netscape" && Version < 4) BRW = "NT3";
else if (Navegador == "Netscape" && Version >= 4) BRW = "NT4";
else BRW = "IE";

function abreventana(nombreventana,ancho,alto){
  window.open(nombreventana ,'PEDIDOS','toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes, resizable=1,top=40,left=50,width='+ ancho +" height="+ alto);
}

function validanumero(valor) {
	var n=parseFloat(valor);
	if (isNaN(n)==true) {
		alert("Unidades debe ser un n�mero");
		return false;
	}  
}
function compruebaobligatoriopedido() {
	if (document.formpedido.nombreagencia.value.length==0){
		alert("Nombre agencia es obligatorio");
		document.formpedido.nombreagencia.focus();
		return false;
	}
	if (document.formpedido.direccion.value.length==0){
		alert("Direcci�n agencia es obligatorio");
		document.formpedido.direccion.focus();
		return false;
	}
	if (document.formpedido.email.value.length==0){
		alert("E-mail agencia es obligatorio");
		document.formpedido.email.focus();
		return false;
	}
	document.formpedido.submit();
}


function quemuestro(nombre, parametro,conparent) {
var ajustedealto = ' onLoad="iFrameHeight(this);"  scrolling="no" ';

(nombre == 'lib/vuelosbaratos')?ajustedealto = ' style="height:2000px;width:800px;" scrolling="yes"' : null;
(nombre == 'lib/eventos')?ajustedealto = ' style="height:1400px;width:800px;" scrolling="yes"' : null;

var pasoparametro = '';
	
	if (parametro) 
		pasoparametro = parametro; 
if (conparent) {

	if (conparent=='parent2') {
		parent.parent.document.getElementById('principal').innerHTML ='<iframe id="iprincial" src="'+nombre+'.php'+pasoparametro+'" frameborder="0" marginheight="0" width="790px"'+ajustedealto+'></iframe>';
	} else {
		parent.document.getElementById('principal').innerHTML ='<iframe id="iprincial" src="'+nombre+'.php'+pasoparametro+'" frameborder="0" marginheight="0"  width="790px" '+ajustedealto+' ></iframe>';
	}
} else {
		document.getElementById('principal').innerHTML ='<iframe id="iprincial" src="'+nombre+'.php'+pasoparametro+'" frameborder="0" marginheight="0"  width="790px" '+ajustedealto+'></iframe>';
}

}
