// JavaScript Document

function getObjectStyle(id)
{		
	if(typeof id != "string")
		return id;
		
	var obj = getObject(id);
	
	if(NN4)
		return obj;
		
	return obj ? obj.style : null;
}

function getObject(id)
{
	if(typeof id != "string")
		return id;
		
	if(document.getElementById)
		return document.getElementById(id);
		
	if(NN4)
		return document[id];
		
	if(document.all)
		return document.all[id];

	return null;
}

function getRandTran()
{
//	Returns a random reveal transition from a preferred subset of available transitions
	var pref = new Array(0,1,2,3,4,5,6,7,13,14,15,16,17,18,19,20);	
	var rand = getRand(pref.length);
	return pref[rand];
}

function getRand(num)
{
//	returns random num such that 0 <= val < num

	return Math.max(0, Math.round(Math.random() * num) - 1);
}

function revealObj(id,tranNo)
{
	if(isIECompat()){
		var obj = getObject(id);
		if(obj){
			var nTran = arguments.length > 1 ? tranNo : getRandTran();			
			obj.style.filter = "RevealTrans(Duration=2, Transition=" + nTran + ")";			
			obj.filters[0].Apply();
			obj.filters[0].Play();			
		}
	}

	getObjectStyle(id).visibility = "visible";
}

function openWindow(url,winName,top,left,width,height,sbars)
{
	this.width = arguments.length > 4 ? width : 800;
	this.height = arguments.length > 5 ? height : 480;
	this.sbars = arguments.length > 6 ? sbars : "no";
	
	return window.open(url,winName,"width="+this.width+",height="+this.height+",location=no,toolbar=no,menubar=no,titlebar=no,scrollbars="+this.sbars+",resizable=no,top="+top+",left="+left);
}

function closeWindow()
{
	if(IE)
		window.close();
	
	else if(opener || confirm("Are you sure you want to close the current window?"))
	   window.close();
}

function doLink(url,w,h,sbars)
{
	if(IE4 || IE5 || IE5p5 || IE6 || NN4 || NN7){
		if(childWin && !childWin.closed){
			childWin.location = url;
			childWin.focus();
			return;
		}
	}					   
			
	this.w = arguments.length > 1 ? w : 580;
	this.h = arguments.length > 2 ? h : 410;
	this.sbars = arguments.length > 3 ? sbars : "no";
	
	var left = screen.availWidth > 800 ? 50 : 0;
	var top = screen.availHeight > 480 ? 50 : 0;
	
	if(IE4 || IE5 || IE5p5 || IE6 || NN4 || NN6 || NN7)
		childWin = openWindow(url,"ChildWindow",top,left,this.w,this.h,this.sbars);
		
	else
		window.location.href = url;
}
var childWin = null;