<!--
//these variables will contain references to toolbar's and main DIV's DOM objects
/////////////////////////////////////////////////////////////////////////////////////
var _s_MainDiv = null;
var _s_TBElemt = null;
var _s_TBPanel = null;
var _c_DefTBId = 'idToolbar';

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
//helpers
function __change_button( obj, src, clr ) {
	try {
		if( obj ) {
			var img = obj.cells[0].childNodes[0];
			obj.style.backgroundColor = clr;
			if ( img ) {
				img.src = src;
			}
		}
	}
	finally {
	}
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function ToolbarPanel( _id, _height, _class ) {
	this.m_height    = _height;
	this.m_class     = _class
	this.m_id        = _id;
	this.m_hilight   = null;
	this.m_items     = new Array();
	this.m_imgs      = new Array();
	
	this.addItem     = ToolbarAddItem;
	this.draw        = ToolbarDraw;
	this.setHilight  = ToolbarSetHilight;
	this.getHeight   = ToolbarGetHeight;
	this.cacheImage  = ToolbarCacheImage;
}

/////////////////////////////////////////////////////////////////////////////////////
function ToolbarCacheImage( srcImg ) {
	if ( srcImg && srcImg != '' ) {
		var img = new Image();
		
		if ( img ) {
			img.src = srcImg;
			
			this.m_imgs[ this.m_imgs.length ] = img;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function ToolbarGetHeight() {
   return this.m_height;
}

/////////////////////////////////////////////////////////////////////////////////////
function ToolbarSetHilight( _clr ) {
	this.m_hilight = _clr;
}

/////////////////////////////////////////////////////////////////////////////////////
function ToolbarAddItem( _item ) {
	if ( _item != null ) {
		this.m_items[ this.m_items.length ] = _item;
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function ToolbarDraw() {
	if ( this.m_items.length > 0 ) {
		var sHtml = "<table id='" + this.m_id + "' class='" + this.m_class + "' cellspacing='0' cellpadding='0' width='100%'";
		
		if ( this.m_height != 0 )
			sHtml += " height='" + this.m_height + "' border='0'><tr>";
		else
			sHtml += " border='0'><tr>";
		
		for (var n = 0; n < this.m_items.length; n++) {
			sHtml += this.m_items[n].draw();
		}
		
		if ( this.m_inner != null && this.m_inner != "" )
			sHtml += "<td class='" + this.m_inner + "' width='100%'>&nbsp;</td></tr></table>";
		else
			sHtml += "<td width='100%'>&nbsp;</td></tr></table>";

		if( this.m_hilight != null ) {
			sHtml += "<table style='background:" + this.m_hilight + ";' height='2' cellspacing='0' cellpadding='0' border='0' width='100%'><tr><td></td></tr></table>";
			this.m_height += 2; 
		}

		document.write( sHtml );
	}
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function TBLabel( _text, _class, _class1 ) {
	this.m_text  = _text;
	this.m_class = _class;
	this.m_cell  = _class1;
	
	this.draw = DrawLabel;
}

/////////////////////////////////////////////////////////////////////////////////////
function DrawLabel( _cell ) {
	var sHtml = "<td align='left'";
	if ( this.m_cell != null && this.m_cell != "" )
		sHtml += " class='" + this.m_cell + "'";
	
	if ( this.m_class != null && this.m_class != "" )
		sHtml += "><nobr><div class='" + this.m_class + "'>" + this.m_text + "</div></nobr></td>";
	else	
		sHtml += "><nobr><div>" + this.m_text + "</div></nobr></td>";
		
	return sHtml;	
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function TBIcon( _src, _width, _height, _class, _class1 ) {
	this.m_src    = _src;
	this.m_width  = _width;
	this.m_height = _height;
	this.m_class  = _class;
	this.m_cell   = _class1;
	
	this.draw     = DrawIcon;
}

/////////////////////////////////////////////////////////////////////////////////////
function DrawIcon( ) {
	var sHtml = "<td align='left'";
	if ( this.m_cell != null && this.m_cell != "" )
		sHtml += " class='" + this.m_cell + "'";

	if ( this.m_class != null && this.m_class != "" )
		sHtml += "><div class='" + this.m_class + "'><img border='0' src='" + this.m_src + "' width='" + this.m_width + "' height='" + this.m_height + "'></div>";
	else
		sHtml += "><div><img border='0' src='" + this.m_src + "' width='" + this.m_width + "' height='" + this.m_height + "'></div>";
		
	return sHtml;
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function TBButton ( _bactive, _script, _imgn, _imga, _imgw, _imgh, _text, _bkclrn, _bkclra, _class, _class1 ) {
	this.m_script	  = _script;
	this.m_img_normal = _imgn;
	this.m_img_active = _imga;
	this.m_img_width  = _imgw;
	this.m_img_height = _imgh;
	this.m_text       = _text;
	this.m_bk_normal  = _bkclrn;
	this.m_bk_active  = _bkclra;
	this.m_class      = _class;
	this.m_cell       = _class1;
	this.m_bactive    = _bactive;

	this.draw         = DrawButton;
}

/////////////////////////////////////////////////////////////////////////////////////
function DrawButton() {
	var sHtml = "<td align='left'";
	if ( this.m_cell != null && this.m_cell != "" )
		sHtml += " class='" + this.m_cell + "'";
	
	sHtml += "><table cellspacing='0' cellpadding='0' width='100%' height='100%' border='0'>";

	if ( this.m_class != null && this.m_class != "" )
		sHtml += "<tr class='" + this.m_class + " 'align='left' valign='middle' ";
	else
		sHtml += "<tr 'align='left' valign='middle' ";

	if( this.m_bactive ) {
		sHtml += " style='background:" + this.m_bk_active + ";'>"  +
		         "<td><img src='" + this.m_img_active + "' width='" + this.m_img_width + "' height='" + this.m_img_height + "' border='0'></td>" + 
				 "<td><nobr><span>&nbsp;" + this.m_text + "&nbsp;&nbsp;</span></nobr></td></tr></table></td>";
	}
	else {
		sHtml +=" onclick=\"" + this.m_script + 
				"\" onmouseover=\"__change_button(this, '" + this.m_img_active + "', '" + this.m_bk_active + "');\"" + 
				" onmouseout=\"__change_button(this, '" + this.m_img_normal + "', '" + this.m_bk_normal + "');\">" + 
				"<td><img src='" + this.m_img_normal + "' width='" + this.m_img_width + "' height='" + this.m_img_height + "' border='0'></td>" + 
				"<td><nobr><span>&nbsp;" + this.m_text + "&nbsp;&nbsp;</span></nobr></td></tr></table></td>";
				
     }

	return sHtml;	    
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function DrawToolbarPanel( ) {
	if ( _s_TBPanel ) {
		_s_TBPanel.draw();
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function CreateToolbarPanel(_height, _class, _id ) {

	if( _id == null ) {
		_id = _c_DefTBId;
	}

	_s_TBPanel = new ToolbarPanel( _id, _height, _class  );
}

/////////////////////////////////////////////////////////////////////////////////////
function AddTBLabel( _text, _class, _class1 ) {
	if ( _s_TBPanel ) {
		var oItem = new TBLabel( _text, _class, _class1 );
		if ( oItem ) {
			_s_TBPanel.addItem( oItem );
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function AddTBIcon( _src, _width, _height, _class, _class1 ) {
	if ( _s_TBPanel ) {
		var oItem = new TBIcon( _src, _width, _height, _class, _class1 );
		if ( oItem ) {
			_s_TBPanel.addItem( oItem );
			
			_s_TBPanel.cacheImage( _src );
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function AddTBButton( _active, _script, _imgn, _imga, _imgw, imgh, _text, _bkclrn, _bkclra, _class, _class1 ) {
	if ( _s_TBPanel ) {
		var oItem = new TBButton ( _active, _script, _imgn, _imga, _imgw, imgh, _text, _bkclrn, _bkclra, _class, _class1 );
		if ( oItem ) {
			_s_TBPanel.addItem( oItem );
			
			_s_TBPanel.cacheImage( _imgn );
			_s_TBPanel.cacheImage( _imga );
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function SetHilight( _clr ) {
	if ( _s_TBPanel ) {
		_s_TBPanel.setHilight( _clr );
	}
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function GetTBPanelHeight() {
	if ( _s_TBPanel ) {
		return _s_TBPanel.getHeight();
	}
	else {
		return 0;
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function GetDivLeftScroll() {
	if ( _s_MainDiv ) {
		return _s_MainDiv.scrollLeft;
	}
	else {
		return 0;
	}
}

/////////////////////////////////////////////////////////////////////////////////////
function GetDivTopScroll() {
	if ( _s_MainDiv ) {
		return _s_MainDiv.scrollTop;
	}
	else {
		return 0;
	}
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function OnInitPage( _divid ) {

	if ( _s_TBPanel )
		_tbid = _s_TBPanel.m_id;
	else	
		_tbid = _c_DefTBId;

	_s_MainDiv = self.document.getElementById( _divid );
	_s_TBElemt = self.document.getElementById( _tbid );
	
	OnResize();
}

/////////////////////////////////////////////////////////////////////////////////////
function OnResize() {
	var h = 0;
	var w = 0;	
	
	//if ( self == top ) {
	if ( _s_TBPanel ) {
		h = self.document.body.clientHeight - _s_TBPanel.m_height;
	}
		
	w = self.document.body.clientWidth;	
	//}
	//else {
	//	if ( _s_TBPanel ) {
	//		h = self.document.body.offsetHeight - _s_TBPanel.m_height;
	//	}
	//	
	//	w = self.document.body.offsetWidth;
	//}

	if (h < 0) h = 0;
	if (w < 0) w = 0;
	
	if ( _s_MainDiv && _s_TBPanel ) {
		_s_MainDiv.style.height = h;
		_s_MainDiv.style.width  = w;
	}
	
	if ( _s_TBElemt ) {
		_s_TBElemt.style.width = w;
	}
}

//-->
//</script>  