﻿/* * Copyright ן¿½ 1995-2005 by 4system Polska Sp. z o.o. * All Rights Reserved. v4 */if (typeof(moduleDone)!="undefined") moduleDone("tools.js");var framesTable = new Array();/* Search */function findPlayer(win){		if (win.extContent) return null;	// Search the window hierarchy for an object named "player"	// Look in the current window (win) and recursively look in any child frames	if (win.player != null) return win.player;	//protect from infinity looping	if (framesTable[win.location]) return null;	framesTable[win.location] = true;		if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var thePlayer = findPlayer(win.frames[i]);			if (thePlayer != null) return thePlayer;		}		var winParent = win.parent;				if(winParent.name == win.name) return null;				if (winParent != null) {			var thePlayer = findPlayer(winParent);			if (thePlayer != null) return thePlayer;		}	}	return null;};function getPlayer(){	// start at the topmost window - findPlayer will recurse down through	// all of the child frames	var obj = window.parent;	while (obj) {		if (obj.player) return obj.player;		if (obj == window.top) break;		obj = obj.parent;	}		var thePlayer = findPlayer(parent);	// the Player wasn't found in the current window's hierarchy.  If the	// current window has an opener (was launched by another window),	// check the opener's window hierarchy.	if (thePlayer == null) {		if (typeof(opener) != "undefined") {			if (opener != null) thePlayer = findPlayer(opener.top);		}	}	//clear array to next search	framesTable = new Array();	return thePlayer;};function findLMS(win){	if (win.extContent) return null;	// Search the window hierarchy for an object named "lms"	// Look in the current window (win) and recursively look in any child frames	if (win.lms != null) return win.lms;	if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var theLMS = findLMS(win.frames[i]);			if (theLMS != null) return theLMS;		}	}	return null;};function getLMS(){	// start at the topmost window - findLMS will recurse down through	// all of the child frames	if (window.lms != null) return window.lms;		var theLMS = findLMS(parent);	if (theLMS == null) theLMS = findLMS(top);	// the LMS wasn't found in the current window's hierarchy.  If the	// current window has an opener (was launched by another window),	// check the opener's window hierarchy.	if (theLMS == null) {		if (typeof(opener) != "undefined") {			if (opener != null) theLMS = findLMS(opener.top);		}	}	return theLMS;};function findUELO(win){	if (win.extContent) return null;	// Search the window hierarchy for an object named "uelo"	// Look in the current window (win) and recursively look in any child frames	if (win.uelo != null) return win.uelo;		if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var theUELO = findUELO(win.frames[i]);			if (theUELO != null) return theUELO;		}	}	return null;};function getUELO(){	// start at the topmost window - findUELO will recurse down through	// all of the child frames	var theUELO = findUELO(parent);	if (theUELO == null) theUELO = findUELO(top);	// the LMS wasn't found in the current window's hierarchy.  If the	// current window has an opener (was launched by another window),	// check the opener's window hierarchy.	if (theUELO == null) {		if (typeof(opener) != "undefined") {			if (opener != null) theUELO = findUELO(opener.top);		}	}	return theUELO;};function findSW(win){	if (win.extContent) return null;	// Search the window hierarchy for an object named "uelo"	// Look in the current window (win) and recursively look in any child frames	if (win.sw != null) return win.sw;		if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var theSW = findSW(win.frames[i]);			if (theSW != null) return theSW;		}	}	return null;};function getSW(){	// start at the topmost window - findUELO will recurse down through	// all of the child frames	var theSW = findSW(parent);	if (theSW == null) theSW = findSW(top);	// the LMS wasn't found in the current window's hierarchy.  If the	// current window has an opener (was launched by another window),	// check the opener's window hierarchy.	if (theSW == null) {		if (typeof(opener) != "undefined") {			if (opener != null) theSW = findSW(opener.top);		}	}	return theSW;};function findPage(win){	// Search the window hierarchy for an object named "page"	// Look in the current window (win) and recursively look in any child frames	if (win.extContent) return null;	if (win.page != null && win.page.pageIsShow) {		return win.page;	}	if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var thePage = findPage(win.frames[i]);			if (thePage != null) return thePage;		}	}	return null;};function getPage(){	// start at the topmost window - findPage will recurse down through	// all of the child frames	var thePage = findPage(parent);	if (thePage == null) thePage = findPage(top);	// the LMS wasn't found in the current window's hierarchy.  If the	// current window has an opener (was launched by another window),	// check the opener's window hierarchy.	if (thePage == null) {		if (typeof(opener) != "undefined") {			if (opener != null) thePage = findPage(opener.top);		}	}	return thePage;};function findStruct(win){	if (win.extContent) return null;	if (win.struct != null) return win.struct;	if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var theStruct = findStruct(win.frames[i]);			if (theStruct != null) return theStruct;		}	}	return null;};function getStruct(){	if (window.struct) return window.struct;	var theStruct = findStruct(parent);	if (theStruct == null) theStruct = findStruct(top);	if (theStruct == null) {		if(typeof(opener) != "undefined") {			if(opener != null) theStruct = findStruct(opener.top);		}	}	return theStruct;};function findSuspendData(win){	if (win.extContent) return null;	if (win.suspendData != null) return win.suspendData;	if (win.length > 0) {		for(var i = 0; i < win.length; i++) {			var theSD = findSuspendData(win.frames[i]);			if (theSD != null) return theSD;		}	}	return null;};function getSuspendData(){	if (window.suspendData) return window.suspendData;	var theSD = findSuspendData(parent);	if (theSD == null) theSD = findSuspendData(top);	if (theSD == null) {		if(typeof(opener) != "undefined") {			if(opener != null) theSD = findSuspendData(opener.top);		}	}	return theSD;};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){  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);};function calculateTimeToString(dateStart, dateEnd){	if (typeof(dateEnd) == "undefined") 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": //P[yY][mM][dD][T[hH][mM][s[.s]S]]		P1Y3M2DT3H			var ti_th = parseInt(th);			var ti_tm = parseInt(tm);			var ti_ts = parseInt(ts);						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 (a.length == 7) ? new Date(a[1], parseInt(a[2]) - 1, a[3], a[4], a[5], a[6]) : new Date(); //pg2-incorrect convertion to date from string	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 showMessage(message){	if (arguments[1]){		prompt(message, arguments[1]);	}else{		alert(message);	}}function displayHTMLElement(obj, value){	if (obj.style)	obj.style.display = value;}