// ***********************************************
// * Author       : Arista Grupo de Comunicación *
// * Copyright    : (c) 2000 Arista Multimedia   *
// * WEB          : http://www.arista.es         *
// * E-Mail       : &#097;&#114;&#105;&#115;&#116;&#097;&#064;&#097;&#114;&#105;&#115;&#116;&#097;&#046;&#101;&#115;             *
// * Tel.         : 0034 943215177               *
// ***********************************************

function verifyBrowser(){
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie6 =(this.dom && navigator.userAgent.toLowerCase().indexOf('msie 6') > -1) ? 1 : 0;
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 

var speed=50 

var loop, timer, bw
 
function ConstructObject(obj,nest){ 
    if (!bw) bw = new verifyBrowser(); 
    nest=(!nest) ? '':'document.'+nest+'.' 
    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?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.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 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) 
        incremento=((altoBarra*this.y)/(-this.scrollHeight+objContainer.clipHeight))
        if (incremento>altoBarra) incremento=altoBarra
        objBarra.MoveArea(leftBarra,topBarra+incremento)
    } 
} 
function MoveAreaUp(move){ 
    if(this.y<0){ 
        this.MoveArea(0,this.y-move) 
        if(loop) setTimeout(this.obj+".up("+move+")",speed) 
        incremento=((altoBarra*this.y)/(-this.scrollHeight+objContainer.clipHeight))
        if (incremento<0) incremento=0
        objBarra.MoveArea(leftBarra,topBarra+incremento)
    } 
} 
 
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(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    altoBarra=50
    leftBarra=763
    topBarra=324
    objBarra=new ConstructObject('divBarra')
    objBarra.MoveArea(leftBarra,topBarra) 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible'
    capturaScroll();
    initialised=true; 
} 

function capturaScroll(){
    obj = window.document;
    if(obj) {
	obj.onmousemove = ArrastraScrollWin;
	obj.onmousedown = ArrastraScrollWin;
	obj.onmouseup = ArrastraScrollWin;
	if(obj.captureEvents) {
	    obj.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP);
	}
        if (bw.ie6){
           document.all('divContainer').onmousewheel = ArrastraScrollWin;
        }
    }
}

var arrastrar,oy
function ArrastraScrollWin(ev){
	if(ev) { px = ev.pageX;py = ev.pageY;}
	else { ev = event;px = ev.x + document.body.scrollLeft;py = ev.y + document.body.scrollTop;}
	if(ev.type == "mousemove") {
		if(arrastrar) {
			yy=py+oy
			if (yy<topBarra) yy=topBarra
			if (yy>topBarra+altoBarra) yy=topBarra+altoBarra
        		objBarra.MoveArea(leftBarra,yy)
        		objScroller.MoveArea(0,(-objScroller.scrollHeight+objContainer.clipHeight)*(objBarra.y-topBarra)/altoBarra)
        		return false;
		}
		/*if (abierto===false||subabierto===false) return true;
		x=nav=='ie'?event.x:evnt.pageX;
		y=nav=='ie'?event.y:evnt.pageY;
		izq=parseInt(eval("capa('menu"+abierto+"sub"+subabierto+"')"+izquierda))
		dcha=izq+parseInt(eval("capa('menu"+abierto+"sub"+subabierto+"')"+ancho))
		arrb=parseInt(eval("capa('menu"+abierto+"sub"+subabierto+"')"+arriba))
		abaj=arrb+parseInt(eval("capa('menu"+abierto+"sub"+subabierto+"')"+alto))
		if (x<izq||x>dcha||y>abaj){
			eval("capa('menu"+abierto+"sub"+subabierto+"')"+ocultar)
			subabierto=false
		}*/
	}
	else if(ev.type == "mousedown") {
		if(px>objBarra.x&&px<objBarra.x+18&py>objBarra.y&&py<objBarra.y+27){
			oy=objBarra.y-py
			arrastrar=true
		}
	}
	else if (ev.type == "mousewheel") {
		if (window.event.wheelDelta <= -120){
			loop = false;
			objScroller.down(15);
		}
		else if (window.event.wheelDelta >= 120){
			loop = false;
		        objScroller.up(-15) 
		}
	}
	else if(ev.type == "mouseup") arrastrar=false
	return true;
}