// JavaScript Document

// Header
function writeHeader() {
	phinTop = '<!-- BEGIN FRAME -->' +
	'<div id="gbl-frame">' +
	'<!--  BEGIN GLOBAL NAVIGATION -->' +
	'<!-- BEGIN TOP NAV -->' +
	'<div id="gbl-topnav">' +
		'<div id="gbl-topnavcontainer">' +
		'<a href="http://www.cdc.gov/page.do">Home</a> | <a href="http://www.cdc.gov/aboutcdc.htm">About CDC</a> | <a href="http://www.cdc.gov/od/oc/media/">Press Room</a> | <a href="http://www.cdc.gov/az.do">A-Z Index</a> | <a href="http://www.cdc.gov/doc.do?id=0900f3ec80093d70">Contact Us</a>' +
		'</div>' +
	'</div>' +
	'<!-- END TOP NAV -->' +
	'<!-- BEGIN TOP HEADER BAR, LOGO -->' +
	'<div id="gbl-headerbar">' +
	'<a href="http://www.cdc.gov/">' +
    '<img src="/phin/images/logo_CDC.gif" alt="Image: CDC Centers for Disease Control and Prevention PHIN" border="0" width="557" height="71"></a>' +
	'</div>' +
	'<!-- END TOP HEADER BAR LOGO -->' +
	'<!-- BEGIN TOP HEADER BAR, SEARCH -->' +
	'<div id="gbl-search">' +
		'<div id="gbl-searchcontent" align="right">' +
			'<form name="searchForm" action="/search.do" method="get">' +
			'<input type="hidden" value="search" name="action"/>' +
			'<a href="http://www.cdc.gov/spanish/default.htm">CDC en Espa&ntilde;ol</a>' +
			'<br />' +
			'<img src="/phin/images/hr_search.gif" vspace="0" border="0" width="189" height="1">' +
			'<br />Search: <input maxlength="160" size="13" name="queryText" class="searchField"/>' +
			'&nbsp;<input name="image" type="image" src="/phin/images/btn_Go.gif" alt="Go" align="middle" class="gobtn" width="27" height="20" />' +
			'</form>' +
	  	'</div>' +
	 '</div>' +
	 '<div id="headershadow">&nbsp;</div>' +
	 '<!-- END TOP HEADER BAR, SEARCH -->' +
	 '<!-- END TOP HEADER BAR-->' ;
document.write(phinTop)
}

// Footer
function writeFooter() {
	cdcFooter = '<!-- BEGIN FOOTER -->' +
  '<div id="gbl-footer">' +
	  '<div id="gbl-footernav">' +
		'<ul>' +
			'<li><A href="http://www.cdc.gov/page.do">Home</A></li>' +
			'<li>|</li>' +
			'<li><A href="http://www.cdc.gov/doc.do/id/0900f3ec800cb856">Policies and Regulations</A></li>' +
			'<li>|</li>' +
			'<li><A href="http://www.cdc.gov/disclaimer.htm">Disclaimer</A></li>' +
			'<li>|</li>' +
			'<li><A href="http://www.cdc.gov/doc.do/id/0900f3ec801153ff">e-Government</A></li>' +
			'<li>|</li>' +
			'<li><A href="http://www.cdc.gov/od/foia/foi.htm">FOIA</A></li>' +
			'<li>|</li>' +
			'<li><A href="http://www.cdc.gov/doc.do/id/0900f3ec80093d70">Contact Us</A></li>' +
		'</ul>' +
	  '</div>' +
  '</div>' +
  '<div id="gbl-footercontainer">' +
		'<div id="gbl-footerContent">' +
			'<div id="gbl-address">' +
				'<img src="/phin/images/ftr_SaferHealthier.gif" alt="Safer Healthier People" width="150" height="7"><br />' +
				'<address>Centers for Disease Control and Prevention, 1600 Clifton Rd, Atlanta, GA 30333, U.S.A.<br />Tel: (404) 639-3311 / Public Inquiries: (404) 639-3534 / (800) 311-3435</address>' +
			'</div>' +
			'<div id="gbl-footerimage">' +
				'<a href="http://firstgov.gov/">' +
                '<img src="/phin/images/logo_FirstGov.gif" alt="FirstGov" border="0" width="147" height="52"></a>' +
				'<a href="http://www.hhs.gov/">' +
                '<img src="/phin/images/logo_dhhs.gif" alt="DHHS" border="0" width="58" height="52"></a>' +
				'<br />' +
				'<a href="http://www.air.org/concord/cdc/html_build/www.hhs.gov">Department of Health<br />and Human Services</a>' +
			'</div>' +
		'</div>' +
  '</div>' +
'<!-- END FOOTER -->';
	document.write(cdcFooter)
}


// ####
// Open Window with given attributes
// ####
function openWindow(URL, winName, status, toolbar, location, menubar, directories, resizable, scrollbars, height, width)
{
	var features = 'status=' + status;
	features+=',toolbar=' + toolbar + ',location=' + location;
	features+=',menubar=' + menubar + ',directories=' + directories;
	features+=',resizable=' + resizable + ',scrollbars=' + scrollbars;
	features+=',height=' + height + ',width=' + width;
	//alert(features);
	window.open(URL, winName, features);
}
// #### 
// General Querystring functions
// ####
function PageQuery(q) 
{
	if(q.length > 1) 
		this.q = q.substring(1, q.length);
	else 
		this.q = null;
	
	this.keyValuePairs = new Array();
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}	
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key)
{
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

//####
// ####
// show the given sub-menu and hide all others
// ####
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i) && ('smenu'+i != id)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

// ####
// show the given sub-menu and hide all others
// ####

function montre2(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

// ####
// find the given object in the given document
// ####
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// ####
// Load all images on the page into a page-level array for later use
// ####
function MM_preloadImages() { //v3.0
  var d=document; 
  if(d.images)
  { 
  	if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0)
		{ 
			d.MM_p[j]=new Image; 
			d.MM_p[j++].src=a[i];
		}
	}
}

// ####
// set a page-level variable for use in highlighting navigation items
// ####
function MM_setPageName(){
	var a=MM_setPageName.arguments;
	document.MM_pn=a[0];	
	highlightTab(document.MM_pn + 'Tab');
}

// ####
// set a page-level variable for use in highlighting secondary navigation items
// ####
function MM_setPageName2(){
	var a=MM_setPageName2.arguments;
	document.MM_pn2=a[0];
	highlightTab2(document.MM_pn2 + 'Tab');
}

// ####
// Based on the current URL, determine whether the "contact us" link should go to a specific anchor
// if not, just use the normal link, otherwise add the anchor to the end
// ####
function contactUsAnchor()
{
	var thisPage = location.href;
	var anchorString = '';
	
	//if (thisPage.indexOf('phinms') > 0)
	//{
	//	anchorString='#phinms';
	//}
	if (thisPage.indexOf('biosense') > 0)
	{
		anchorString='#biosense';
	}
	if (thisPage.indexOf('vocab') > 0)
	{
		anchorString='#vocab';
	}
	if (thisPage.indexOf('epi-x') > 0)
	{
		anchorString='#epix';
	}
	if (thisPage.indexOf('cra') > 0)
	{
		anchorString='#cra';
	}
	if (thisPage.indexOf('nedss') > 0)
	{
		anchorString='#nedss';
	}
	

	return anchorString;	
}

//####
// Create the link to the contact us page using the anchor for specific links.
//####
function contactUsLink()
{
	document.write('<A href="/phin/Contact.html');
	document.write(contactUsAnchor());
	document.write('">');
}

//####
// Create the link to the Forum based on the current page
//####
function forumLink()
{
	document.write('<a href=https://team.cdc.gov');
	
	var thisPage = location.href;
	var stringLength = thisPage.length;
	var stringStart = thisPage.indexOf('/phin/');
	stringStart = stringStart + 6;
	var pageOnly = thisPage.substring(stringStart, stringLength);
	

	// resources, architecture, tech assistance, resource exchange
	if ((pageOnly == 'resources/architecture.html') || (pageOnly == 'resources/index.html') || (pageOnly == 'resources/tech-assistance.html') || (pageOnly == 'resources/resource-exchange.html'))
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion_of_phin_applications_solutions');
	}
	//certifiction, requirements
	else if ((pageOnly == 'resources/certification.html') || (pageOnly == 'resources/requirements.html'))
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion7');
	}
	// guides
	else if (pageOnly == 'resources/guides.html')
	{
		document.write('/team/cdc/dispatch.cgi/f.message_mapping_guides');
	}
	// activities, apps and services
	else if ((pageOnly == 'activities/index.html') || (pageOnly == 'activities/applications-services/index.html'))
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion_of_phin_communication_collabor');
	}
	// other apps
	else if (pageOnly == 'activities/applications-services/other.html')
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion_of_off_shelf_solutions');
	}
	// cdc apps and services
	else if (pageOnly.indexOf('applications-services') >= 0)
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion_of_cdc_developed_solutions');
	}
	// education
	else if (pageOnly.indexOf('education') >=0)
	{
		document.write('/team/cdc/dispatch.cgi/w.phin_education/tart/f.general_discussion_forum_for_phin_education/.frame');
	}
	// evaluation
	else if (pageOnly.indexOf('evaluation') >=0)
	{
		document.write('/team/cdc/dispatch.cgi/w.phin_evaluation/tart/f.general_discussion_forum_for_phin_evaluation/.frame');
	}
	// policy
	else if (pageOnly.indexOf('policy') >=0)
	{
		document.write('/team/cdc/dispatch.cgi/w.phin_policy/tart/f.general_discussion_forum_for_phin_policy/.frame');
	}
	// centers of excellence
	else if (pageOnly.indexOf('phi-coe') >=0)
	{
		document.write('/team/cdc/dispatch.cgi/w.phin_research1/tart/f.centers_of_excellence/.frame');
	}
	// research
	else if (pageOnly.indexOf('research') >=0)
	{
		document.write('/team/cdc/dispatch.cgi/w.phin_research1/tart/f.general_discussion_forum_for_phin_research/.frame');
	}
	// policy - vocab and messaging
	else if ((pageOnly.indexOf('vocab') >=0) ||(pageOnly.indexOf('messaging') >=0))
	{
		document.write('/team/cdc/dispatch.cgi/w.vocabularyc/tart/f.generaldisc26/.frame');
	}
	// conference
	else if (pageOnly.indexOf('conference') >= 0)
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion9');
	}
	// partner calls
	else if (pageOnly.indexOf('partner-calls') >= 0)
	{
		document.write('/team/cdc/dispatch.cgi/f.discussion_of_monthly_phin_partner_calls');
	}
	// sme
	else if (pageOnly == 'sme.html')
	{
		document.write('/team/cdc/dispatch.cgi/f.discussion88');
	}
	// website feedback
	else if ((pageOnly.indexOf('feedback') >=0) || (pageOnly.indexOf('newphinsite') >=0))
	{
		document.write('/team/cdc/dispatch.cgi/f.discussion_of_phin_website_re_design');
	}
	else
	{
		document.write('/team/cdc/dispatch.cgi/f.general_discussion_forum_for_phin');
	}

	document.write(' target=_blank>');
}	

// ####
// Change the display of a tab in the sub-menu
// change the class of the tab (td object) and change the source of the image inside (the arrow)
// ####
function highlightTabSub(tabName)
{
	var tab = document.getElementById(tabName);
	tab.className='copTabOnSub';
	var arrow = document.getElementById(tabName + "Arrow");
	arrow.src="/phin/images/nav-arrow-ovr.gif";
}

// ####
// Change the display of a tab in the sub-menu
// change the class of the tab (td object) and change the source of the image inside (the arrow)
// ####
function highlightTab2(tabName)
{
	var tab = document.getElementById(tabName);
	tab.className='copTabOnSub';
	var arrow = document.getElementById(tabName + "Arrow");
	arrow.src="/phin/images/nav-arrow-ovr.gif";
}

// ####
// Change the display of a tab in the main navigation menu
// change the class of the tab (td object) and change the source of the image inside (the arrow)
// ####
function highlightTab(tabName)
{
	var tab = document.getElementById(tabName);
	tab.className='copTabOn';
	var arrow = document.getElementById(tabName + "Arrow");
	arrow.src="/phin/images/nav-arrow-ovr.gif";
}

// ####
// Change the display of a tab in the sub-menu back to the original (un-highlighted)
// change the class of the tab (td object) and change the source of the image inside(the arrow)
// only do this if the current page is NOT associated with the tab
// this is called in onMouseOut - when the mouse moves away, so if it is the appropriate tab, do not change it back
// ####
function unHighlightTab(tabName)
{
	var tab = document.getElementById(tabName);
	var pn=document.MM_pn;
	if (!pn) 
	{pn='none';}
	pn+='Tab';
	if (tabName!=pn)
	{
		tab.className='copTabOff';
		var arrow = document.getElementById(tabName + "Arrow");
		arrow.src="/phin/images/nav-arrow.gif";
	}
}

// ####
// Same as unHighlightTab, but for the sub-menu
// ####
function unHighlightTab2(tabName)
{
	var tab = document.getElementById(tabName);
	var pn=document.MM_pn2;
	if (!pn) 
	{pn='none';}
	pn+='Tab';
	if (tabName!=pn)
	{
		tab.className='copTabOff';
		var arrow = document.getElementById(tabName + "Arrow");
		arrow.src="/phin/images/nav-arrow.gif";
	}
}


