var speed=10;
var loop, timer;
var objContainer,objScroller;

function inicio_zona_scroll(top,left,clipx,clipy){
	if(typeof(bw)=='undefined') return;
	if(bw.ns4) {
		//document.write('<ilayer name="contenedor" left="0" top="0" width="'+clipx+'" height="'+clipy+'" visibility="show" clip="'+clipx+','+clipy+'" id="contenedor"  bgcolor="#00FFFF">');
		//document.write('<layer name="contenido" width="'+clipx+'" visibility="show" id="contenido">');
		;
	} else {
		document.write('<div id="contenedor" style="top:'+top+'px; width:'+clipx+'px; height:'+clipy+'px; clip: rect('+clipx+'px, '+clipy+'px); overflow:hidden; " name="contenedor">');
		document.write('<div name="contenido" id="contenido" style="width:'+clipx+'px;">');
	}
}

function fin_zona_scroll(){
	if(typeof(bw)=='undefined') return;
	if(bw.ns4) ; //document.write('</layer></ilayer>');
	else document.write('</div></div>');
}

// contenido

function hide(contenedor){
return;
	if(document.layers){
		o0=document.layers['contenedor']
		o1=o0.layers['contenido'];
		o1.visibility = 'hide';
	}
	else if(document.getElementById) 
		document.getElementById(contenedor).style.visibility = 'hidden'
	else if(document.all)
		document.all.contenedor.style.visibility = 'hidden'
}
function show(contenedor){
return;
	if(document.layers){
		document.layers['contenedor'].document.layers['centenido'].visibility = 'show';
	}
	else if(document.getElementById)
		document.getElementById(contenedor).style.visibility = 'visible'
	else if(document.all)
		document.all.contenedor.style.visibility = 'visible'
}

// scroll

function subir(c){
	document.ics.src='_res/s_'+c+'.gif';
	window.status='subiendo';
	PerformScroll(1); 
	return true;
}
function bajar(c){
	document.icb.src='_res/b_'+c+'.gif';
	window.status='bajando';
	PerformScroll(-1);
	return true;
}
function parar(c){
	document.ics.src='_res/s_'+c+'.gif';
	document.icb.src='_res/b_'+c+'.gif';
	window.status='';
	CeaseScroll();
	return true;
}
function arriba(){
	window.status='arriba';
	CeaseScroll();
	objScroller.MoveArea(0,-objScroller.scrollHeight+objContainer.clipHeight);
}
function abajo(){
	window.status='abajo';
	CeaseScroll();
	objScroller.MoveArea(0,0);
}

function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
function MoveAreaDown(move){ 
   if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
   } 
} 
function MoveAreaUp(move){ 
   if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
   } 
} 

function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
	if(bw.ns4){
		if(obj=='contenedor'){
			this.el=document.layers.contenedor;
			this.css=document.layers.contenedor;
		} else {
			this.el=document.layers.contenedor.document.layers.contenedor.layers.contenido;
			this.css=document.layers.contenedor.document.layers.contenedor.layers.contenido;
		}

		
	} else {
	    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	}
    this.scrollHeight=bw.ns4?document.layers.contenedor.document.layers.contenedor.layers.contenido.clip.height:this.el.offsetHeight; 
    this.clipHeight=bw.ns4?document.layers.contenedor.clip.height:this.el.offsetHeight;
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object";
    eval(this.obj + "=this");
    return this;
} 

function PerformScroll(speed){ 
   if(initialised){ 
      loop=true; 
      if(speed>0) objScroller.down(speed);
      else objScroller.up(speed);
   } 
} 
function CeaseScroll(){ 
    loop=false;
    if(timer) clearTimeout(timer);
} 

var initialised; 
function InitialiseScrollableArea(){ 
//return;
    objContainer=new ConstructObject('contenedor') 
    objScroller=new ConstructObject('contenido','contenedor');
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible';
	if(objContainer.scrollHeight<objScroller.scrollHeight){
		var o=d_obj('botonera_scroll');
		if(o) o.style.visibility='visible';
	}
    initialised=true; 
} 

//OK MSIE6
function init_scroll(){	
	InitialiseScrollableArea();
}
function refrescar(){ window.location.reload(); }
window.onresize=refrescar;
