// START CODING BLOCK FOR BUILDING CYCLE NAVIGATION FOR 3-LEVEL PAGES
//********************************************************************
/*
	Builds navigational links inside content module,
	specifically, inside div element with specific id "cyclediv".
	If element is not found - nothing is done.
	If element is found, its inner HTML is used to determine which link definition
	should be used (stored in the global array "cn_array").
	For this purpose the text inside the div element should be one of the numbers used in
	one of the definition cases.
	Links are separated by globally declared variable "separator_"
	Styles for the div element can be defined in existing CSS file.
*/

//Global variables:
var separator_ = " | ";
var cn_array = new Array();

//Load array with navigational schema
//Elements are separated by pipe "|"
//Each array element has 4 components separated by pipe "|":
//	first - number is the navigation group number (type);
//	second - menu title;
//	third - menu url
//	frouth - link target (leave empty for same window)
//Array contains all links from all groups. They'll be mached one by one with the type passed
//from the div on the page

/*
	Array declaration example:

cn_array.push("1|Link to Page 1|page1.htm|");
cn_array.push("1|Link to Page 2|page2.htm|");
cn_array.push("2|Link to Page 1|pageA1.htm|");
cn_array.push("2|Link to Page 2|pageA2.htm|");

	Start array declaration below this comment
*/

//Business forms Consultants circuite
cn_array.push("1|Business Home|../business/business.shtml|");
cn_array.push("1|Forms Home|../business/bus_forms.shtml|");
cn_array.push("1|Consultant Procurement|../business/otherfrm.shtml|");
cn_array.push("1|Division of Structures|../business/consulpay.shtml|");
cn_array.push("1|Payments|../business/payments.shtml|");
cn_array.push("1|Universal Design|../pubs/publications.shtml#universal|");
//Business forms Contractor circuite
cn_array.push("2|Business Home|../business/business.shtml|");
cn_array.push("2|Forms Home|../business/bus_forms.shtml|");
cn_array.push("2|Infrastructure|../business/payinfra.shtml|");
cn_array.push("2|Structures & Tech Support|../business/paystruc.shtml|");
cn_array.push("2|Change Order/Overrun|../business/chngfrm.shtml|");
cn_array.push("2|Payments|../business/payments.shtml|");
//About DDC circuite
cn_array.push("3|Commissioner's Message|../about/com_message.shtml|");
cn_array.push("3|Organizational Structure|../about/agencystructure.shtml|");
cn_array.push("3|Client Agencies|../about/clientagencies.shtml|");
cn_array.push("3|Performance Stats|../about/performance.shtml|");
cn_array.push("3|Travel Directions|../contact/directions.shtml|");


//Advisories circuite
//cn_array.push("4|Advisories Home|../advisories/advisories.shtml|");
cn_array.push("4|Construction Inconveniences|../neighborhood/inconveniences.shtml|");
//Site-cycling nav adjustment 04/30/08
//cn_array.push("4|Summer Heat Alert|../advisories/alert.shtml|");
//cn_array.push("4|Staff Advisories|../advisories/staff.shtml|");
//Site-cycling nav adjustment 04/30/08

//Non-for-Profit (business) circuite
cn_array.push("5|Not-for-Profit|../business/nonprofit.shtml|");
cn_array.push("5|Capital Funding Agreement and Security|../business/nfp_agreement.shtml|");
cn_array.push("5|Document Checklist|../business/nfp_doclist.shtml|");
//Process for bidders various stuff circuite
cn_array.push("6|Business Home|../business/business.shtml|");
cn_array.push("6|Bid Process|../business/processcont.shtml|");
cn_array.push("6|Bidders 12 Tips|../business/bidtips.shtml|");
cn_array.push("6|Payments|../business/payments.shtml|");
cn_array.push("6|Payment 12 Tips|../business/paytips.shtml|");
//Business payments circuite
cn_array.push("7|Business Home|../business/business.shtml|");
cn_array.push("7|Payments|../business/payments.shtml|");
cn_array.push("7|Payment Flowchart|../business/payflow.shtml|");
cn_array.push("7|Payment 12 Tips|../business/paytips.shtml|");
cn_array.push("7|Contractor Payment Forms - Infrastructure|../business/payinfra.shtml|");
cn_array.push("7|Contractor Payment Forms - Structures and Tech Support|../business/paystruc.shtml|");
cn_array.push("7|Consultant Payment Forms - Structures|../business/consulpay.shtml|");
//Process for Consultants various stuff circuite
cn_array.push("8|Business Home|../business/business.shtml|");
cn_array.push("8|Process for Consultants/Subconsultants|../business/processcons.shtml|");
cn_array.push("8|Payments|../business/payments.shtml|");
cn_array.push("8|Payment 12 Tips|../business/paytips.shtml|");

//Add onload event to the window
addEvent(window, "load", buildCircumNav);

//Builds navigational links
function buildCircumNav()	{
	var obj = document.getElementById("cyclediv");
	if (obj == null)	{
		return false;
	}
	var type_ = obj.innerHTML;
	var href_ = document.location.href;
	var ar_href = href_.split("/");
	var current_page_ = ar_href[ar_href.length-1];

	var s = "";
	for (var i=0; i < cn_array.length; i++)	{
		var ar = cn_array[i].split("|");
		if (type_ == ar[0])	{
			var np_array = ar[2].split("/");
			var nav_page_ = np_array[np_array.length-1];
			//If not same page
			if (nav_page_.toLowerCase() != current_page_.toLowerCase())	{
				if (s != "")	// add link separator
					s += separator_;
				s += "<a href='" + ar[2] + "' target='" + ar[3] + "'>" + ar[1] + "</a>";
			}
		}
	}
	obj.innerHTML = s;
}


function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}
//********************************************************************
// END CODING BLOCK FOR BUILDING CYCLE NAVIGATION FOR 3-LEVEL PAGES
