/****************************************************************************************

	READ ME FIRST
	
	This file builds the top and bottom part of the XML menu. This file also reads out 
	the code in the XML to create the correct JavaScript menu. Below we break the code
	out into the top & bottom sections, and show where the uses XML content is read into
	the system to build the menu. Users should never save this file loacly doing so will
	cause the site to break as changes are added in. 	
	
	
	Author: Alex Belleque
	Date: 23APR11
	Version: 9.2.4.2
	
	Changes:
			23APR11: ACB, Updated Security & Search to match that of all other systems. 		
	
******************************************************************************************/
/* This code is used to build the date stamp on the top of the left menu, we will call the 
resaults of this content later inside the the left menu ID. */
var mydate=new Date()
var year=mydate.getYear()

if (year < 1000)
    year+=1900

var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()

if (daym<10)
    daym="0"+daym
    
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

/* Now we start the left menu, the follwoing content is printed on all XML template menus. */
document.write('<div id="sidenav">');
document.write('<div class="date_line">');
document.write(dayarray[day]+", "+montharray[month]+" "+daym+", "+year) // this gets the date from the code above
document.write('</div>'); // closes "date_line"

/* This section builds the basic layout options for the left menu top content section. 
We also format the first level content options inside the XML file. */
document.write('<ul id="MenuBar2" class="MenuBarVertical SpryHiddenRegion"  spry:region="dsItems1 dslinks">');
document.write('  <li spry:repeat="dsItems1">');
document.write('    <div class="{styles}" href="{url}" spry:if="{pic} == 2"> <img src="{picsrc}" alt="{picalt}" width="{width}" height="{height}" /><br />{header1}<br />{header2}</div>');
document.write('    <div spry:if="{pic} == 1"><a class="MenuBarItemSubmenu {styles}" href="{url}" title="{title}" target="{target}" spry:if="{dslinks::ds_RowCount} != 0">{name}<img src="{picsrc}" alt="{picalt}" width="{width}" height="{height}" /></a> <a class="{styles}" href="{url}" title="{title}" target="{target}" spry:if="{dslinks::ds_RowCount} == 0">{name}<img src="{picsrc}" alt="{picalt}" width="{width}" height="{height}" /></a></div>');
document.write('    <div spry:if="{pic} == 0"><a class="MenuBarItemSubmenu {styles}" href="{url}" title="{title}" spry:if="{dslinks::ds_RowCount} != 0">{name}</a> <a class="{styles}" href="{url}" title="{title}" spry:if="{dslinks::ds_RowCount} == 0">{name}</a></div>');

/* Now we define the second level menu toptions and XML format for link options. */
document.write('    <ul spry:if="{dslinks::ds_RowCount} != 0">');
document.write('      <li spry:repeat="dslinks">');
document.write('      <a href="{dslinks::url}" target="{dslinks::target}" title="{dslinks::title}">{dslinks::name} <img spry:if="{dslinks::pic} == 1" src="{dslinks::picsrc}" alt="{dslinks::picalt}" width="{dslinks::width}" height="{dslinks::height}" /></a></li>');
document.write('    </ul>');
document.write('  </li>');
document.write('</ul>');
Spry.Data.Region.addObserver('MenuBar2',{onPostUpdate:function(){var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2");}});
document.write('</div>'); // closes sidenav 
document.write('<div id="sectnav">'); // this opens the normal left menu class sectnav
document.write('</ul>');

/* 

When this file is called in the XML Template modle the 
content of the of local unit XML file will be formated via 
the above and CSS file, then printed here on the site. 

/* This section builds the search content and input form. This search code will disply on
every website using the XML model.*/
document.write('<div class="sidenav_divider_search">SEARCH NATIONAL SITE</div>'); 
document.write('<div id="searchnav">');
document.write('<div>');	//  this is required to pass XHTML 1.0 Strict 
document.write('<form method="get" target="_blank" action="http://search.usa.gov/search"/>');
document.write('<input type="hidden" name="affiliate" value="cgaux" />');
document.write('<label for="query-field"><span class="search_term">Enter Search Term(s):</span></label>');
document.write('<input type="text" name="query" id="query-field" class="usagov-search-autocomplete ui-autocomplete-input ui-corner-all"/>');
document.write('<input class="field_padding" type="submit" value="Search" />');
document.write('</div>');	//	this closes the required div statment to pass XHTML 1.0 Strict
document.write('</form>');
document.write('</div>');	//	closes searchnav 	

/* This section builds the security badge content area */
document.write('<div class="sidenav_divider_security">Security levels</div>');
document.write('<div class="security_contents">');
document.write('<ul>');
document.write('<li><a href="http://www.dhs.gov/files/programs/ntas.shtm" target="_blank"><img title="National Threat Level" alt="National Threat Level" src="http://cgaux.org/_images/ntas-badge.jpg"/></li></a>');
document.write('<li><a href="http://www.uscg.mil/safetylevels/whatismarsec.asp" target="_blank"><img src=\"http://www.uscg.mil/safetylevels/level1.gif\" alt =\"MARSEC Level 1: Significant Risk - Click for details\"/></a></li>');
document.write('</ul>');
document.write('</div>');	//	closes security_content
document.write('</div>');	//	closes sectnav

