ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = (document.getElementById) ? true : false;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sElement(sParentId,sValue,sDescription)
{	
	// elements that will be loaded into the array structure and persisted
	// think of it as an object.
	this.ParentId = sParentId
	this.Id = sValue
	this.Description = sDescription
}

function bCascadeDrop(oDDsource,oDDdest)
{
	//function to enable cascading dropdowns
	//called as the parent dropdown changes.
	var iX
	var sText
	var iY= 0
	var sOptionId
	var sOptionDesc
	var iStartPos
		
	//find the value of the item currently selected		
	sText = oDDsource.options[oDDsource.selectedIndex].value 
	//alert('bOk='+bOk+',oDDsource='+oDDsource+', v='+oDDsource.options[oDDsource.selectedIndex].value+', sText='+sText);
	//if (sText != '0')
	//{
		//clear down the destination list box
		oDDdest.options.length = 0                
		
		//loop through the elements that are in the array
		// if they match the parent if then they should be displayed.
		for (iX=0; iX<=iArrayMax; iX++) 
		{		
			if(sText == Array[iX].ParentId)
			{
			//grab the values out of the element (Netscape is not happy doing too many things in a function call!)
			sOptionId = Array[iX].Id
			sOptionDesc= Array[iX].Description
			//alert(sOptionDesc)
			
			//write the element into the dripdown box.		
			oDDdest.options[iY] = new Option (sOptionDesc,sOptionId)	
			iY = iY +1		
			}	
		}	
	//}
	//else
	//{
		
	//}
}//-->

function set_display (obiekt,wyswietl)                                                                                     
{
    ie=document.all?1:0;
    ie4=ie&&!document.getElementById?1:0;
    ie5=ie&&document.getElementById?1:0;
    ie6 = (navigator.appVersion.indexOf('MSIE 6')>=0)?1:0;    
    op = (navigator.appName.indexOf('Opera')>=0)?1:0;        
    ns=document.layers||(document.getElementById&&!document.all)?1:0
    ns4=document.layers?1:0;
    ns6=ns&&!ns4?1:0

    if (op)
	obiekt.style = wyswietl ? 'display:yes' : 'display:none' ; 
    else if (ns6)
	obiekt.style.display = wyswietl ? '' : 'none' ;     
    else if (ie5 || ie6)
	obiekt.style.display = wyswietl ? 'inline' : 'none' ; 
    else
	obiekt.style = wyswietl ? 'display:yes' : 'display:none' ; 

    return 0;
}
  
function showadvanced(dopokazania, form_object)                                                                                   
{                                                                                                                
    wiersz = document.getElementById(dopokazania);                                                   
    if (wiersz == null)                                                                                      
	return 0;

	set_display(wiersz,true);
	
    return 0;                                                                                                    
}

function hideadvanced(form_object, start, end)                                                                                   
{
	for (var i=start; i<=end; i++)
	{
	    wiersz = document.getElementById(i);
    	if (wiersz == null)                                                                                      
		continue;
	
		set_display(wiersz,false);
	}
	
	return 0;                                                                                                    
}

function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
}

function setTextColor(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.color = thePointerColor;
    }

    return true;
}

function bgCell(theCell, thePointerColor)
{
    if (thePointerColor == '' || typeof(theCell.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theCell.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theCell.cells;
    }
    else {
        return false;
    }

	theCell.style.backgroundColor = thePointerColor;
    //var rowCellsCnt  = theCells.length;
    //for (var c = 0; c < rowCellsCnt; c++) {
    //    theCells[c].style.backgroundColor = thePointerColor;
    //}

    return true;
}

function displayWindow(url, name, width, height, scrollbar, resizable)
{
	var NewWindowWidth=width;
	var NewWindowHeight=height;
	var ScreenWidth=screen.availWidth;
	var ScreenHeight=screen.availHeight;
	var posx=(ScreenWidth/2)-(NewWindowWidth/2);
	var posy=(ScreenHeight/2)-(NewWindowHeight/2)
	scrollbar = (typeof scrollbar == 'undefined') ? 'no' : scrollbar;
	resizable = (typeof resizable == 'undefined') ? '0' : resizable;
	var Win = window.open(url, name,'width=' + NewWindowWidth + ',height=' + NewWindowHeight + ',resizable='+resizable+',scrollbars='+scrollbar+',menubar=no,statusbar=no, top='+posy+', left='+posx); Win.focus();
}

function OKStrOfPenny(X, roundX)
{
	var T, S=new String(Math.round(X*100)), number;
	while (S.length<3) { S='0'+S; }
	number=S.substr(0, T=(S.length-2)) + '.' + S.substr(T, 2);
	if (roundX==1) { return parseInt(Math.round(number)); }
	return number;
 }
