var tiempo=0;
var tiempo2=0;
var objSel='';
var objClick='';
var level3 = [
				{ obj : 's3-2', datos : [
											{ name: '· Administración Pública Local', ur : 'ss-administracion-portal-ciudadano.htm'},
											{ name: '· Administración Pública Central', ur : 'ss-administracion-central-portal-ciudadano.htm'},
											{ name: '· Promoción Inmobiliaria y Construcción', ur : 'ss-promocion-contruccion.htm '},
											{ name: '· Banca', ur : 'ss-gestion-expedientes-hipotecarios.htm'},
											{ name: '· Seguros', ur : 'ss-gestion-expedientes-reclamaciones.htm '},
											{ name: '· Industria y Servicios', ur : 'ss-industria-servicios.htm '}




										]
				}
			]
function xMen(obj,ev){
	if(ev==1){
		if(document.getElementById('s3')) xLevel3Out(2,'s3');
		clearTimeout(tiempo);
		if(objSel!=''&&objSel!=obj){
			xClass(objSel,0);
			xDisplay(objSel,0);
		}
		if(objClick!=''&&objClick!=obj)	xClass(objClick,0);
		xClass(obj,1);
		xDisplay(obj,1);
		objSel=obj;
	}else if(ev==0){
		tiempo=setTimeout('xMen("'+obj.id+'",2)',500);
	}else{
		if(objClick!=''&&objClick!=obj)	xClass(document.getElementById(obj),0);
		xDisplay(document.getElementById(obj),0);
		xClass(objClick,1);
	}
}
function xLevel2(obj,ev){
	if(ev==1){
		clearTimeout(tiempo);
	}else{
		xMen(document.getElementById('p-'+obj.id.substring(1,2)),0);
	}
}

function xDisplay(obj,act){
	if(document.getElementById('s'+obj.id.split('-')[1])){
		document.getElementById('s'+obj.id.split('-')[1]).style.display=((act==0)? 'none' : 'block');
		document.getElementById('s'+obj.id.split('-')[1]).style.visibility=((act==0)? 'hidden' : 'visible');
	}
}

function xClass(obj,act){ obj.className=((act==0)? '' : 'on'); }

var auxURL=['home-gestion-documental-workflow.asp','compania-quienes.htm','sn-index.htm','on-descripcion.htm','productos-gestion-contenidos.htm','servicios-gestion-documental.htm','partners-area.htm','clientes-que-ofrecemos.htm','noticias-gestion-documental-1.asp','contactar-donde.htm']		
function xLevelA(act){
	var strAux='<ul>';
	for(var i=1;i<=10;i++){
		strAux+='<li'+((i==10)? ' class="fin"':'')+'><a href="'+auxURL[i-1]+'" id="p-'+i+'" onmouseover="xMen(this,1)" onmouseout="xMen(this,0)"'+((act==i)? ' class="on"' : '')+'>&nbsp;</a></li>';
	}
	strAux+='</ul>';
	objClick=document.getElementById('p-'+act);
	document.getElementById('mkMenu').innerHTML=strAux;
}
function xLevelAHome(act){
	var strAux='<ul>';
	for(var i=1;i<=11;i++){
		if(i!=11) strAux+='<li'+((i==10)? ' class="fin"':'')+'><a href="'+auxURL[i-1]+'" id="p-'+i+'" onmouseover="xMen(this,1)" onmouseout="xMen(this,0)"'+((act==i)? ' class="on"' : '')+'>&nbsp;</a></li>';
	}
	strAux+='</ul>';
	objClick=document.getElementById('p-'+act);
	document.getElementById('mkMenu').innerHTML=strAux;
}
function veaForm(){//Lo que hace cuando se pincha en el banner de abajo de la pantalla de inicio.
  document.location.href="compania-que-ofrecemos.htm";
}
 
function veaForm2(){//Lo que hace cuando se pincha en el banner de abajo de la pantalla de inicio.
  document.location.href="plataforma-factura-electronica.htm";
}

function xLevel3Over(obj,e){
	clearTimeout(tiempo2);
	clearTimeout(tiempo);
	var aux = -1
	var auxObj = obj.id
	for(var i=0;i<level3.length;i++){
		if(auxObj == level3[i].obj){
			aux = i;
			break;
		}
	}
	if(aux != -1){
		var auxStr ='<ul>';
		for(var i=0;i<level3[aux].datos.length;i++){
			auxStr +='<li><a href="'+level3[aux].datos[i].ur+'" onmouseover="xLevel3Out(1,\'s3\')" onmouseout="xLevel3Out(0,\'s3\',1)">'+level3[aux].datos[i].name+'</a></li>'
		}
		auxStr+='</ul>';
		document.getElementById('n-3').style.marginTop = ((auxObj.split('-')[1]-1)*19)+'px';
		document.getElementById('n-3').innerHTML = auxStr;
		document.getElementById('n-3').style.display = 'inline';
		document.getElementById('n-3').style.visibility = 'visible';
	}
}

function xLevel3Out(ev,obj,tp){
	if(ev == 0){
		var aux = (tp)? tp : null;
		tiempo2 = setTimeout('xLevel3Out(2,"'+obj+'", '+aux+')',500);
	}
	else if(ev == 1){
		clearTimeout(tiempo2);
		clearTimeout(tiempo);
	}
	else{
		document.getElementById('n-3').style.display = 'none';
		document.getElementById('n-3').style.visible = 'hidden';
		document.getElementById('n-3').innerHTML = '';
		if(tp) xMen(document.getElementById('p-'+obj.substring(1,2)),0);
		clearTimeout(tiempo2);
	}
}

CreateTag=function(param){
	eval(param.IdClass+'=new CreateTag.create(param)');
	param.IdClass=eval(param.IdClass);
}
CreateTag.create=function(par){
	this.par = par;
	this.oAux = null;
	this.xDrawElement(this.par);
}

CreateTag.create.prototype={
	xDrawElement : function(arg){
		this.oAux = document.createElement(arg.typeElement);
		if(arg.id) this.oAux.id = arg.id;
		if(arg.properties) this.oAsignProperties('this.oAux' , arg.properties);
		
		switch(arg.typeElement){
			case 'input' : {
				this.oAux.value = arg.str || '';
				break;
			}
			default : {
				if(arg.str) this.oAux.innerHTML = arg.str;
			}
		}
		if(arg.clase) this.oAux.className = arg.clase;
		
		if(arg.style) this.oAsignStyle('this.oAux' , arg.style);
		
		((arg.idFather)? $(arg.idFather) : document.body).appendChild(this.oAux);
		
		if(arg.event) this.oAsignEvent(arg.id , arg.event);
	
		this.oAux=null;
		eval(this.par.IdClass+'=null');
	},
	// Método interno que asigna Propiedades a un elemento HTML
	oAsignProperties : function(obj,arg){
		for(var i=0;i<arg.length;i++){ if(arg[i] !='') eval(obj+'.setAttribute("'+arg[i].name+'" , "'+arg[i].value+'")'); }
	},
	// Método interno que asigna Estilos a un elemento HTML
	oAsignStyle : function(obj,arg){
		for(var i=0;i<arg.length;i++){ if(arg[i] !='') eval(obj+'.style.'+arg[i].name+' = "'+arg[i].value+'"'); }
	},
	// Método interno que asigna Eventos a un elemento HTML
	oAsignEvent : function(obj,arg){
		for(var i=0;i<arg.length;i++){ if(arg[i] !='') this.oEventCapture(obj,arg[i].name,"function("+((navigator.appName!='Microsoft Internet Explorer')? 'event' : '')+"){ "+arg[i].value+" }"); }
	},
	// Método interno que asigna una función a un evento
	oEventCapture : function(id,evento,fun){
		eval("document.getElementById('"+id+"').on"+evento+" = "+fun);
	}
}
