
function scenarioNotAvail(){ 
	alert("This scenario is not available.\nPlease try again.")
}	

function scenariosNotAvail(){ 
	alert("These scenarios are not available.\nPlease try again.")
}	

function linkNotActive(){ 
	alert("This link is not active for this screen.\nPlease try again.")
}	

function reportButton(){ 
	alert("This link is not active for this screen.\nPlease try again.")
}	

function buttonNotActive(){ 
	alert("This button is not active for this screen.\nPlease try again.")
}	

function menuNotActive(){ 
	alert("This LOLO side menu item is not active for this screen.\nPlease try again.")
}	

function showInst(fname){
if (fname=="orig"){
	if (browser == "netscape"){
		document.inst.visibility="visible";
		window.scrollTo(0,0)}
	if (browser == "ie"){
		inst.style.visibility="visible";
		window.scrollTo(0,0)}}
else {
newWin=window.open(fname,'inst','scrollbars=yes,width=610,height=360,screenX=10,screenY=10,top=10,left=10');}
}

function hideInst(){
	if (browser == "netscape")
		document.inst.visibility="hide";
	if (browser == "ie")
		inst.style.visibility="hidden";
	if (browser == "NN6")
		inst.style.visibility="hidden";
}

function detectBrowser(){
	if ((navigator.appVersion.charAt(0) == "4")	|| (navigator.appVersion.charAt(0) == "5")  || (navigator.appVersion.charAt(0) == "6")){
		if (navigator.appName == "Microsoft Internet Explorer")
			browser="ie";
		if (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"))
			browser="NN6";
		if (navigator.appName == "Netscape")
			browser="netscape";
}
else {
alert("Sorry:\n\nYou will need Version 4 or greater of\nMicrosoft Internet Explorer or Netscape   \nNavigator to access this site.\n")
}}


function extLink(section,extAddress){
if (confirm('\nThis link will take you outside this training site, to the\n'+section+' area of the Telstra Wholesale Web site.    \n\nPress OK to leave this training site.\nPress Cancel to remain on this page.')){
window.location.href=extAddress;}
}

function extTLink(section,extAddress){
if (confirm('\nThis link will take you outside this training site, to the\n'+section+' area of the Telstra Web site.    \n\nPress OK to leave this training site.\nPress Cancel to remain on this page.')){
window.location.href=extAddress;}
}

function noChange(fieldLabel){
	alert('\nFor the purposes of this scenario, please do not   \nchange the ' + fieldLabel+ ' field.');
	document.form1.spRef.focus();
}

// --------------------------------------------------------------------------------------
//                   Show Me/Clear Button (on Training Window)
// --------------------------------------------------------------------------------------

var showMeColor = "#d9ecff";
var clearColor = "#ffffff";

function showMe(field, showMe) {
	if (field && showMe) {
		field.style.backgroundColor = showMeColor;
	}
	else if (field) {
		field.style.backgroundColor = clearColor;
	}
}

function showButtonUp() {
if (document.all){
    if (document.form1[testElementName]) {
		if (document.form1[testElementName].style.backgroundColor==showMeColor){
			document.images["btnShowme"].src="images/clear_up.gif";}
		else {
			document.images["btnShowme"].src="images/showme_up.gif";}
		}
	}
}

function showButtonDown() {
if (document.all){
    if (document.form1[testElementName]) {
		if (document.form1[testElementName].style.backgroundColor==showMeColor){
			document.images["btnShowme"].src="images/clear_down.gif";}
		else {
			document.images["btnShowme"].src="images/showme_down.gif";}
		}
	}
}

// --------------------------------------------------------------------------------------
//                   Training Window
// --------------------------------------------------------------------------------------

function trainingWindow (titleText,trainingText,scenarioText,disableShowme,disableScenario){
this.titleText = titleText || "LOLO Training";
this.trainingText = trainingText || "Training Text";
this.scenarioText = scenarioText || "Scenario Text";
this.disableShowme =  disableShowme || 0;
this.disableScenario =  disableScenario || 0;
this.makeWindow = makeWindow;
}

function textButtonDown() {
if(document.all){ source = document.images["btnScenario"].src;}
if(document.getElementById && !document.all){ source = document.images["btnScenario"].src;}
if(document.layers){ source = source = document.layers["buttons"].document.images["btnScenario"].src;}
numchars = source.length;
filepos = source.lastIndexOf("/");
firstchar = filepos + 1;
lastchar = numchars + 1;
filename = source.substring(firstchar,lastchar);
if (filename=="training_up.gif"){
if(document.all){ document.images["btnScenario"].src="images/training_down.gif";}
if(document.getElementById && !document.all){ document.images["btnScenario"].src="images/training_down.gif";}
if(document.layers){ document.layers["buttons"].document.images["btnScenario"].src="images/training_down.gif";}}
else {
if(document.all){ document.images["btnScenario"].src="images/scenario_down.gif";}
if(document.getElementById && !document.all){ document.images["btnScenario"].src="images/scenario_down.gif";}
if(document.layers){ document.layers["buttons"].document.images["btnScenario"].src="images/scenario_down.gif";}}
setTimeout("toggleText();",150);
}

function toggleText(){
if(document.all){
    if (IEtrainingbody.style.visibility=="visible"){
	    IEtrainingbody.style.visibility="hidden";
	    IEscenariobody.style.visibility="visible";
        document.images["btnScenario"].src="images/training_up.gif";}
    else {
        IEtrainingbody.style.visibility="visible";
        IEscenariobody.style.visibility="hidden";
        document.images["btnScenario"].src="images/scenario_up.gif";}}	
}

function setTextValue(){
if(document.all){
    if ((IEtrainingbody.style.visibility=="visible") || (IEtrainingbody.style.visibility=="hidden" && IEscenariobody.style.visibility=="hidden")){
        form1.text.value="1";}
    else {
        form1.text.value="0";}}
}

function getTextValue(){
if(document.all){
    if (form1.text.value=="1"){
        IEtrainingbody.style.visibility="visible";}
    else{
        IEscenariobody.style.visibility="visible";}}
}


function makeWindow () {
// name = training | height = 200 | width = 370 | top = 95 | left = 0
// IE container and Title Bar, including drag functions
if(document.all){
    document.write('<div id="training" style="visibility:visible;z-index:100;">');
    document.write('<div align="right" id="titleBar" onmousedown="initDrag();" onmouseup="endDrag();" style="position:absolute;z-index:100;top:0;right:0;clip:rect(0 370 24 0);">');
    document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCCCC"><img src="images/top_left.gif" border=0></td>');
    document.write('<td><img src="images/training_label.gif" width="84" height="24"></td>');
    document.write('<td><img src="images/top_middle.gif" width="205" height="24"></td>'); // image width = ((width - 99) - 66)
    document.write('<td bgcolor="#000080"><img name="btnMin"src="images/min_up.gif" onMouseDown="btnMin.src=\'images/min_down.gif\';" onMouseUp="btnMin.src=\'images/min_up.gif\';setTextValue();document.all(\'buttons\').style.visibility = \'hidden\';document.all(\'leftSide\').style.visibility = \'hidden\';document.all(\'rightSide\').style.visibility = \'hidden\';document.all(\'IEtrainingbody\').style.visibility = \'hidden\';document.all(\'IEscenariobody\').style.visibility = \'hidden\';"></td>');
    document.write('<td bgcolor="#000080"><img name="btnMax" src="images/max_up.gif" onMouseDown="btnMax.src=\'images/max_down.gif\';" onMouseUp="btnMax.src=\'images/max_up.gif\';document.all(\'buttons\').style.visibility = \'visible\';document.all(\'leftSide\').style.visibility = \'visible\';document.all(\'rightSide\').style.visibility = \'visible\';getTextValue();"></td>');
    document.write('</tr></table>');
    document.write('<script language="JavaScript">');
    document.write('function initDrag(e){');
    document.write('document.all("training").document.onmousemove=doDrag;');
    document.write('startDragX = event.clientX;');
    document.write('startDragY = event.clientY;');
    document.write('if (event.srcElement.tagName == "IMG")');
    document.write('event.returnValue=false;');
    document.write('moveWindow = "true";return false;');
    document.write('};');
    document.write('function doDrag(){');
    document.write('if(moveWindow == "true"){');
    document.write('calcRight = event.clientX-startDragX;');
    document.write('calcTop = event.clientY-startDragY;');
    document.write('document.all("training").style.pixelRight -= calcRight;');
    document.write('document.all("training").style.pixelTop += calcTop;');
    document.write('document.all("titleBar").style.pixelRight -= calcRight;');
    document.write('document.all("titleBar").style.pixelTop += calcTop;');
    document.write('document.all("buttons").style.pixelRight -= calcRight;');
    document.write('document.all("buttons").style.pixelTop += calcTop;');
    document.write('document.all("leftSide").style.pixelRight -= calcRight;');
    document.write('document.all("leftSide").style.pixelTop += calcTop;');
    document.write('document.all("rightSide").style.pixelRight -= calcRight;');
    document.write('document.all("rightSide").style.pixelTop += calcTop;');
    document.write('document.all("IEtrainingbody").style.pixelRight -= calcRight;');
    document.write('document.all("IETrainingbody").style.pixelTop += calcTop;');
    document.write('document.all("IEscenariobody").style.pixelRight -= calcRight;');
    document.write('document.all("IEscenariobody").style.pixelTop += calcTop;');
    document.write('startDragX = event.clientX;');
    document.write('startDragY = event.clientY;');
    document.write('event.cancelBubble = true;');
    document.write('event.returnValue = false;');	
    document.write('}else{}');
    document.write('}');
    document.write('function endDrag(){');
    document.write('moveWindow == "false";');
    document.write('document.onmousemove=null;');
    document.write('return false');
    document.write('}');
    document.write('</script>');
    document.write('</div>');}

// IE left side
if(document.all){
    document.write('<div id="leftSide" align="right" style="position:absolute;background:red;width:6;z-index:100;top:23;right:0;visibility:visible;">');// top = (top + 23)
    document.write('<img src="images/right.jpg" height="154"  width="6"><br>'); // image right.jpg height = (height - 46)
    document.write('</div>');}

// IE right side
if(document.all){
    document.write('<div id="rightSide" align="right" style="position:absolute;background:red;width:6;z-index:100;top:23;right:364;visibility:visible;">');// top = (top + 23) , left = ((width - 6) + left)
    document.write('<img src="images/right.jpg" height="154" width="6"><br>');// image right.jpg height = (height - 46)
    document.write('</div>');}

// IE body area
if(document.all){
    document.write('<div id="IEtrainingbody" align="right" style="position:absolute;z-index:100;background:#fff3eb;width:359;top:24;right:6;clip:rect(0 359 153 0);height:153;overflow:auto;visibility:visible;">');// left = (left + 6) , top = (top + 24) , clip = (width - 11) (height - 47) ,width = (width - 11)
    document.write('<table border="0" cellpadding="5" cellspacing="0" align="left"><tr><td align="left" class="trainingTxt">');
document.write('<font class="stryHedTxt">'+this.titleText+'</font><br><br>');
    document.write(this.trainingText);
    document.write('</td></tr></table>');
    document.write('</div>');
    document.write('<div id="IEscenariobody" align="right" style="position:absolute;z-index:100;background:#fff3eb;width:359;top:24;right:6;clip:rect(0 359 153 0);height:153;overflow:auto;visibility:visible;">');// left = (left + 6) , top = (top + 24) , clip = (width - 11) (height - 47),width = (width - 11)
    document.write('<table border="0" cellpadding="5" cellspacing="0" align="left"><tr><td class="trainingTxt" align="left">');
    document.write(this.scenarioText);
    document.write('</td></tr></table>');
    document.write('</div>');}

// IE function buttons
if(document.all){
    document.write('<div id="buttons" align="right" style="position:absolute;z-index:100;top:177;right:0;clip:rect(0 370 34 0);visibility:visible;">'); // top = (top + (height - 23))
    document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td><img src="images/bottom_left.gif" width="91" height="34">');
        if (this.disableShowme==0){
            document.write('</td><td><img name="btnShowme" src="images/showme_up.gif" width="88" height="34" onMouseDown="showButtonDown();" onMouseUp="toggleForm();showButtonUp();"></td>');}
        else{
            document.write('</td><td><img name="btnShowme" src="images/showme_disabled.gif" width="88" height="34" onClick="alert(\'The Show Me button is disabled for this screen.   \')"></td>');}
        if (this.disableScenario==0){
            document.write('</td><td><img name="btnScenario" src="images/scenario_up.gif" width="87" height="34" onMouseDown="textButtonDown();"></td>');}
        else{
            document.write('</td><td><img name="btnScenario" src="images/scenario_disabled.gif" width="87" height="34" onClick="alert(\'The Scenario button is disabled for this screen.   \')"></td>');}
    document.write('<td><img src="images/bottom_right.jpg" width="105" height="34"></td></tr></table>');
    document.write('</div>');}
	
	
// Display training window
if(document.all){
    document.all("IEtrainingbody").style.visibility = "visible";
    document.all("IEscenariobody").style.visibility = "hidden";
    document.all("buttons").style.visibility = "visible";
    document.all("leftSide").style.visibility = "visible";
    document.all("rightSide").style.visibility = "visible";
    document.all("training").style.visibility = "visible";
	}
}

//---------------------------------------------------------------
//  Misc
//---------------------------------------------------------------

// Get image filename for Netscape
function getImage(){
source = document.images["image1"].src;
numchars = source.length;
filepos = source.lastIndexOf("/");
firstchar = filepos + 1;
lastchar = numchars + 1;
filename = source.substring(firstchar,lastchar);
}

// Cookie functions for preferences

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());
var todays_date = new Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
var expires_date = new Date(todays_date.getTime() + (1000 * 60 * 60 * 24 * 365));

function getCookieVal (offset) { // thanks to Bill Dortch
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
    endstr = document.cookie.length;
    crumb=unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {// thanks to Bill Dortch
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
    while (i < clen) {
    var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) break;}
            crumb="0";
}

function SetCookie (name,value,expires,path,domain,secure) {// thanks to Bill Dortch
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain) {// thanks to Bill Dortch
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT"; }
}

function checkCookie() {
GetCookie('checkcookie');
if (crumb=="0"){
SetCookie('checkcookie','checkcookie');
}}

