
// ==============================================================
// 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);
	}
}

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY)
    {
		//Added by T Bhanu on 12th Feb 2009
		//Begin :
		var ScrollAreaHeight;
		var buttons ='';
		var browserName=navigator.appName;
		var style='';
		ScrollAreaHeight = 24;
		
		if(browserName.toLowerCase() == "netscape".toLowerCase())
		{
		    style = ' style="z-index:1"';
		} 
	    //End : 
		buttons += '<div class="up"' + style + '  id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="Images/ScrollDown.jpg" ></a></div>';
		buttons += '<div class="dn" ' + style + '  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="Images/ScrollUp.jpg"></a></div>';
		buttons += '<div class="thumb" ' + style + ' id="'+thumb+'" style="left: 135px; top: 15px;align:center;"><img src="Images/Scroller.jpg" width="11" height="25"></div>';
		buttons += '<div id="scrollarea'+count+ '" class="thumb" style="width:11px;border-width:1px;"></div>';
		ScrollAreaHeight = maxY+ScrollAreaHeight;
		document.getElementById(root).innerHTML = buttons + document.getElementById(root).innerHTML;

		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+0)+3 + "px";
		thisup.style.left = parseInt(minX+0)+3 + "px";
		thisdn.style.left = parseInt(minX+0)+3 + "px";
		
		theThumb[count].style.border =0;
		
		theThumb[count].style.top = parseInt(minY)-2 + "px";
		thisup.style.top = 0 + "px";
		thisdn.style.top = parseInt(minY+maxY)+ 4  + "px";
		
		//thisdn.style.top = 15 + "px";
		//Added by T Bhanu on 12th Feb 2009
		//Begin :
		var theScrollarea = [];
		theScrollarea[count]  = document.getElementById("scrollarea" + count);
		theScrollarea[count].style.left = parseInt(minX+0)+2 + "px";
		theScrollarea[count].style.top = parseInt(minY) - 11 + "px";
		theScrollarea[count].style.height = ScrollAreaHeight-1 + "px";
		theScroll[count].load();
        //End :
		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init(theThumb[count], null, minX+3, maxX+3, minY-2, maxY-10);
		
		// 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]));
		}
}	

// 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();
         //document.getElementById("divLanguage")
         }
      }
   }
addLoadEvent(function(){
		if(theScroll.length>0) {
		for(var i=0;i<theScroll.length;i++){
		//Modified By T Bhanu on 22nd Jan 2008
			createDragger(i, "handle"+i, "root"+i, "thumb"+i, theScroll[i].clipW, theScroll[i].clipW, 10, theScroll[i].clipH-20);
			//createDragger(count, handler, root, thumb, minX, maxX, minY, maxY)
		}
	}
}) 
