// *** BEGIN NEW CONTENT REQUIRED FOR HEADER INCLUDE *** 

// *** Websphere parameters *** 
var wcs_storeId;
var wcs_catalogId;
var wcs_langId;

// *** login related settings - start *** 

// loginState denotes whether the user is logged in (1) or not (-1)
var telstra_global_loginState ;

// telstra_global_login_url denotes the URL to be returned to upon successful login
var telstra_global_login_url;

// username should be set to the user's firstname
var telstra_global_header_firstname;

//define a custom logout function routine --%>
var telstra_global_header_fn_logout = "ssoLogout()";

var sso_logoff_url;

// *** login related settings - end *** 

// telstra_global_tabId denotes which tab is selected and can be determine counting left to right, starting from zero (ie. 2 = third tab)
var telstra_global_tabId = 1;   //1

// telstra_global_contactus_contactId denotes content of 'Contact Us' tile
var telstra_global_contactus_contactId = 3;

// lhnavId denotes which left hand nav item is selected and must match an array item defined in lhnavArrays.js (or below)
var telstra_global_lhnav_id = "sso";  

// Second level Left Hand Nav menu items can be defined as follows (note the naming convention of 'olb_array')
// Each item in the array must contain the following parameters:
// 	[	Unique ID , (note this must be unique and follow a naming convention of "111_2")
//		Menu Item Title ,
//		URL , 
//		Name of Third level array, (or null if none exists)
//  		Login Display Level (-1, 0, or 1)
//// 	]
var lhnavArray	= [];
function ssoLogout()
{
	//***********************************************
	//delete the siteminder cookie in browser store 
	//***********************************************
	deleteCookie("globalFirstName");
	
	this.location.href = sso_logoff_url;
	//this.location.href = "/global/includes/logout.html";
}
function setGlobalNavId(categoryId) {
		//*******************************************************************************
		//Need to determine the currently selected item and assign to javascript variable 
		//'telstra_global_lhnav_id'.
		//*******************************************************************************
	
	var arrayId = "";
	var url = "";
	var searchText = "categoryId="+categoryId;
	var categoryFound = false;
	//alert("In setGlobalNavId - categoryId is "+categoryId);
	for (var i=0; i < lhnavArray.length; i++)
	{
		arrayId = lhnavArray[i][0];  
		url = lhnavArray[i][2];
		//alert("Checking selection - want categoryId="+categoryId+", arrayId="+arrayId+", url="+url);
		if (url.indexOf(searchText) != -1) {
			categoryFound = true;
			break;
		}	

		if (lhnavArray[i][3] != null)
		{
			for (var j=0; j < lhnavArray[i][3].length; j++)
			{
				arrayId = lhnavArray[i][3][j][0];
				url = lhnavArray[i][3][j][2];
				//alert("Checking selection - want categoryId="+categoryId+", arrayId="+arrayId+", url="+url);
				
				if (url.indexOf(searchText) != -1) {
					categoryFound = true;
					break;
				}	
			}
			if (categoryFound) {
				break;
			}	
		}
	}
	if (categoryFound) {
		//alert("Found current selection - arrayId="+arrayId+", url="+url);
		telstra_global_lhnav_id = arrayId;
	}	
}

function showArrayContents() {
		//*********************
		//Used for debugging!!
		//*********************

	alert("Looping thru telstra_global_header_tabId1_array - num  of elements are "+telstra_global_header_tabId1_array.length);
	for (var i=0; i < telstra_global_header_tabId1_array.length; i++) {
		alert(telstra_global_header_tabId1_array[i][0]+","+telstra_global_header_tabId1_array[i][1]+","+telstra_global_header_tabId1_array[i][2]+","+telstra_global_header_tabId1_array[i][3]+","+telstra_global_header_tabId1_array[i][4]);
	}

	alert("** Looping thru lhnavArray ** lhnavArray.length -> "+lhnavArray.length);
	for (var i=0; i < lhnavArray.length; i++) {
	
		alert("Processing row - " + lhnavArray[i][0]+","+lhnavArray[i][1]);
		alert("Value of third level array is lhnavArray[i][3] -> "+lhnavArray[i][3]);

		if (lhnavArray[i][3] != null) {  //added!!
			alert("Looping for "+lhnavArray[i][1]);
			
			for (var j=0; j < lhnavArray[i][3].length; j++) {
			
				//this is supposed to be the position in the array for the 'login state' ?
				alert("loginState is lhnavArray[i][3][j][4]="+lhnavArray[i][3][j][4]);
								
			}
	
		}
				
	}
	
	alert("Looping thru mph_array");
	for (var i=0; i < mph_array.length; i++) {
		alert(mph_array[i][0]+","+mph_array[i][1]+","+mph_array[i][2]+","+mph_array[i][3]+","+mph_array[i][4]);
	}
	
	
	alert("Looping thru hph_array");
	for (var i=0; i < mph_array.length; i++) {
		alert(hph_array[i][0]+","+hph_array[i][1]+","+hph_array[i][2]+","+hph_array[i][3]+","+hph_array[i][4]);
	}
	
}

// *** END NEW CONTENT REQUIRED FOR HEADER INCLUDE *** 

