//FUNCIONES DE CREACION DE OBJETOS-CAPA
/*
NOMBRE LIBRERIA: DynBasic.js
VERSION: v1.0
DOCUMENTACION ASOCIADA: DynBasic.doc
HISTORICO:
	-fecha modificacion:28/08/00 , modificador:Jordi Blasco/Pedro Redondo  , descripcion: generamos libreria y documentacion
*/
/*if(!ie && document.getElementById)*/
var PageLoaded=false;
var nets7=false;
function What_Browser(){
	var Browser = navigator.appName;
	var Version = navigator.appVersion;
	if (Browser == "Netscape"){
		if (document.getElementById) {
			this.name="IE";
			nets7=true;
			}
		else
			this.name = "NS"
	}
	else{
		if (Browser == "Microsoft Internet Explorer"){
			this.name = "IE"
		} 
		else{
			this.name = Browser 
		} 
	}
//.............................................................................................	
//.. inicio a–adido #1      jbb 04.09.00
//.. busco el tipo de plataforma
	var agt=navigator.userAgent.toLowerCase();

	this.mac= (agt.indexOf("mac")!=-1);
	this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
	this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
	this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
	if(this.mac){
		this.plataforma="MAC";
	}
	else if (this.win95||this.win98||this.winnt){
		this.plataforma="PC";
	}
//.. fin a–adido #1      jbb 04.09.00
//.............................................................................................	

	this.version = parseInt( navigator.appVersion);
	this.NS = (this.name =="NS" && this.version >=4)
	this.NS4 = (this.name=="NS" && this.version ==4)
	this.NS5 = (this.name=="NS" && this.version ==5)
	this.NS6 = (this.name=="NS6" && this.version ==6)
	this.NS7 = (this.name=="NS7" && this.version ==7)
	this.IE = (this.name=="IE" && this.version >=4)
	this.IE4 = (Version.indexOf('MSIE 4')>0)
	this.IE5 = (Version.indexOf('MSIE 5')>0)
//.............................................................................................	
//.. inicio a–adido #2      jbb 04.09.00
//.. busco si es Insterner Explorer 4.5 para Mac
	this.DOM=document.getElementById?1:0   					
	this.IE45 = (Version.indexOf('MSIE 4.5')>0)
	this.IE45mac = (this.IE45 && this.plataforma=="MAC")
//.. fin a–adido #2      jbb 04.09.00
//.............................................................................................	
}
var BW = new What_Browser();


function initObject(id,nestref) {
	if (BW.NS) {
		if (BW.NS) {
			if (!nestref) var nestref = initObject.nestRefArray[id]
			this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		if (BW.NS5) { 
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.height= this.css.document.height;
		this.width= this.css.document.width;
	}
	else 
		if (BW.IE) {
			this.elm = this.event = eval("document.getElementById('"+id+"')");
			this.css = eval("document.getElementById('"+id+"').style");
			this.doc = document
			//... aunque parezca mentira no funciona cuando hay capas anidadas en Explorer si no lo asignamos dos veces!!!
			this.x = this.elm.offsetLeft;
			this.x = this.elm.offsetLeft;
			this.y = this.elm.offsetTop
			this.height=this.elm.scrollHeight;
			this.width=this.elm.scrollWidth		 
	}
	this.id = id
	this.name = id.substr(0,id.indexOf("Div")); //nombre de la capa
	this.obj=this.name
	this.show = LayerShow
	this.hide = LayerHide
	this.LayerWrite = LayerWrite
	this.ISclip = determineClip
	this.changeImg = ChangeImg
}
//-------------FUNCIONES CLIP --------------------------------------------------------
function determineClip(){
//.. excluyo IE45 para mac e IE5	
	if (BW.IE4 && !BW.IE45mac){
		if (this.css.clip) {
			var clip = this.css.clip.split("rect(")[1].split(")")[0].split("px")
			this.clipx=parseInt(clip[3])
			this.clipy=parseInt(clip[0])
			this.clipxx=parseInt(clip[1])
			this.clipyy=parseInt(clip[2])
		}
		else {
			this.clipx=0
			this.clipy=0
			this.clipxx=0
			this.clipyy=0
			//alert(this.clipx+'\n'+this.clipy+'\n'+this.clipxx+'\n'+this.clipyy+'\n')
		}
	}
//.. a–ado IE45mac, IE5, puesto que se comportan igual (aparentemente).	
	if (BW.NS||BW.IE5){							
		this.clipx=parseInt(this.css.clip.left);
		this.clipy=parseInt(this.css.clip.top);
		this.clipxx=parseInt(this.css.clip.right);
		this.clipyy=parseInt(this.css.clip.bottom);
		//alert(this.name+'\n'+this.x+'\n'+this.y+'\n'+this.height+'\n'+this.width+'\n'+this.css)
		//alert(this.clipx+'\n'+this.clipy+'\n'+this.clipxx+'\n'+this.clipyy+'\n')
	}
//.. trato por separado a IE45mac	
	if (BW.IE45mac){							
		this.clipx=0
		this.clipy=0
		this.clipxx=0
		this.clipyy=0
	}
	this.clipTo = clipTo
	this.clipBy = clipBy
}                                       

function clipTo(x,y,x1,y1){
	//alert(this.id+'\n'+this.name+'\n')
	//alert(x+'\n'+y+'\n'+x1+'\n'+y1)
	if (x==null){x=this.clipx}
	if (y==null){y=this.clipy}
	if (x1==null){x1=this.clipxx}
	if (y1==null){y1=this.clipyy}
//.. excluyo IE45 para mac	
	if(BW.IE && !BW.IE45mac){
		var rect_str = "rect("+y+"px "+x1+"px "+y1+"px "+x+"px)";
		this.css.clip = rect_str;
	} 
//.. trato separadamente IE45 para mac	
	if(BW.IE45mac){
		var rect_str = "rect("+y+"px "+x1+"px "+y1+"px "+x+"px)";
		this.css.clip = rect_str;
	} 
//.. a–ado IE45mac, IE5, puesto que se comportan igual (aparentemente).	
	if(BW.NS||BW.IE5){
		this.css.clip.left = x;
		this.css.clip.right = x1;
		this.css.clip.top = y;
		this.css.clip.bottom = y1;
	}
	this.clipx=x
	this.clipy=y
	this.clipxx=x1
	this.clipyy=y1
}                                                       
function clipBy(x,y,x1,y1){
	//alert("clipBy")
	if (x==null){x=0}
	if (y==null){y=0}
	if (x1==null){x1=0}
	if (y1==null){y1=0}
	this.clipTo((this.clipx+(x)), (this.clipy+(y)), (this.clipxx+(x1)), (this.clipyy+(y1)));
}
//--------------- FUNCIONES PARA MOSTRAR/OCULTAR CAPAS -------------------------------
function LayerShow(){
this.css.visibility = (BW.NS)? "show" : "visible" 
}
function LayerHide(){
this.css.visibility = (BW.NS)? "hide" : "hidden" 
}
//--------------- FUNCIONES PARA CAMBIAR IMAGENES Y TEXTO DE UN LAYER ----------------
function ChangeImg(name,img){
if (BW.NS){ 
this.doc.images[name].src = img; 
}
if (BW.IE){ document.images[name].src = img;}
}				
function LayerWrite(str) {
if (BW.NS) { 
this.doc.open()
this.doc.write(str)
this.doc.close()
}
else if (BW.IE) {
this.event.innerHTML = str
}
}
//--------------- FUNCIONES PARA INICIALIZAR TODAS LAS CAPAS -------------------------
function InitLayers(nestref) {
if (BW.NS){
if (nestref) {index = eval('document.'+nestref+'.document')} else {nestref = ''; index = document;}
for (var i=0; i<index.layers.length; i++) {
var layername = index.layers[i].name
initObject.nestRefArray[layername] = nestref
var isDynamic = layername.indexOf("Div")
// Si la Capa Contiene el texto Div
if (isDynamic > 0) { eval(layername.substr(0,isDynamic)+' = new initObject("'+layername+'","'+nestref+'")') }
if (index.layers[i].document.layers.length > 0) {       
initObject.refArray[initObject.refArray.length] = (nestref=='')? index.layers[i].name : nestref+'.document.'+index.layers[i].name }
}
// Si existen capas Acomodadas
if (initObject.refArray.i < initObject.refArray.length) { InitLayers(initObject.refArray[initObject.refArray.i++])      }
} 
else { // Si es Explorer
if (BW.IE) 
{
	if(nets7)
		for (var i=0; i<document.getElementsByTagName("DIV").length; i++) 
		{
			var divname = document.getElementsByTagName("DIV")[i].id
			var isDynamic = divname.indexOf("Div")
		// Si la Capa Contiene el texto Div                     
			if (isDynamic > 0) 
				{
				eval(divname.substr(0,isDynamic)+' = new initObject("'+divname+'")')
				}
		}		
	else
		for (var i=0; i<document.all.tags("DIV").length; i++) 
		{
			var divname = document.all.tags("DIV")[i].id
			var isDynamic = divname.indexOf("Div")
		// Si la Capa Contiene el texto Div                     
			if (isDynamic > 0) 
				{
				eval(divname.substr(0,isDynamic)+' = new initObject("'+divname+'")')
				}
		}
}
return true;
}
}
initObject.nestRefArray = new Array()
initObject.refArray = new Array()
initObject.refArray.i = 0
initObject.set = false 
initObject.bufferCount = 0;
initObject.bufferObjName = new Array();
