// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addToFavorites(){
if (window.external){
window.external.Addfavorite('http://www.ibdg.co.nz/','IBDG : Web Design, Web Hosting, E-Commerce : ')
}
else{
alert('You are using a browser that does not support adding Favorites by script, please add it manually');
  }
}

function td_mouse(td,color){
	if(td.style){
		td.style.backgroundColor = color
	}
}

// -- functions for drop menu

var menu_timer = new Array();
var menu_cell = "";
var highlight = '#BED6EB';
var menu_status = new Array();
var browser;

function browser(){
	if (document.all){
		browser = 'ie'
	}else if (document.getElementById){
		browser = 'moz'
	}else if (document.layers){
		browser = 'ns4'
	}
	return browser
}
browser = browser()

function persistent_highlight(cell){
	close_all_subs()
	if (cell) {
		menu_cell = cell
	}
}
function mouseon(cell,submenu){
	if (browser != 'ns4' && cell){
		cell.style.backgroundColor = highlight;
		cell.style.borderColor = '#666666';
		cell.style.borderWidth = '1px';
		cell.style.paddingLeft = '0';
	}
	if (submenu){
		submenu_on(submenu)
	} else {
		close_all_subs()
	}
}
function mouseout(cell,submenu){
	
	if (browser != 'ns4' && menu_cell != cell && cell){
		cell.style.backgroundColor = ""
		cell.style.borderColor = '';
		cell.style.borderWidth = '0px';
		cell.style.paddingLeft = '1';
	}
	if (submenu){
		submenu_off(submenu)
	}
}
function menu(file_path){
	winpop=window.open(file_path,"ConsoleWindow1","toolbar=no,,width=550,height=447,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
	winpop.focus();
}


function menu_div(div_name){
	
	if (browser == 'ie'){
		construct = document.all[div_name].style;
	}else if (browser == 'moz'){
		construct = document.getElementById(div_name).style
	}else if (browser == 'ns4'){
		construct = document.layers[div_name]
	}
	return construct
}
function subClick(href){
	document.location.href = href
}
function submenu_on(menu){
	menu_status[menu] = 0;
	close_all_subs();
	clear_timer(menu);
	menu_status[menu] = 1;
	if (document.getElementById("hide_me")){
		menu_div("hide_me").visibility = 'hidden';
	}
	menu_div(menu).visibility = 'visible';
  	menu_div(menu+"_bg").visibility = 'visible';
}
function submenu_off(menu){
	set_timer(menu)
}
function close_menu(menu){
		menu_div(menu).visibility = 'hidden';
		menu_div(menu+"_bg").visibility = 'hidden';
		if (document.getElementById("hide_me")){
			menu_div("hide_me").visibility = 'visible';
		}
		menu_status[menu] = 0;
		if (!document.layers && menu_cell) menu_cell.style.backgroundColor = "";
}
function set_timer(menu){
	menu_timer[menu] = setTimeout("close_menu('"+menu+"')",1000)
}
function clear_timer(menu){
	clearTimeout(menu_timer[menu]);
}
function close_all_subs(){
	for (i in menu_status){
		if (menu_status[i] == 1) {
			close_menu(i);
			clear_timer(i);
		}
	}
}