/*!
**********************************************************************
@file WizardWidgets.js

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

***********************************************************************
*/
/**
Button widget
*/

function WizardLower1(left, top, addToContainer, inId, inClName)
{
	this.elementheightglobal=21;
	this.elementwidthglobal="248px";
	this.elementcountglobal=0;
	
	/*PART1 :: WizardImage1 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;
	
		var imagefolderArray =  new Array(gSession.GetResourcesPath(), "media", "img");
		this.imagefolderURL = "file://" + _concatPaths(imagefolderArray, gSession.GetDefaultProperties().platform)+"/";
		var systemInfo = gSession.systemInfo;
		var currentPlatform = systemInfo.Macintosh ? "Mac" : "Win";
		if(currentPlatform=="Win")
		{
			this.imagefolderURL = this.imagefolderURL.replace(/\\+/g, "/");
		}
		
		//LOWER
			function lower_wz_clicker()
			{
				var opener = this.parentWizard.opener;
				if(opener.style.display=="none")
				{
					opener.style.display="block";
				}
				else
				{
					opener.style.display="none";
				}
			};

			this.lower_wz = new WizardImage1(this.imagefolderURL + "WizardLower.png", null, null, maindiv, lower_wz_clicker);
			this.lower = this.lower_wz.GetDisplayElement();
				this.lower.style.position = "absolute";
				this.lower.style.left = "0px";
				this.lower.style.top = "0px";
				this.lower.style["z-index"]="78";
				this.lower.style.height = this.elementheightglobal.toString()+"px";
				this.lower.style.width = this.elementwidthglobal;
				
		//PRIMESELECTER
		this.primeselecter = document.createElement("span");
			this.primeselecter.innerHTML="";
			this.primeselecter.className = "";
			this.primeselecter.style.position = "absolute";
			this.lower.style.left = "0px";
			this.lower.style.top = "0px";
			this.primeselecter.style["z-index"]="79";
			this.primeselecter.style.color = "white";
			this.primeselecter.style["font-weight"] = "bold";
	
		//OPENER
			this.opener = document.createElement("table");
				this.opener.style.position = "absolute";
				this.opener.style.left = "0px";
				this.opener.style.top = this.lower.style.height;
				this.opener.style.height = ((this.elementcountglobal)*(this.elementheightglobal)).toString()+"px";
				this.opener.style.width = this.elementwidthglobal;
				this.opener.style["z-index"]=this.lower.style["z-index"];
				this.opener.style.color = "white";
				this.opener.style.display = "none";
				
				this.opener.bodyel = document.createElement("tbody");
				this.opener.appendChild(this.opener.bodyel);

		//ADDING
		maindiv.appendChild(this.primeselecter);
		maindiv.appendChild(this.opener);
		
		//FUNCTIONING
		maindiv.imagefolderURL = this.imagefolderURL;
		this.uielement.lower_wz=this.lower_wz;//for mouseup and mousedown eventzg
		this.uielement.opener=this.opener;//for mouseup and mousedown eventzg
		this.opener.lower_wz=this.lower_wz;
		this.lower_wz.opener=this.opener;
		this.opener.primeselecter=this.primeselecter;
		this.lower_wz.primeselecter=this.primeselecter;
		
			maindiv.style.position = "absolute";
			maindiv.style.left = left;
			maindiv.style.top = top;
			maindiv.style.height = this.elementheightglobal.toString()+"px";
			maindiv.style.width = this.elementwidthglobal;
			//maindiv.style.border = "3px blue groove";
			maindiv.style["z-index"]="77";
			maindiv.style.display="block";
			maindiv.style.visibility="visible";
			maindiv.style["text-align"]="center";
			maindiv.style["vertical-align"]="middle";
			
		maindiv.lower_wz=this.lower_wz;
	/*END OF PART2*/
	
	/*PART3 :: Create, object of event references in proper format*/
	/*END OF PART3*/
	
	/*PART4 :: Inheritance Part, Call Parent Constructor*/
	this.base(this.maindiv, null, null, null, addToContainer, null);
	//this.prototype = new WizardWidget1(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
	//opener positioning center offsetWidth
	//this.opener.style.left = ((sizeX.replace("px","")-this.opener.offsetWidth)/2)+"px";//center X
	//this.opener.style.top = ((sizeY.replace("px","")-this.opener.offsetHeight)/2)+"px";//making inopener.height == 3px//center Y
	
	this.maindiv.style.cursor="default";
	/*END OF PART5*/
}

//WizardLower1.prototype = new WizardWidget1;
WizardLower1.prototype = WizardWidget1.prototype;

WizardLower1.prototype.AddElement = function(inEtexter)
{
	var z = document.createElement("tr");
	this.opener.bodyel.appendChild(z);
	z.p=this.opener;
	var e = document.createElement("td");
	z.appendChild(e);
	e.innerHTML=inEtexter;
	z.onmousover = function()
	{
		this.style.border="3px solid orange";
	};
	z.onclick = function()
	{
		this.style.border="3px solid orange";
		this.p.primeselecter.innerHTML=""+z.firstChild.innerHTML;
		this.p.style.display="none";
	};
}

WizardLower1.prototype.SetSelectedElement = function(inEtexter)
{
	var e = this.opener.bodyel.children;
	for(var i=0;i<e.length;i++)
	{
		if(e[i].firstChild.innerHTML==inEtexter)
		{
			this.primeselecter.innerHTML=""+e[i].firstChild.innerHTML;
			break;
		}
	}
}

WizardLower1.prototype.SetSelectedElementViaNumber = function(innumber)
{
	var e = this.opener.bodyel.children;
	this.primeselecter.innerHTML=""+e[innumber].firstChild.innerHTML;
}

WizardLower1.prototype.GetSelected = function()
{
	return this.primeselecter.innerHTML;
}
