
function WizStep(owner,i)
	{
	this.elem = document.getElementById(owner.wizId+i);
	this.onstart = false;
	this.showNext = true;
	this.title = this.elem.title;
	this.elem.title = "";
	};

function Wizard(wizId,pNum)
	{
	this.wizId = wizId;
	this.pageArr = new Array();
	this.frameHolder = document.getElementById(wizId+"Frame");
	this.frameHeader = document.getElementById(wizId+"Head");
	this.frameHeaderSpan = document.getElementById(wizId+"HeadSpan");
	this.frameFoot = document.getElementById(wizId+"Foot");
	this.nextBtn = false;
	this.prevBtn = false;
	this.pNum = pNum;
	this.nowPage = 0;
	for(var i=0; i<pNum; i++) { this.pageArr[i] = new WizStep(this,i); };
	this.initSpecialG(); // global init
	this.initPage(); // recurring init
	}
	
Wizard.prototype.initPage = function()
	{
	var thisP = this.pageArr[this.nowPage];
	for(var i=0; i<this.pageArr.length; i++)
		{
		if(i!=this.nowPage) 
			{ this.pageArr[i].elem.className = "wizStep off"; } else 
			{ this.pageArr[i].elem.className = "wizStep on"; };
		}
	this.frameHeaderSpan.innerHTML = this.pageArr[this.nowPage].title;
	this.initSpecial();
	this.doButtons();
	this.valNext();
	this.valPrev();
	}

Wizard.prototype.initSpecialG = function()
	{
	}
	
Wizard.prototype.initSpecial = function()
	{
	}

Wizard.prototype.doPrev = function(e,wiz)
	{
	if(!wiz) wiz = this;
	wiz.nowPage = wiz.nowPage-1;
	wiz.initPage();
	}
	
Wizard.prototype.doNext = function(e,wiz)
	{
	if(!wiz) wiz = this;
	wiz.nowPage = wiz.nowPage+1;
	wiz.initPage();
	}

Wizard.prototype.valPrev = function() { return(true) };
Wizard.prototype.valNext = function() { return(true) };

Wizard.prototype.setBtn = function(butIsNext,butState)
	{
	var but=(butIsNext?this.nextBtn:this.prevBtn);
	//if(!but) return(false);
	var dom = YAHOO.util.Dom;
	if(!butState) {dom.addClass(but,"btnDisabled") } else {dom.removeClass(but,"btnDisabled")};
	but.disabled = !butState;
	//gLog("Setting "+(butIsNext?"next":"prev")+" button to "+butState+". But is disabled? "+but.disabled+" with classname "+but.className);
	}

Wizard.prototype.doButtons = function()
	{
	this.frameFoot.innerHTML = "";
	if (this.nowPage>0)
		{
		var b = document.createElement("BUTTON");
		b.id = this.wizId+"Prev";
		b.innerHTML = "&lt;- Back";
		b.className = "wizButt btn btnRed";
		this.frameFoot.appendChild(b);
		this.frameFoot.appendChild(document.createTextNode(" "));
		this.prevBtn = b;
		YAHOO.util.Event.addListener(this.wizId+"Prev", "click", this.doPrev, this);
		};
	if (this.pageArr[this.nowPage].showNext)
		{
		var b = document.createElement("BUTTON");
		b.id = this.wizId+"Next";
		if(this.nowPage==(this.pageArr.length-1)) {b.innerHTML="Finish"} else {b.innerHTML = "Next -&gt;"};
		b.className = "wizButt btn btnGreen";
		this.frameFoot.appendChild(b);
		this.nextBtn = b;
		YAHOO.util.Event.addListener(this.wizId+"Next", "click", this.doNext, this);
		};
	};

function makeWizard(wizId,pNum)
	{
	specials[wizId] = new Wizard(wizId,pNum);
	}
