// JavaScript Document
/** IE7 FIX **/
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

function initialize(){
	global_number = 1;
	return;
}

function add_events_over(){
	this.style.color='#FFFFFF';
	this.style.textDecoration='underline'; 
}
function add_events_out(){
	this.style.color='#FFFFFF';
	this.style.textDecoration='none'; 
}

function show_events_area_2(which)
{
	document.getElementById('events_area_2').style.display='none';
	document.getElementById('events_area_1').style.display='none';
	
	if (which == 1){
		document.getElementById('events_area_1').style.display='block';
	}
	if (which == 2){
		document.getElementById('events_area_2').style.display='block'; 
	}
	
	for (i=1; i <= 2; i++){
		for (j=1; j <= 3; j++){
			document.getElementById('events_tab_'+i+'_'+j).className = 'events_tab_off_'+j;
		}
	}
	
	for (i=1; i <= 3; i++){
		document.getElementById('events_tab_'+which+'_'+i).className = 'events_tab_on_'+i;
	}
}

function show_news_tabs(which)
{
	document.getElementById('news_col_1').style.display='none';
	document.getElementById('news_col_2').style.display='none';
	document.getElementById('news_col_3').style.display='none';
	document.getElementById('news_col_4').style.display='none';
	document.getElementById('news_col_5').style.display='none';
	
	for (i=1; i <= 5; i++){
		document.getElementById('img_'+i).src = 'images/news_tabs_'+i+'.gif';
	}
	document.getElementById('img_'+which).src = 'images/news_tabs_'+which+'_i.gif';
	
	if (which == 1){
		document.getElementById('news_col_1').style.display='block';
	}
	if (which == 2){
		document.getElementById('news_col_2').style.display='block'; 
	}
	if (which == 3){
		document.getElementById('news_col_3').style.display='block';
	}
	if (which == 4){
		document.getElementById('news_col_4').style.display='block';
	}
	if (which == 5){
		document.getElementById('news_col_5').style.display='block';
	}	
}

var menu = Array();
var links = Array();

menu[1] = Array();
links[1] = Array();

menu[2] = Array();
links[2] = Array();

menu[3] = Array('Shelf Companies','Companies With Your Own Choice Of Name','Company Name Searches','Public & Nl Companies','Companies Limited By Guarantee','Change Of Company Name','Superannuation Trustee Companies','Company Searches','Company Secretarial Services','Company Deregistrations','Orders from Overseas - Australian Companies','Orders From Overseas - Registration of Foreign Companies in Australia','Structuring Requirements For Australian Companies');
links[3] = Array('shelf-companies.php','companies-with-your-own-choice-of-name.php','company-name-searches.php','public-and-nl-companies.php','companies-limited-by-guarantee.php','change-of-company-name.php','superannuation-trustee-companies.php','company-searches.php','company-secretarial-services.php','company-deregistrations.php','orders-from-overseas-australian-companies.php','orders-from-overseas-registration-of-foreign-companies-in-australia.php','structuring-requirements-for-australian-companies.php');

menu[4] = Array('Professional Package','Full Fee Schedules'); // Standard Package
links[4] = Array('professional-package.php','full-fee-schedules.php');  // standard-package.php

menu[5] = Array('Register your Company - DIY','Proprietary Companies','Shelf Companies with Australian Business Numbers ("ABN")','Public Companies','Companies Limited by Guarantee','Nominee/Residential Services','Company Secretary','Public Officer','Discretionary Trusts','Unit Trusts','Superannuation Trusts','Superannuation Trustee Companies','Overseas Clients','New Zealand Companies');
links[5] = Array('company-order-wizard.php','proprietary-companies.php','shelf-companies-with-australian-business-numbers-abn.php','public-companies.php','companies-limited-by-guarantee-info.php','nominee-residential-service.php','company-secretary.php','public-officer.php','discretionary-trusts.php','unit-trusts.php','superannuation-trusts.php','superannuation-trustee-companies.php','overseas-clients.php','new-zealand-companies.php','pdf-order-forms.php');

menu[6] = Array();
links[6] = Array();

menu[7] = Array();
links[7] = Array();

menu[8] = Array();
links[8] = Array();

menu[9] = Array();
links[9] = Array();

menuPos = Array();

var menuElements = Array();
var t;
var show = false;

function getY( oElement )
{
    var iReturnValue = 0;
    while( oElement != null ) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
	
    return iReturnValue;
}

function getX( oElement )
{
    var iReturnValue = 0;
    while( oElement != null ) {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}


function clearMenu(){
	p = document.getElementById('sub_menu_elements');
	c = p.firstChild
	while (c != null){
		n = c.nextSibling;
		p.removeChild(c);
		c = n;
	}
}

function show_menu(number){

	if (show)
		return;
		
	global_number = number;
	
	menuElements[number].firstChild.style.textDecoration = 'none';
	menuElements[number].firstChild.style.color = 'white';
	menuElements[number].firstChild.style.backgroundPosition = '0px -37px';
	menuElements[number].firstChild.style.textWeight = 'bold';
	
	show = true;
	elems = document.getElementById('sub_menu');
	clearMenu();
	
	if (menu[number].length > 0)
		elems.style.display = 'block';	
	
	//this is aplyed to all elements
	var add = 0;
	
	//this is aplyed to the first element
	if (number == 1){ 
		add += 0;
	}
	
	//this is aplyed to the end element
	if (number == 8){
		add += -60;
	}
	
	//additional exeption can be added here
	//if (number == 2){
	//	add += 2;
	//}
	
	elems.style.left = (getX(menuElements[number]) + add) + 'px';
	elems.style.top = (getY(menuElements[number]) + menuElements[number].offsetHeight) + 'px';
	elems.onmouseover = new Function('show_menu('+number+')');
	elems.onmouseout = new Function('hide_menu('+number+')');
	elems = document.getElementById('sub_menu_elements');
	


	for (i = 0; i < menu[number].length; i++){
		node = document.createElement('LI');
		if (links[number][i] == 'company-order-wizard.php') {
		    node.className  = 'register_your_company';
		}
		a = document.createElement('A');
		a.appendChild(document.createTextNode(menu[number][i]));
		a.href = links[number][i];
		node.appendChild(a);
		elems.appendChild(node);
		node.style.dipslay = 'none';
		node.style.zIndex = 30;
	}

}

function hide_menu(number){
	
	if (!show)
		return;
	show = false;
	
	menuElements[number].firstChild.style.textDecoration = 'none';
	menuElements[number].firstChild.style.color = '#fff';
    //menuElements[number].firstChild.style.color = 'black';
	if (number != active_menu_no) {
	    menuElements[number].firstChild.style.backgroundPosition = '0px 0px';
	}
	elems = document.getElementById('sub_menu');
	elems.style.display = 'none';
}


function register_menus(){
	menus = document.getElementById('main_menu_area');
	obj = menus.firstChild;
	no = 1;
	while (obj.nextSibling != null){
		if (obj.tagName != 'DIV'){
			obj = obj.nextSibling;
			continue;
		}
		obj.onmouseover = new Function('show_menu('+no+')');
		obj.onmouseout  = new Function('hide_menu('+no+')');
		if (no == active_menu_no) {
		    obj.firstChild.style.backgroundPosition = '0px -37px';
		}
		menuElements[no] = obj;
		no++;
		obj = obj.nextSibling;
	}
}



