function createTable(
	title,
	titleAlign,
	subtitle,
	content,
	contentAlign,
	link,
	tableHeight,
	tableWidth
)
{
	var border = "0px";
	var stdTableHeight = "1px";
	var stdTableWidth = "640px";
	var stdTitleAlign = "left";
	var stdContentAlign = "justify";
	
	tableHeight = makeStandart( tableHeight, stdTableHeight );
	tableWidth = makeStandart( tableWidth, stdTableWidth );
	titleAlign = makeStandart( titleAlign, stdTitleAlign );
	contentAlign = makeStandart( contentAlign, stdContentAlign );

	var tableContent = "";
	
	tableContent += '<table class="normal" border="' + border + '" height="' + tableHeight + '" width="' + tableWidth + '">';
	tableContent += '	<tbody>';
	tableContent += '		<tr class="heading1" height="1px" valign="top" align="'+ titleAlign +'">';
	tableContent += '			<td valign="top" align="'+titleAlign + '" >';
	 
	if ( link != null && link != "")
	{
		tableContent += '				<a href="' + link + '" class="link" >' + title + '</a>';
	} else {
		tableContent += '				' + title;
	}
	
	if ( subtitle != null && subtitle != "" )
	{
		tableContent += '				<br/><span class="normal">'+ subtitle + '<span>';
	}
	
	tableContent += '			</td>';
	tableContent += '		</tr>';
	tableContent += '		<tr>';
	tableContent += '			<td valign="top" align="' + contentAlign + '">';
	
	if ( content != null && content != "" )
	{
		if ( content.indexOf('.htm') == -1 )
		{
			tableContent += '<p>' + content + '</p>';
		} else {
			tableContent += getHTML( content );
		}
	}
	
	tableContent += '			</td>';
	tableContent += '		</tr>';
	tableContent += '	</tbody>';
	tableContent += '</table>';
	tableContent += '<br/><br/>';
	
	return tableContent;
}



function insertTable(
	id,
	title,
	titleAlign,
	subtitle,
	content,
	contentAlign,
	link,
	tableHeight,
	tableWidth
)
{
	var tableContent = createTable(title, titleAlign, subtitle, content, contentAlign, link, tableHeight, tableWidth );
	document.getElementById(id).innerHTML += tableContent;
}



function insertTableFromXML(
	id,
	tablesXML
)
{
	//var id = "content";
	//var tablesXML = "development_content.xml";
	
	document.getElementById(id).innerHTML = "";
	
	
	var xmlDoc = getXML( tablesXML );
	var tables = xmlDoc.getElementsByTagName("table");
	
	var i = 0;
	for (i = 0 ; i < tables.length ; i++ )
	{
		insertTable(
			id,
			tables[i].getAttribute("title"),
			tables[i].getAttribute("titleAlign"),
			tables[i].getAttribute("subtitle"),
			tables[i].getAttribute("content"),
			tables[i].getAttribute("contentAlign"),
			tables[i].getAttribute("link"),
			tables[i].getAttribute("tableHeight"),
			tables[i].getAttribute("tableWidth")
		);
	}

}



function getXML( xmlFileName )
{
	var xmlDoc;
	if (window.XMLHttpRequest)
	{
		xmlDoc = new window.XMLHttpRequest();
		xmlDoc.open("GET", xmlFileName, false);
		xmlDoc.send(null);
		xmlDoc = xmlDoc.responseXML;
	}
	// IE 5 and IE 6
	else if ( ActiveXObject("Microsoft.XMLDOM") )
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		xmlDoc.load(xmlFileName);
	}
	return xmlDoc;
}



function getHTML( url )
{
	var htmlDocRequest = false;
	var text;
	
	if ( window.XMLHttpRequest) // mozilla, safari
	{
		htmlDocRequest = new XMLHttpRequest();
	} else if ( window.ActiveXObject ) { // IE
		htmlDocRequest = ActiveXObject("Microsoft.XMLHTTP");
	}
	
	htmlDocRequest.open('GET', url, false); // synchronous
	htmlDocRequest.send(null);
	
	text = htmlDocRequest.responseText;
	
	return text;
}



function makeStandart( value, stdValue )
{
	var returnVal = value;
	
	if ( value == null || value == "" )
			returnVal = stdValue;
	
	return returnVal;
}



function createMenu(
	menuData,
	currentMenuId,
	style,
	styleCurrent
)
{
	var addLink = true;
	var menu = "";
	var styleLocal = style;
	
	menu += '<table>';
	menu += '	<tbody>';
	menu += '		<tr>';
	
	var i;
	for ( i = 0 ; i < menuData.length ; i++ )
	{
		addLink = true;
		styleLocal = style;
		
		//alert( menuData[i].getAttribute("id") + " : " + currentMenuId );
		
		if ( menuData[i].getAttribute("id") == currentMenuId )
		{
			addLink = false;
			styleLocal = styleCurrent;
		}
		
		menu += '			<tc class="' + styleLocal + '" id="'+ menuData[i].getAttribute('id') +'">';
		
		
		if ( addLink )
		{
			menu += '				<a href="'+menuData[i].getAttribute('link')+'">';
			menu += menuData[i].getAttribute('title');
			menu += '				</a>';
		} else {
			menu += menuData[i].getAttribute('title')+" ";
		}
		
		
		if ( i != menuData.length-1 )
		{
		menu += '</tc>|<tc>';
		}
		
		if ( addLink )
		
		menu += '			</tc>';
	}
	menu += '		</tr>';
	menu += '	</tbody>';
	menu += '</table>';
	
	return menu;
}



function insertMenu( menuDivId, menuXMLFile, currentMenuId, style, styleCurrent )
{
	var xmlDoc = getXML( menuXMLFile );
	var menuData = xmlDoc.getElementsByTagName("menu");
	
	menuAsHTML = createMenu( menuData, currentMenuId, style, styleCurrent );
	document.getElementById( menuDivId ).innerHTML = menuAsHTML;
}



function insertHTML( id, htmlFilePath )
{
	document.getElementById( id ).innerHTML = getHTML( htmlFilePath );
}



function appendHTML( id, htmlFilePath )
{
	document.getElementById( id ).innerHTML += getHTML( htmlFilePath );
}

