var activeSub=0;
var SubNum=0;

function preloadImages() {
  var d=document; 
	if(d.images){ 
		if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; 
		for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ 
				d.p[j]=new Image; 
				d.p[j++].src=a[i];
			}
	}
}
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; 
	document.sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function swapImgRestore() {
  var i,x,a=document.sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
		x.src=x.oSrc;
}
function findObj(n, d) {
  var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
  if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); 
	return x;
}

function reDo(){ window.location.reload() }

//window.onresize = reDo;


//Define global variables

var timerID = null;
var timerOn = false;
var timecount = 500;
var what = null;
var newbrowser = true;
var check = false;

/*
 *
 */
function init(){
	if (!check) {
		if (document.layers) {
			//  Netscape 4
			layerRef="document.layers";
			styleSwitch="";
			visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";
		}
		else if(document.all){
			//  IE
			layerRef="document.all";
			styleSwitch=".style";
			visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";
		}
		else if(document.getElementById){
			//  Netscape 6
			layerRef="document.getElementByID";
			styleSwitch=".style";
			visibleVar="visible";
			what="moz";
		}
		else{
			// Older than 4.0 browser
			what="none";
			newbrowser = false;
		}
		check = true;
	}
} // init
/*
 *
 */
function showLayer(layerName){
	if(check){
		if (what =="none"){
			return;
		}
		else if (what == "moz"){
			document.getElementById(layerName).style.visibility="visible";
		}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
		}
	}
	else {
		return;
	}
} // showLayer
/*
 *
 */
function hideLayer(layerName){
	if(check){
		if (what =="none"){
			return;
		}
		else if (what == "moz"){
			document.getElementById(layerName).style.visibility="hidden";
		}
		else{
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		}
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
} // hideLayer
/*
 *
 */
function hideAll(){
	hideLayer('company');
	hideLayer('services');
	hideLayer('support');
	hideSubmenus();
} // hideAll
function hideSubmenus() {
	hideLayer('athomenet');
	hideLayer('buscorp');
}
function handleMenuOver(p_m, p_sub) {
	stopTime();
	p_m.style.backgroundColor="#9999cc";
	if (!p_sub) { hideSubmenus(); }
	else if (p_sub == true) {}
	else if (p_sub && p_sub != true) { hideSubmenus(); showLayer(p_sub); }
}
function handleMenuOut(p_m) {
	p_m.style.backgroundColor='#cccce6';
	startTime();	
}
/*
 *
 */
function startTime() {
	if (timerOn == false) {
		timerID=setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
} // startTime
/*
 *
 */
function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
} // stopTime
/*
 *
 */
function onLoad(){
	init();
} // onLoad
function openWizard() {
	var w;
	if (!check) init();
	if (what == "ie") {
		var iW = screen.availWidth;
		var iH = screen.availHeight;
		var wizW = 700, wizH = 550; 
		var leftPos = (iW-wizW)/2, topPos = (iH-wizH)/2; 
		w = window.open("../configurator/configurator.html", "CW", "height=" + wizH + ",width=" + wizW + ",top=" + topPos + ",left=" + leftPos + ",toolbar=no,sizeable=no,scrollbars=no");
	}
	else {
		w = window.open("../configurator/browser.html", "CW", "height=550,width=700,toolbar=no,sizeable=no,scrollbars=no");
	}
	w.focus();
}