/**
 * Funciones para hacer los Scrolls de las páginas
 *
 */
function mover_noticias(){		
		PerformScroll(1);	
}
function mover_noticias2(){	
	PerformScroll(-1);	
}


function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?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 
} 
bw=new verifyCompatibleBrowser() 
 
 
var speed=50 
 
var loop, timer 
 
function ConstructObject(obj,nest){ 
    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) 
		
	}
	else { 				
		Timer=setTimeout('mover_noticias2()',1000); 	
	}
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
		this.MoveArea(0,this.y-move) 
	  if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
	else { 		
		Timer=setTimeout('mover_noticias()',1000);	
	}
} 
 
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) 
    Timer=setTimeout('mover_noticias()',1000);
} 
var initialised; 
function InitialiseScrollableArea(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true; 
} 

///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var scrTimer = 20; // interval between calls to scroll onmouseover
var scrTmId=0;	// for setTimeouts

var pgLoaded;
wndo = new Array();	// "window" for scrollable content

function dw_shiftTo(x,y) {
	if (ns4) { this.css.moveTo(x,y); } 
	else { this.css.left=x+"px"; this.css.top=y+"px"; }
}

function dw_shiftBy(x,y) {
	if (ns4) { this.css.moveBy(x,y); }
	else { 
		this.css.left = parseInt(this.css.left)+x+"px";
		this.css.top = parseInt(this.css.top)+y+"px";
	}
}

function dw_show() {	this.css.visibility = "visible"; }
function dw_hide() { this.css.visibility = "hidden"; }

// These functions are for onclick scrolling
function jumpDown(num,jump) {
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>(-wndo[num].maxY)) { 
		if ((y-jump)>(-wndo[num].maxY)) wndo[num].cnt.shiftBy(0,-jump);
		else wndo[num].cnt.shiftBy(0,-(wndo[num].maxY-Math.abs(y)));	
  }
}

function jumpRight(num,jump) {
	var x = parseInt(wndo[num].cnt.css.left);
	if (x>(-wndo[num].maxX)) {
		if ((x-jump)>(-wndo[num].maxX)) wndo[num].cnt.shiftBy(-jump,0);
		else wndo[num].cnt.shiftBy(-(wndo[num].maxX-Math.abs(x)),0);	
  }
}

function jumpUp(num,jump) {
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		if ((y+jump)<=0) wndo[num].cnt.shiftBy(0,jump); 
		else wndo[num].cnt.shiftBy(0,-y); 
	}
}

function jumpLeft(num,jump) {
	var x = parseInt(wndo[num].cnt.css.left);
	if (x<0) { 
		if ((x+jump)<=0) wndo[num].cnt.shiftBy(jump,0); 
		else wndo[num].cnt.shiftBy(-x,0); 
	}
}

// These functions are for onmouseover scrolling
function inchDown(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y>-wndo[num].maxY) { 
		wndo[num].cnt.shiftBy(0,-inc);
		scrTmId = setTimeout("inchDown("+num+","+inc+")",scrTimer);	
	}
}

function inchUp(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		wndo[num].cnt.shiftBy(0,inc);
		scrTmId = setTimeout("inchUp("+num+","+inc+")",scrTimer);	
  }
}

function inchRight(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);	
	if (y>-wndo[num].maxX) { 
		wndo[num].cnt.shiftBy(-inc,0);
		scrTmId = setTimeout("inchRight("+num+","+inc+")",scrTimer);	
	}
}

function inchLeft(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);
	if (y<0) { 
		wndo[num].cnt.shiftBy(inc,0);
		scrTmId = setTimeout("inchLeft("+num+","+inc+")",scrTimer);	
  }
}

function stopScroll() {
	clearTimeout(scrTmId);
}

////////////////////////////////////////////////////////////////////
//  Constructor function used for creating scrollable content areas.
//	Used to create both wndo and content objects.
//  Argument for creating wndo objects:	id of wndo div.
//	Arguments for creating content (done in loadScrLyr function):
//	id of content div, id of html element that contains content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
////////////////////////////////////////////////////////////////////
function dw_lyrObj(obj,id) {
	this.el = (ns4)? getLyrRef(obj,document): (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;
	this.css = (ns4)? this.el: (ie4||ie5||ns5)? this.el.style: null;
	this.height = (ns4)? this.el.clip.height: (ie4||ie5)? this.el.clientHeight: (ns5)? this.el.offsetHeight: 0;
	this.width = (ns4)? this.el.clip.width: (ie4||ie5)? this.el.clientWidth: (ns5)? (id)? document.getElementById(id).offsetWidth: this.el.offsetWidth: 0;
}

/////////////////////////////////////////////////////////////////////
// loadScrLyr function: loads scrollable content div(s)
//	arg's: wndo array number, id of scrollable div,
//	and id of table or other html element that contains div content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
/////////////////////////////////////////////////////////////////////
function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
	wndo[num].cnt = new dw_lyrObj(lyr,id);
	wndo[num].cnt.show();
	wndo[num].cnt.shiftTo(0,0);	// restore top/left to 0 
	wndo[num].maxX = wndo[num].cnt.width - wndo[num].width;
	wndo[num].maxY = wndo[num].cnt.height - wndo[num].height
} 

dw_lyrObj.prototype.shiftBy=dw_shiftBy;
dw_lyrObj.prototype.shiftTo=dw_shiftTo;
dw_lyrObj.prototype.show=dw_show; 
dw_lyrObj.prototype.hide=dw_hide;

// get reference to nested layer for ns4
// from dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (ns4) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}
