   
   
					/* Purpose: Scroll through panes by either autoscroll, arrow buttons or pane indicator buttons  */

					//document.getElementById("tooltipPool").styles.display="none";
 
					TECHTREE.namespace('Games');	 
					TECHTREE.Games.Scroller = function(args) {	 
					args = args || {};

				
  					this.viewableArea = document.getElementById(args.viewableArea) || 'ynscrollviewable';
					

					this.scrollerContainer = args.scrollerContainer || 'ynscroll';
					this.indicatorContainer = args.indicatorContainer || 'ynindcont';
					this.scrollButtonContainer = args.scrollButtonContainer || 'scrollButtonContainer';
					
	
					this.delayTime = args.delayTime || 10000;
						
			

					this.currentPane = 0;
					this.autoScroll = null;
					this.autoScrollOn =true;
	 
					/* Setup ID/Class Names */
					this.sclBtnLft = "sclBtnLft";
					this.sclBtnRgt = "sclBtnRgt";
					this.sclBtnClassOff = "buttonOff";
					this.sclBtnClassOn  = "buttonOn";
					this.indicatorClassOff = "off";
					this.indicatorClassOn = "on";

					
	
					/*this.w = this.viewableArea.offsetWidth;*/
					this.w=594;/*This is hardcoded & overrided  by saradhi to fix IE bug */
					
					this.viewableArea.scrollLeft = '100px';
	
					// ********************* Count DIVs and assign a Global Value of Panes ******************
					var gettabs = document.getElementById(this.scrollerContainer); 
					var getdiv = gettabs.getElementsByTagName("div"); 			
	
					var countPanes = 0;
					var dl = getdiv.length;
					for (var x=0; x < dl; x++) {
					var classkey = getdiv[x].getAttribute("name");	
		
					if ((x === 0) && (classkey == "container")) {
					var getFirst = getdiv[x]; 
					}
			
	    				if (classkey == "container") {
	 	    			var idstring = getdiv[x].id;
					countPanes++;  
	    				}				
					}
					this.maxpanes = countPanes-1;
					this.max_width = this.w * this.maxpanes;
	
					// ************************  Duplicate 1st Pane and append to end of ynscroll ****************************
					var duplicate = getFirst.cloneNode(true);
					duplicate.removeAttribute("id");
					duplicate.setAttribute("name", "duplicate");
					document.getElementById(this.scrollerContainer).appendChild(duplicate);
	
	
					// ************************  Setup Arrow Buttons and Indicator Button Links ****************************
					//document.write('<div class="dline_vert"></div>');
					document.write('<div id="'+this.scrollButtonContainer+'">');
					document.write('<div class="fscleft">');
					document.write('<a href="/" class="'+this.sclBtnClassOff+'"><strong>Left Arrow</strong></a>');
					document.write('</div>');	
					document.write('<div class="fscright">');
					if (this.maxpanes > 0) {
					document.write('<a href="/" class="'+this.sclBtnClassOn+'"><strong>Right Arrow</strong></a>');
					} else if (this.maxpanes == 0) {
					document.write('<a href="/" class="'+this.sclBtnClassOff+'"><strong>Right Arrow</strong></a>');
					}
					document.write('</div>');
					document.write('</div>');
	
	
					document.write('<div id="'+this.indicatorContainer+'" class="dots">');
					for (x=0; x <= this.maxpanes; x++) {
					if (x == 0) {
					document.write('<a href="/" id="'+this.indicatorContainer+x+'" class="'+this.indicatorClassOn+'"><strong>Pane '+x+'</strong>&nbsp;</a>');
					} else {
					document.write('<a href="/" id="'+this.indicatorContainer+x+'" class="'+this.indicatorClassOff+'"><strong>Pane '+x+'</strong>&nbsp;</a>');
					}
					}
					document.write('</div>');		
	 
					TECHTREE.util.Event.onAvailable(this.scrollerContainer, this.init, this, true);
					//TECHTREE.util.Event.addListener(window, 'load', this.init, this, true);
					};

					TECHTREE.Games.Scroller.prototype = {
					init : function() {		
					var getContainer = document.getElementById(this.scrollButtonContainer);
				        var getanchor = getContainer.getElementsByTagName("a"); 			
		  			var al = getanchor.length;
	
					for (var x=0; x < al; x++) {
					if (x == 0) {
					var getLeft = getanchor[x];
				  	TECHTREE.util.Event.addListener(getLeft, 'click', this.prev, this, true);
					} else if (x == 1) {
					var getRight = getanchor[x];			  
				  	TECHTREE.util.Event.addListener(getRight, 'click', this.next, this, true);
					}
					}	  
		
		  			// ******************  Setup Indicator Button Links *****************
		  			var getcont = document.getElementById(this.indicatorContainer);
			         	var getAnchor = getcont.getElementsByTagName('a');
		                        var il = getAnchor.length;
		   
		  			for (var n = 0; n < il; n++) {		  	
		  	    		getAnchor[n].cp = n;
					TECHTREE.util.Event.addListener(getAnchor[n], 'click', this.indicators, this, true);					
					}
		  			if (this.maxpanes != 0) { this.autoStart(); }
					}, 	
	
					indicators : function(e) {
					if (this.maxpanes != 0) { 
					this.stopInterval();
					this.currentPane = TECHTREE.util.Event.getTarget(e).cp; 
					this.scrollToPane(this.currentPane); 
					}		
					TECHTREE.util.Event.preventDefault(e);	
					},
	

					prev : function(e) {
					if (this.currentPane < 0) { this.currentPane = 0; TECHTREE.util.Event.preventDefault(e); return; } 
					this.stopInterval();
					this.currentPane--; 
					this.scrollToPane(this.currentPane);
					TECHTREE.util.Event.preventDefault(e);		
					},

					next : function(e) {
					if (this.currentPane == this.maxpanes) { this.currentPane = this.maxpanes; TECHTREE.util.Event.preventDefault(e); return; }
					this.stopInterval(); 
					this.currentPane++;
					this.scrollToPane(this.currentPane); 
					TECHTREE.util.Event.preventDefault(e);
					},	

					changeStates : function(currentPane) {
					if (currentPane == 0) {
					this.changeButtons('f');
					} else {
					this.changeButtons('m');
					}
					//var check = (currentPane == 0)  ? this.changeButtons('f') : this.changeButtons('m');
					if (currentPane > 0) { this.changeButtons('m'); }
					if (currentPane == this.maxpanes) { this.changeButtons('l'); }		
		
					var count = 0;
	    				while (count <= this.maxpanes) {
		   			var a = this.indicatorContainer + count; 
		   			var setIndiOff = document.getElementById(a);	
		   			setIndiOff.className = this.indicatorClassOff;
					setIndiOff.setAttribute("class", this.indicatorClassOff);
		   			count++;
	    				}			
	    				if (currentPane > this.maxpanes) { currentPane = 0; this.currentPane = 0; this.changeButtons('f'); }
					var temp = this.indicatorContainer + currentPane;
	    				var setIndiOn = document.getElementById(temp);
					setIndiOn.className = this.indicatorClassOn;
	    				setIndiOn.setAttribute("class", this.indicatorClassOn); 
					},
   
					changeButtons : function(m) {
					switch (m) {
					case "f":
					this.bgPos(this.sclBtnLft,"off");
					this.bgPos(this.sclBtnRgt,"on");
					break;
					case "m":
					this.bgPos(this.sclBtnLft,"on");	
					this.bgPos(this.sclBtnRgt,"on");
					break;
					case "l":
					this.bgPos(this.sclBtnLft,"on");	
					this.bgPos(this.sclBtnRgt,"off");
					break;
					default: 
					this.bgPos(this.sclBtnLft,"off");
					this.bgPos(this.sclBtnRgt,"on");	
					}
					},

	 				bgPos : function(classNm,state) {	
        				var getContainer = document.getElementById(this.scrollButtonContainer);
	    				var getanchor = getContainer.getElementsByTagName("a");
					if (classNm == this.sclBtnLft) { 
					var button = getanchor[0];
					} else if (classNm == this.sclBtnRgt) {
			 		var button = getanchor[1];
					}
					if (state == "off") { 
					button.className = this.sclBtnClassOff+" "+this.classNm;
					button.setAttribute("class", this.sclBtnClassOff+" "+this.classNm); 
					} else if  (state == "on") {
					button.className = this.sclBtnClassOn+" "+classNm;
					button.setAttribute("class", this.sclBtnClassOn+" "+this.classNm);
					}
	 				},		
	   
	 				scrollToPane : function(currentPane) {
	      				if (currentPane == -1) { return; }	
		  			this.currentPane = currentPane;
		  			this.animate(currentPane);
		  			this.changeStates(currentPane);	 
	 				}, 

	 				animate : function(currentPane) {
									
					//alert("this object this.viewableArea:"+this.viewableArea.id);
					
	 	  			var move = currentPane * this.w;	
	 	 
	  	  			var attributes = {
		  			scroll: { to: [move, 0] }
	   	  			};
	   	  			var anim = new TECHTREE.util.Scroll(this.viewableArea, attributes, 0.5, TECHTREE.util.Easing.easeOut);
													
		  			if ((this.autoScrollOn === true) && (currentPane > this.maxpanes)) {
					anim.onComplete.subscribe(this.setToZero);
	        			this.stopInterval();
					this.currentPane = 0;
	        			this.changeStates(this.currentPane);
		  			}
		  			anim.animate();	
		  			return false;
	 				},
  
					setToZero : function() {
	      				var el = this.getEl();
	      				el.scrollLeft = 0;	
	 				},
 
					autoStart : function() {
					if (this.autoScrollOn) {
					var doit = function(self) {
					return function() {
		  			self.scrollToPane(self.currentPane+1);
					self.autoStart();
		      			}
					}
			
					clearTimeout(this.autoScroll);
					this.autoScroll = setTimeout(doit(this),this.delayTime); 
					}
					}, 	
	
					stopInterval : function() {
					if (this.autoScrollOn === true) {
					clearTimeout(this.autoScroll);
					this.autoScrollOn = true;
					}
					}
	
					};
   
   
   

