// 
// Copyright (c) 2002, Thought By Design  All rights reserved.
// 
// This computer program is protected by copyright law and international treaties.
// Unauthorized reproduction or distribution of this program, or any portion of it,
// may result in severe civil and criminal penalties, and will be prosecuted to the
// maximum extent possible under the law.
// 
// Class: PageBanner
// 
// Author: Rob Allen
// Last Modified: June 4, 2002
// 
// Usage: var pb = new PageBanner("Title text",decor);
// decor ::= {	_type: one of the page banner's pre-defined types, 
//		_label: the programmatic name of the item, 
//		_value: the item's value or visible label, 
//		_onClick: the method to run when the item is clicked, 
//		_title: hover help to be displayed [,
//		_choices: optional list of choices to be displayed in a choice list,
//		_text: optional printed text (appears to left of check box control only)]};
//

function PageBanner(title,decor) {
	this.title = title;
	this.decor = decor;
	this.controlClass = "clsControl";
}


PageBanner.prototype.isFullControl = function() {
	return (this.controlClass == "clsFullControl");
} // isFullControl()


PageBanner.prototype.setFullControl = function() {
	this.controlClass = "clsFullControl";
} // setFullControl()


PageBanner.prototype.getHTML = function() {

	var html = "";
	html += "<div class='"+this.controlClass+"'>";
	html += "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td class='clsPageHeader' style='padding-left:10px'>"+this.title+"</td>";
	for (var i = 0; i < this.decor.length; i++) {
		if (this.decor[i]._type == PageBanner.k_decoratorType_statistic) {	
			html += "<td class='clsStatLabel'><nobr>"+this.decor[i]._label+"</nobr></td>";
		} // if
	} // for
	html += "<td align='right' class='clsText' style='width: 100%'>";
	for (var i = 0; i < this.decor.length; i++) {
		if (this.decor[i]._type == PageBanner.k_decoratorType_button || this.decor[i]._type == PageBanner.k_decoratorType_smallbutton || this.decor[i]._type == PageBanner.k_decoratorType_submit) {
			var title = "";
			if (this.decor[i]._title != null && this.decor[i]._title != "") {
				title =  " title='"+this.decor[i]._title+"'";
			} // if
			var displayClass = "clsActionButton";
			var buttonType = this.decor[i]._type;
			
			if (this.decor[i]._type == PageBanner.k_decoratorType_smallbutton) {
				displayClass = "clsSmallButton";
				buttonType = "button";
			} // if
			html += "<input class='"+displayClass+"' type='"+buttonType+"' value='"+this.decor[i]._value+"' name='"+this.decor[i]._label+"' id='"+this.decor[i]._label+"'"+title;
			if (this.decor[i]._type != PageBanner.k_decoratorType_submit) {
				html += " onClick='"+this.decor[i]._onClick+"'";
			} // if
			html += ">&nbsp;";
		} // if
		else if (this.decor[i]._type == PageBanner.k_decoratorType_select) {
			var choices = this.decor[i]._choices;
			html += "<select name='"+this.decor[i]._label+"'>";
			for (var j = 0; j < choices.length; j++) {
				var selected = "";
				if (this.decor[i]._value == choices[j]._text) {
					selected = " SELECTED";
				} // if
				html += "<option value='"+choices[j]._id+"'"+selected+">"+choices[j]._text;
			} // for
			html += "</select>";
		} // else if
		else if (this.decor[i]._type == PageBanner.k_decoratorType_radio) {
			var choices = this.decor[i]._choices;
			for (var j = 0; j < choices.length; j++) {
				var checked = "";
				if (this.decor[i]._value == choices[j]._text) {
					checked = "CHECKED";
					
				} // if
				html += "<input type='radio' name='"+this.decor[i]._label+"' value='"+choices[j]._id+"' onClick='"+choices[j]._onClick+"' "+checked+">"+choices[j]._text;
			} // for
			html += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		} // else if
		else if (this.decor[i]._type == PageBanner.k_decoratorType_buttonSpacer) {
			html += this.decor[i]._value;
		} // else if
		else if (this.decor[i]._type == PageBanner.k_decoratorType_checkBox) {
		
			html += this.decor[i]._text+"<input type='checkbox' name='"+this.decor[i]._label+"' value='X' onClick='"+decor[i]._onClick+"' "+(this.decor[i]._value=="X"?" checked":"")+">"; 
			
			html += "&nbsp;&nbsp;&nbsp;";
		} // else if
		
	} // for
	html += "</td></tr>";
	html += "</table>";
	html += "</div>";
	return html;

} // getHTML()


PageBanner.getStandardDecorator = function(lastModified) {

	var _decor = new Array();
	_decor[0] = {_type:PageBanner.k_decoratorType_statistic,_label:"last modified:",_value:lastModified,_onClick:null};
	_decor[1] = {_type:PageBanner.k_decoratorType_submit,_label:"Commit",_value:"Commit",_onClick:null};

	return _decor;
} // getStandardDecorator()


PageBanner.k_decoratorType_submit = "submit";
PageBanner.k_decoratorType_statistic = "statistic";
PageBanner.k_decoratorType_button = "button";
PageBanner.k_decoratorType_smallbutton = "smallbutton";
PageBanner.k_decoratorType_select = "select";
PageBanner.k_decoratorType_radio = "radio";
PageBanner.k_decoratorType_buttonSpacer = "buttonSpacer";
PageBanner.k_decoratorType_checkBox = "checkBox";

PageBanner.k_decorator_empty = new Array();




