/* ---------------------------
' (C) Copyright 2008
' Niro Solutions Pty Limited
' ABN 89 106 967 140
' ---------------------------
' Revision: 2.00
' Author: Robert Spackman
' Modtime: 02/01/2008
' --------------------------- */

var cCol="";
var numberOfTabs = 3
var fcs=false
var initGSL1="";

function showDIV(myDIV, noOfTabs)
{
	var setDIV = myDIV.getAttribute("ID");
	for(i=1;i<=noOfTabs;i++)
	{
		// disable all DIVs
		eval("divTab"+i+".style.display = 'none';")
		// change element's class to another class:
		eval("tab"+i+".className='tabOff';")
		eval("document['i"+i+"'].src = ctab"+i+"off.src;")
	}
	myDIV.style.display = "";
	for(i=1;i<=noOfTabs;i++)
	{
		eval("if(setDIV == 'divTab"+i+"')	{	tab"+i+".className='tabOn';	document['i"+i+"'].src = ctab"+i+"on.src;}")
	}
}

function cursorH(e)
{
	//window.event.srcElement.style.cursor = "hand";
	e.style.cursor = "pointer";
}
function cursorA(e)
{
	//window.event.srcElement.style.cursor = "default";
	e.style.cursor = "default";
}					

function doChanges(e)
{
	// get this 'e' element's table and set backgroundColor
	// of rows to cCol
	var rr = getMyTable(e);
	for(i=0;i<rr.rows.length-3;i++)
		rr.rows[i].style.backgroundColor=cCol
	e.style.backgroundColor = "#e6e6e6";
}

function restore(e)
{
	var rr = getMyTable(e);
	for(i=0;i<rr.rows.length-3;i++)
		rr.rows[i].style.backgroundColor=cCol
	e.style.backgroundColor = cCol;
}


function select(field)
{
	field.focus()
	field.select()
}

function isInt_MinMax(field,min1,max1,prompt1)
{
    var v=field.value
    var int1 = /^\d{1,7}$/;
    var reg=new RegExp(int1);
    var ret = reg.test(v);

    if(ret && v >= min1 && v <= max1)
	    return true;
    else
    {
	    mySelect(field)
	    if(prompt1)
		    alert("Please enter a whole number between " + min1 + " and " + max1 +".")
	    return false;
    }
}

function getMyDIV(x)
{
	// start with an element and go up through the tree trying to find
	// a <DIV> HTML element;
	// return a reference to an object of type <DIV>
	// or, if not found, return null
	if(x!=null && x.tagName!="DIV")
		return (getMyDIV(x.parentElement));
	else
		return x;
}

function getMyTable(x)
{
	if(x!=null && x.tagName!="TABLE")
		return (getMyTable(x.parentElement));
	else
		return x;
}

function selectCmb(field)
{
	field.focus()
}

function goToStep2(e,tabNumber)
{
	var f=document.forms.frmName
	if(validStep1(f))
	{
		calcResults(f)
		showTab(tabNumber);
	}
}

function goToStep3(e,tabNumber)
{
	var f=document.forms.frmName
	if(validStep1(f))
	{
		showTab(tabNumber);
	}
}

function loadAndShow()
{   
    ajaxManager('start_up')
   
 	preLoadImages(3)
	initialise();

	setPlannerStuff()
    disableColumn2()
	showTab(1);
	fcs=true
	
	setTotalSec1(document.forms.frmName)
	setTotalSec2(document.forms.frmName)
	setTotalTer1(document.forms.frmName)
	setTotalTer2(document.forms.frmName)
	
	document.getElementById("spacer1").className = "td_space";
    document.getElementById("spacer2").className = "td_space";
	
	//if((navigator.appName).toUpperCase()=="NETSCAPE")
    //{
    //document.getElementById("toolbar").className = "toolbarFF";
    //document.getElementById("spacer1").className = "td_spaceFF";
    //document.getElementById("spacer2").className = "td_spaceFF";
	//}
    
}

function preLoadImages(noOfTabs)
{
	var i;
    var p = "images/calculators/"

	for(i=1;i<=noOfTabs;i++)
	{
		eval("ctab"+i+"on = new Image();")
		eval("ctab"+i+"on.src = '"+p+"menu_"+i+"g.gif';")
		eval("ctab"+i+"off = new Image();")
		eval("ctab"+i+"off.src = '"+p+"menu_"+i+".gif';")
	}
		eval("gtabl = new Image();")
		eval("gtabl.src = '"+p+"menu_gtab-left.gif';")
		eval("gtabr = new Image();")
		eval("gtabr.src = '"+p+"menu_gtab-right.gif';")

		eval("wtabl = new Image();")
		eval("wtabl.src = '"+p+"menu_wtab-left.gif';")
		eval("wtabr = new Image();")
		eval("wtabr.src = '"+p+"menu_wtab-right.gif';")
		
}
function initialise()
{
    try
{
	var f=document.forms.frmName
	f.txtGSL1.value=(isInt(initGSL1))?initGSL1:""
}
catch(e)
{
	alert(e)
}
}

function openInMain(page1)
{
    try
    {
	    (window.opener).location=page1
	    window.opener.focus()
    }
    catch(e)
    {
	    msgWindow1=null;
	    msgWindow1=window.open(page1,'mainWindow');
	    self.close()
    }
}

function cursorHU(e)
{
	e.style.cursor = "pointer";
	//e.className='hrHoover1';
}

function cursorHU0(e)
{
	//window.event.srcElement.className='hrHoover0';
}

function openPrintWnd()
{
    window.print()
}

function showTab(tabNumber)
{
	document.getElementById("divPreLoad").style.display = "none";
	document.getElementById("divMain").style.display = "";
	
		/*  disable all DIVs */
		document.getElementById("divTab1").style.display = "none";
		document.getElementById("divTab2").style.display = "none";
		document.getElementById("divTab3").style.display = "none";
		
		document.getElementById("tabImgL1").src = wtabl.src;
        document.getElementById("tabImgL2").src = wtabl.src;
        document.getElementById("tabImgL3").src = wtabl.src;
           
	    document.getElementById("tabImg1").src = ctab1off.src;
	    document.getElementById("tabImg2").src = ctab2off.src;
	    document.getElementById("tabImg3").src = ctab3off.src;
	    		
        document.getElementById("tabImgR1").src = wtabr.src;
        document.getElementById("tabImgR2").src = wtabr.src;
        document.getElementById("tabImgR3").src = wtabr.src;
                        	
		switch (tabNumber)
		{
			case 1 :
				document.getElementById("tabImgL1").src = gtabl.src;
				document.getElementById("tabImg1").src = ctab1on.src;
				document.getElementById("tabImgR1").src = gtabr.src;
				document.getElementById("divTab1").style.display = "";
				document.getElementById("header1").innerHTML = "Education Details";
				document.getElementById("header2").innerHTML = "Enter education details";
				
				if(fcs)
				{
					window.location.href="#top1"
					//select(document.forms.frmName.txtGrossIncome)
				}
				break;
			case 2 :
				document.getElementById("tabImgL2").src = gtabl.src;
				document.getElementById("tabImg2").src = ctab2on.src;
				document.getElementById("tabImgR2").src = gtabr.src;
				document.getElementById("divTab2").style.display = "";
				document.getElementById("header1").innerHTML = "Your Results";
				document.getElementById("header2").innerHTML = "Cost of education results";
				break;
			case 3 :
				document.getElementById("tabImgL3").src = gtabl.src;
				document.getElementById("tabImg3").src = ctab3on.src;
				document.getElementById("tabImgR3").src = gtabr.src;
				document.getElementById("divTab3").style.display = "";
				document.getElementById("header1").innerHTML = "Next Steps";
				document.getElementById("header2").innerHTML = "So what will you do now?";
				break;
		}
		if(tabNumber!=1) window.location.href="#top1"
		}

		
function ToggleInfo(strSection)
    {
        SectionTitle=document.getElementById(strSection+'title')
        SectionText=document.getElementById(strSection+'text')

        if (SectionText.style.display=='none')
        {
            SectionText.style.display='block';
            SectionTitle.className='botinfo_title_exp';
        }
        else
        {
            SectionText.style.display='none';
            SectionTitle.className='botinfo_title_col';
        }
    }