//                           +++++++++++++++++++++++++++++++++++
//                           (C) Copyright 2003 - 2008 Niro Solutions Pty Limited ABN 89 106 967 140
//			+++++++++++++++++++++++++++++++++++
//			Version: 3.0.0
//			+++++++++++++++++++++++++++++++++++
//			Original author: Miles Glisovic
//			Last update completed by: Robert Spackman
//			Modification date: 09/08/07
//			+++++++++++++++++++++++++++++++++++

var cCol="";
var numberOfTabs = 3
var fcs=false
var save=false
var ctab=1

function setLimits()
{
	save=false
}

function bHover (e, pos, tab, btn){
    var f=document.forms.frmName
    e.style.backgroundPosition = pos + ' -28px';
    
    switch (tab)
		{
			case 1 :
				f.btnNext1.style.backgroundPosition = 'right' + ' -28px';
				break;
			case 2 :
			    switch (btn)
		            {
			        case 1 :
				        f.btnSave2.style.backgroundPosition = 'right' + ' -28px';
				        break;
			        case 2 :
				        f.btnBack2.style.backgroundPosition = 'right' + ' -28px';
				        break;
			        case 3 :
				        f.btnNext2.style.backgroundPosition = 'right' + ' -28px';
				        break;
		        }
				//f.btnSave2.style.backgroundPosition = 'right' + ' -28px';
				//f.btnBack2.style.backgroundPosition = 'right' + ' -28px';
				//f.btnNext2.style.backgroundPosition = 'right' + ' -28px';
				break;
			case 3 :
				f.btnBack3.style.backgroundPosition = 'right' + ' -28px';
				break;
		}
    
}
function bHoverOut(e, pos, tab, btn){
    var f=document.forms.frmName
    e.style.backgroundPosition = pos + ' 0px';
    
    switch (tab)
		{
			case 1 :
				f.btnNext1.style.backgroundPosition = 'right' + ' 0px';
				break;
			case 2 :
				switch (btn)
		            {
			        case 1 :
				        f.btnSave2.style.backgroundPosition = 'right' + ' 0px';
				        break;
			        case 2 :
				        f.btnBack2.style.backgroundPosition = 'right' + ' 0px';
				        break;
			        case 3 :
				        f.btnNext2.style.backgroundPosition = 'right' + ' 0px';
				        break;
		        }
				break;
			case 3 :
				f.btnBack3.style.backgroundPosition = 'right' + ' 0px';
				break;
		}
}
function CloseCalc()
{
var oCalc = window.parent.document.getElementById("frmSalSac")
oCalc.src = ""
oCalc.style.display = "none"
}

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 cursorT(e, tabNo)
{
	//window.event.srcElement.style.cursor = "hand";
	//window.alert(ctab)
	if (tabNo!=ctab)
	{e.style.textDecorationUnderline = true;}
	
}

function cursorO(e)
{
	//window.event.srcElement.style.cursor = "hand";
	e.style.textDecorationUnderline = false;
}				

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 = "#ffffff";
}

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 mySelect(field)
{
try
{
	field.focus()
	field.select()
}
catch(e)
{
	;
}
}


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")
		//mg240208 return (getMyTable(x.parentElement));
		return (getMyTable(x.parentNode));
	else
		return x;
}

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

function initialise()
{
try
{
	var f=document.forms.frmName

	f.cmbIncomeG.value=1;
	f.cmbIncomeI.value=1;
	f.cmbCont.value=1;
	CalcTotalIncome()
	
}
catch(e)
{
	alert(e)
}
}

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

function goToStep3(e,tabNumber)
{
	var f=document.forms.frmName
	if(validStep1(f))
	{
	    if (!save){
	        if(confirm("Do you want to save the results of this calculation?")){
                SaveResults()
            }
        }
		showTab(tabNumber);
	}
}

function loadAndShow()
{   
    ajaxManager('start_up')
    initialise();
	LoadResults ()
	CalcTotalIncome()
	//select(document.forms.frmName.txtIncomeG)
	//fcs=true
	
	if((navigator.appName).toUpperCase()=="NETSCAPE")
    {
    //260511 document.getElementById("tab1img").width = "91";
    document.getElementById("tab1img").width = "90";
    document.getElementById("tab2img").width = "10";
    document.getElementById("tab3img").width = "14";
    }
    
}

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("mainTable").style.display = "";
	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;
        
        //document.getElementById("header1row").style.display = "";
        ctab=tabNumber
                        	
		switch (tabNumber)
		{
			case 1 :
				//document.getElementById("tabImgL1").src = gtabl.src;
				//document.getElementById("tabImg1").src = ctab1on.src;
				//document.getElementById("tabImgR1").src = gtabr.src;
				document.getElementById("tab1").className = "current";
				document.getElementById("tab2").className = "";
				document.getElementById("tab3").className = "";
				document.getElementById("divTab1").style.display = "";
				document.getElementById("header1").innerHTML = "Financial details";

				
				if(fcs)
				{
					window.location.href="#top1"
					mySelect(document.forms.frmName.txtIncomeG)
				}
				break;
			case 2 :
				//document.getElementById("tabImgL2").src = gtabl.src;
				//document.getElementById("tabImg2").src = ctab2on.src;
				//document.getElementById("tabImgR2").src = gtabr.src;
				document.getElementById("tab1").className = "";
				document.getElementById("tab2").className = "current";
				document.getElementById("tab3").className = "";
				document.getElementById("divTab2").style.display = "";
				document.getElementById("header1").innerHTML = "Co-contribution results";
				//document.getElementById("header1row").style.display = "none";

				break;
			case 3 :
				//document.getElementById("tabImgL3").src = gtabl.src;
				//document.getElementById("tabImg3").src = ctab3on.src;
				//document.getElementById("tabImgR3").src = gtabr.src;
				document.getElementById("tab1").className = "";
				document.getElementById("tab2").className = "";
				document.getElementById("tab3").className = "current";
				document.getElementById("divTab3").style.display = "";
				document.getElementById("header1").innerHTML = "What is your next step?";

				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';
	}
}
    
function hidePleaseWait()
{
    document.getElementById("divPreLoad").style.display = "none";
}

