
function subWindow(url ,w, h, name)
{
	subWindowR(url ,w, h, name);
}

function subWindowR(url ,w, h, name)
{
	if (name == undefined)
	{
		name = "subwindow";
	}
	var subWin = window.open(
				url, 
				name,
				'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 
	subWin.focus();
	
	return subWin;
}

function subWindowScroll(url ,w, h, name)
{
	subWindowScrollR(url ,w, h, name);
}

function subWindowScrollR(url ,w, h, name)
{
	if (name == undefined)
	{
		name = "subwindow";
	}
	var subWin = window.open(
				url, 
				name,
				'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 
	subWin.focus();
	
	return subWin;
}


function playMedia(t, w, h)
{
	playMediaR(t, w, h);
}

function playMediaR(t, w, h)
{
	var UPDOWN_MARGIN = 75;
	var SIDE_MARGIN = 50;
	
	var winWidth = w + SIDE_MARGIN * 2;
	var winHeight = h + UPDOWN_MARGIN * 2;
	
	var playerUrl = "/media/wmPlayer.cgi?t=" + t  + "&w=" + w + "&h=" + h;
	var subWin = subWindowR(playerUrl ,winWidth, winHeight, 'Player')
	
	return subWin;
}

function playFlashMedia(t, w, h)
{
	playFlashMediaR(t, w, h);
}

function playFlashMediaR(t, w, h)
{
	var UPDOWN_MARGIN = 50;
	var SIDE_MARGIN = 50;
	
	var winWidth = w + SIDE_MARGIN * 2;
	var winHeight = h + UPDOWN_MARGIN * 2;
	
	var playerUrl = "/media/flvPlayer.cgi?t=" + t  + "&w=" + w + "&h=" + h;
	var subWin = subWindowR(playerUrl ,winWidth, winHeight, 'Player')
	
	return subWin;
}

// how to use : preLoadImages(["/images/XXX.gif", "/images/YYYY.jpg", "images/ZZZZ.png"]);
function preLoadImages(files)
{
	if (!isArray(files))
	{
		return;
	}
	
	var images = new Array();
	for(i = 0;i < files.length; i++)
	{
		images[i] = new Image();
		images[i].src = files[i];
	}
}

function swapImage(id, image)
{
	if (document.images[id] != null)
	{
		document.images[id].src = image;
	}
}

function resizeParent()
{
	if ((window.parent == null) || 
		(window.name == ''))
	{
		return;
	}
	
	if ((window.name != 'div_right') && 
		(window.name != 'div_left'))
	{
		return;
	}
	var self = window.parent.document.getElementById(window.name);
	if (self == null)
	{
		return;
	}
	self.height = document.body.scrollHeight;
//	alert("self.name = " + self.name + ", height = " + self.height + ", width = " + document.body.scrollWidth);
}

function isArray(obj)
{ 
    return ((typeof obj == "object") && (obj.constructor == Array));
}
