

/**********************************************************************************   
//--- La definición de divCont nos estadando: width:750 (anchura de toda la ventana)  recorto a una ventana de 600 de ancho x 116 de alto
*********************************************************************************/
var id_explorer=1;//---------1 internet explorer 2---- netscape 4.0  3---- netscape 6.0 o más
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	if(this.ie6 || this.ie5 || this.ie4) id_explorer=1;
	if( this.ns4 ) id_explorer=2;
	if( this.ns6 ) id_explorer=3;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	this.id_explorer=id_explorer;
	return this
}
var bw=new lib_bwcheck()

// JavaScript Document
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];}
   
}
function Cambiar() { 
  var i,x,a=document.MM_sr;
  var c=Cambiar.arguments;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.oSrc=c[1];
}
//-->
elipse_c=60;
elipse_b=140;
elipse_a=-20;

bserv_left=elipse_c;bserv_top=10;ciclo=0;z_serv=1;
bproy_left=elipse_c;bproy_top=25;ciclo_proy=0;z_proy=3;
bclie_left=elipse_a;bclie_top=10;ciclo_clie=0;z_clie=1;
blsl_left=elipse_b;blsl_top=25;ciclo_lsl=0;z_lsl=3;
factor_suma=10;timer=250;

parar=0;
function start()
{
if(parar==0)
{
  if(ciclo==0)
   {
      if(bserv_left<elipse_b) {bserv_left+=factor_suma;}
	  if(bserv_left >= elipse_b){ciclo=1;z_serv=2;}
   }
   else if(ciclo==1)
   {
      if(bserv_left > elipse_c) {bserv_left-=factor_suma;bserv_top+=2;}
	  if(bserv_left <= elipse_c) {ciclo=2;}
   }
   else if(ciclo==2)
   {
      if(bserv_left > elipse_a) {bserv_left-=factor_suma;bserv_top-=2;}
	  if(bserv_left <= elipse_a) {ciclo=0;z_serv=1;}
   }
       if(id_explorer==1){
		document.all["divBotonServicios"].style.left=bserv_left;		
        document.all["divBotonServicios"].style.top =bserv_top;
        document.all["divBotonServicios"].style.zIndex =z_serv;
	   }
	  if(id_explorer==2)
	  {
	   document.layers["divBotonServicios"].left=bserv_left;		
       document.layers["divBotonServicios"].top =bserv_top;
       document.layers["divBotonServicios"].zIndex =z_serv;
	  }  
	 if(id_explorer==3){ 
	  document.getElementById("divBotonServicios").style.left=bserv_left;		
      document.getElementById("divBotonServicios").style.top =bserv_top;
      document.getElementById("divBotonServicios").style.zIndex =z_serv;
	  }
	  
  
  
  if(ciclo_proy==0)
   {
      if(bproy_left > elipse_a) {bproy_left-=factor_suma;bproy_top-=2;}
	  if(bproy_left <= elipse_a) {ciclo_proy=1;z_proy=1;}
   }
   else if(ciclo_proy==1)
   {
      if(bproy_left<elipse_b) {bproy_left+=factor_suma;}
	  if(bproy_left >= elipse_b){ciclo_proy=2;z_proy=3;}
   }
   else if(ciclo_proy==2)
   {
      if(bproy_left > elipse_c) {bproy_left-=factor_suma;bproy_top+=2;}
	  if(bproy_left <= elipse_c) {ciclo_proy=0;z_proy=3;}
   }
   if(id_explorer==1){
	   document.all["divBotonProyectos"].style.left=bproy_left;		
       document.all["divBotonProyectos"].style.top =bproy_top;
       document.all["divBotonProyectos"].style.zIndex =z_proy;
	   }
	  if(id_explorer==2)
	  {
	   document.layers["divBotonProyectos"].left=bproy_left;		
       document.layers["divBotonProyectos"].top =bproy_top;
       document.layers["divBotonProyectos"].zIndex =z_proy;
	  }  
	 if(id_explorer==3){ 
	  document.getElementById("divBotonProyectos").style.left=bproy_left;		
      document.getElementById("divBotonProyectos").style.top =bproy_top;
      document.getElementById("divBotonProyectos").style.zIndex =z_proy;
	  }
  
  if(ciclo_clie==0)
   {
      if(bclie_left<elipse_b) {bclie_left+=factor_suma;}
	  if(bclie_left >= elipse_b){ciclo_clie=1;z_clie=3;}
   }
   else if(ciclo_clie==1)
   {
     if(bclie_left > elipse_c) {bclie_left-=factor_suma;bclie_top+=2;}
	  if(bclie_left <= elipse_c) {ciclo_clie=2;z_clie=3;}
   }
   else if(ciclo_clie==2)
   {
      if(bclie_left > elipse_a) {bclie_left-=factor_suma;bclie_top-=2;}
	  if(bclie_left <= elipse_a) {ciclo_clie=0;z_clie=1;}
      
   } 
     if(id_explorer==1){
	   document.all["divBotonClientes"].style.left=bclie_left;		
       document.all["divBotonClientes"].style.top =bclie_top;
       document.all["divBotonClientes"].style.zIndex =z_clie;
	   }
	  if(id_explorer==2)
	  {
	   document.layers["divBotonClientes"].left=bclie_left;		
       document.layers["divBotonClientes"].top =bclie_top;
       document.layers["divBotonClientes"].zIndex =z_clie;
	  }  
	 if(id_explorer==3){ 
	  document.getElementById("divBotonClientes").style.left=bclie_left;		
      document.getElementById("divBotonClientes").style.top =bclie_top;
      document.getElementById("divBotonClientes").style.zIndex =z_clie;
	  } 
  
 
 
   if(ciclo_lsl==0)
   {
      if(blsl_left > elipse_c) {blsl_left-=factor_suma;blsl_top+=2;}
	  if(blsl_left <= elipse_c) {ciclo_lsl=1;z_lsl=3;}
   }
   else if(ciclo_lsl==1)
   {
      if(blsl_left > elipse_a) {blsl_left-=factor_suma;blsl_top-=2;}
	  if(blsl_left <= elipse_a) {ciclo_lsl=2;z_lsl=1;}
   }
   else if(ciclo_lsl==2)
   {
      if(blsl_left<elipse_b) {blsl_left+=factor_suma;}
	  if(blsl_left >= elipse_b){ciclo_lsl=0;z_lsl=3;}   
   } 
   if(id_explorer==1){
	   document.all["divBotonLSL"].style.left=blsl_left;		
       document.all["divBotonLSL"].style.top =blsl_top;
       document.all["divBotonLSL"].style.zIndex =z_lsl;
	   }
	  if(id_explorer==2)
	  {
	   document.layers["divBotonLSL"].left=blsl_left;		
       document.layers["divBotonLSL"].top =blsl_top;
       document.layers["divBotonLSL"].zIndex =z_lsl;
	  }  
	 if(id_explorer==3){ 
	  document.getElementById("divBotonLSL").style.left=blsl_left;		
      document.getElementById("divBotonLSL").style.top =blsl_top;
      document.getElementById("divBotonLSL").style.zIndex =z_lsl;
	  } 
  
  
  setTimeout("start()",timer);
  }
}

function parada()
{
	parar=1;
}
function arranque()
{
	parar=0;
	start();
}

function Init()
{
 MM_preloadImages('images/boton_servicios2.gif','images/boton_clientes2.gif','images/boton_proyectos2.gif','images/boton_lsluz2');
 height=window.screen.height;
 width=window.screen.width;
 if(width<=1024) factor=0.90;
 else factor =1.0;
  if(id_explorer==1){
	   document.all["divPrincipal"].style.left=(width-(1024*factor))/2;		
       document.all["divPrincipal"].style.top =(height-(768*factor))/2;
	   }
	  if(id_explorer==2)
	  {
	   document.layers["divPrincipal"].left=(width-(1024*factor))/2;		
       document.layers["divPrincipal"].top =(height-(768*factor))/2;
	  }  
	 if(id_explorer==3){ 
	  document.getElementById("divPrincipal").style.left=(width-(1024*factor))/2;		
      document.getElementById("divPrincipal").style.top =(height-(768*factor))/2;
	  } 
  
 start();
 
}

function aceptar(){
{
	var usuario = document.acceso.usuario.value;
	var password = document.acceso.password.value;
	if (usuario == ""){
  		alert("Debes rellenar el campo 'usuario'");
	return false;	
    } else if (password == ""){
  		alert("Debes rellenar el campo 'contraseña'");
	return false;	
    } else 
		try{
		    document.acceso.submit();
			}
  		catch (e){
		          alert(e.message);
		   };		
}
}

function buscar(){
{
	var bgeneral = document.acceso.bgeneral.value;
	var pclave = document.acceso.pclave.value;
	if (bgeneral == ""){
  		alert("Debes rellenar el campo busqueda general'");
	return false;	
    } else if (ppclave == ""){
  		alert("Debes indicar palabra clave");
	return false;	
    } else 
		try{
		    document.busqueda.submit();
			}
  		catch (e){
		          alert(e.message);
		   };		
}
}

/*Detección de navegador*/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

/*Generador de números aleatorios en un intervalo */
function aleatorio(inferior,superior){ 
	numPosibilidades = superior - inferior 
	aleat = Math.random() * numPosibilidades 
	aleat = Math.round(aleat) 
	return parseInt(inferior) + aleat 
} 