function cell(sh_height, sh_width, k, time, res, size, file, comment, undo){

	var k = k + 1

	// get image width
	explode(res, 'x')
	// correct for MSIE
	if(bw.ie) tempArray[0] = tempArray[0] -1

	// 11/17/2002: E-Card option
	if ( card == 'on' ) ecard = ''
	else ecard = ''

	// 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">')

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

	//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="',comment,'">');
	else if ( tempArray[0] <= 200 | (tempArray[0] < screen.availWidth && tempArray[1] < screen.availHeight) ) document.write('<a href="#" onclick="window.open(\'scripts/popup.php?did=',df['did'],'&id=',k,'&t=t\', \'Popup\',\'width=',tempArray[0],',height=',tempArray[1],'screenX=0,screenY=0,top=0,left=0,scrollbars=no\')" onmouseover="window.status=\'Click to view full size.\';return true" title="Click to view full size.">');
	else document.write('<a href="#" onclick="window.open(\'scripts/popup.php?did=',df['did'],'&id=',k,'&t=t\', \'Popup\',\'width=',tempArray[0],',height=',tempArray[1],',screenX=0,screenY=0,top=0,left=0,scrollbars=yes,status=no\')" onmouseover="window.status=\'Click to view full size.\';return true" title="Click to view full size.">');

	// insert thumbnail
	document.write('<img src="',df['base'],'/',df['did'],'/thumbs/',filename,'" border=0 alt="',comment,'"></a>')

	// insert shadows
	if (df['shadow'] == 'on'){
		document.write('</td><td><img src="pix/sh1.png" width="6" height="6" border=0>')
		if (bw.ns6 == 0 | bw.opera) document.write('<br>') //12/31/2002: correction for netscape; exception for opera
		document.write('<img src="pix/sh2.png" width="6" height="',(sh_height + 1),'" 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),'" 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'
//	if (df['name'] == 'yes' && df['shadow'] == 'on') document.write(file)
//	else if (df['name'] == 'yes') document.write('<br>',file)

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

	// 8-10-2002: check for original; if present insert undo option
	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'] + '\')">';
	else undo_html = '';

	// create edit button
	edit = '<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\'"><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" OnClick="confirmDelete(\'' + filename + '\',\'' + df['did'] + '\',\'' + df['page'] + '\')"><img src="pix/del.gif" width="12" height="12" border=0 alt="Delete"></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;&nbsp;',undo_html,'&nbsp;&nbsp;',del,'</td></form>');

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

	else if (df['props'] == 1 && df['admin'] != 'on') document.write('<td align=center width=53 class="Main">',time,'<br><br>',res,'<br>',size,'Kb<br><br>',ecard,'</td>');

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



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

	if ( card == 'on' ) ecard = '<tr><td colspan=3 align="center"><a href="scripts/ecard.php?did=' + did + '&id=' + (id + 1) + '" 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=2 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
	if (file != '') document.write('<img src="',base,'/',did,'/',file,'.',ext,'" border=0></a></td>');
	else document.write('<img src="',base,'/',did,'/',did,'_',id,'.',ext,'" 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>');
	else document.write('<td> </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=3> <td></tr>');

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


function nav(){

if ( !df['did'] && df['list'] == 'on' ) did = '&list=on';

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

if ( !df['did'] ) did = '';
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>&laquo;</b></a> ');
//	else document.write('<b>&laquo;</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="#CCE6FF"><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>&raquo;</b></a>');
//	else document.write('<b>&raquo;</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() {

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

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

	if ( (Awidth <= Pwidth) && (Aheight <= Pheight) ) window.resizeTo(Awidth, Aheight)
	else if ( (Awidth <= Pwidth) && (Aheight >= Pheight) ) window.resizeTo(Awidth, Pheight)
	else if ( (Awidth >= Pwidth) && (Aheight <= Pheight) ) window.resizeTo(Pwidth+width, Aheight)
	else if ( (Pwidth <= 250)) window.resizeTo(267, Pheight+height)
	else window.resizeTo(Pwidth + width, Pheight + height)
}

// 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 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 = (document.body.clientWidth / 2) - 125;
		else positiex = (window.innerWidth / 2) - 125;

		if (positiex < 0) positiex = 0;
		pop.style.left = positiex;
		pop.style.top = 62;
		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=\"\"><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=\"\"><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=\"\"><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=""><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=""><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";
		if ( card == 'on' ) ecard = '<a href="ecard.php?did=' + df['did'] + '&id=' + df['id'] + '" target="blank"><img src="../pix/ecard1.gif" width="12" height="12" border=0 alt="Send this picture as E-Card!"></a>';
		else  ecard = '&nbsp;';

		if (df['id'] == df['total']) var next = '<img src="../pix/next_end.gif" alt="Next" border=0>';
		else var next = '<a href="popup.php?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="popup.php?did=' + df['did'] + '&id=' + (df['id'] - 1) + '&t=t"><img src="../pix/previous.gif" alt="Previous" border=0></a>';

		var top = '<tr><td align=left bgcolor=' + df['table'] + ' width="25">&nbsp;' + ecard + '</td><td align=center bgcolor=' + df['table'] + ' width="200">' + previous + ' &nbsp;&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="Main"><tr><td><table border=0 cellspacing=0 cellpadding=0 class="Main" 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;
	}
}


// 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()