

// ==============================================================
// HANDLES SCROLLER/S
// Modified from Aaron Boodman http://webapp.youngpup.net/?request=/components/ypSimpleScroll.xml
// mixed ypSimpleScroll with dom-drag script and allowed multiple scrolelrs through array instances
// (c)2004 Sergi Meseguer (http://zigotica.com/), 04/2004:
// ==============================================================
var theHandle = []; var theRoot = []; var theThumb = []; var theScroll = []; var thumbTravel = []; var ratio = [];

function instantiateScroller(count, id, left, top, width, height, speed){
	if(document.getElementById) {
		theScroll[count] = new ypSimpleScroll(id, left, top, width, height, speed);
	}
}
var content = Array();
//yusuf81
content[0] = '<iframe src="gestion/giras/agenda.php?anteriores=0&css=giras.css" id="agenda" allowtransparency="true" width="400" style="height:500px;" scrolling="no" framespacing="0" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
content[1] = '<iframe src="noticias.php" id="noticias" allowtransparency="true" width="240" marginwidth="0" style="height:220px;" marginheight="0" scrolling="No" frameborder="0" id="agenda" framespacing="0"></iframe>';

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY, izquierda, arriba){
		
		var buttons = '<div class="up" id="up'+count+'"><a href="javascript:void(0);" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="/img/scroll/up'+count+'.gif" width="8" height="8"></a></div><div class="dn" id="dn'+count+'""><a href="javascript:void(0);" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="/img/scroll/dn'+count+'.gif" width="8" height="8"></a></div><div class="thumb" id="'+thumb+'"><img src="/img/scroll/thumb'+count+'.gif" width="6" height="14"></div>';
		document.getElementById(root).innerHTML = buttons + document.getElementById(root).innerHTML;

		var iframe = [];
		iframe[count] = content[count];
		
		var contenedor = document.getElementById(root);
		contenedor.style.left = izquierda+"px";
		contenedor.style.top = arriba+"px";
		//alert(izquierda);
		
		document.getElementById("scroll"+count+"Content").innerHTML = iframe[count];
		
		theRoot[count]   = document.getElementById(root);
		theThumb[count]  = document.getElementById(thumb);
		var thisup = document.getElementById("up"+count);
		var thisdn = document.getElementById("dn"+count);
		theThumb[count].style.left = parseInt(minX+1) + "px";
		thisup.style.left = parseInt(minX) + "px";
		thisdn.style.left = parseInt(minX) + "px";
		theThumb[count].style.border = 0;
		theThumb[count].style.top = parseInt(minY-5) +"px";
		thisup.style.top = 0 + "px";
		thisdn.style.top = parseInt(minY+maxY) + "px";
		//thisdn.style.top = 15 + "px";

		theScroll[count].load();

		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init(theThumb[count], null, minX+1, maxX+1, minY-5, maxY);
		
		// the number of pixels the thumb can travel vertically (max - min)
		thumbTravel[count] = theThumb[count].maxY - theThumb[count].minY;

		// the ratio between scroller movement and thumbMovement
		ratio[count] = theScroll[count].scrollH / thumbTravel[count];

		theThumb[count].onDrag = function(x, y) {
			theScroll[count].jumpTo(null, Math.round((y - theThumb[count].minY) * ratio[count]));
		}
		
		var mi_iframe = document.getElementById("agenda");
		//alert(mi_iframe.style.height);
}		
		

// INITIALIZER:
// ==============================================================
// ala Simon Willison http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(fn) {
      var old = window.onload;
      if (typeof window.onload != 'function') {
         window.onload = fn;
      }
      else {
         window.onload = function() {
         old();
         fn();
         }
      }
   }
addLoadEvent(function(){
		if(theScroll.length>0) {
		for(var i=0;i<theScroll.length;i++){
			createDragger(i, "handle"+i, "root"+i, "thumb"+i, theScroll[i].clipW, theScroll[i].clipW, 15, theScroll[i].clipH-30, theScroll[i].scrollIzquierda, theScroll[i].scrollArriba);
		}
	}
}) 
