/*!
**********************************************************************
@file WizardScrollbar1.js

Copyright 2003-2008 Adobe Systems Incorporated.                     
All Rights Reserved.                                                
                                                                    
NOTICE: All information contained herein is the property of Adobe   
Systems Incorporated.                                                                                                                    

***********************************************************************
*/

var mobar_active = null;//dynamic setting it to the currently active vertical scrollbar

/**
Wizard Scrollbar for scrolling, what else can it be for?! :)
*/

function WizardScrollbar1(inbgClName, infgClName, affixToContainer)
{
	//ZZZZZZZZZZZZZZZZZZZZZZZZ
	var addToContainer = affixToContainer.parentElement;
	
	addToContainer.style.border="3px solid orange";
	affixToContainer.style.border="3px solid yellow";
	
	//addToContainer.style["overflow"]="hidden";
	affixToContainer.style["overflow"]="hidden";
	//ZZZZZZZZZZZZZZZZZZZZZZZZ
	
	/*PART1 :: WizardScrollbar1 inherits from WizardWidget1*/
	this.base=WizardWidget1;
	/*END OF PART1*/
	
	/*PART2 :: Create main element*/
		//MAIN DIV
		var maindiv = document.createElement("a");
		this.uielement=maindiv;
		this.maindiv=maindiv;
		
		//IMAGE
		this.bar_bg_wz = new WizardImage1("media/img/scroll_well.png", null, inbgClName, maindiv,null,null,null,true);
		this.bar_bg = this.bar_bg_wz.GetDisplayElement();
			this.bar_bg.style["z-index"]="188";
			this.bar_bg.style.position = "absolute";
			this.bar_bg.style.left = "0px";
			this.bar_bg.style.top = "0px";
			this.bar_bg.style.display="block";
			this.bar_bg.style.height="215px";
			this.bar_bg.style.width = "16px";
			
		//IMAGE
		this.bar_wz = new WizardImage1("media/img/scroll_thumb.png", null, infgClName, maindiv,null,null,null,true);
		this.bar = this.bar_wz.GetDisplayElement();
			this.bar.style["z-index"]="189";
			this.bar.style.position = "absolute";
			this.bar.style.left = this.bar_bg.style.left;
			this.bar.style.top = this.bar_bg.style.top;
			this.bar.style.display="block";
			this.bar.style.height="65px";
			this.bar.style.width = "16px";
			
		//CROSS RELATIONS
		this.bar.bg=this.bar_bg;
		this.bar_bg.fg=this.bar;
		this.bar_bg.mousebuttondown=false;
		this.bar.mousebuttondown=false;
		maindiv.bar=this.bar;
		this.affixToContainer=affixToContainer;
		this.bar.affixToContainer=this.affixToContainer;
		
		//FUNCTIONING
		maindiv.style.border="3px solid blue";
		maindiv.style.position = "absolute";
		try
		{
			maindiv.style.left = parseInt(affixToContainer.style.left.replace("px",""))+(affixToContainer.offsetWidth+0);
		}
		catch(ex)
		{
		}
		maindiv.style.top = affixToContainer.style.top;
		maindiv.style.height = affixToContainer.style.height;
		maindiv.style.width = "16px";
		maindiv.style["z-index"]="187";
		maindiv.style.height="215px";
	/*END OF PART2*/
	
	/*PART3 :: Create, object of event references in proper format*/
	
		var z1,z2;
		z1=document.createElement("input");
		z1.id="p6l";
		addToContainer.appendChild(z1);
		z2=document.createElement("input");
		z2.id="p5";
		addToContainer.appendChild(z2);
		
		this.dragger = function()
		{
			mobar_active=this.bar;
			document.getElementById("p5").value=mobar_active.tagName+" : "+mobar_active.id;
			
			//g_canDrag=true;
			
			mobar_active.mousebuttondown=true;
			if(mobar_active.style.top==null || mobar_active.style.top=="")
				mobar_active.style.top="0px";
			mobar_active.registerTimeY=parseInt(mobar_active.style.top.replace("px","")+0);//elemental Y
			mobar_active.y=event.clientY;//evental Y
			
			document.getElementById("p6l").value="y:"+mobar_active.y;
			
			mobar_active.style.cursor="default";
			return false;
		
		}
		this.mover = function()
		{
			if(mobar_active && mobar_active.mousebuttondown)
			{
				var newvalue=mobar_active.registerTimeY+parseInt(event.clientY-mobar_active.y);
				var mydelta=newvalue - parseInt(mobar_active.style.top.replace("px",""));
				mobar_active.style.top=newvalue;
				mobar_active.style.cursor="default";
				if(mobar_active.affixToContainer.style.top==null || mobar_active.affixToContainer.style.top=="")
					mobar_active.affixToContainer.style.top="0px";
				mobar_active.affixToContainer.style.top=parseInt(mobar_active.affixToContainer.style.top)-mydelta;
				document.getElementById("p5").value=mobar_active.style.top;
				return false;
			}
		}
		this.stopper = function()
		{
			mobar_active.mousebuttondown=false;
			mobar_active=null;
			//g_canDrag=false;
		}
	
	var objectEventRef=		{
								onmousedown:this.dragger,
								onmouseup:this.stopper,
								onmousemove:this.mover
							};
	/*END OF PART3*/
	
	/*PART4 :: Inheritance Part, Call Parent Constructor*/
	this.base(this.maindiv, null, null, null, addToContainer, objectEventRef);
	//this.prototype = new WizardImage1(this.maindiv, null, null, null, addToContainer, objectEventRef);
	/*END OF PART4*/
	
	/*PART5 :: Any Extra Performance, Post Appending To Dom, Etc.*/
	//centering possible only here after an element is part of the main dom
	this.maindiv.style.cursor="default";
	/*END OF PART5*/
}

//WizardScrollbar1.prototype = new WizardWidget1;
WizardScrollbar1.prototype = WizardWidget1.prototype;