// File:		StdScriptLibrary.js
// Version:		1.0
// Author:		Anl. MCP. Larry Suárez L.
// Company:		Systems Technology Development - STD
//				2000(c) All rights reserved.
//				webmaster@stdsolutions.com

function clsBrowserBehavior()
{
	this.documentActive = false;
	this.isMicrosoft	= (document.all) ? true : false;
	this.isNetscape		= (document.layers) ? true : false;
	this.createLayer	= libBrowserCreateLayer;
	this.execute		= libBrowserExecute;
}

function libBrowserExecute(Command)
{	
	if (this.documentActive)
		eval(Command);
}

function libBrowserCreateLayer(LayerId,Type)
{
	if ((this.isMicrosoft) && (Type==0))
		document.writeln('<DIV ID="' + LayerId + '">'); 
	if ((this.isMicrosoft) && (Type==1))
		document.writeln('</DIV>');
	if ((this.isNetscape) && (Type==0))
		document.writeln('<DIV ID="' + LayerId + '">'); 
	if ((this.isNetscape) && (Type==1))
		document.writeln('</DIV>');
}

function clsLayerDef(browserBehavior,layerId)
{
	if (browserBehavior.isMicrosoft)
	{
		this.cHIDE		= "HIDDEN";
		this.cSHOW		= "VISIBLE";
		this.element	= document.all[layerId].style; 
		this.me			= document.all[layerId];
	}
	if (browserBehavior.isNetscape)
	{
		this.cHIDE		= "HIDE";
		this.cSHOW		= "SHOW";
		this.element	= document.layers[layerId]; 		
		this.me			= document.layers[layerId];
		}
	this.isHide		= true;
	this.layerId	= layerId;
	this.x			= parseInt(this.element.left);
	this.y			= parseInt(this.element.top);
	this.lastPosx	= this.x;
	this.lastPosy	= this.y;
	this.slideHeight= 0;
	this.move		= libMoveLayer;
	this.moveTo		= libMoveLayerTo;
	this.back		= libLayerBack;
	this.show		= libShowLayer;
	this.hide		= libHideLayer;
	this.element.visibility = this.cHIDE;	
}

function libShowLayer()
{
	this.element.visibility = this.cSHOW;
	this.isHide = false;
}

function libHideLayer()
{
	this.element.visibility = this.cHIDE;
	this.isHide = true;
}

function libMoveLayer(xpos,ypos)
{
	if (xpos!=null)
	{
		this.x += xpos;
	}
	if (ypos!=null)
	{
		this.y += ypos;
	}
	this.lastPosx		= parseInt(this.element.left);
	this.lastPosy		= parseInt(this.element.top);
	this.element.left	= this.x;
	this.element.top	= this.y;
}

function libMoveLayerTo(xpos,ypos)
{
	if (xpos!=null)
	{
		this.x = xpos;
	}
	if (ypos!=null)
	{
		this.y = ypos;
	}
	this.lastPosx		= parseInt(this.element.left);
	this.lastPosy		= parseInt(this.element.top);
	this.element.left	= this.x;
	this.element.top	= this.y;
}

function libLayerBack()
{
	this.element.left = this.lastPosx;
	this.element.top = this.lastPosy;
}

function clsImage(browserBehavior,layerId,imageId)
{
	this.browser		= browserBehavior;
	this.layerId		= layerId;
	this.imageName		= imageId;
	this.normalImage	= new Image();
	this.popupImage		= new Image();
	this.popup			= libImagePopup;
	this.normal			= libImageNormal;
}

function libImagePopup()
{
var Img = new Image();
	if (document.images)
	{
		if (this.browser.isNetscape && this.layerId!=null) 
				Img = eval('document.'+this.layerId+'.document.images["'+this.imageName+'"]');
		else	
				Img = document.images[this.imageName];//ambos browsers

		Img.src = this.popupImage.src;				
	}
	return false;
}

function libImageNormal()
{
var Img = new Image();
	if (document.images)
	{
		if (this.browser.isNetscape && this.layerId!=null) 
				Img = eval('document.'+this.layerId+'.document.images["'+this.imageName+'"]');
		else 
				Img = document.images[this.imageName];
	
		Img.src = this.normalImage.src;				
	}
	return false;
}