var bigImage;

function czytacz(){
    if (image.complete){
	width = image.width + 60;
	height = image.height + 80;
        if (width > 790 )
    	    width = 790;
	if (height > 570 )
	    height = 570;
        if (bigImage==null || bigImage.closed)
    	    bigImage = window.open ("", "Image", 'dependent=yes,toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=no,width='+width+',height='+height);
        else
    	    bigImage.resizeTo(width , height);
        var read = 1;
        if (!image.complete)
    	    read = 0;
    }else
	setTimeout('czytacz()',100)
}

function showBig(path){
     str = '';
     image = new Image();
     image.src = path;

     str += "<HTML>\n";
     str += "<HEAD>\n";
     str += "<META http-equiv=\"content-type\" content=\"text/htnl; charset=iso-8859-2\">\n";
     str += "<TITLE>Powiększenie</TITLE>\n";
     str += "<link rel=\"stylesheet\" href=\"/res/style/central.css\">\n";
     str += "</HEAD>\n";
     str += "<BODY>\n";
     str += "<TABLE WIDTH=100%><TR><TD>\n";
     str += "<CENTER><IMG SRC=\""+path+"\"</CENTER>\n";
     str += "</TD></TR><TR><TD>\n";
     str += "<CENTER><a href=\"javascript:self.close()\" class=\"actlink\">zamknij</a><CENTER>";
     str += "</TD></TR></TABLE>\n";
     str += "</BODY>\n";
     str += "</HTML>\n";
     
     if (bigImage==null || bigImage.closed)
	 bigImage = window.open ("", "Image", 'dependent=yes,toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,titlebar=no,width=250,height=60');
     else{
    	bigImage.resizeTo(250 , 60);
	bigImage.document.write("");
     }
     bigImage.document.write(str);
     bigImage.document.close();
     bigImage.focus();     
     czytacz();
}

function picreader(idpic){
    image = document.images["ID"+idpic];
    if (image) {
	document.getElementById("ID"+idpic).style.width = image.width+5;
    } else {
	setTimeout('picreader(\''+idpic+'\')',100);
    }
}

function picture(align,title,width,height,smallpic,bigpic) {
    picreader(smallpic);
    var out="";
    out+="<table id=\"ID"+smallpic+"\" border=0 cellspacing=0 cellpadding=1 ";
    if (align!="") out+="align='"+align+"' ";
    out+="><tr><td>";
    if (bigpic && bigpic!=null && bigpic!="") {
        out+="<a title=\"Kliknij aby powiększyć\" href=\"javascript:showBig('"+bigpic+"');\">";
    }
    out+="<img name=\"ID"+smallpic+"\" src='"+smallpic+"' ";
    if (width!="") out+="width='"+width+"' ";
    if (height!="") out+="height='"+height+"' ";
    if (align!="") out+="align='"+align+"' ";
    if (title!="") out+="title='"+title+"' ";
    out+=" hspace=\"5\" border=\"0\">";
    if (bigpic && bigpic!=null && bigpic!="") {
	out+="</a>";
    }
    out+="</td></tr>";
    if (bigpic && bigpic!=null && bigpic!="") {
	out+="<tr><td>";
	out+="<a title=\"Kliknij aby powiększyć\" href=\"javascript:showBig('"+bigpic+"');\"><img src=\"/res/img/common/lupa.gif\" width=\"16\" height=\"16\" border=0></a>";
	out+="</td></tr>";
    }
    out+="</table>";
    return out;
}
