function PrintListBorderTable(ListElement)
{
	var HeadNode 	= ListElement.childNodes[0];
	var BodyNode 	= ListElement.childNodes[1];
	var containerId	= ListElement.getAttribute("container");
	var addingMethod= ListElement.getAttribute("addingMethod");
	var BodyId		= BodyNode.getAttribute("id");
	var BodyClass	= BodyNode.getAttribute("class");
	var BodyStyle	= BodyNode.getAttribute("style");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var contHtml	= '';
	var listId		= ListElement.getAttribute("id");
	contHtml +="<div class='input-view' style='z-index:0;'><div id='"+listId+"'><ul id='list-head'>";
	for(HIndx = 0; HIndx < HeadNode.childNodes.length; HIndx++ )
	{
		var childNode	= HeadNode.childNodes[HIndx];
		var chName		= childNode.getAttribute("name");
		var chId		= childNode.getAttribute("id");
		var chClass		= childNode.getAttribute("class");
		var chStyle		= childNode.getAttribute("style");
		var chHref		= childNode.getAttribute("href");
		var chValue		= childNode.getAttribute("value");
		contHtml += "<li class='"+chClass+"' style='"+chStyle+"'>"+chValue+"</li>";
	}
	contHtml += "</ul><div id='"+BodyId+"' style='"+BodyStyle+"'>";
	contHtml += GetListBorderTableRow(BodyNode);
	contHtml += "</div></div></div>";
	if(container)
	{
		if(addingMethod == "append")
		{
			container.innerHTML	+= contHtml;
		}		
		else
		{
			container.innerHTML	 = contHtml;
		}
	}
}

function PrintListBorderTableRow(rowNode)
{
	var containerId	= rowNode.getAttribute("container");
	var removeUL	= rowNode.getAttribute("removeUL");
	var addingMethod= rowNode.getAttribute("addingMethod");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var removeUL	= removeUL	? true : false;
	contHtml		= GetListBorderTableRow(rowNode,removeUL);
	if(container)
	{
		if(addingMethod == "append")
		{
			container.innerHTML	+= contHtml;
		}		
		else
		{
			container.innerHTML	 = contHtml;
		}
	}
}

function GetListBorderTableRow(BodyNode,removeUL)
{
	var returnHtml = "";
	for(rIndx = 0; rIndx < BodyNode.childNodes.length; rIndx++ )
	{
		var rowNode		= BodyNode.childNodes[rIndx];
		var rowId		= rowNode.getAttribute("name");
		var rowId		= rowNode.getAttribute("id");
		var rowClass	= rowNode.getAttribute("class");
		var rowStyle 	= rowNode.getAttribute("style");
		var rowHref	 	= rowNode.getAttribute("href");
		var rowAction	= rowNode.getAttribute("action");
		if(!removeUL) returnHtml += "<ul id='"+rowId+"' class='"+rowClass+"' "+rowAction+">"
		for(iIndx = 0; iIndx < rowNode.childNodes.length; iIndx++ )
		{
			var childNode	= rowNode.childNodes[iIndx];	
			var chName		= childNode.getAttribute("name");
			var chId		= childNode.getAttribute("id");
			var chClass		= childNode.getAttribute("class");
			var chStyle		= childNode.getAttribute("style");
			var chAction	= childNode.getAttribute("action");
			var chValue		= childNode.getAttribute("value");
			
			returnHtml += "<li class='"+chClass+"' style='"+chStyle+"' "+chAction+">"+chValue+"</li>";
		}
		if(!removeUL) returnHtml += "</ul>";
	}	
	return returnHtml;
}
/**
Parses the XML content of the form  and inserts it into the specified container as thumbinails
<CONTENT  type=\"xml\" display=\"icon\" style=\"\" container=\"content-wrap\">
	<icon class=\".col1\" id=\"" style=\"\" image=\"" action=\"\" title=\"" caption=\""></icon>
</CONTENT>
**/
function PrintIconListTable(Container)
{
	var containerId		= Container.getAttribute("container");
	var addingMethod	= Container.getAttribute("addingMethod");
	var displayStyle	= Container.getAttribute("style");
	var containerClass	= Container.getAttribute("class");
	var container		= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var contHtml		= '';
	var contHtml	= '';
	for(Iidx = 0; Iidx < Container.childNodes.length; Iidx++ )
	{
		var childNode	= Container.childNodes[Iidx];
		var iconTitle	= childNode.getAttribute("title");
		var iconId		= childNode.getAttribute("id");
		var iconClass	= childNode.getAttribute("class");
		
		var iconStyle	= childNode.getAttribute("style");
		var iconAction	= childNode.getAttribute("action");
		var iconImage	= childNode.getAttribute("image");
		var iconCaption	= childNode.getAttribute("caption");
		contHtml += "<div class='icon'>";
		if(iconTitle)
			contHtml += "<div class='icon_info'>"+iconCaption+"</div>";
		if(iconImage)
		{
			var iconImg	= new Image();
			iconImg.src	= iconImage;
			imgW	= iconImg.width;
			imgH	= iconImg.height;
			imgClass= imgW < imgH ? "icon-vert"  : "icon-horz";
			contHtml += "<div class='"+iconClass+"'><img src='"+iconImage+"' alt='' "+iconAction+"></div>";
		}
		if(iconCaption)
			contHtml += "<div class='icon_caption'>"+iconTitle+"</div></div>";
	}
	contHtml +="</ul></div>";
	if(container)
	{
		if(addingMethod == "append")
		{
			container.innerHTML	+= contHtml;
		}		
		else
		{
			container.innerHTML	 = contHtml;
		}
	}
}

/**
Parses the XML content of the form  and inserts it into the specified container
<CONTENT  type=\"css\" display=\"css\" style=\"\" container=\"content-wrap\">
	<style name=\".col1\" value=\"width:30px; text-align:right;\"></style>
</CONTENT>
**/
function PrintCSS(CSSElement)
{
	var styleSheetId = CSSElement.getAttribute("container");
	if(CSSElement.childNodes.length <= 0) return;
	CSSRules = (browser == "MSIE" ? document.styleSheets[1].rules  : document.styleSheets[1].cssRules);
	for(csIdx = 0;csIdx < CSSElement.childNodes.length; csIdx++)
	{
		styleNode	= CSSElement.childNodes[csIdx];
		switch(styleNode.getAttribute("type"))
		{
			case "link":         
				for(idx=0; idx < styleNode.childNodes.length; idx++)
				{
					LoadJsCSSfile(styleNode.childNodes[idx].firstChild.data,'css');
				}
			break;
			
			default:
				for(idx=0; idx < styleNode.childNodes.length; idx++)
				{
					var styleElmnt	= styleNode.childNodes[idx];	
					var title		= styleElmnt.getAttribute("name");
					var styles		= styleElmnt.getAttribute("value");
					for(sIdx = 0; sIdx < CSSRules.length; sIdx++)
					{
						if(title == CSSRules[sIdx].selectorText)
						{
							CSSRules[sIdx].style.cssText	= styles;
							//alert(title +" { " +styles + "}");
						}
					}
				}
			break;		
		}
	}
	
}

function FormatScript(ScriptElement)
{
	var containerId	= ScriptElement.getAttribute("container");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var contScript	= '';
	for(nIdx = 0; nIdx <ScriptElement.childNodes.length; nIdx++)
	{
		var varElmnt	= ScriptElement.childNodes[nIdx];
		switch(varElmnt.getAttribute("type"))
		{
			case "variable":
				this.ProcessScript	= SetXMLVariable;
			break;
			
			case "array":
				this.ProcessScript	= SetXMLArray;
			break;
			
			case "function":
				this.ProcessScript	= SetXMLFunction;		
			break;
			
			case "script":	
				eval(varElmnt.firstChild.data); 
			break;
			
			case "link":
				LoadJsCSSfile(varElmnt.firstChild.data,'js');
			break;
		}
		if(this.ProcessScript)
		this.ProcessScript(varElmnt);
	}
}

function SetXMLVariable(varNode)
{
	var varName	= varNode.getAttribute("varName");
	if(varName)
		eval(varName+"	= "+varNode.getAttribute("value")+";");	
}

function SetXMLArray(arrayData)
{
	var tempArray	= new Array();
	var varName	= arrayData.getAttribute("varName");
	
	for(vidx =0; vidx < arrayData.childNodes.length; vidx++)
	{		
		childNode	= arrayData.childNodes[vidx];
		try
		{
			if(childNode.tagName)
			{
				var key		= childNode.getAttribute("key");
				switch(childNode.getAttribute("type"))
				{			
					case "variable":
						eval(varName+"['"+key+"']	= '"+childNode.getAttribute("value")+"'");
					break;
					
					case "array":
						//alert(key)
						var subArray		= GetXMLArrayValues(childNode,key);
						eval(varName+"['"+key+"']	= new Array("+subArray+")");
					break;
				}
			}
		}
		catch (err)
		{
			//alert(err)
		}
	}
}

function GetXMLArrayValues (arrayData,parentKey)
{
	var tempArray	= new Array();
	for(v2idx =0; v2idx < arrayData.childNodes.length; v2idx++)
	{		
		childNode	= arrayData.childNodes[v2idx];
		if(childNode.tagName)
		{
			var key		= childNode.getAttribute("key");
			switch(childNode.getAttribute("type"))
			{			
				case "variable":
					tempArray[key]		= ""+childNode.getAttribute("value")+"";			
				break;
				
				case "array":				
					var subArray		= GetXMLArrayValues(childNode,key);
						tempArray[key]	= "new Array("+subArray+")";
				break;
			}
		}
	}
	return(tempArray);
}


/*-------------------------------------------------------*/
function PrintHTML(HTMLElement)
{
	var containerId	= HTMLElement.getAttribute("container");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var addingMethod= HTMLElement.getAttribute("addingMethod");
	var contHTML	= HTMLElement.firstChild.data;
	
	if(container)
	{
		if(addingMethod == "append")
		{
			document.getElementById(container.id).innerHTML	+= contHTML;
		}		
		else
		{
			document.getElementById(container.id).innerHTML	 = contHTML;
		}
	}
}
/*----------------------------------------------------------------*/
function PrintSelectBox(SelectElement)
{
	var containerId	= SelectElement.getAttribute("container");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var addingMethod= SelectElement.getAttribute("addingMethod");
	var SelectNode 	= SelectElement.childNodes[0];
	var id			= SelectNode.getAttribute("id");
	var name		= SelectNode.getAttribute("name");
	var selClass	= SelectNode.getAttribute("class");
	var selStyle	= SelectNode.getAttribute("style");
	var action		= SelectNode.getAttribute("action");
	var contHtml	= "<select id='"+id+"' name='"+name+"' class='"+selClass+"' style='"+selStyle+"' "+action+">";
	for(indx = 0; indx < SelectNode.childNodes.length; indx++ )
	{
		var childNode	= SelectNode.childNodes[indx];
		var chValue		= childNode.getAttribute("value");
		var chMode		= childNode.getAttribute("mode");
		var chDisplay	= childNode.firstChild.data;
		contHtml += "<option value='"+chValue+"' "+chMode+">"+chDisplay+"</option>";
	}
	contHtml += "</select>";	
	if(container)
	{
		if(addingMethod == "append")
		{
			document.getElementById(container.id).innerHTML	+= contHtml;
		}		
		else
		{
			document.getElementById(container.id).innerHTML	 = contHtml;
		}
	}
}

function PrintJSelectBox(options,boxName,boxId,boxClass,boxStyle,boxAction,container,selValue)
{
	var selBox	= "<select name='"+boxName+"' id='"+boxId+"' class='"+boxClass+"' style='"+boxStyle+"' "+boxAction+">";
	for(i=0; i < options.length; i++)
	{
		var value	= options[i][0];
		var display	= options[i][1];
		var action	= options[i][2];
		var style	= options[i][3] ? options[i][3] : "";
		var opClass	= options[i][4] ? options[i][4] : "";
		var selected= (value == selValue ? "selected" : "" );
		selBox += "<option class='"+opClass+"' style='"+style+"' value='"+value+"' "+selected+" "+action+">"+display+"</option>";
	}
	selBox += "</select>";
	document.getElementById(container).innerHTML	= selBox;
	
}

function PrintToolTip(ToolTipElement)
{
	var displayStyle	= ToolTipElement.getAttribute("style");
	var toolTipId		= ToolTipElement.getAttribute("id");
	var toolTipImg		= ToolTipElement.getAttribute("image");
	var toolTipTitle	= ToolTipElement.getAttribute("title");
	var numChilds		= ToolTipElement.childNodes.length;
	var contTip			= "<div class='infotip'><div class='tip_thumbnail'><img src='"+toolTipImg+"' /></div><div class='tip_info'><div class='tip_title'>"+toolTipTitle+"</div><div class='tip_details'><table>";
	for(idx = 0; idx < numChilds; idx++)
	{
		var childElement= ToolTipElement.childNodes[idx];
		var label		= childElement.getAttribute("label");
		var value		= childElement.getAttribute("value");
		contTip		   += "<tr><td class='normal bold' nowrap>"+label+"</td><td width='200'> "+value+"</td></tr>";
	}
	contTip			   += "</table></div></div></div>";
	ShowToolTip(contTip);
}

// Print HTML Form 
function PrintHTMLForm(FormElement)
{
	var containerId	= FormElement.getAttribute("container");
	var container	= (containerId.length > 1 ? document.getElementById(containerId) : false);
	var addingMethod= FormElement.getAttribute("addingMethod");
	var form		= FormElement.childNodes[0];
	var contHTML		= "";
	/* Form Attributes */	
	var formName 	= form.getAttribute("name");
	var formId 		= form.getAttribute("id");
	var formStyle 	= form.getAttribute("style");
	var formClass 	= form.getAttribute("class");
	var formMethod 	= form.getAttribute("method");
	var formAction 	= form.getAttribute("action");
	var formEncType = form.getAttribute("encType");
		
		contHTML   += "<div style=\"width:700px;clear:both;float:left;\"><form name='"+formName+"' id='"+formId+"' class='"+formClass+"' enctype='"+formEncType+"' method='"+formMethod+"' action='"+formAction+"'>";
		
	
	var formElements= form.childNodes[0];
	for(rIdx = 0; rIdx < formElements.childNodes.length; rIdx++)
	{
		var elementsRow	= formElements.childNodes[rIdx];
		var rowId	 	= elementsRow.getAttribute("id");
		var rowClass 	= elementsRow.getAttribute("class");
		var rowStyle 	= elementsRow.getAttribute("style");
		
		contHTML	   += "<div id='"+rowId+"' class='"+rowClass+"' style='"+rowStyle+"' >";
		
		for(eIdx = 0;eIdx < elementsRow.childNodes.length; eIdx++)
		{
			var element	= elementsRow.childNodes[eIdx];
			var divId	= element.getAttribute("CID");
			var divClass= element.getAttribute("CClass");
			var divStyle= element.getAttribute("CStyle");
			
			contHTML	   += "<div id='"+divId+"' class='"+divClass+"' style='"+divStyle+"' >";
			
			var elmType	= element.getAttribute("type");
			var id		= element.getAttribute("id");
			var name	= element.getAttribute("name");
			var value	= element.getAttribute("value");
			var style	= element.getAttribute("style");
			var elmClass= element.getAttribute("class");
			var action	= element.getAttribute("action");
			var HTMLAttr= element.getAttribute("HTMLAttribs");
			var elmCont	= element.getAttribute("contType");
			var elmReq	= element.getAttribute("required");
			
			switch(elmType)
			{
				case "label":
					contHTML   += value+"</div>";
					continue;
				break;
				case "separator":
					contHTML   += ":";				
				break;
				default:
					contHTML   += "<"+elmType+" id='"+id+"'  name='"+name+"' class='"+elmClass+"' style='"+style+"'  "+HTMLAttr+" "+action+"";					
				break;
			}
			if(elmType == "textarea")
			{
				contHTML	   += ">"+value;
			}
					
			else if(elmType == "select")
			{
				contHTML	   += ">";
				for(oIdx = 0;oIdx < element.childNodes.length; oIdx++)
				{
					var optionId	= element.childNodes[oIdx].getAttribute("id");
					var optionClass	= element.childNodes[oIdx].getAttribute("class");
					var optionStyle	= element.childNodes[oIdx].getAttribute("style");
					var optionHAttr	= element.childNodes[oIdx].getAttribute("HTMLAttr");
					var optionAction= element.childNodes[oIdx].getAttribute("action");
					var optionValue	= element.childNodes[oIdx].getAttribute("value");
					var optionDisp	= element.childNodes[oIdx].getAttribute("display");
					contHTML	   += "<option id='"+optionId+"' value='"+optionValue+"' class='"+optionClass+"' style='"+optionStyle+"'  "+optionHAttr+" "+optionAction+">"+optionDisp+"</option>";
				}
			}
			else
			{
				contHTML   += " value='"+value+"'";
			}
			contHTML	   += (elmType == "select" || elmType == "textarea") ? "</"+elmType+">" : " />";
			contHTML	   += " </div>";
		}
		contHTML	   += " </div>";
	}
	contHTML	   += " </form></div>";
	//alert(contHTML)
	if(container)
	{
		if(addingMethod == "append")
		{
			document.getElementById(container.id).innerHTML	+= contHTML;
		}		
		else
		{
			document.getElementById(container.id).innerHTML	 = contHTML;
		}
	}	
}

function DisplayTopMenu(arrayMenuItems,currentItem)
{
	var strHTML	= "<ul>";
	for(i = 0; i < arrayMenuItems.length; i++)
	{				
		var menuItem		= arrayMenuItems[i];
		var menuId			= menuItem[0];
		var menuLabel		= menuItem[1];
		var menuTitle		= menuItem[2];	
		
		var liId	= currentItem == menuId ? "tab_active" : "";
		var liHref	= currentItem == menuId ? "#" : "javascript:Perpetrate("+menuId+")" ;
		if(menuLabel)
		{
			strHTML	+= "<li title='"+menuTitle+"' id='"+liId+"'><a href='"+liHref+"'>"+menuLabel+"</a></li>"; 
		}
	}				
	strHTML	+= "</ul>";
	document.getElementById("tabsmenu").innerHTML	= strHTML;	
}