/*
 * Copyright (c) 1995-2011 by 4system Polska Sp. z o.o.
 * All Rights Reserved. v4
 */
if (typeof(moduleDone)!="undefined") moduleDone("tools.js");

var oPlayer = null;
var oLMS = null;
var oUELO = null;
var oSW = null;
var oPage = null;
var oStruct = null;
var oSuspendData = null;
var oLang = null;	
var framesTable = new Array();

/* Search */
function checkFrame(f)
{
	for (var i in framesTable) {
		if (framesTable[i] === f) return true;
	}
	return false;
}

function storeFrame(f)
{
	framesTable[framesTable.length] = f;	
}

function findObject(win, m)
{
	// try {
		// if (!(win instanceof Window)) return null;
	// } catch(e) {
		// return null;
	// };

	try {
		if (win.extContent) return null;
		if (win[m] != null) return win[m];
	} catch(e) {};

	if (checkFrame(win)) return null;
	storeFrame(win);		
	
	if (win != null) {
		var i = 0;
		while (typeof(win.frames[i]) !== "undefined") {
			var o = findObject(win.frames[i], m);
			if (o != null) return o;
			i++;
		}
	}
	
	return null;
};

function findObjectUp(w, m)
{
	var obj = w;
	while (obj != null && !checkFrame(obj)) {
		try {
			var o = findObject(obj, m);
			if (o != null) return o;
		} catch(e) {};		
		obj = obj.parent;
	}

	if (w != null && !checkFrame(w.opener)) {
		return findObjectUp(w.opener, m);
	}
	
	return null;
};

function getObject(m)
{
	return findObjectUp(window, m);
};

function getPlayer()
{
	framesTable = new Array();
	if (oPlayer == null) oPlayer = getObject("player");
	return oPlayer;
};

function getLMS()
{
	framesTable = new Array();
	if (oLMS == null) oLMS = getObject("lms");
	return oLMS;
};
function getUELO()
{
	framesTable = new Array();
	if (oUELO == null) oUELO = getObject("uelo");
	return oUELO;
};
function getSW()
{
	framesTable = new Array();
	if (oSW == null) oSW = getObject("sw");
	return oSW;
};
function getPage()
{
	framesTable = new Array();
	if (oPage == null) oPage = getObject("page");
	return oPage;
};
function getStruct()
{
	framesTable = new Array();
	if (oStruct == null) oStruct = getObject("struct");
	return oStruct;
}
function getSuspendData()
{
	framesTable = new Array();
	if (oSuspendData == null) oSuspendData = getObject("suspendData");
	return oSuspendData;
};
function getLang()
{
	framesTable = new Array();
	if (oLang == null) oLang = getObject("lang");	
	return oLang;
}

function findWBTServerTop(win) {
	try {
		if (typeof(win.isWBTServer) != "undefined" && win.isWBTServer != null) return win;
	} catch(e) {};
	if (win.length > 0) {
		for(var i = 0; i < win.length; i++) {
			var theWBTServerTop = findWBTServerTop(win.frames[i]);
			if (theWBTServerTop != null) return theWBTServerTop;
		}
	}
	return null;
}
function getWBTServerTop()
{
	var theWBTServerTop = findWBTServerTop(parent);
	if (theWBTServerTop == null) theWBTServerTop = findWBTServerTop(top);
	if (theWBTServerTop == null) {
		if (typeof(opener) != "undefined") {
			if (opener != null) theWBTServerTop = findWBTServerTop(opener.top);
		}
	}
	return theWBTServerTop;
}
function findFrame(name, frame)
{
	var oldFrameName = null;
	if (name == "navigation") {
		oldFrameName = "header";
	}

	if (typeof(frame) == "undefined") {
		frame = frames;
	}
	for (var i = 0; i < frame.length; i++) {
		if (frame[i].name == name || (oldFrameName && frame[i].name == oldFrameName)) {
			return frame[i];
		} else {
			var result = findFrame(name, frame[i]);
			if (result) return(result);
		}
	}
	return(null);
};
function findHTMLObjInFrame(name, frame) 
{
	if (typeof(frame) == "undefined") {
		frame = frames;
	};
	var htmlObj = frame.document.getElementById(name);
	if (htmlObj) return htmlObj;
	for (var i = 0; i < frame.length; i++) {
		var result = this.findHTMLObjInFrame(name, frame[i]);
		if (result) return result;
	}
	return null;
}
/* Array */
function fnArrayPop()
{
	var response = this[this.length - 1];
	this.length--;
	return response;
};

if (typeof(Array.prototype.pop) == "undefined") {
	Array.prototype.pop = fnArrayPop;
}

function fnArrayPush()
{
	for (var A_p=0; A_p<arguments.length; A_p++) {
		this[this.length] = arguments[A_p];
	}
	return this.length;
};

if (typeof Array.prototype.push == "undefined") {
	Array.prototype.push = fnArrayPush;
}

function fnArraySplice(index, delTotal)
{
	var temp = new Array();
	var response = new Array();

	var A_s = 0;
	for (A_s = 0; A_s < index; A_s++) {
		temp[temp.length] = this[A_s];
	}
	for (A_s = 2; A_s < arguments.length; A_s++) {
		temp[temp.length] = arguments[A_s];
	}
	for (A_s = index + delTotal; A_s < this.length; A_s++) {
		temp[temp.length] = this[A_s];
	}
	for (A_s = 0; A_s < delTotal; A_s++) {
		response[A_s] = this[index + A_s];
	}
	this.length = 0;
	for (A_s = 0; A_s < temp.length; A_s++) {
		this[this.length] = temp[A_s];
	}
	return response;
};

if (typeof Array.prototype.splice == "undefined") {
	Array.prototype.splice = fnArraySplice;
}

function inArray(value, searchArray)
{
	for (var i = 0; i < searchArray.length; i++) {
		if (value == searchArray[i]) return true;
	}
	return false;
};

/* String */
function quotedString(value)
{
	var new_value = value;
	new_value = new_value.replace(/"/g, "&quot;");
	new_value = new_value.replace(/'/g, "&#146;");
	return new_value;
};

function unquotedString(value)
{
	var new_value = value;
	new_value = new_value.replace(/&quot;/g, '"');
	new_value = new_value.replace(/#&034/g, '"');
	new_value = new_value.replace(/&#146;/g, "'");
	return new_value;
}; 
 
function trim(str)
{
   if (typeof(str) != "undefined") {
		return str.replace(/^\s*|\s*$/g, "");
	} else {
		return "";
	}
};

function binIntoDec(bin)
{
	return parseInt(bin, 10);
}

function decIntoBin(dec)
{
	if (isNaN(dec)) return "";
	var bin = "";
	while (dec != 0){
		bin += dec % 2;
		dec = Math.floor(dec / 2);	
	}
	return bin;
};

function formatString(value, keywords)
{
	var result = value;
	for (var i = 1; i < arguments.length; i++) {
		if (result.indexOf("%s") > -1) {
			result = result.replace("%s", arguments[i]);
		} else break;
	}
	return result;
};

/* NN4 Tools */
function getFormNS4(name, obj)
{
	for (var i = 0; i < obj.forms.length; i++) {
		if (obj.forms[i].name == name) return obj.forms[i];
	}
	for (var i = 0; i < obj.layers.length; i++) {
		var res = getFormNS4(name, obj.layers[i].document);
		if (res) return res;
	}
	return null;
};

function getObjNS4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
  
	for (var i = 0; i < x.length; i++) {
		if (x[i].id == name) foundLayer = x[i]; else 
		if (x[i].layers.length) var tmp = getObjNS4(x[i], name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
};

function getForm(name)
{
	if (is.ns4) {
		return getFormNS4(name, document);
	} else {
		return document.forms[name];
	}
};

/* Date & Time Class */
Date.prototype.getFotmatedTime = function()
{
	var hours = this.getHours();
	hours = ((hours < 10) ? "0" : "") + hours;
	var minutes = this.getMinutes();
	minutes = ((minutes < 10) ? "0" : "") + minutes;
	var seconds = this.getSeconds();
	seconds = ((seconds < 10) ? "0" : "") + seconds;
	return hours + ":" + minutes + ":" + seconds;
};
Date.prototype.subtractTimeToString = function(dateStart)
{
  if (typeof(dateStart) == "undefined" || dateStart == null) dateStart = new Date(); //pg2-exceptions in offline- page status = F or P, and check answer (via some image, etc)
  var dd = Math.abs(this.getTime() - dateStart.getTime());
  var ts = Math.floor( ( ( (dd % (60 * 60 * 1000 * 24) ) % (60 * 60 * 1000) ) % ( 60 * 1000 ) ) / 1000 * 1);
  var tm = Math.floor( (dd % (60 * 60 * 1000 * 24)) % ((60 * 60 * 1000)) / (60 * 1000));
  var th = Math.floor( (dd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000));

  var sh = ((th < 10) ? "0" : "") + th;
  var sm = ((tm < 10) ? "0" : "") + tm;
  var ss = ((ts < 10) ? "0" : "") + ts;

  return ("" + sh + ":" + sm + ":" + ss);
};
Date.prototype.getMilisecondsBetweenDates = function(dateStart, dateEnd)
{
  if (typeof(dateStart) == "undefined" || dateStart == null) dateStart = new Date(); //pg2
  if (typeof(dateEnd) == "undefined" || dateEnd == null) dateEnd = new Date(); //pg2
  var miliseconds = Math.abs(dateStart.getTime() - dateEnd.getTime());

  return miliseconds;
};
function convertStringTimeToInt(stringDate)
{
	var timeArr = stringDate.split(":");
	
	var h = parseInt(timeArr[0], 10)*60*60;
	var m = parseInt(timeArr[1], 10)*60;
	var s = parseInt(timeArr[2], 10);
	var ms = parseInt(timeArr[3], 10);
	
	return h+m+s+ms/1000;
};
function calculateTimeIntToString(timeInt)
{
	var sh = parseInt(timeInt/(60*60));
	var timeLeft = timeInt - sh*60*60;
	var sm = parseInt(timeLeft/60);
	timeLeft = timeLeft - sm*60;
	var ss = timeLeft;	
	
	return "" + sh + ":" + sm + ":" + ss;
}
function calculateTimeToString(dateStart, dateEnd)
{
	if (typeof(dateStart) == "undefined" || dateStart == null) dateStart = new Date(); //pg2
	if (typeof(dateEnd) == "undefined" || dateEnd == null) dateEnd = new Date();
	
	var dtm = Math.abs(dateEnd.getTime() - dateStart.getTime());
	
	var th = Math.floor((dtm % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000));
	var tm = Math.floor((dtm % (60 * 60 * 1000 * 24)) % ((60 * 60 * 1000)) / (60 * 1000));
	var ts = Math.floor((((dtm % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);
	
	var sh = ((th < 10) ? "0" : "") + th;
	var sm = ((tm < 10) ? "0" : "") + tm;
	var ss = ((ts < 10) ? "0" : "") + ts;
	
	return "" + sh + ":" + sm + ":" + ss;
};

function formatTime(format, date, dateSep)
{
	if (typeof(format) == "undefined") format = "time";
	if (typeof(date) == "undefined") date = new Date();
	if (typeof(dateSep) == "undefined") dateSep = "-";
	var timeSep = ":";
	
	var dy = date.getFullYear();
	var dm = date.getMonth() + 1;
	dm = ((dm < 10) ? "0" : "") + dm;
	var dd = date.getDate();
	dd = ((dd < 10) ? "0" : "") + dd;
	var th = date.getHours();
	th = ((th < 10) ? "0" : "") + th;
	var tm = date.getMinutes();
	tm = ((tm < 10) ? "0" : "") + tm;
	var ts = date.getSeconds();
	ts = ((ts < 10) ? "0" : "") + ts;
	
	var result = "";
	switch (format) {
		case "time": //HH:MM:SS								03:00:00
			result = th + timeSep + tm + timeSep + ts;
			break;
		case "date": //YYYY-MM-DD								2003-07-25
			result = dy + dateSep + dm + dateSep + dd;
			break;
		case "datetime": //YYYY-MM-DD HH:MM:SS					2003-07-25 03:00:00
			result = dy + dateSep + dm + dateSep + dd
				+ " " + th + timeSep + tm + timeSep + ts;
			break;
		case "timestamp": //YYYY[-MM[-DD[Thh[:mm[:ss[.s[TZD]]]]]]]		2003-07-25T03:00:00
			result = dy + dateSep + dm + dateSep + dd
				+ "T" + th + timeSep + tm + timeSep + ts;
			break;
		case "timeinterval": //PT[yY][mM][dD][T[hH][mM][s[.s]S]]		PT1Y3M2DT3H
			var ti_th = parseInt(th, 10);
			var ti_tm = parseInt(tm, 10);
			var ti_ts = parseInt(ts, 10);
			
			result = "PT";
			result += (ti_th > 0) ? ti_th + "H" : "";
			result += (ti_tm > 0) ? ti_tm + "M" : "";
			result += ti_ts + "S";
			break;
	}
	
	return result;
};

function stringToDate(s)
{
	if (typeof(s) == "undefined" || s == "") return new Date();
	var r = new RegExp("(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})");
	var a = s.match(r);
	
	//pg2-fixed convertion from string to date
	var resDate = new Date();
	if (a.length == 7) {
		var param2 = a[2];
		if (param2.indexOf('0') == 0) {
			param2.substring(1,2);
		}
		var param1 = parseInt(param2, 10) - 1;
		resDate = new Date(a[1], param1, a[3], a[4], a[5], a[6]);
	}
	
	return resDate;
};

function addVersionControl(millis) 
{
	date = new Date();
	var curDate = null;
	
	do {
		var curDate = new Date();
	} while(curDate - date < millis);
};

/* Cookie Class */
function Cookie()
{
	this.get = function (nameOfCookie, doc)
	{
		if (typeof(doc) == "undefined") doc = top.window.document;
		
		if (doc.cookie.length > 0) { 
			var begin = -1;
			var code = '';
			code += (is.ns4) ? '' : 'try {';
			code += 'begin = doc.cookie.indexOf("' + nameOfCookie + '=");';
			code += (is.ns4) ? '' : '} catch(e) {}';
			eval(code);
			if (begin != -1) { 
				begin += nameOfCookie.length+1; 
				var end = doc.cookie.indexOf(";", begin);
				if (end == -1) end = doc.cookie.length;
				return unescape(doc.cookie.substring(begin, end));
			} 
		}
		return null; 
	} 

	this.set = function (nameOfCookie, value, expiredays, doc) 
	{
		if (typeof(doc) == "undefined") doc = top.window.document;
		
		if (typeof(expiredays) == "undefined") expiredays = 10;

		var ExpireDate = new Date ();
		ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
		var code = '';
		code += (is.ns4) ? '' : 'try {';
		code += 'doc.cookie = "' + nameOfCookie + '=' + escape(value) + ((expiredays == null) ? '' : '; expires=' + ExpireDate.toGMTString()) + '"';
		code += (is.ns4) ? '' : '} catch(e) {}';
		eval(code);
	}

	this.remove = function (nameOfCookie, doc)
	{
		if (typeof(doc) == "undefined") doc = document;

		if (this.get(nameOfCookie)) {
			var code = '';
			code += (is.ns4) ? '' : 'try {';
			code += 'doc.cookie = "' + nameOfCookie + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT"';
			code += (is.ns4) ? '' : '} catch(e) {}';
			eval(code);
		}
	} 
};

cookie = new Cookie();

/* URL */
function getCommandUrl(name, def)
{
	try {
		name = name.toLowerCase();
		var arr = location.search.slice(1).split('&');
		for (var i = 0; i < arr.length; i++) {
			var keyName = arr[i].slice(0, arr[i].indexOf('=')).toLowerCase();
			if (keyName == name) {
				return arr[i].slice(arr[i].indexOf('=') + 1);
			}
		}
	} catch(e) {
		if (log) log.error(e + " : getTopCommandUrl name=" + name + "");
	}
	if (typeof(def) == "undefined") return null
	else return def;
};

function getTopCommandUrl(name)
{
	return getCommandUrl(name);
};

/* Fonts */
function isDefaultFont(font)
{
	var result = true;
	if (font.family != 'Arial') {
		result = false;
	} else 
	if (font.size != 2) {
		result = false;
	} else 
	if (font.color.replace(/#/g, "") != '000000') {
		result = false;
	}
	return result;
};

function getFontSize(value, format)
{
	var fontSizesPX = new Array(0,10,13,16,18,24,32,48);
	var fontSizesPT = new Array(0, 8,10,12,14,18,24,36);
	var pxSize = fontSizesPT[parseInt(value)];
	if (format == "px") {
		pxSize = fontSizesPX[parseInt(value)];
	}
	if (typeof(pxSize) == "undefined") pxSize = value;	
	return pxSize;
};

function getProjectFont(fontGlobalFormating, family, size, color)
{
	var font = {};
	font.family = family;
	font.size = size;
	font.color = color;
	
	if (fontGlobalFormating && project.globalFormating)
	{
		font.family = project.font.family;
		font.size = project.font.size;
		font.color = project.font.color;
	};
	
	return font;
};

function sameFonts(font1, font2)
{
	var result = true;
	if (font1.family != font2.family) {
		result = false;
	} else 
	if (font1.size != font2.size) {
		result = false;
	} else 
	if (font1.color.replace(/#/g, "") != font2.color.replace(/#/g, "")) {
		result = false;
	}
	return result;
};

function checkFont(font)
{
	var result = true;
	if (typeof(font) != "object") {
		result = false;
	} else 
	if (!font.family || font.family == '') {
		result = false;
	} else 
	if (!font.size || font.size == '' || isNaN(font.size)) {
		result = false;
	} else 
	if (!font.color || font.color.replace(/#/g, "") == '') {
		result = false;
	}
	return result;
};

function Font()
{
	this.family = "Arial";
	this.size = "2";
	this.color = "#000000";
};

/* other */
function showConfiguration(isNew, x, y, w, h)
{
	var url = "ds_configuration.html";
	if (isNew) url = "configuration.html";
	
	if (w == null) w = 600;
	if (h == null) h = 280;
	
	var opt = "";
	opt += (x != null) ? ', left=' + x : ', left=' + ((screen.availWidth - w) / 2);
	opt += (y != null) ? ', top=' + y : ', top=' + ((screen.availHeight - h) / 2);
	opt += ', width=' + w;
	opt += ', height=' + h;
	
	window.open(url, "", opt);
	
	return false;
};

function getURIParam(name)
{
	var r = "";
	name = name.toLowerCase();
	var paramsList = location.search.slice(1).split('&');
	for (var i = 0; i < paramsList.length; i++)
	{
		keyName = paramsList[i].slice(0, paramsList[i].indexOf('=')).toLowerCase();
		if (keyName == name) {
			r = paramsList[i].slice(paramsList[i].indexOf('=') + 1);
			break;
		}
	}
	return r;
};

function preloadImage(obj, id)
{
	var isLoaded = false;
	
	if (obj.paintLocked || obj.isLoaded 
		|| typeof(obj.preloadImages) == "undefined" || obj.preloadImages == null
		|| typeof(obj.preloadImages["src" + id]) == "undefined" || obj.preloadImages["src" + id] == null) return true;
	
    if (obj.preloadImages["src" + id] == "" || obj.preloadImages["src" + id] == "empty"
			|| page.state == psDesigning || page.state == psPreview) {
		isLoaded = true;
    } else {
		if (obj.preloadImages["pim" + id] == null) {
			obj.preloadImages["pim" + id] = new Image();
			obj.preloadImages["pim" + id].src = obj.preloadImages["src" + id];
		}
		
        if (typeof(obj.preloadImages["pim" + id].complete) == "undefined"){
			isLoaded = true;
        } else {
            if (obj.preloadImages["pim" + id].complete) {
				isLoaded = true;
			} else {
				do {
					if (obj.preloadImages["pim" + id].complete) return true;
					++obj.preloadImages["wtc" + id];
				} while (obj.preloadImages["wtc" + id] < 50 && !obj.preloadImages["pim" + id].complete)
			};
		};
	};
	return isLoaded;
};

function getImageSize(imgName)
{
	var img = new Image();
	if (PageInterface.GetValue("state") == psDesigning) {
		img.src = PageInterface.GetValue("resourcesURL") + imgName;
	} else {
		img.src = PlayerInterface.GetValue("resourcesURL") + imgName;
	}
	if (isImageLoaded(img) || (!isNaN(img.width) && !isNaN(img.height))) {
		//var size = new Array(img.width, img.height);
		var size = new Array();
		size[0] = img.width;
		size[1] = img.height;
		img = null;
		return size;
	} else {
		img = null;
		return getImageSize(imgName);
	}
};

function getImageHeight(imgName)
{
	var img = new Image();
	if (PageInterface.GetValue("state") == psDesigning || !page.allowCommunication()) {
		img.src = PageInterface.GetValue("resourcesURL") + imgName;
	} else {
		img.src = PlayerInterface.GetValue("resourcesURL") + imgName;
	}
	if (isImageLoaded(img) || !isNaN(img.height)) {
		var height = img.height;
		img = null;
		return height;
	} else {
		img = null;
		return getImageHeight(imgName);	
	};
}; 

function getImageWidth(imgName)
{
	var img = new Image();
	if (PageInterface.GetValue("state") == psDesigning || !page.allowCommunication()) {
		img.src = PageInterface.GetValue("resourcesURL") + imgName;
	} else {
		img.src = PlayerInterface.GetValue("resourcesURL") + imgName;
	}
	
	if (isImageLoaded(img) || !isNaN(img.width)) {
		var width = img.width;
		img = null;
		return width;
	} else {
		img = null;
		return getImageWidth(imgName);	
	};
};

function isImageLoaded(imgObj)
{
	var isLoaded = false;
	var counter = 0;
	if (imgObj.complete) {
		isLoaded = true;
	} else {
		if (typeof(imgObj.complete) == "undefined") {
			isLoaded = true;
		}
	};		
	return isLoaded;
};

function clone(obj)
{
	for (o in obj) {
        if (typeof obj[o] == 'object') {
            this[o] = new clone(obj[o]);
        } else {
            this[o] = obj[o];
		}
    }
};

function getAttributeText(obj, name)
{
	var result = "";
	for (var i=0; i<obj.attributes.length; i++) {
		if (obj.attributes[i].specified && (obj.attributes[i].nodeName.toLowerCase() == name.toLowerCase())) {
			result += ' ' + obj.attributes[i].nodeName + '="' + obj.attributes[i].nodeValue + '" ';
		}
	}
	
	return result;
};

function clearHTMLTags(inHTML) { 
	var regEx = '';
	var outText = '';
	regEx = /<[^>]*>/g;
	outText = inHTML.replace(regEx, "");	
	regEx = /&nbsp;/g;	
	outText = outText.replace(regEx, "");	
	return outText;
};

function checkExportType(exportType, checkType)
{
	exportType = exportType.toLowerCase();
	switch (checkType) {
		case "single":
			return ((exportType == "wbtserver_singlesco") || (exportType == "offline") ||
			(exportType == "exe") || (exportType == "exe_cbt") || (exportType == "poll") || 
			(exportType == "exe_cbtlight") || (exportType == "scorm12_singlesco") ||
			(exportType == "scorm2004_singlesco") || (exportType == "aicc_singlesco") ||
			(exportType == "aicc_multisinglesco") || (exportType == "oracle_singlesco") ||
			(exportType == "moodle_singlesco") || (exportType == "aicc_singlesco") ||
			(exportType == "scorm2004_singlesco") || (exportType == "aicc_singlesco"));
		case "multi":
			return ((exportType == "wbtserver_multisco") || (exportType == "exam") ||
			(exportType == "encyclopedia") || (exportType == "oracle_multisco") ||
			(exportType == "scorm12_multisco") || (exportType == "scorm2004_multisco") ||
			(exportType == "aicc_multisco") || (exportType == "moodle_multisco"));
		case "singleMulti":
			return ((exportType == "wbtserver_multisinglesco") || (exportType == "scorm12_multisinglesco") ||
			(exportType == "scorm2004_multisinglesco") || (exportType == "oracle_multisinglesco") ||
			(exportType == "moodle_multisinglesco"));
	};
}

function showMessage(message)
{
	if (arguments[1]){
		prompt(message, arguments[1]);
	} else {
		alert(message);
	}
}

function displayHTMLElement(obj, value)
{
	if (obj.style)	obj.style.display = value;
}

function convertStatusToName(shortStatus)
{
	switch (shortStatus.toUpperCase()){
		case "C" : 
				return 'completed'; 
			break;
		case "f" : 
				return 'failed'; 
			break;
		case "I" : 
				return 'incomplete'; 
			break;
		case "N" : 
				return 'not attempted'; 
			break;
		case "P" : 
				return 'passed'; 
			break;
		default : 
				return shortStatus.toUpperCase(); 
			break;			
	};	
}

function convertStatusToLetter(longStatus)
{
	switch (longStatus){
		case "browsed" : 
				return 'N'; 
			break;
		case "completed" : 
				return 'C'; 
			break;
		case "failed" : 
				return 'F'; 
			break;
		case "incomplete" : 
				return 'I'; 
			break;
		case "not attempted" : 
				return 'N'; 
			break;
		case "passed" : 
				return 'P'; 
			break;
		case "unknown" : 
				return 'N'; 
			break;
		default : 
				return longStatus; 
			break;
	};	
}

function setWindowTitle(title)
{
	try {
		top.window.document.title = title;
	} catch(e) {};
}

function Size(x, y, w, h)
{
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
}

function getElementSize(o)
{
    var s = new Size(o.offsetLeft, o.offsetTop, o.offsetWidth, o.offsetHeight);
    while (o.offsetParent && o.offsetParent.offsetLeft !== undefined)
    {
        o = o.offsetParent;
		if (o.style.position == "absolute"){break}
        s.x += o.offsetLeft;
        s.y += o.offsetTop;
    }
    return s;
}
