// open link in a new window
function links_openWindow(obj, bNewWindow, nTop, nLeft, nWidth, nHeight, bToolbar, bScrollbar, bResizeable, strSrc, bAutoStart, bShowControls, nPlayerWidth, nPlayerHeight)
{
	// if not need to open  the link in a new window exit from the function and do the href action
	if (bNewWindow == "False")
	{
		return;
	}

	// open the link in a new window
	if (strSrc != "")
	{
		// open window with media player
		var re = new RegExp("&", "ig");
		strSrc = strSrc.replace(re, "*");
		window.open(obj.href + "?src=" + strSrc + "&autoStart=" + bAutoStart + "&showControls=" + bShowControls + "&width=" + nPlayerWidth + "&height=" + nPlayerHeight, 'links_openWindow', 'top=' + nTop + ',left=' + nLeft + ',width=' + nWidth + ',height=' + nHeight + ',status=yes,toolbar=' + (bToolbar=='True'?'yes':'no') + ',scrollbars=' + (bScrollbar=='True'?'yes':'no') + ',resizable=' + (bResizeable=='True'?'yes':'no'));
		//window.open(PLAYER_URL + "?src=" + strSrc + "&autoStart=" + bAutoStart + "&showControls=" + bShowControls + "&width=" + nPlayerWidth + "&height=" + nPlayerHeight, 'links_openWindow', 'top=' + nTop + ',left=' + nLeft + ',width=' + nWidth + ',height=' + nHeight + ',status=yes,toolbar=' + (bToolbar=='True'?'yes':'no') + ',scrollbars=' + (bScrollbar=='True'?'yes':'no') + ',resizable=' + (bResizeable=='True'?'yes':'no'));
	}
	else
	{	
		// open window with simple link
		window.open(obj.href, 'links_openWindow', 'top=' + nTop + ',left=' + nLeft + ',width=' + nWidth + ',height=' + nHeight + ',toolbar=' + (bToolbar=='True'?'yes':'no') + ',scrollbars=' + (bScrollbar=='True'?'yes':'no') + ',status=yes,resizable=' + (bResizeable=='True'?'yes':'no'));
	}

	// cancle the href action
	event.returnValue = false;
}



///////////////////
// media player
///////////////////

var bPlay = false;
var bPause = false;
var bStop = false;
var bMute = false;

// that fucntion will happen when the media player window will load
function player_init()
{
	// get parameter for automatic start from the querystring
	var bAutoStart = player_getParam("autoStart").toLowerCase();
	
	if (bAutoStart != "false")
	{ 
		// show on image for the play
		setTimeout("bPlay = true;", 1200);
	}	
	else
	{
		// show on image for the stop
		setTimeout("bStop = true;", 1200);
		
		// show disable image for the pause
		setTimeout("bPause = true;", 1200);
	}
}

// that fucntion will happen when the media player movie will be ended
function player_endOfStream(e)
{	
	player_clickStop(document.all.imgStop);
}





// get parameter value from the querystring
function player_getParam(strParam)
{
	var url = document.URL.split('?');
	
	if (url.length != 2)
	{
		return "";
	}

	var params = url[1].split('&');

	for (var i=0 ; i<params.length ; i++)
	{
		var param = params[i].split('=');

        if (param.length != 2)
        {
			return "";
		}

		if (param[0].toLowerCase() == strParam.toLowerCase())
		{
			return param[1];
		}
	}

	return "";
}