var dialogWindow;// uchwyt okna symulujacego okno dialogowe

function setCookie(name, value)
{
//alert ('BEGIN OF setCookie('+name+', '+value+')');
document.cookie = escape(name) + "=" + escape(value);
//alert ('END OF setCookie('+name+', '+value+')');
}

function getCookie(name)
{
var i;
var cookieArray;
var nameValue;
var value;

cookieArray = document.cookie.split("; ");
for (i=0; i < cookieArray.length; i++)
{
nameValue = cookieArray[i].split("=");
if (escape(name) == nameValue[0])
{
value = unescape(nameValue[1]);
if (value == 'true')
{
return true;
}
else if (value == 'false')
{
return false;
}
else
{
return value;
}
}
}

return null;
}

function dumpobject(dumpedobject)
{
varobj;
vara;

obj = eval(dumpedobject);
w = window.open('', '_blank');
w.document.open();
w.document.writeln ('<html><head><title>Dump</title></head><body><pre>');
w.document.writeln (dumpedobject + ' = ' + obj + '\n');
for (a in obj)
{
w.document.write (dumpedobject + '.' + a);
w.document.write (' = ' + eval(dumpedobject + '.' + a));
w.document.write ('\n');
}
w.document.close();
}

function crossGetObject(id)
{
var isDOM = document.getElementById ? true : false;
var isIE = document.all ? true : false;
var isNN = document.layers ? true : false;

if (isDOM && document.getElementById(id)) {
return document.getElementById(id);
} else if (isIE && document.all[id]) {
return document.all[id];
} else if (isNN && document.layers[id]) {
return document.layers[id];
} else {
return false;
}
}

function crossGetStyle(id, property)
{
var isDOM = document.getElementById ? true : false;
var isIE = document.all ? true : false;
var isNN = document.layers ? true : false;
var object = crossGetObject(id);

if (object && (isDOM || isIE)) {
return eval ('object.style.'+property);
} else if (object && isNN) {
return eval ('object.'+property);
}
}

function crossSetStyle(id, property, value)
{
var isDOM = document.getElementById ? true : false;
var isIE = document.all ? true : false;
var isNN = document.layers ? true : false;
var object = crossGetObject(id);
if (object && (isDOM || isIE)) {
eval ('object.style.'+property+' = \''+value+'\';');
} else if (object && isNN) {
eval ('object.'+property+' = \''+value+'\';');
}
}

function crossGetClass(id)
{
return crossGetObject(id).className;
}

function crossSetClass(id, value)
{
var object = crossGetObject(id);

object.className = value;
}

function crossWindowWidth()
{
if (typeof(window.innerWidth) == 'number')
{
// Non-IE
return window.innerWidth;
}
else if (document.documentElement && document.documentElement.clientWidth)
{
// IE 6 + in 'standards compliant mode'
return document.documentElement.clientWidth;
}
else
{
// IE 4 compatible
return document.body.clientWidth;
}
}

function crossWindowHeight()
{
if (typeof(window.innerHeight) == 'number')
{
// Non-IE
return window.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
{
// IE 6 + in 'standards compliant mode'
return document.documentElement.clientHeight;
}
else
{
// IE 4 compatible
return document.body.clientHeight;
}
}

function crossDocumentWidth()
{
return document.body.scrollWidth;
}

function crossDocumentHeight()
{
return document.body.scrollHeight;
}

function crossObjectWidth(object)
{
return crossGetObject(object).offsetWidth;
}

function crossObjectHeight(object)
{
return crossGetObject(object).offsetHeight;
}

function crossModalDialog(url, width, height)
{
var top;
var left;

top = (screen.availHeight - height) / 2;
left = (screen.availWidth - width) / 2;

if (top < 0) top = 0;
if (left < 0) left = 0;

if (window.showModalDialog)
{
return window.showModalDialog(url, true, 'dialogHeight: '+height+'px; dialogWidth: '+width+'px; help: no; resizable: yes; scroll: no; status: no;');
}
else
{
if (dialogWindow && !dialogWindow.closed)
{
dialogWindow.close();
}
dialogWindow = window.open(url, '_blank', 'toolbar=no,menubar=no,directories=no,resizable=yes,width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=no,status=yes');
return null;
}
}

function crossNoScrollPopup(url, width, height)
{
var top;
var left;

top = (screen.availHeight - height) / 2;
left = (screen.availWidth - width) / 2;

if (top < 0) top = 0;
if (left < 0) left = 0;

return window.open(url, '_blank', 'toolbar=no,menubar=no,directories=no,resizable=yes,width=' + parseInt(width) + ',height=' + parseInt(height) + ',top=' + parseInt(top) + ',left=' + parseInt(left) + ',scrollbars=no,status=yes');
}

function crossPopup(url, width, height)
{
var top;
var left;

top = (screen.availHeight - height) / 2;
left = (screen.availWidth - width) / 2;

if (top < 0) top = 0;
if (left < 0) left = 0;

return window.open(url, '_blank', 'toolbar=no,menubar=no,directories=no,resizable=yes,width=' + parseInt(width) + ',height=' + parseInt(height) + ',top=' + parseInt(top) + ',left=' + parseInt(left) + ',scrollbars=yes,status=yes');
}

function crossInnerScroll(headerObject, scrollObject, marginx, marginy)
{
var height;
var width;

if (!marginx)
{
marginx = 0;
}
if (!marginy && marginy != 0)
{
marginy = marginx;
}

height = crossWindowHeight() - crossObjectHeight(headerObject);
if (height < marginy + 1) height = marginy + 1;
width = crossWindowWidth();
if (width < marginx + 1) width = marginx + 1;
crossSetStyle(scrollObject, 'height', '' + (height - marginy) + 'px');
crossSetStyle(scrollObject, 'width',  '' + (width - marginx) + 'px');
crossSetStyle(scrollObject, 'overflow', 'auto');
crossSetStyle(scrollObject, 'visibility', 'inherit');
}

function crossDoubleScroll(headerObject, scrollObject, scale)
{
var height;
var width;

if (!scale)
{
scale = 0.35;
}

height = crossWindowHeight() - crossObjectHeight(headerObject);
if (height < 1) height = 1;
width = crossWindowWidth();
if (width < 1) width = 1;

crossSetStyle(scrollObject, 'height', '' + height + 'px');
crossSetStyle(scrollObject, 'width',  '' + width + 'px');
crossSetStyle(scrollObject, 'visibility', 'inherit');

crossSetStyle(scrollObject + '_A', 'height', '' + height + 'px');
crossSetStyle(scrollObject + '_A', 'width',  '' + parseInt(width * scale) + 'px');
crossSetStyle(scrollObject + '_A', 'overflow', 'auto');

crossSetStyle(scrollObject + '_AB', 'width',  '1px');

crossSetStyle(scrollObject + '_B', 'height', '' + height + 'px');
crossSetStyle(scrollObject + '_B', 'width',  '' + (width - parseInt(width * scale) - 3) + 'px');
crossSetStyle(scrollObject + '_B', 'overflow', 'auto');
}

function crossPageScroll()
{
var height;
var width;

height = crossWindowHeight() - crossObjectHeight('pageHeader') - crossObjectHeight('pageFooter');
if (height < 1) height = 1;
width = crossWindowWidth();
if (width < 1) width = 1;
crossSetStyle('pageBody', 'height', '' + height + 'px');
crossSetStyle('pageBody', 'width',  '' + width + 'px');
crossSetStyle('pageBody', 'overflow', 'auto');
crossSetStyle('pageBody', 'visibility', 'inherit');
crossSetStyle('pageFooter', 'visibility', 'inherit');
}

function crossToolbarDisable(toolbar_object, disable_status)
{
crossSetClass(toolbar_object, (disable_status) ? 'toolbar_disabled' : '');
toolbar = crossGetObject(toolbar_object);
for (i=0; i < toolbar.childNodes.length; i++)
{
if (toolbar.childNodes.item(i).tagName != 'BUTTON')
{
continue;
}
toolbar.childNodes.item(i).disabled = disable_status;
}
}
