﻿/*==========================
 * Atomi Ajax Player
 * Author: Le Hong Dang <dangle@atomisystems.com>
 * Company: Atomi Systems Inc.
 * http://www.atomisystems.com
 * Created: 2008/01/20
 * Modified: 2009/12/01
 * Version 2.1
==========================*/

//Important Note: This file MUST be included AFTER the language.js file 

//Declare an array of parameters used to decide the size and position of new browser window when open presentation
var OpenParams = 
[
	{ ViewPort: {width:640, height:480}, CaptionH: 20, ToolbarH: 23, SlideList: { Position: "right", Ratio: 35 } }
	//manually put more param object declarations here if you wish to combine many projects to one html index file
	//NOTE: this is a JSON object
];


//This function will determine the position and size of new browser window and open the presentation in specified mode
//Parameters:
// + mode is a number. Available mode values are: 1 (demo), 2 (tutorial), 4 (practice) and 8 (test)
// + param can be specified directly as JSON object (same as declared in OpenParams' single object) or by index in OpenParams array
function OpenPrez(mode, param)
{
	if (param == undefined) 
	{
		if (OpenParams.length<=0)
		{
			alert("OpenPrez: OpenParams not defined!\nPlease define OpenParams array or pass a specific parameter to this function.");
			return;
		};
		//get the first param as default
		param = OpenParams[0];
	};
	if (typeof param == "number")
		param = OpenParams[param];
	if ((param==undefined) || (param.ViewPort==undefined) || (param.SlideList==undefined))
	{
		alert("OpenPrez: Invalid parameter object!");
		return;
	}
    var w = param.ViewPort.width;
    var h = param.ViewPort.height+Params.CaptionH;
	if ((mode==1)||(mode==2))
	{		
		h += param.ToolbarH;
	}
	var mt=0;
	var ml=parseInt((screen.availWidth-w)/2);
	if (ml<0) ml = 0;
	try
	{
		var strURL = "rlplayer.html?m=" + mode;
		var owin=null;
		if ((w<screen.availWidth) || (h<screen.availHeight))
			owin = window.open(encodeURI(strURL),'_blank','top=' + mt + ',left=' + ml + ',height=' + h + ',width=' + w + ',fullscreen=no,channelmode=no,location=no,toolbar=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes');
		else
			owin = window.open(encodeURI(strURL),'_blank','channelmode=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes');
		if ((owin==undefined)||(owin==null))
		{
			alert(Lang.TurnoffPopupBlocker);
			return;
		}
		owin.focus();
	}
	catch (e)
	{
		alert(Lang.OpenPrezError + e);
	}
	return false;
}


