function cell(sh_height, sh_width, k, time, res, size, file, title, comment, undo, exif){
//cell(73,32,25,'','394x800','45.4','jfc3','','590x1199, 154.4');
        var k = k + 1

        if ( time != '' ) time = time + '<br>'

        // get image width
        explode(res, 'x') // returns tempArray[0] as widht & tempArray[1] as height

        // 9/14/2003: give oversized image a distinctive colour
        if ( df['props'] == 1 && df['admin'] == 'on' ) {
                colour = 'red'
                if ( tempArray[0] > 1024 || tempArray[1] > 768 ) resolution = '<font color=' + colour + '>' + res + '</font>'
                else resolution = res
        }
        else resolution = res

        // correct for MSIE
        if(bw.ie) tempArray[0] = tempArray[0] -1

        // if renaming is off, insert filename
        if (file != '0') var filename = file + '.' + df['ext']
        else var filename = df['did'] + '_' + (k - 1) + '.' + df['ext']

        // start cell
        document.write('<td align=center width=',df['cell_size'],' ID="',filename,'" class="Main" valign="',df['valign'],'">')

        // start table if shadows are requested
        if (df['shadow'] == 'on') document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2>')

        // insert exif image
        if ( exif == 1) exif = '<br><a href="#" onclick="window.open(\''+ df['parent'] + '?action=exif&did=' + df['did'] + '&id=' + k + '\', \'EXIF\',\'width=320,height=315,screenX=0,screenY=0,top=0,left=0,scrollbars=yes,status=no\'); return false" onmouseover="window.status=\'Click to view EXIF information.\';return true"><img src="pix/exif2.gif" border=0 alt="EXIF Information"></a>&nbsp;&nbsp;&nbsp;';
        else exif = '';

//cell(73,46,5,'12:10:31 07/06/03','530x800','58.7','cc_BritainsBadGirl_29_Jordan','','','530x800, 144.7',0)

        if ( comment != '' ) chop(comment, 50, '\n') // returns var 'newf'
        else newf = ''

        if (newf == '' && title != '') newf = title
        else if ( newf != '' && title != '' ) newf = title + '\n\n' + newf
        else newf = ''

        //2-9-2002: check for popup
        if (df['popup'] == 0) {
                document.write('<a href="',df['parent'],'?did=',df['did'],'&id=',k,'&page=',df['page'],'" OnMouseOver="window.status=\'',df['text'],' ',k,'\'; return true" title="',newf,'">')
        }
        else if ( tempArray[0] <= 200 | (tempArray[0] < screen.availWidth && tempArray[1] < screen.availHeight) ) {
                document.write('<a href="#" onclick="window.open(\'',df['parent'],'?action=popup&did=',df['did'],'&id=',k,'&t=t\', \'Popup\',\'width=',tempArray[0],',height=',tempArray[1],'screenX=0,screenY=0,top=0,left=0,scrollbars=no,status=no\'); return false" onmouseover="window.status=\'Click to view full size.\';return true" title="Click to view full size.">')
        }
        else {
                document.write('<a href="#" onclick="window.open(\'',df['parent'],'?action=popup&did=',df['did'],'&id=',k,'&t=t\', \'Popup\',\'width=',tempArray[0],',height=',tempArray[1],',screenX=0,screenY=0,top=0,left=0,scrollbars=no,status=no\'); return false" onmouseover="window.status=\'Click to view full size.\';return true" title="Click to view full size.">')
        }


        // insert thumbnail; 4/8/2003: added opacity option
        if ( df['opac'] == 100 ) {
                document.write('<img src="',df['parent'],'?action=thumb&file=',df['base'],'/',df['did'],'/thumbs/',filename,'" alt="',newf,'" class="Thumb"></a>')
        }
        else {
                document.write('<img src="',df['parent'],'?action=thumb&file=',df['base'],'/',df['did'],'/thumbs/',filename,'" alt="',newf,'" OnMouseOver="MakeVisible(this,0)" OnMouseOut="MakeVisible(this,1)" style="FILTER: alpha(opacity=',df['opac'],'); -moz-opacity: ',(df['opac'] / 100),'" class="Thumb"></a>')
        }


        // insert shadows
        if (df['shadow'] == 'on'){
                // alert('NS:' + bw.ns6 + ', IE:' + bw.ie)
                //if (bw.ns6 == 1 && bw.ie != 1) var extra = '<br>' //12/31/2002: correction for netscape

                document.write('</td><td><img src="pix/sh1.png" width="6" height="6" border=0><br>')
                document.write('<img src="pix/sh2.png" width="6" height="',(sh_height + 1 + 2*df['border'] ),'" border=0></td></tr>')
                document.write('<tr><td width="6"><img src="pix/sh3.png" width="6" height="6" border=0></td><td><img src="pix/sh4.png" width="',(sh_width + 1 + 2*df['border'] ),'" height="6" border=0></td><td width="6"><img src="pix/sh5.png" width="6" height="6" border=0></td></tr></table>');
        }

        // 29-3-2002: insert filename if requested
        // 30-9-2002: removed file-extension. Was 'filename'; is 'file'
        // 5/29/2003: cut up the filename if it is too long
        if ( df['title'] == 1 && title != '' ) newf = title // show title iso filename
        else newf = file

        chop(newf, 15, '<br>')

        if (df['name'] == 'yes' && df['shadow'] == 'on') document.write(newf)
        else if (df['name'] == 'yes') document.write('<br>',newf)

        // 8-10-2002: check for original; if present insert undo option
        // 2/20/2003: add properties of the original image if present
        if (undo != '0') {
                undo_html = ' <input type="hidden" name=undo value="y"><input type="hidden" name=did value="' + df['did'] + '"><input type="hidden" name=file value="' + filename + '"><input type="image" src="pix/undo.gif" title="Undo" OnFocus="this.blur()" OnClick="return confirmUndo(\'' + filename + '\',\'' + df['did'] + '\',\'' + df['page'] + '\')">'
                undo_spec = '(' + undo + 'Kb)'
                undo_view = '&nbsp;<a href="#" onclick="window.open(\'scripts/thumb.php?file=../'+df['base']+'/'+df['did']+'/originals/'+filename+'\',\'Orig\',\'screenX=0,screenY=0,top=0,left=0,scrollbars=yes,status=no\'); return false"><img src="pix/image.gif" border=0 alt="View Original"></a>'
        }
        else {
                undo_html = ''
                undo_spec = ''
                undo_view = ''
        }

        // create edit button
        edit = '<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><form method=post action=""><a href="#" title="Edit" OnClick="popup(0); popup(1,\'' + filename + '\',\'' + res + '\',\'' + undo + '\'); document.getElementById(\'' + filename + '\').style.borderColor = \'red\'; document.getElementById(\'' + filename + '\').style.borderRightColor = \'red\'; return false" OnMouseOver="window.status=\'Edit image.\';return true"><img src="pix/edit.gif" border=0 alt="Edit"></a>'; // undo grays out the save-original checkbox

        // create delete button
        del = '<a href="#" title="Delete Image" OnClick="confirmDelete(\'' + filename + '\',\'' + df['did'] + '\',\'' + df['page'] + '\'); return false" OnMouseOver="window.status=\'Delete Image.\';return true"><img src="pix/del.gif" width="12" height="12" border=0 alt="Delete"></a>';

        // 5/29/2003: create thumbnail delete button
        del_thumb = '<a href="#" title="Delete Thumbnail" OnClick="confirmDeleteThumb(\'' + filename + '\',\'' + df['did'] + '\',\'' + df['page'] + '\'); return false" OnMouseOver="window.status=\'Delete Thumbnail.\';return true"><img src="pix/del_thumb.gif" border=0 alt="Delete Thumbnail"></a>';

        // 5/28/2003: create crop button
        crop = '<a href="' + df['parent'] + '?did=' + df['did'] + '&id=' + k + '&page=' + df['page'] + '&action=crop" title="Crop Image" OnMouseOver="window.status=\'Crop image.\';return true"><img src="pix/crop.gif" width="12" height="12" border=0 alt="Crop Image"></a>';

        // 11-9-2002: insert admin options if no properties are to be shown
        if (df['props'] == 0 && df['admin'] == 'on' ) document.write('<br>',edit,'&nbsp;',crop,'&nbsp;',undo_html,'<br>',del,'&nbsp;',del_thumb,undo_view,exif,'</td></form>');

        // 6-9-2002: added admin options with properties shown
        else if (df['props'] == 1 && df['admin'] == 'on') document.write('<td align=center valign=top width=53 class="Main">',time,'<br>',resolution,'<br>',size,'Kb<br><font color="green">',undo_spec,'</font><br>',edit,'&nbsp;',crop,'&nbsp;',undo_html,'<br>',del,'&nbsp;',del_thumb,undo_view,exif,'</td></form>');

        // show properties without admin options
        else if (df['props'] == 1 && df['admin'] != 'on') document.write('<td align=center valign=top width=53 class="Main">',time,'<br>',resolution,'<br>',size,'Kb<br>',exif,'</td>');

        else document.write('</td>');
}


// 5/31/2003: function returns a 'chopped' string
// text = string
// maxlength = cut off length
// type = <br> or \n
function chop(text, maxlength, type) {
        newf = ''
        linebreak = 0
        space = 0
        j = 0
        var space = new Array
        var linebreak = new Array
        line = ''

        if ( text.length > maxlength ) { // word overflow function
                for (i = 0; i < text.length; i++) { // look for spaces or original linebreaks
                        ch = text.substring(i, i+1)
                        if (ch == '\n') linebreak[j++] = i
                        if (ch == ' ')   space[j++]      = i
                }

                for (i = 0; i < (space.length + 1); i++) {
                        old_line = line
                        word     = text.substring(space[i - 1], space[i])
                        line       = line + word

                        if ( line.length > maxlength && line.length > (maxlength + 1) ) { // +1 defines the 'tolerance'; ie. accept an question mark oss.
                                newf += trim(old_line) + '\n'
                                line     = word
                        }
                        else if ( i == space.length ) {
                                newf += trim(old_line)
                        }
                }
        }
        else newf = text // nothing to chop


        if ( (newf.length == 1 || newf.length == 2) && newf != text ) { // no spaces or linebreaks found; we do it the hard way
                runs = Math.ceil (text.length / maxlength)
                newf = ''
                for (i = 0; i < runs; i++) {
                        newf += text.substring(i * maxlength, (i+1) * maxlength) + '<br>'
                }
        }

        return newf
}

function trim(str) {
        return( (""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
}

function show_pic(base, did, id, page, parent, text, ext, hsize, wsize, shadow, file){

        // determin position of E-Card popup
        var UpperLeft = Math.ceil( (screen.availWidth - 330) / 2 )

        if (shadow == 'on') colspan = 2
        else colspan = 3

        if ( card == 'on' ) ecard = '<tr><td colspan=3 align="center"><a href="#" onclick="window.open(\'' + parent + '?action=ecard&did=' + did + '&id=' + id + '\', \'ECard\',\'width=330,height=520,screenX=' + UpperLeft + ',screenY=0,top=0,left=' + UpperLeft + ',status=no, scrollbars=yes, resizable=yes\'); return false" onmouseover="window.status=\'Send this picture as E-Card!\';return true" title="Send this picture as E-Card!" target="blank"><img src="pix/ecard1.gif" width="12" height="12" border=0 alt="Send this picture as E-Card!"> &nbsp;Send this picture as E-Card!</a><br><br></td></tr>';
        else  ecard = '';

        document.write('<table border=0 cellpadding=0 cellspacing=0>');
        document.write(ecard,'<tr><td colspan=',colspan,' valign=bottom align=center><a href="',parent,'?did=',did,'&page=',page,'" OnMouseOver="window.status=\'',text,'\'; return true" title="',text,'">');

        // if renaming is off, insert filename
        document.write('<img src="',base,'" border=0></a></td>');

        if (shadow == 'on') document.write('<td><img src="pix/sh1.png" width="6" height="7" border=0><br><img src="pix/sh2.png" width="6" height="',hsize,'" border=0></td>');

        document.write('</tr>');

        if (shadow == 'on') document.write('<tr><td><img src="pix/sh3.png" width="7" height="6" border=0></td><td><img src="pix/sh4.png" width="',wsize,'" height="6" border=0></td><td><img src="pix/sh5.png" width="6" height="6" border=0></td></tr>');
        else document.write('<tr><td colspan=',colspan,'> <td></tr>');

        document.write('</table>');
}


function nav(){

if ( !df['comments'] ) comments = ''
else comments = df['comments']

if ( !df['did'] ) did = did = '&list=' + df['list']
else did = '&did=' + df['did']

        // previous
        if (df['page'] > 1) document.write('<a href="',df['parent'],'?page=',(df['page'] - 1),did,comments,'" title="',df['prev'],'" OnMouseOver="window.status=\'',df['prev'],'\'; return true"><b>&lt;&lt;</b></a> ')
        //else document.write('<b>&lt;&lt;</b> ')

        // page numbers // 11/17/2002: brake pagenumber when there are a lot!
        for (i = 1 ; i < df['total'] + 1; i++){
                if ( parseInt(i/31) == i/31 ) document.write('<br>')

                if (i == df['page']) document.write('<font color="red"><b>',i,'</b></font>&nbsp;')
                else document.write('<a href="',df['parent'],'?page=',i,did,comments,'" OnMouseOver="window.status=\'',df['page_name'],' ',i,'\'; return true">',i,'</a>&nbsp;')
        }

        // next
        if (df['page'] < df['total']) document.write('<a href="',df['parent'],'?page=',(df['page'] + 1),did,comments,'" title="',df['next'],'" OnMouseOver="window.status=\'',df['next'],'\'; return true"><b>&gt;&gt;</b></a>')
        //else document.write('<b>&gt;&gt;</b>')
}


function explode(item,delimiter) {
        tempArray       = new Array(1)
        var Count        = 0
        var tempString = new String(item)

        while (tempString.indexOf(delimiter)>0) {
                tempArray[Count] = tempString.substr(0,tempString.indexOf(delimiter))
                tempString            = tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1)
                Count                   = Count+1
        }

        tempArray[Count] = tempString
        return tempArray
}


function res() {

//moz-scrollbars-horizontal
//moz-scrollbars-vertical
//style.MozOpacity
//this.style.MozScrollbars.horizontal
//overflow: -moz-scrollbars-none | -moz-scrollbars-horizontal | -moz-scrollbars-vertical

        if( bw.opera ){
                var width          = 13
                var width_scroll = 24
                var height         = 33
        }
        else if ( bw.ns6 == 1 ){
                var width          = 8
                var width_scroll = 24
                var height         = 28
        }
        else {
                var width          = 9
                var width_scroll = 26
                var height         = 29
        }

        var Pwidth  = document.getElementById('picture').width
        var Pheight = document.getElementById('picture').height
        var Aheight = screen.availHeight
        var Awidth  = screen.availWidth

        if ( Aheight > Pheight && Aheight < (Pheight + 10) ) Pheight = Pheight + 10 // correct for images for which height is ok, but not when window title bar is included

        if ( (Awidth <= Pwidth) && (Aheight <= Pheight) ) { // image larger then screen
                window.resizeTo(Awidth, Aheight)
                document.body.scroll = "yes"

                document.body.style.width     = Awidth - 8
                document.body.style.height    = Aheight
                document.body.style.overflow = 'auto'
        }
        else if ( (Awidth <= Pwidth) && (Aheight >= Pheight) ) { // image wider then screen
                window.resizeTo(Awidth, Pheight)
                document.body.scroll = "yes"
        }
        else if ( (Awidth >= Pwidth) && (Aheight <= Pheight) ) { // image higher then screen
                window.resizeTo(Pwidth+width_scroll, Aheight)
                document.body.scroll = "yes"
        }
        else if ( (Pwidth <= 250)) {
                window.resizeTo(267, Pheight+height) // image smaller then 250 pixels
                                document.body.scroll = "no"
        }
        else if ( (Pwidth == 500)) {
                window.resizeTo(Pwidth + width - 2, Pheight + 325 + height) // images that will fit anyhow
                document.body.scroll = "no"
        }
        else if ( (Pheight == 500)) {
                window.resizeTo(Pwidth + 300 + width, Pheight + height) // images that will fit anyhow
                document.body.scroll = "no"
        }

}

// 4-10-2002: calculate ratios
function resizer(width, height){
        ratio = width/height
}


// 30-10-2002: added undo to blank checkbox for original
popupstat = 0;
function popup(mode, text, res, undo){

// get form action field
form_action = df['parent'] + '?did=' + df['did'] + '&page=' + df['page']

// get properties for popupbox
if(document.all) var pop = document.all('popupbox')
else if(document.getElementById) var pop = document.getElementById('popupbox')
if(!pop) return

// get properties for popupshadow
//if(document.all) var pops = document.all('popupshadow');
//else if(document.getElementById) var pops = document.getElementById('popupshadow');
//if(!pops) return;

// get properties for closepopup
if(document.all) var cpop = document.all('closepopup')
else if(document.getElementById) var cpop = document.getElementById('closepopup')
if(!cpop) return

if (mode == 1){

        if (popupstat == 1){
                pop.innerHTML = ""
                cpop.style.visibility = "hidden"
                //spop.style.visibility = "hidden"
        }

        popupstat = 1;

        if ( df['shadow'] != '' ){ // no popup -. edit function
                colspan = 1
                if (document.all) {
                        positiex = event.clientX + document.body.scrollLeft - 25
                        positiey = event.clientY + document.body.scrollTop - 105
                }
                else {
                        positiex = (window.innerWidth / 2) - 125
                        positiey = (window.innerHeight / 2) - 125
                }

                if (positiex < 0) positiex = 0
                pop.style.left = positiex
                pop.style.top = positiey
                cross = "pix/smallcross.gif"
                //10-9-2002: fill pull down box for move menu ----------------------------------------
                fn = text
                text = '<tr bgcolor=' + df['table_bck'] + '><td colspan=3 valign=top align=left>&nbsp;&nbsp;<b>Filename: ' + text + '</b></td></tr>'

                // 30-10-2002: set original checkbox status
                if ( undo != '0' ) {
                        var checkbox = 'disabled title="Original Image already present!"'
                        text += '<tr bgcolor=' + df['table_bck'] + '><td colspan=3 valign=top align=left>&nbsp;&nbsp;<b>Original: &nbsp;&nbsp;' + undo + 'Kb</b></td></tr>'
                }
                else var checkbox = 'checked title="Select to keep original Image"'

                var pull = "<option value=\"none\">Select<option value=\"" + df['did'] + "/error\" style=\"color:green\">" + df['did'] + "/error"
                for ( i = 0; i < (galleries.length - 1) ; i++ ){
                        if ( df['did'] == galleries[i][0] ) continue
                        pull += "<option value=\"" + galleries[i][0] + "\">" + galleries[i][1] // [0] dir name; [1] gallery name
                }

                if (df['ext'] == 'jpg') {
                        quality_res = '<br>&nbsp;&nbsp;<b>Quality: </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="2" name="kwal" tabindex=6 value="75" style="color:gray; font-size:9px; border-color: gray; border-width: 1px" OnFocus="this.select()" OnChange="return qual(document.forms[3].kwal.value, \'res\')">'
                        quality_rot = '<br>&nbsp;&nbsp;<b>Quality: </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="2" name="kwal" tabindex=10 value="75" style="color:gray; font-size:9px; border-color: gray; border-width: 1px" OnFocus="this.select()" OnChange="return qual(document.forms[4].kwal.value, \'rot\')">'
                }
                else {
                        quality_res = ''
                        quality_rot = ''
                }

                // copy
                text += "<tr bgcolor=" + df['table_bck'] + "><td valign=top align=left><hr color=\"" + df['table'] + "\" style=\"height: 1px\"></td></tr><tr bgcolor=" + df['table_bck'] + "><td valign=top align=left><form method=post name=\"edit\" action=\"" + form_action + "\"><input type=\"hidden\" id=\"file\" name=\"file\" value=\"" + fn + "\">&nbsp;&nbsp;<b>Copy to:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><select style=\"color:gray; font-size:9px; border: none\" ID=\"copy\" name=\"copy\" tabindex=1>" + pull + "</select>&nbsp;<input type=\"image\" src=\"pix/go.gif\" title=\"Submit Changes\" OnFocus=\"this.blur()\" OnClick=\"return confirmCopy('" + fn + "', df['did'], document.getElementById('copy').value)\"></td></tr></form>"

                // move
                text += "<tr bgcolor=" + df['table_bck'] + "><td valign=top align=left><form method=post name=\"edit\" action=\"" + form_action + "\"><input type=\"hidden\" name=file value=\"" + fn + "\">&nbsp;&nbsp;<b>Move to:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><select style=\"color:gray; font-size:9px; border: none\" ID=\"move\" name=\"move\" tabindex=2>" + pull + "</select>&nbsp;<input type=\"image\" src=\"pix/go.gif\" title=\"Submit Changes\" OnFocus=\"this.blur()\" OnClick=\"return confirmMove('" + fn + "', df['did'], document.getElementById('move').value)\"></td></tr></form>"

                // rename; we only want this option when renaming is turned off! otherwise it is meaningless
                if ( df['rename'] != 'on' ) text += "<tr bgcolor=" + df['table_bck'] + " height=10><td valign=top align=left><form method=post name=\"edit\" action=\"" + form_action + "\"><input type=\"hidden\" name=file value=\"" + fn + "\">&nbsp;&nbsp;<b>Rename to: </b><input type=\"text\" ID=\"rename\" name=\"rename\" tabindex=3 value=\"\" size=18 style=\"color:gray; font-size:9px; border-color: gray; border-width: 1px\" OnFocus=\"this.select()\">&nbsp;<input type=\"image\" src=\"pix/go.gif\" title=\"Submit Changes\" OnFocus=\"this.blur()\" OnClick=\"return confirmRename('" + fn + "', document.getElementById('rename').value)\"></td></tr></form>"

                // resize
                explode(res, 'x'); // tempArray[x] as output
                ratio = (Math.round(( tempArray[0] / tempArray[1] ) * 100))/100
                // important vars: file; width; height; ratio; orig ----------------------------------
                text += '<tr bgcolor=' + df['table_bck'] + '><td valign=top align=left><hr color="' + df['table'] + '" style="height: 1px"></td></tr><tr bgcolor=' + df['table_bck'] + '><td valign=top align=left><form method=post name="resizer" action="' + form_action + '"><input type="hidden" name=file value="' + fn + '"><input type="hidden" ID="or_width" name="or_width" value="' + tempArray[0] + '"><input type="hidden" ID="or_height" name="or_height" value="' + tempArray[1] + '">&nbsp;&nbsp;<b>Resize to:&nbsp;&nbsp;&nbsp;</b>&nbsp;<input type="text" name="width" ID="width"  tabindex=4 maxlength="4" size="3" value="' + tempArray[0] + '" onchange="resize(\'w\')" onfocus="this.select()" style="color:gray; font-size:9px; border-color: gray; border-width: 1px"> W x <input type="text" name="height" ID="height" tabindex=5 maxlength="4" value="' + tempArray[1] + '" size="3" onchange="resize(\'h\')" onfocus="this.select()" style="color:gray; font-size:9px; border-color: gray; border-width: 1px"> H&nbsp;&nbsp;<input type="image" src="pix/go.gif" title="Submit Changes" OnFocus="this.blur()" OnClick="return confirmResize(\'' + fn + '\', df[\'did\'], document.getElementById(\'width\').value, document.getElementById(\'height\').value)">' + quality_res + '<br>&nbsp;&nbsp;<b>Lock ratio:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="fix" ID="fix" tabindex=7 checked> <input type="text" name="ratio" ID="ratio" size="3" value="' + ratio + '" style="font-family: Arial; font-size: 9px; border: none; color: red; background: ' + df['table_bck'] + '" readonly><br>&nbsp;&nbsp;<b>Save original:</b><input type="checkbox" name="orig" ID="orig" tabindex=8 ' + checkbox + '><input type="reset" style="border: none; color: red; background: ' + df['table_bck'] + '; font-family: Arial; font-size: 9px" title="Reset Resize Fields"></td></tr></form>'

                // 10/30/2002: rotate -------------------------------------------------------------------
                // vars: rotate (form); file; angle; orig
                rot   = '<option value="none" selected>Angle'
                rot += '<option value="90">&nbsp;&nbsp;90° CW'
                rot += '<option value="180">180° CW'
                rot += '<option value="270">&nbsp;&nbsp;90° CCW'
                rot += '<option value="mirror">&nbsp;&nbsp;Mirror'
                rot += '<option value="flip">&nbsp;&nbsp;Flip'


                text += '<tr bgcolor=' + df['table_bck'] + '><td valign=top><hr color="' + df['table'] + '" style="height: 1px"></td></tr><tr bgcolor=' + df['table_bck'] + '><td valign=top align=left><form method=post name="rotate" action="' + form_action + '"><input type="hidden" name=file value="' + fn + '">&nbsp;&nbsp;<b>Rotate:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select style="color:gray; font-size:9px; border: none" ID="angle" name="angle" tabindex=9 OnChange="qual(document.forms[4].kwal.value, \'rot\')">' + rot + '</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="image" src="pix/go.gif" title="Submit Changes" OnFocus="this.blur()" OnClick="return confirmRotate(\'' + fn + '\', df[\'did\'], document.getElementById(\'angle\').value)">' + quality_rot + '<br>&nbsp;&nbsp;<b>Save original:</b><input type="checkbox" name="orig" ID="orig" tabindex=11 ' + checkbox + '></td></tr></form>'

                //---------------------------------------------------------------------------------------------
                // 12/10/2002: add DOM to turn off bordercolor of active image!
                top = '<tr><td colspan=' +  colspan + ' align=right style="cursor: hand; background-image: url(\'pix/admin_header.jpg\')" OnFocus="obj.dragdrop()" OnBlur="obj.nodragdrop()"><IMG src="' + cross + '" alt="Close Menu" OnMouseDown="document.getElementById(\'' + fn + '\').style.borderColor  = \'' + df['table'] + '\'; popup(0)"></td></tr>'

                libinit()
                obj.dragdrop()
        }
        else { // popup
                colspan=2
                positiex = (document.images.picture.width / 2) - 125
                if (positiex < 0) positiex = 0
                pop.style.left = positiex
                pop.style.top = 0
                cross = "pix/smallcross.gif"

                // E-card code -------------------------

                // determin position of E-Card popup
                var UpperLeft = Math.ceil( (screen.availWidth - 330) / 2 )

                if ( card == 'on' ) ecard = '<a href="#" onclick="window.open(\'' + df['parent'] + '?action=ecard&did=' + df['did'] + '&id=' + df['id'] + '\', \'ECard\',\'width=330,height=520,screenX=' + UpperLeft + ',screenY=0,top=0,left=' + UpperLeft + ',status=no, scrollbars=yes, resizable=yes\'); return false" onmouseover="window.status=\'Send this picture as E-Card!\';return true" title="Send this picture as E-Card!" target="top"><img src="pix/ecard1.gif" width="12" height="12" border=0 alt="Send this picture as E-Card!"></a>';
                else  ecard = '&nbsp;'
                // ----------------------------------------

                // popup navigation code -------------
                if (df['id'] == df['total']) var next = '<img src="pix/next_end.gif" alt="Next" border=0>'
                else var next = '<a href="' + df['parent'] + '?action=popup&did=' + df['did'] + '&id=' + (df['id'] + 1) + '&t=t"><img src="pix/next.gif" alt="Next" border=0></a>'

                if (df['id'] == 1) var previous = '<img src="pix/previous_end.gif" alt="Previous" border=0>'
                else var previous = '<a href="' + df['parent'] + '?action=popup&did=' + df['did'] + '&id=' + (df['id'] - 1) + '&t=t"><img src="pix/previous.gif" alt="Previous" border=0></a>'

                // slideshow refreshrate pulldown
                var pulldown = '<select name="refresh_time" ID="refresh_time" class="Refresh" OnChange="timer(\'on\')" style="background-color: ' + df['table'] + '">'
                for ( s = 1 ; s < 7 ; s++){
                        time = s * 5
                        if ( time == df['time'] ) pulldown += '<option value="' + time + '" selected>' + time
                        else pulldown += '<option value="' + time + '">' + time
                }
                pulldown += '</select>'

                if (df['slide'] == 'on' ) var start_stop = '<a href="#" OnClick="timer(\'off\')"><img src="pix/stop.gif" alt="Stop Slideshow" border=0></a>&nbsp;' // slideshow is on; stop
                else { // slideshow is off
                        if ( df['total'] == df['id'] ) var start_stop = '&nbsp;<img src="pix/start_end.gif" alt="Start Slideshow" border=0>' // end of slides
                        else var start_stop = '&nbsp;<a href="#" OnClick="timer(\'on\')"><img src="pix/start.gif" alt="Start Slideshow" border=0></a>' // sildeshow is off; start
                }

                var top = '<tr><td align=left bgcolor=' + df['table'] + ' width="105">&nbsp;' + ecard + '&nbsp;&nbsp;' + pulldown + '&nbsp;&nbsp;' + df['id'] + '/' + df['total'] + '</td><td align=center bgcolor=' + df['table'] + ' width="120">' + previous + ' &nbsp;&nbsp;' + start_stop + '&nbsp;&nbsp;' + next + '</td><td align="right" bgcolor=' + df['table'] + ' width="25"><IMG src="' + cross + '" alt="Close Info" onmousedown=popup(0)></td></tr>'
                // ----------------------------------------

        }

        var table = '<table bgcolor=' + df['table_bck'] + ' class="Edit" cellpadding=0 cellspacing=0><tr><td><table border=0 cellspacing=0 cellpadding=0 class="Edit" width=250 align=left>' + top + text + '</table></td></tr></table>'

        if (document.all){
                pop.insertAdjacentHTML('BeforeEnd', table)
                /*
                pops.style.left = parseInt(pop.style.left) + 3
                pops.style.top = parseInt(pop.style.top) + 3
                pops.style.width = pop.offsetWidth
                pops.style.height = pop.offsetHeight
                pops.style.backgroundColor = "#000000"
                pops.style.visibility = "visible"
                */
        }
        else {
                var nTABLE = document.createElement('TABLE')
                nTABLE.innerHTML = table
                pop.appendChild(nTABLE)
        }

}

        if (popupstat == 1 && mode == 0){
                pop.innerHTML = ""
                cpop.style.visibility = "hidden"
                //pops.style.visibility = "hidden"
                popupstat = 0
        }

        // end of slideshow; disable pulldown menu
        if ( df['total'] == df['id'] && pulldown != '') document.getElementById('refresh_time').disabled = true

}


// 10-9-2002: added general link blur function
function blurred(){ for (a in document.links) document.links[a].onfocus = document.links[a].blur }

if (document.all) document.onmousedown = blurred


// 26-9-2002: disable right mouse button if requested
var message="Function Disabled";
function click(e) {
if (document.all) {
        if (event.button==2||event.button==3) {
                alert(message)
                return false
        }
}
if (document.layers) {
        if (e.which == 3) {
                alert(message)
                return false
        }
}
}
if (document.layers) document.captureEvents(Event.MOUSEDOWN)
//document.onmousedown=click; --> inserted in applicable document!

//Default browsercheck
function checkBrowser(){
        this.ver=navigator.appVersion
        this.agent=navigator.userAgent
        this.dom=document.getElementById?1:0
        this.opera5=this.agent.indexOf("Opera 5")>-1
        this.opera=this.agent.indexOf("Opera")>-1

        this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0
        this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0
        this.ie4=(document.all && !this.dom && !this.opera5)?1:0
        this.ie=this.ie4||this.ie5||this.ie6
        this.mac=this.agent.indexOf("Mac")>-1
        this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0
        this.ns4=(document.layers && !this.dom)?1:0
        this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
        return this
}

bw = new checkBrowser()

// slideshow timer; action equals either on or off
function timer(action){
        var timeout = document.getElementById('refresh_time').value
        var slide_link = df['parent'] + '?action=popup&did=' + df['did'] + '&id=' + df['id'] + '&t=t&slide=' + action + '&time_out=' + timeout
        location = slide_link
}


function MakeVisible(cur, which){
        strength = (which==0)? 1 : df['opac'] / 100

        if (cur.style.MozOpacity) cur.style.MozOpacity = strength
        else if (cur.filters) cur.filters.alpha.opacity = strength * 100
}
