function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}

addLoadListener(function()
{
	preloading('menu_hover_bg.gif');
});


var myimages = [];
//var loadCount = 0;
function preloading() {
for (i = 0; i < preloading.arguments.length; i++) {
	myimages[i] = new Image();
	myimages[i].src = "/images/"+preloading.arguments[i];
//	myimages[i].onload = new function() {
//		loadCount++;
//		if (loadCount == preloading.arguments.length) {
//			alert(preloading.arguments.length);
//		}
//	};
}
}

function showPopup(option,pObj) {
if (option == 'show') {
//	if (isIE6) {
//		shSelects(option);	
//	}
//	darkenPage();
	
	topOffset = 20;
	op = document.getElementById(pObj);
	op.style.display = 'block';
	screenWidth = f_clientWidth();
	screenHeight = f_clientHeight();
	divWidth = op.offsetWidth;
	divHeight = op.offsetHeight;
	scrollPosTop = f_scrollTop();
	divLeft = parseInt((screenWidth-divWidth)/2);
	divTop = parseInt((screenHeight-divHeight)/2);
	op.style.left = divLeft+'px';
	op.style.top = scrollPosTop+divTop+topOffset+'px';
//	setTimeout(function() {
//		oICp.style.visibility = 'visible';
//		document.icpopform.first_name.focus();
//	}, 250);
	op.style.visibility = 'visible';
//	document.icpopform.first_name.focus();
	
//	popOT = new OpacityTween(oICp,'', 0, 100, .25);
//	popOT.start();
} else {
//	if (isIE6) {
//		shSelects(option);
//	}
//	lightenPage();

	op = document.getElementById(pObj);
//	popOT = new OpacityTween(oICp,'', 100, 0, .25);
//	popOT.onMotionFinished = function() {
		op.style.display = 'none';
		op.style.visibility = 'hidden';
//	}
//	popOT.start();
}
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
