// redirect non-standard compliant browsers to upgrade page
if( !(document.all||document.getElementById) ) location.href = "/upgrade.html";

// generic image preloader
preload = function()
{
	for( var i=0; i<arguments.length; i++){
		img = new Image();
		img.src = arguments[i];
	}
}
 
// generic image rollover/out functions
var oversuffix = "_over";
var onsuffix = "_on";
rollover = function( img )
{
	if( typeof img == "string" ) img = document.getElementById(img);
	if( !img ) return;
	var src = img.src;
	img.src = src.substring(0,src.length-4) + oversuffix +  src.substring(src.length-4, src.length) 
}
rollout = function( img )
{
	if( typeof img == "string" ) img = document.getElementById(img);
	if( !img) return false;
	var src = img.src;
	if( src.indexOf( oversuffix ) < 0 );
	img.src = src.substring(0,src.indexOf( oversuffix )) + src.substring(src.length-4, src.length);
}

// custom dropdown menu controller
menu = new Object();
menu.current = null;
menu.canceleventprop = false;
menu.open = function( o )
{
	this.close();
	if( !o ) return;
	if( typeof o == "string" ) o = client.getObject( o );
	if( !o ) return;
	
	client.getStyle( o ).visibility = "visible";
	this.current = o;
}
menu.close = function()
{
	if( !menu.current ) return;
	client.getStyle( menu.current ).visibility = "hidden";
	menu.current = null;
}
menu.activaterow = function( row )
{
	row.className = "activerow";
	client.getStyle( row ).cursor = "hand";
}
menu.deactivaterow = function( row )
{
	row.className = "menuitem";
	client.getStyle( row ).cursor = "default";
}
	
document.onclick = function()
{
	if( !menu.canceleventprop){
		menu.close();
	}
}





// pop-up window function
function winXPos() {
	if (screen.width > 800) {
		return ((screen.width - 800) / 2);
	}
	else return (0);
}

function winYPos() {
	if (screen.height > 600) {
		return ((screen.height - 600) / 2);
	}
	else return (0);
}

function openPopup(myUrl,w,h,scroll){
	scroll ? scroll = 'no' : scroll = 'yes';
	aWindow=window.open(myUrl,"ContentPopUpWindow","width="+w+",height="+h+",status=no,resize=no,toolbar=no,scrollbars="+scroll+",menubar=no,left=" + winXPos() + ",top=" + winYPos());
}



// random number generator:
//	returns an integer between 0 and the number supplied
getRandomNumber = function( n ){return Math.floor(Math.random() * (n ? n : 32768) );}
