
function leftnav(highlight,subnav) {
	var lPosSep = 0;
	var oElem;
	
	if ( highlight != '' ) {
           oElem = document.getElementById(highlight);
	   if (oElem.className.indexOf('xtopic') > -1)  {
  	      oElem.className = 'xtopicon';
	   }
	   else {
  	      oElem.className = 'topicon';
	   }
	}

	if ( subnav != '' ) {

    		document.getElementById(subnav).className = 'subtopicson';

  	}
	
	// if there is an optional third argument, use it to turn on a left nav item that only appears sometimes (ie. "full story")
	// the actual leftnav item should start with a class of "topichide"
	
	if (arguments.length == 3) { 
		var singlesub = arguments[2];

         if (singlesub.length > 0) {
			lPosSep = singlesub.indexOf(';');
			if (lPosSep > 0) {
				// -- two possibilites sent; find the one to use
				oElem = document.getElementById(singlesub.substring(0, lPosSep));
				if (oElem) {
					oElem.className = 'topicLive';
				}
				else {
				   singlesub = singlesub.substring(lPosSep+1);
				   if (singlesub.length > 0)  {
   				      document.getElementById(singlesub).className = 'topicLive';
				   }
				}
			}
			else {
				oElem = document.getElementById(singlesub);
				if (oElem.className == 'subtopicoff3') {
					// -- indented 3rd level nav element
					// --
      	  	   oElem.className = 'topicLive3';
					lPosSep = oElem.id.indexOf('_');
					if (lPosSep > 0) {
						oElem = document.getElementById(oElem.id.substring(0,lPosSep));
						if (oElem) {
							oElem.className = 'topicLive';
							oElem.style.backgroundColor = "#CB2121";
						}
					}
				}
				else {
      	  	   oElem.className = 'topicLive';
				}
			}
		}
	}

	// after the display options for the leftnav have been exectuted, make the whole left nav visible on the page

//	document.getElementById('leftnav').style.visibility = "visible"; 

}

function jumpMenu(targ,selObj,bRestore){ 
  
  var theURL = selObj.options[selObj.selectedIndex].value;
  var rc = false;

  if (theURL.length <= 1) {
	  // -- nada 
  }
  else {
	// -- URL may have a 1 or a 0 as first character indicating whether URL
	// -- shourl (1) or should not (0) be opened in a new window.
	// -- if first char is not a 0 or 1, do not open in new win
	// --
    var bNewWin = theURL.substring(0,1);
	if (bNewWin == '0' || bNewWin == '1' ) {
		theURL = theURL.substring(1,theURL.length);
	}

    if (bRestore) selObj.selectedIndex=0;

    if (bNewWin == 1) {
		 // -- open a new window
		 var oWin = eval(targ+".open('"+theURL+"', 'winSite')");
		 oWin.focus();
	}
   	else {
        eval(targ+".location='"+theURL+"'");
    }
    rc = true;
  }

  return rc
}

function jumpToMenu(targ,selObj,bRestore,sWinNm)       { 
  
  var theURL = selObj.options[selObj.selectedIndex].value;
  var rc = false;
  var numArgs = jumpToMenu.arguments.length;
  if (numArgs < 4) {
	  sWinNm = '';
  }


  if (theURL.length <= 1) {
	  // -- nada 
  }
  else {
    if (bRestore) selObj.selectedIndex=0;

    if (sWinNm.length >0) {
		 // -- open a new window
		 var oWin = eval(targ+".open('"+theURL+"', sWinNm)");
		 oWin.focus();
    }
    else {
       eval(targ+".location='"+theURL+"'");
    }

    rc = true;
  }

  return rc;
}

function winClose (theWin) {
	alert ("in there");
	theWin.close();
	
	return (false);
}

function winMin (theWin) {
	theWin.close();
	
	return (false);
}

function toggleTabs (sUL, iTabIdx) {
    var oUL = document.getElementById (sUL);
    var oSelectedLI = oUL.getElementsByTagName('li').item(iTabIdx);
	  
	if ( oSelectedLI.className == 'current' ) {
		// -- tab already selected; nada
		return (false);
	}
	else {
	   	var oTheLIs = oUL.getElementsByTagName('li');
		var oTheLI;
		 
		for (var i = 0; i < oTheLIs.length; i++) {
		    oTheLI = oTheLIs.item(i);
			   
		    if ( i == iTabIdx ) {
			   // -- select this one
			   oTheLI.className = 'current';
			   oTheLI.getElementsByTagName('a').item(0).className = 'on';
			} else {
			   oTheLI.className = 'tab';
			   oTheLI.getElementsByTagName('a').item(0).className = '';
            }			
			
		 }
	}
	  
	return (false);
}

function SubmitHahtLogin(oForm)
{
	//var oForm = document.getElementById('loginForm');
   var sLogin  = oForm.slogin.value;
   var sPwd    = oForm.spwd.value;
   if ((sLogin == "") || (sPwd == ""))
   {
   		alert ("You must supply both a UserName and Password.");
   } else
   {
   		// Have to copy the file "SiteUnavailable.shtml" to each site Rinker_US, Rinker_STC & Rinker_MTLS
   		//oForm.action = "/SiteUnavailable.shtml";	
   		
   		oForm.action = oForm.action + sLogin + "&pwd=" + sPwd;
   		window.location = oForm.action;
   }
} 


// 2006-06-22 HLM. Separate into 2 function calls SubmitHahtLogin() & SubmitHahtLoginAU() to 
// have more control over the setup of Hahtsite not available (either one of them, or both)
function SubmitHahtLoginAU(oForm)
{
	//var oForm = document.getElementById('loginForm');
   var sLogin  = oForm.slogin.value;
   var sPwd    = oForm.spwd.value;
   if ((sLogin == "") || (sPwd == ""))
   {
   		alert ("You must supply both a UserName and Password.");
   } else
   {
   		// Have to copy the file "SiteUnavailable.shtml" to each site Rinker_AU, Rinker_HMS & Rinker_RDYMX
   		//oForm.action = "/SiteUnavailable.shtml";	
   		
   		oForm.action = oForm.action + sLogin + "&pwd=" + sPwd;
   		window.location = oForm.action;
   }
} 


function SetOptionValueThruGoListOfTools(oSelectID)
{
	//var oSelectID = document.getElementById (selectID);
	var oOpts = oSelectID.getElementsByTagName('option');
			 
	 for (var i = 0; i < oOpts.length; i++) {
		oOpts[i].value = goListOfTools.entryByID(oOpts[i].value).URL;
		//alert (oOpts[i].value);
	 }
}

function thisIsAnAUSite()
{
	// Detect the URL to see if this is an Australian site (=1) or not (=0)
	var AUSite      = new Array("RinkerGroup", "rinker.com.au", "Readymix", "Humes", 	// Real sites
								"Rinker_AU", "RinkerAU", "Rinker_HMS", "RinkerHMS",		// Test sites
								"Rinker_RDYMX", "RinkerRDYMX");							// Test sites
	var isAUSite    = 0;		// default to US sites
	
	var locHostName = window.location.hostname.toLowerCase();
	//Test - locHostName = "www.rinker.com.au";

	var test;
	for (var i=0; i < AUSite.length; i++)
	{
		
		test = locHostName.indexOf(AUSite[i].toLowerCase());
		//alert (i + ": " + test);
		if (test != -1)			// Find a match
		{
			isAUSite = 1;
			return isAUSite;
		}
	}
	return isAUSite;
}

function ShowMap(whichMap)
{
	// Detect the URL to see if this is an Australian Production, Local, DEV or TST site
	var AUSite     = new Array("www.rinkergroup.com.au", "www.Readymix.com.au", "www.Humes.com.au", 
	                           "www.rinker.com.au", "www.Readymix.com.au", "www.Humes.com.au", 	// Production sites
								"Rinker_AU", "Rinker_Rdymx", "Rinker_HMS",						// Local sites
								"DevRinkerAU", "DevRinkerRdymx", "DevRinkerHMS",				// DEV sites
								"TstRinkerAU", "TstRinkerRdymx", "TstRinkerHMS");				// TST sites
	var test;
	var rdyLink;
	var hmsLink;
	
	var locHostName = window.location.hostname.toLowerCase();
	//For example - locHostName = "www.rinker.com.au";
	
	for (var i=0; i < AUSite.length; i=i+3)
	{
		test = locHostName.indexOf(AUSite[i].toLowerCase());
		//alert (i + ": " + test + " " + locHostName + " " + AUSite[i]);
		if (test != -1)			// Find a match
		{
			//alert("Find site: " + AUSite[i]);
			rdyLink = "http://" + AUSite[i+1] + "/locations/";		// Link to Readymix site
			hmsLink = "http://" + AUSite[i+2] + "/locations/";		// Link to Humes site
			break;
		}
	}

	if (whichMap==0)
	{
		location.href = rdyLink;
	} else
	{
		location.href = hmsLink;
	}
}

