
/**
* @version $Id: _nerGlobal.js,v 1.1 240508 00:00:00 _ner_nucleo_pe $
* @package Proyecto e...
* @copyright (C) 2000 - 2015 Nervio*.org Mex Xico
* @correo-e n@nervio.org
* Global Media in Frente GV - Nervio*
*/

_nerGlobal = {
	ids				: 0,
	actiMov			: null,
	actiReTama		: null,
	idPulsado		: '',
	posiX			: 0,
	origenX			: 0, 
	posiY			: 0, 
	origenY			: 0,
	anchoX			: 0,
	altoY			: 0,
	origenW			: 0,
	origenH			: 0,
	tiempo			: null,
	txtGlobal		: null,
	actiCajaMensa	: false,
	actiMin			: false,
	actiMax			: false,
	anchoMax		: null,
	altoMax			: null,
	evento			: null,
	cliY			: null,
	dR				: 'http://nervio.org/_n/'
}

_nerGlobal.fondo = function(idiv){
	_nerGlobal.ids++;
	var d = _nerGlobal.creaCapa({idiv: idiv, estilo: 'fonFondo', agregar: true});
	var aaT =_nerGlobal.venAnchoAlto(true);
	var aa =_nerGlobal.venAnchoAlto(false);
	d.style.width	= (aaT['ancho'] >= aa['ancho']) ? aaT['ancho'] : aa['ancho'];
	d.style.height  = (aaT['alto'] >= aa['alto']) ? aaT['alto'] : aa['alto'];
	d.style.zIndex  = _nerGlobal.ids;
}

_nerGlobal.creaCapa = function(c){
	c = c || {};
	var d = _nel(c.idiv, 'div', c.agregar);
	d.className = c.estilo;
	return d;
}

_nerGlobal.modCapa = function(v, estilo){
	var txt;
	estilo = estilo || '';
	var d = _nerGlobal.creaCapa({idiv: v.idiv, estilo: estilo, agregar: true});
	d.style.top = v.tope;
	d.style.left = v.izquierda;
	d.style.width = v.ancho;
	d.style.height = v.alto;

	_nerGlobal.posi(v.idiv, v.esquinado, v.evento);

	d.style.zIndex = _nerGlobal.ids;
	switch(v.tipo){
		case 0	: txt = _nerGlobal.ven.txt0(v);break;
		default	: txt = '';
	}
	d.innerHTML = txt;

	return d;
}

_nerGlobal.agranda = function(idiv, ancho, alto, extra){
	for(q = 0; q <= 5; q++){
		an = (ancho * (15 + q)) / 20 + 'px';
		al = (alto * (15 + q)) / 20 + 'px';
		d  = 20 * q;
		  setTimeout(function(){
			if((an <= ancho) && (al <= alto)){
			  _gel(idiv).style.width = an;
			  _gel(idiv).style.height = al;
			  if(extra)eval(extra);
			}
		  }, d);
	}
}

_nerGlobal.achica = function(idiv, ancho, alto){
	for(q = 10; q >= 0; q--){
		an = (ancho * (10 + q)) / 20 + 'px';
		al = (alto * (10 + q)) / 20 + 'px';
		d  = 40 * q;
		  setTimeout(function() {
			  _gel(idiv).style.width = an;
			  _gel(idiv).style.height = al;
		  }, d);
	}
}

_nerGlobal.posi = function(idiv, esqui, evento){
	var d = _gel(idiv);
	var y = (evento) ? evento.pageY : 0;
	aa=_nerGlobal.venAnchoAlto();
	realY = esIE ? _nerGlobal.cliY + document.body.scrollTop : y;
	relaY = esIE ? _nerGlobal.cliY : y - document.body.scrollTop;
	switch(esqui){
		case 1 :d.style.left = 1;d.style.top = (realY-relaY);break;
		case 1.5:d.style.left = (aa['ancho']/2)-(parseInt(d.style.width)/2);d.style.top = (realY-relaY);break;
		case 2:d.style.left = aa['ancho'] - parseInt(d.style.width);d.style.top = (realY-relaY);break;
		case 3:d.style.left = 1;d.style.top = (realY-relaY) + aa['alto'] - parseInt(d.style.height);break;
		case 3.5:d.style.left = (aa['ancho']/2)-(parseInt(d.style.width)/2);d.style.top = aa['alto'] - parseInt(d.style.height);break;
		case 4:d.style.left = aa['ancho'] - parseInt(d.style.width);d.style.top = (realY-relaY) + aa['alto'] - parseInt(d.style.height);break;
		default:d.style.left = (aa['ancho']/2)-(parseInt(d.style.width)/2);d.style.top = (realY-relaY)+(aa['alto']/2)-(parseInt(d.style.height)/2);break;
	}
}

_nerGlobal.remoCapa = function(idiv){_rem(idiv);}

_nerGlobal.fonCerrar = function(idiv){
	_nerGlobal.remoCapa(idiv);
}

_nerGlobal.venAnchoAlto = function(t){
	var ancho;
	var alto;
	var d = _nerGlobal.creaCapa({idiv: 'dMaximoVen', estilo: 'venMaximo', agregar: true});

	if(t){
		ancho = _gel('tPrincipal') ? _gel('tPrincipal').offsetWidth : d.offsetWidth;
		alto = _gel('tPrincipal') ? _gel('tPrincipal').offsetHeight : d.offsetHeight;
	} else{
		ancho = d.offsetWidth;
		alto = d.offsetHeight;
	}

	_nerGlobal.remoCapa('dMaximoVen');
	return {ancho: ancho, alto: alto};
}

_nerGlobal.enProgreso = function(dir, tipo, mini){
	mini = (mini) ? mini : '';
	tipo = (tipo) ? 'n' : '';
	_nerGlobal.ids++;
	_nerGlobal.fondo('nEnProEnProFondo');
	var d = _nerGlobal.creaCapa({idiv: 'nEnProEnPro', estilo: 'enProEnPro', agregar: true});
	_nerGlobal.ids++;
	d.style.zIndex = _nerGlobal.ids;

	if(mini != ''){
		_gel(mini).style.position = 'relative';
		d.style.top = _gel(mini).offsetTop;
		d.style.left = _gel(mini).offsetLeft;
		d.style.width = _gel(mini).offsetWidth;
		d.style.height = _gel(mini).offsetHeight;
		_gel('nEnProEnProFondo').style.position = 'relative';
		_gel('nEnProEnProFondo').style.top = _gel(mini).offsetTop;
		_gel('nEnProEnProFondo').style.left = _gel(mini).offsetLeft;
		_gel('nEnProEnProFondo').style.width = _gel(mini).offsetWidth;
		_gel('nEnProEnProFondo').style.height = _gel(mini).offsetHeight;
	}

	var txt='';

	txt+='<table class="alto99p ancho100p"><tr><td align="center">';
	txt+='<table class="ancho200 alto50 fondofbfbfc"><tr><td class="texto12 color039 celdae0e0e0 centrar"><div id="nenprodenu">';
	txt+='<img src="' + _nerGlobal.dR + '_ani/enp' + tipo + '.gif" align="absmiddle">&nbsp;&nbsp; En progreso...';
	txt+='</div></td></tr></table>';
	txt+='</td></tr></table>';
	d.innerHTML=txt;
}

_nerGlobal.enProCerrar = function(){
	_nerGlobal.remoCapa('nEnProEnPro');
	_nerGlobal.fonCerrar('nEnProEnProFondo');
}

window.onclick=function(e){_nerGlobal.evento = e;}

window.onerror = function(){/*alert('Fallo... \n\n NComando incompleto... \n\n tn7r53pu9hcdld44trrd78q9b02mu9p55g5r47t617s');*/}

function _Script(src){
	var p = document.getElementsByTagName('HEAD')[0] || document.body;
	var s = document.createElement('script');s.type	= 'text/javascript';s.src = src + '.js';p.appendChild(s);
}

function _Link(h){
	var p = document.getElementsByTagName('HEAD')[0] || document.body;
	var l = document.createElement('link');l.href = h;l.rel = 'stylesheet';l.type = 'text/css';p.appendChild(l);
}

document.writeln('<script src="http://nervio.org/_n/_njs/_nerGlobalCal.js"></script>');
document.writeln('<script src="http://nervio.org/_n/_njs/_nerGlobalCalEs.js"></script>');
document.writeln('<script src="http://nervio.org/_n/_njs/_nerGlobalCalS.js"></script>');
_Script('http://nervio.org/_n/_njs/f');
_Script('http://nervio.org/_n/_njs/_nerGlobalX');
_Script('http://nervio.org/_n/_njs/_nerGlobalE');
_Script('http://nervio.org/_n/_njs/_nerGlobalCA');
_Script('http://nervio.org/_n/_njs/_nerGlobalCM');
_Script('http://nervio.org/_n/_njs/_nerGlobalBot');
_Script('http://nervio.org/_n/_njs/_nerGlobalVen');
_Script('http://nervio.org/_n/_njs/_nerGlobalG');