// misc functions

function playSound(baseUrl,soundFile)
{	
	document.body.insertAdjacentHTML("BeforeEnd","<EMBED hidden='true' autostart='true' src='http://" + baseUrl + soundFile + "'>");
}

function addFavourite()
{
	if(!IE)
		return;

	var url =  location.href;
	var title = document.title;

	window.external.AddFavorite(url,title);
}

function openWindow(url, winName, top, left, width, height, scrll)
{
	this.width = arguments.length > 4 ? width : 800;
	this.height = arguments.length > 5 ? height : 340;
	this.scrll = arguments.length > 6 ? scrll : "yes";
	
	return window.open(url,winName,"width="+this.width+",height="+this.height+",location=no,toolbar=no,menubar=no,titlebar=yes,scrollbars="+this.scrll+",resizable=yes,top="+top+",left="+left);
}

function doLinkA(url, w, h)
{
	var width = arguments.length > 1 ? w : 400;
	var height = arguments.length > 2 ? h : 340;
	
	doLink(url, width, height, true);
}

function doLink(url, w, h, bScroll)
{
	var left = screen.availWidth > 800 ? 50 : 0;
	var top = screen.availHeight > 480 ? 50 : 0;
	
	var width = arguments.length > 1 ? w : 400;
	var height = arguments.length > 2 ? h : 400;
	
	var scrll = arguments.length > 3 ? "yes" : "no";
	
	if(IE4 || IE5 || IE5p5 || IE6 || IE7 || NN4 || NN7){
		if(childWin && !childWin.closed){
			childWin.location = url;
			childWin.resizeTo(width, height);
			childWin.focus();
			return;
		}
	}					   
	
	if(IE4 || IE5 || IE5p5 || IE6 || IE7 || NN4 || NN6 || NN7)
		childWin = openWindow(url, "ChildWindow", top, left, width, height, scrll);
		
	else
		window.location.href = url;
}
function killChild()
{
	try
	{
		if(childWin && !childWin.closed)
			childWin.close();
	}
	catch(ex)
	{
	//	Ignore permission denied errs
	}
}
var childWin = null;
window.onfocus = killChild;

function show(id)
{
	var obj = getObjectStyle(id);	
	if(obj){
		obj.visibility = "visible";
		obj.display = "block";
	}
}

function hide(id)
{
	var obj = getObjectStyle(id);
	if(obj){
		obj.visibilty = "hidden";
		obj.display = "none";
	}
}

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 getBodyClientWidth()
{
	if(!isIECompat())
		return null;
		
	return IE6 ? document.documentElement.clientWidth : document.body.clientWidth;
}

function getBodyClientHeight()
{
	if(!isIECompat())
		return null;
		
	return IE6 ? document.documentElement.clientHeight : document.body.clientHeight;
}

function getBodyScrollTop()
{
	if(!isIECompat())
		return null;
		
	return IE6 ? document.documentElement.scrollTop : document.body.scrollTop;
}

function getBodyScrollLeft()
{
	if(!isIECompat())
		return null;

	return IE6 ? document.documentElement.scrollLeft : document.body.scrollLeft;
}

function reveal(imgNum,transNum,duration)
{
	if(!IE)
		return;
		
	this.imgNum = arguments.length > 0 ? imgNum : 0;
	this.transNum = arguments.length > 1 ? transNum : 12;
	this.duration = arguments.length > 2 ? duration : 1;
	
	document.images[this.imgNum].style.filter = "RevealTrans(Duration=" + this.duration + ", Transition=" + this.transNum + ")";
	document.images[this.imgNum].filters[0].Apply();
	document.images[this.imgNum].style.visibility = "visible";
	document.images[this.imgNum].filters[0].Play();
}

function conceal(imgNum,transNum,duration)
{
	if(!IE)
		return;
		
	this.imgNum = arguments.length > 0 ? imgNum : 0;
	this.transNum = arguments.length > 1 ? transNum : 12;
	this.duration = arguments.length > 2 ? duration : 1;
	
	document.images[this.imgNum].style.filter = "RevealTrans(Duration=" + this.duration + ", Transition=" + this.transNum + ")";
	document.images[this.imgNum].filters[0].Apply();
	document.images[this.imgNum].style.visibility = "hidden";
	document.images[this.imgNum].filters[0].Play();
}

function fadeIn(imgNum,duration)
{
	if(!IE)
		return;
		
	this.imgNum = arguments.length > 0 ? imgNum : 0;	
	this.duration = arguments.length > 1 ? duration : 2;
	
	document.images[this.imgNum].style.filter = "BlendTrans(Duration=" + this.duration + ")";
	document.images[this.imgNum].filters[0].Apply();
	document.images[this.imgNum].style.visibility = "visible";
	document.images[this.imgNum].filters[0].Play();
}

function fadeOut(imgNum,duration)
{
	if(!IE)
		return;
		
	this.imgNum = arguments.length > 0 ? imgNum : 0;		
	this.duration = arguments.length > 1 ? duration : 2;
	
	document.images[this.imgNum].style.filter = "BlendTrans(Duration=" + this.duration + ")";
	document.images[this.imgNum].filters[0].Apply();
	document.images[this.imgNum].style.visibility = hidden;
	document.images[this.imgNum].filters[0].Play();
}

function doCode()
{
	var str = "";
	for (var i=0; i < arguments.length; i++)
		str += String.fromCharCode(arguments[i]);

	document.writeln(str);
}

