/* --------------------------------------------------------------------------

	(c) 2006 U.S. Robotics Corporation

	-------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------

	RTL SUPPORT

	To enable right-to-left CSS conversion, call this function in the page's
	onload event.

	If there is an Arabic character set in a META tag, enable the RTL stylesheet.

	It returns true if the page is right-to-left.

	Example:
		<link href="usr_rtl.css"				type="text/css" rel="stylesheet" />
		<script src="usr_rtl.js" 	type="text/javascript"></script>

		<body onload="manageRTL(); initMenu();">
*/
function manageRTL()
{
	if (!isPageRTL())
		return;

	/*
		We found an Arabic charset. Enable the RTL stylesheet.
	*/
	var sheets = document.styleSheets;
	for (var ix in sheets)
	{
		if (sheets[ix].href == "usr_rtl.css")
			sheets[ix].disabled = false;
	}
}

function isPageRTL()
{
	/*
		Test all META tags to see if one specifies an Arabic character set
	*/
	var metas = document.getElementsByTagName("META");
	for (var i = 0; i < metas.length; ++i)
	{
		if (metas[i].attributes.content.nodeValue.indexOf("windows-1256") != -1)
			return true;
	}
	return false;
}




/* --------------------------------------------------------------------------

	PAGE HEADER AND FOOTER FUNCTIONS

*/

/*
	Set document's title.

	If the <title> element is empty or doesn't exist, it uses the passed
	string. Then it appends the product name to the title. If nothing
	(or null) is passed, it uses the product name as the title.
*/
function setPageTitle(strTitle)
{
	
		document.title = getString("idProdNum") + " " + getString("idProdName") + ", " + getString("idProdNum1") + " " + getString("idProdName1") + ": " + getString("idDocType"); 
	
}

/*
	Write the page header

	The calling page should set the <title> element to the desired header
	text and page title. This function calls another that prepends the
	product name to the document title.
*/
function writeHeader(strTitle)
{
	// This lets the calling page override the <title> element.
	if (strTitle == null)
		strTitle = document.title;
	setPageTitle(strTitle);

	_writeHeader(strTitle);
}


/*
	This writes out a page's header, including the optional menu bar.
	The title parameter is optional. If passed, it's written out
	as the header text. If you're not including a picture of the device,
	remove the line containing "device.gif" and the three "<br>" lines 
	that follow it.
*/
function _writeHeader(strTitle)
{
	
	document.write("<div id=\"idHeader\">");
	document.write("<img  id=\"idCopyright\" src=\"device.gif\" height=\"80\">");
	document.write("<br>");
	document.write("<br>");
	document.write("<br>");
	document.write("<img  id=\"idImgHeader\" src=\"usr_logo_rgb.gif\">");
	

	if (strTitle == null)
		document.write("&nbsp;");	// to make sure header is tall enough
	else
		/*document.write(getString("idProdName") + ": " + getString("idDocType")); */
		document.write(getString("idProdName") + ", " + getString("idProdName1") + ": " + getString("idDocType")); 

	document.write("<\/div>");

	/*
		If this page doesn't include the menu script, don't create a menu
	*/
	if (typeof(createMenu) != "undefined")
		createMenu().write();

	document.write("<div id=\"idContent\">");
}


function writeFooter()
{
	document.write("<\/div>");
	document.write("<img  id=\"idCopyright\" src=\"bg_color_cubes.gif\" width=\"16\" height=\"83\" \/>");
	document.write("<p class=\"clsCopyright\">&copy; 2005-2007 <a href=\"http://www.usr.com\">U.S. Robotics Corporation<\/a><\/p>");
}
