/*
====================	Funciones de Layers		=======================
*/


distLayers = new Array(3);

for (x = 0; x < distLayers.length; x++)
{
	distLayers[x] = new Array(6);
	distLayers[x][0] = 'Barra'+(x+1)+'';
	distLayers[x][2] = new Array(4)
	distLayers[x][3] = false;
}


function MM_showHideLayers() 
{ //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;

	if (args[0] != "")
	{	
		for (i=0; i<(args.length-2); i+=3) 
		{
			if ((obj=MM_findObj(args[i]))!=null) 
			{ 
				name = args[i];
				v=args[i+2];
				if (obj.style) 
				{ 
					obj=obj.style;

					v=(v=='show')?'visible':(v='hide')?'hidden':v;

					//alert(name + " " + v);
					
					if (v == 'visible')
					{
						for (i = 0; i < distLayers.length; i++)
						{
							if (distLayers[i][0] == name)
							{
								//alert(distLayers[i][0]);
								distLayers[i][3] = true;
							}
						}
					}


				}
				obj.visibility=v;
			}
		}
	}
}


function iniciaValores(capa,X,Y) {
//var leftsize = ((screen.width-779)/2)-34 //absolute

//alert(X);

//alert(Y);

var leftsize = 0 //relative

  if(ie)
   {
     document.all[capa].style.top=Y;
     document.all[capa].style.left=X + leftsize;
   }
   else if(n4)
    {
      document.layers[capa].top=Y;
      document.layers[capa].left=X + leftsize;
    }
    if(n6)
     {
       document.getElementById(capa).style.top=Y;
       document.getElementById(capa).style.left=X + leftsize;
     }
}


function PositionLayers() { 
  var i=0,LayersName=PositionLayers.arguments;

  for(i=0;i<=(LayersName.length-3);i+=3) {	
	iniciaValores(LayersName[i],LayersName[i+1],LayersName[i+2]);
  }
}


/*
Informacion de configuracion de pantalla
del servidor
*/
function Ver(data)
{
	var myWidth = 0, myHeight = 0;
	if (typeof( window.innerWidth ) == 'number') 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if ( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
			{
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
	}

	if (data == "width")
		return myWidth;
	else
		return myHeight;

}



function SetBottomClip()
{               
	if (document.all)
	{

		for (x = 0; x < distLayers.length; x++)
		{
			document.all[distLayers[x][0]].style.clip="rect("+distLayers[x][2][0]+","+distLayers[x][2][1]+","+distLayers[x][2][2]+","+distLayers[x][2][3]+")";
		}
	}

	else if(document.layers)
		{
			for (x = 0; x < distLayers.length; x++)
			{	
				document.layers[distLayers[x][0]].clip.top = distLayers[x][2][0];
				document.layers[distLayers[x][0]].clip.right = distLayers[x][2][1];
				document.layers[distLayers[x][0]].clip.bottom = distLayers[x][2][2];
				document.layers[distLayers[x][0]].clip.left = distLayers[x][2][3]; 				
			}

		}

		else if(document.getElementById)
		{
			for (x = 0; x < distLayers.length; x++)
			{                             
				document.getElementById(distLayers[x][0]).style.clip="rect("+distLayers[x][2][0]+","+distLayers[x][2][1]+","+distLayers[x][2][2]+","+distLayers[x][2][3]+")";
			}            
		}
}



/*
Funcion que ubica los layers segun la 
configuracion de pantalla del cliente
*/

function DistanciasLayers()
{
	
	width = Ver("width");
	marginwidth = (width - 779) / 2 ;

	height = Ver("height");

	marginheight = (height - 411) / 2 ;
	
	//left
	if (width < 781)
		if (ie)
			distLayers[0][1] = marginwidth + 257;
		else
			distLayers[0][1] = marginwidth + 250;
	else
		if (width < 1133)
			if (ie)
				distLayers[0][1] = marginwidth + 257;
			else
				distLayers[0][1] = marginwidth + 250;
		else
			if (ie)
				distLayers[0][1] = marginwidth + 257;
			else
				distLayers[0][1] = marginwidth + 250;

	//top
	distLayers[0][4] = 219;	

	//posicion de los clips del Layer 1
	distLayers[0][2][0] = '0';
	distLayers[0][2][1] = '177';
	distLayers[0][2][2] = '0';
	distLayers[0][2][3] = '0';
	
	//====================================================

	//left
	if (width < 781)
		if (ie)
			distLayers[1][1] = marginwidth + 437;
		else
			distLayers[1][1] = marginwidth + 430;
	else
		if (width < 1133)
			if (ie)
				distLayers[1][1] = marginwidth + 437;
			else
				distLayers[1][1] = marginwidth + 430;
		else
			if (ie)
				distLayers[1][1] = marginwidth + 437;
			else
				distLayers[1][1] = marginwidth + 430;

	//top
	distLayers[1][4] = 219;	

	//posicion de los clips del Layer 1
	distLayers[1][2][0] = '0';
	distLayers[1][2][1] = '177';
	distLayers[1][2][2] = '0';
	distLayers[1][2][3] = '0';

	//====================================================

	//left
	if (width < 781)
		if (ie)
			distLayers[2][1] = marginwidth + 622;
		else
			distLayers[2][1] = marginwidth + 615;
	else
		if (width < 1133)
			if (ie)
				distLayers[2][1] = marginwidth + 622;
			else
				distLayers[2][1] = marginwidth + 615;
		else
			if (ie)
				distLayers[2][1] = marginwidth + 622;
			else
				distLayers[2][1] = marginwidth + 615;

	//top
	distLayers[2][4] = 219;	

	//posicion de los clips del Layer 1
	distLayers[2][2][0] = '0';
	distLayers[2][2][1] = '177';
	distLayers[2][2][2] = '0';
	distLayers[2][2][3] = '0';
	
	//====================================================
	
	texto = "";

	for (x = 0; x < distLayers.length; x++)	
	{		
		texto = texto + '\'' + distLayers[x][0] + '\',' + distLayers[x][1] + ',\''+distLayers[x][4]+'\',';
		//alert(texto);
	}

	texto = texto.substring(0,texto.length-1);


	eval('PositionLayers('+texto+');');	
	
}


function init()
{
	//ubica los layers
	DistanciasLayers();
	
}

function refresh()
{
	init();
	setTimeout("refresh()",50);
}


function hideLay(name)
{
	for (w = 0; w < distLayers.length; w++)
	{
		if (distLayers[w][0] == name)
		{
			distLayers[w][3] = false;
		}	
	}	
}


function showLay(name)
{
	for (w = 0; w < distLayers.length; w++)
	{
		if (distLayers[w][0] == name)
		{
			distLayers[w][3] = true;
		}	
	}	
}


function refreshHideLayers()
{
	
	for (z = 0; z < distLayers.length; z++)
	{
		if (distLayers[z][3] == false)
		{
			MM_showHideLayers(distLayers[z][0],'','hide');
		}
	}
	

	setTimeout("refreshHideLayers()",1500);
}


/*
====================	Fin Funciones de Layers		=======================
*/