
	var max_thumbnail_rows = 4;
	var numbered_blocks = false;
	var th_diff = 39;
	
	var show_thumb_name = false;
	
	if(show_gallery)
	{
		th_diff = 19;
		max_thumbnail_rows = 1;
		show_thumb_name = true;
	}
	if(upload_owner)
	{
		th_diff = 2;
		max_thumbnail_rows = 3;
	}
	
	//// set location
	var base_url = 'postimage.org/';
	
	// check browser /////
	agent = navigator.userAgent.toLowerCase();
	msie = (agent.indexOf("msie")!=-1);
	
	//// global active items
	
	var reloading = false;
	
	var IMAGE_LIST = new Array();
	var IMAGES = new Array();
	
	var th_array = new Array();
	
	//// file count
	var files;
		
	//// private variables
	var thumbnail_max_size = 101;
	
	var pid=new Array();
	
	pid['s1']="gx";
	pid['s2']="Ts";
	pid['s3']="Pq";
	pid['s4']="aV";
	
	//// calculated variables

	var th_min = 1;
	var th_max = th_diff;
	
	var count=1;
	
	window.onload = init;
	
	var PRELOAD = new Array();

	function image_preload(id,src)
	{
		if(PRELOAD[id])
		{
			var tmp = PRELOAD[id];
		}
		else
		{
			var tmp = new Image;
			tmp.src = src;
			
			PRELOAD[id] = tmp;
		}
		
		if(!tmp.width)
		{
			setTimeout('image_preload('+id+')',50);
		}
	}
	
	function image_resize(id)
	{
		var src=get("id_"+id);
		
		if (!src)
		{
			return;
		}
		
		if(PRELOAD[id])
		{
			var tmp = PRELOAD[id];
		}
		else
		{
			var tmp = new Image;
			tmp.src = src.src;
			
			PRELOAD[id] = tmp;
		}
		
		if(!tmp.width)
		{
			setTimeout('image_resize('+id+')',50);
		}
		else
		{
			if(src.width==1)
			{
				var o=get("loading_"+id);
				if(o)
				{
					o.style.display='none';
				}
				
				if(tmp.width>180 || tmp.height>180)
				{
					var scaled = get_scaled_size(tmp.width, tmp.height, 180, 180, true);
					var fix_x=Math.floor((180 - scaled[0]) / 2);
					var fix_y=Math.floor((180 - scaled[1]) / 2);
					
					src.style.margin = fix_y+'px 0px 0px '+fix_x+'px';
					src.style.clip = 'rect('+(1-fix_y)+'px,'+(180-fix_x)+'px,'+(180-fix_y)+'px,'+(1-fix_x)+'px)';
					src.width = scaled[0];
					src.height = scaled[1];
				}
				else
				{
					src.width = tmp.width;
					src.height = tmp.height;
				}
			}
		}
	}

	function get_scaled_size(width, height, max_width, max_height, crop)
	{
		if (width <= max_width && height <= max_height && !crop)
		{
			return [width, height];
		}
		
		if (crop)
		{
			max_width  += 15;
			max_height += 15;
		}

		height *= 1.0;
		width  *= 1.0;
		k = crop ? Math.max(max_width/width, max_height/height) : Math.min(max_width/width, max_height/height);;
		w = Math.floor(width * k);
		h = Math.floor(height * k);
		if (w == 0)
		{
			w = 1;
		}
		if (h == 0)
		{
			h = 1;
		}
		return [w, h];
	}
	
	function uerror(id)
	{
		var src=get("id_"+id);
		
		if (!src)
		{
			return;
		}
		
		src.src='http://www.postimage.org/templates/images/error.png';
		src.width=100;
		src.height=100;
	}
	
	function init()
	{
		innerhtml('thumbs_cont','');
		IMAGES = new Array();
		
		i=1;
		
		while(getID('i' + i))
		{
			var o = getID('i' + i);
			var ti = get_attr(o, 'ii');
			var ts = get_attr(o, 'is');
			var tf = get_attr(o, 'if');
			var tr = get_attr(o, 'ir');
			var tl = get_attr(o, 'il');
			var tc = get_attr(o, 'ic');
			var ta = get_attr(o, 'ia');
			var te = get_attr(o, 'ie');
			
			if(ti)
			{
				IMAGES[IMAGES.length] = [i,ti, ts, tf, tr, tl, tc, ta, te];
			}
			i++;
		}
		
		count=i;
		
		if(upload_owner)
		{
			//IMAGES.reverse();
		}
		
		files=IMAGES.length;
		
		if(getID('operation'))
		{
			if(files>0)
			{
				$('operation').setStyle('display', 'block');
				$('operation').fade('in');
			}
			else
			{
				//getID('operation').style.display='none';
				$('operation').fade('toggle');
			}
		}
		
		reloading = true;
		
		if(files<=th_diff || th_min==1)
		{
			reloading = false;
		}
		
		if(!reloading)
		{
			th_min = 1;
			th_max = ((th_min+th_diff) < files)
				? (th_min+th_diff)
				: files;
		}
		else
		{
			reloading = false;
			
			if (files==th_max+1 && th_min+th_diff>=files)
			{
				th_max = files;
			}
			
			if (th_max > files)
			{
				th_max = files;
			}
			
			if(th_min>th_max)
			{
				th_min=th_max-th_diff;
			}
		}
		
		IMAGE_LIST = Array();
		
		getThumbs(th_min,th_max);
	}
	
	//
	// add code to textarea
	//

	function add_code(text)
	{
		var area_ignore_name = /username_list|search/i;
		var area_e=document.getElementsByTagName('TEXTAREA');
		for(var i=0;i<area_e.length;i++)
		{
			if(!area_e[i].name.match(area_ignore_name))
			{
				var area=area_e[i];
				break;
			}
		}
		
		insertAtCursor(area,text);
	}

	function insertAtCursor(myField, myValue)
	{
		//IE support
		if (document.selection)
		{
			myField.focus();

			sel = document.selection.createRange();

			sel.text = myValue;
		}

		//MOZILLA/NETSCAPE support
		else if (myField.selectionStart || myField.selectionStart == '0')
		{
			var startPos = myField.selectionStart;

			var endPos = myField.selectionEnd;

			myField.value = myField.value.substring(0, startPos)
			+ myValue
			+ myField.value.substring(endPos, myField.value.length);
			
		}
		else
		{
			myField.value += myValue;
		}
	}
	
	//// get gallery data ///////////////////////////////////////
	
	function getBlockNav()
	{
		if (files > th_diff+1)
		{
			display('gallery_nav','block');
			
			if(getID('gallery_nav2'))
			{
				display('gallery_nav2','block');
			}
			
			var block = '';
			var l = Math.round(files);
			var block_number = 0;
			
			//// arrow nav
			//block += '<a href="javascript:void(0);">&larr;</a> ';
		
			var i = 1;
			
			while (i<=l)
			{
				var min = i;
				var max = (i+th_diff < l)
					? Math.round(i+th_diff)
					: l;
			
				var show_min = Math.round(min);
				var show_max = Math.round(max);
			
				current_block = ((th_min <= i) && (th_max >= i)) ? true : false;
			
				if (!current_block)
				{
					block += '<a href="javascript:void(0);" onclick="getThumbs(';
					block += min+","+max;
					block += ')">';
				}
			
				block_number++;
			
				if (!numbered_blocks)
				{
					if (show_min == show_max) {
						block += ' '+zero(show_max)+'';
					} else {
						block += ' '+zero(show_min)+'..'+zero(show_max)+'';
					}
				} else {
					block += ''+zero(block_number)+'';
				}
			
				if (!current_block) block += '</a>';
				
				i = max+1;
				
				if(!(block_number%9))
				{
					block += '<br />';
				}
				else if(i<=l)
				{
					block += ' | ';
				}
			}
			
			//// arrow nav
			//block += ' <a href="javascript:void(0);">&rarr;</a>';
			
			innerhtml('gallery_block', block);
			
			if(getID('gallery_block2'))
			{
				innerhtml('gallery_block2', block);
			}
		}
		else
		{
			display('gallery_nav','none');
			if(getID('gallery_nav2'))
			{
				display('gallery_nav2','none');
			}
		}
	}
	
	
	//// update thumbs //////////////////////////////////////////////
	
	function getThumbs(min, max)
	{
		th_min = min;
		th_max = max;
		
		innerhtml('thumbs_cont','<table border="0" cellpadding="0px" cellspacing="30px" valign="top" style="text-align:left" id="table_cont"></table>');
		
		thStart=th_min;
		thLimit=th_max;
		
		getBlockNav();
		
		updateThumbs();
	}
	
	var thStart=1;
	var thLimit=0;
	
	function get_attr(o, id)
	{
	    var items = o.getElementsByTagName('div');
	    if (!items)
	        return null;
	    var i;
	    for (i = 0; i < items.length; i++)
	        if (items[i].className == id)
	            return items[i].innerHTML;
	    return null;
	}
	
	function remove_attr(o, id)
	{
	    var items = o.getElementsByTagName('div');
	    if (!items)
		{
	        return null;
		}
	    var i;
	    for (i = 0; i < items.length; i++)
		{
	        if (items[i].className == id)
			{
	            items[i].className='';
			}
		}
	}
	
	function image_id(id)
	{
	    var pos = IMAGES[id][1].lastIndexOf('.');
		
	    if(pos == -1)
		{
			return '';
		}
		
		var path='image';
		
		if(owner)
		{
			path='my';
		}
		
		if(IMAGES[id][1]=='sWqrA.png')
		{
			return 'http://www.'+base_url+'index.php?gallery='+IMAGES[id][5];
		}
		else if(IMAGES[id][5])
		{
			return 'http://www.'+base_url+path+'.php?gallery='+IMAGES[id][5];
		}
		else
		{
			return 'http://www.'+base_url+'image.php?v='+pid[IMAGES[id][2]]+IMAGES[id][1].substr(0,pos);
		}
	}
	
	function updateThumbs()
	{
		var total = 0;
		
		IMAGE_LIST = [];
		
		var tbody=document.createElement("TBODY");
		
		for (i=thStart; i<=thLimit; i++)
		{
			if(IMAGES[i-1])
			{
				var thumbPath = 'http://'+IMAGES[i-1][2]+'.'+base_url + IMAGES[i-1][1];
				image_preload(IMAGES[i-1][0],thumbPath);
				
				if(show_gallery)
				{
					if(i==thStart || i%max_thumbnail_rows==true || max_thumbnail_rows==1)
					{
						var row = document.createElement("TR");
					}
				}
				else
				{
					if(i==thStart || (i-thStart+max_thumbnail_rows)%max_thumbnail_rows==false)
					{
						var row = document.createElement("TR");
					}
				}
				
				var loading_div = document.createElement('div')
				loading_div.setAttribute('id','loading_'+i)
				loading_div.style.fontSize="10px";
				loading_div.style.height='180px';
				loading_div.style.width='180px';
				loading_div.style.textAlign="center";
				loading_div.style.marginTop="40px";
				loading_div.style.display="block";
				loading_div.style.position="absolute";
				//loading_div.style.backgroundColor="#f6f6f6";
				
				if(show_gallery)
				{
					loading_div.innerHTML = '<a href="'+image_id(i-1)+'" style="padding:40px 23px 48px 25px;">loading...</a>';
				}
				else
				{
					loading_div.innerHTML = '<a target="_blank" href="'+image_id(i-1)+'" style="padding:40px 23px 48px 25px;">loading...</a>';
				}
				
				var cell = document.createElement("TD");
				cell.style.width='161px';
				cell.style.height='161px';
				cell.style.verticalAlign="top";
				cell.setAttribute('id','image_'+i)
				//cell.style.backgroundColor="#f6f6f6";
				
				cell.appendChild(loading_div);
				row.appendChild(cell);
				
				if (show_thumb_name)
				{
					var cell = document.createElement("TD");
					cell.style.width='201px';
					cell.style.height='161px';
					cell.style.verticalAlign="top";
					
					var p = document.createElement('p')
					p.setAttribute('id','text_'+i)
					p.innerHTML = '&nbsp;'
					cell.appendChild(p);
					row.appendChild(cell);
				}
				
				if(show_gallery)
				{
					if(i==thLimit || i%max_thumbnail_rows==false || max_thumbnail_rows)
					{
						tbody.appendChild(row);
					}
				}
				else
				{
					if(i==thLimit || (i-thStart+2)%max_thumbnail_rows==false)
					{
						tbody.appendChild(row);
					}
				}
			}
		}
		
		getID('table_cont').appendChild(tbody);
		
		inum = thStart;
		
		while(inum<=thLimit && IMAGES[inum-1])
		{
			var image = IMAGES[inum-1];
			var link = image[5];
			var count = image[6];
			var add_date = image[7];
			var ed = image[8];
			
			IMAGE_LIST[inum] = new Array();
			IMAGE_LIST[inum]['image']=image[1];
			IMAGE_LIST[inum]['server']=image[2];
			IMAGE_LIST[inum]['name']=image[3];
			IMAGE_LIST[inum]['resize']=image[4];
			IMAGE_LIST[inum]['link']=link;
			
			text_count='images';
			
			var output_text = '';
			
			if (show_thumb_name)
			{
				if(owner)
				{
					if(count>0)
					{
						output_text = thumbName(IMAGE_LIST[inum]['name'])+"<br /><br />"+count+' '+text_count+'<br /><br /><a href="javascript:confirmDelete(\'?delete='+IMAGE_LIST[inum]['link']+'\')">delete</a><br /><br /><a href="/index.php?gallery='+IMAGE_LIST[inum]['link']+'">upload</a>';
					}
					else
					{
						output_text = thumbName(IMAGE_LIST[inum]['name'])+"<br /><br />"+count+' '+text_count;
					}
					
					if(thumbName(IMAGE_LIST[inum]['name'])!='NoName')
					{
						output_text = '<span id="'+link+'" class="editText">'+thumbName(IMAGE_LIST[inum]['name'])+"</span>&nbsp;&nbsp;<img src='/templates/images/pencil.png' /><br /><br />"+count+' '+text_count+'<br /><br /><a href="javascript:confirmDelete(\'?delete='+IMAGE_LIST[inum]['link']+'\')">Delete</a><br /><br /><a href="/index.php?gallery='+IMAGE_LIST[inum]['link']+'">Upload</a>';
					}
					else
					{
						output_text = '<span id="'+link+'">'+thumbName(IMAGE_LIST[inum]['name'])+"</span><br /><br />"+count+' '+text_count+'<br /><br /><a href="/index.php?gallery='+IMAGE_LIST[inum]['link']+'">Upload</a>';
					}
				}
				else
				{
					var edit_date='';
					if(ed)
					{
						edit_date='<br /><br />Edited on '+ed;
					}
					output_text = '<b>'+thumbName(IMAGE_LIST[inum]['name'])+"</b><br /><br />"+count+' '+text_count+"<br /><br />Created on "+add_date+edit_date;
				}
				getID('text_'+inum).innerHTML = output_text;
			}
			
			if(owner && show_gallery)
			{
				editbox_init();
			}
			
			if(IMAGE_LIST[inum])
			{
				var thumbPath = 'http://'+IMAGE_LIST[inum]['server']+'.'+base_url + IMAGE_LIST[inum]['image'];
				
				var name = IMAGE_LIST[inum]['name'];
				
				var codehtml='';
				
				if(upload_owner)
				{
					//codehtml='<div class="image_rotate1"><a id="imagecode'+inum+'" href="javascript:void(0);" onclick="add_code(get_code(\''+inum+'\',5));">-90%</a></div>';
					//codehtml+='<div class="image_rotate2"><a id="imagecode'+inum+'" href="javascript:void(0);" onclick="add_code(get_code(\''+inum+'\',5));">180</a></div>';
					//codehtml+='<div class="image_rotate3"><a id="imagecode'+inum+'" href="javascript:void(0);" onclick="add_code(get_code(\''+inum+'\',5));">+90%</a></div>';
					codehtml+='<div class="imagecode"><a id="imagecode'+inum+'" href="javascript:void(0);" onclick="add_code(get_code(\''+inum+'\',5));">Insert</a></div>';
					codehtml+='<div class="imagecode2"><a id="imagecode'+inum+'" href="javascript:void(0);" onclick="remove_item(\''+inum+'\');">Remove</a></div>';
				}
				else if(owner)
				{
					if(get_code(inum,1))
					{
						codehtml='<div class="imagebox" style="display: none;" id="imagebox'+inum+'" onmouseover="mouse_codes(\''+inum+'\')" onmouseout="prepare_hide_codes(\''+inum+'\')"></div><div class="imagecode"><a id="imagecode'+inum+'" href="javascript:void(0);" onmouseover="show_codes(\''+inum+'\');mouse_codes(\''+inum+'\');" onmouseout="prepare_hide_codes(\''+inum+'\')">links</a></div>';
						codehtml='<div class="imagebox" style="display: none;" id="imagebox'+inum+'" onmouseover="mouse_codes(\''+inum+'\')" onmouseout="prepare_hide_codes(\''+inum+'\')"></div>';
					}
				}
				
				if(show_gallery)
				{
					output_image = '<a href="'+image_id(inum-1)+'"><img id="id_'+IMAGES[inum-1][0]+'" '
						+' style="position:absolute;" '
						+' title="'+name+'" width="1px" height="1px"'
						+' src="'+thumbPath+'" '
						+' onload="image_resize('+IMAGES[inum-1][0]+')" onerror=\"uerror('+IMAGES[inum-1][0]+')\" /></a>'+codehtml;
				}
				else
				{
					output_image = '<a target="_blank" href="'+image_id(inum-1)+'" onmouseover="prepare_show_codes(\''+inum+'\');" onmouseout="prepare_hide_codes(\''+inum+'\')"><img id="id_'+IMAGES[inum-1][0]+'" '
						+' style="position:absolute;" '
						+' title="'+name+'" width="1px" height="1px"'
						+' src="'+thumbPath+'" '
						+' onload="image_resize('+IMAGES[inum-1][0]+')" onerror=\"uerror('+IMAGES[inum-1][0]+')\" /></a>'+codehtml;
				}
				
				if(getID('image_'+inum))
				{
					innerhtml('image_'+inum,getID('image_'+inum).innerHTML+output_image);
					image_resize(IMAGES[inum-1][0]);
				}
			}
			
			inum++;
		}
	}
	
	function confirmDelete(delUrl)
	{
		if(confirm("Are you sure you want to delete?"))
		{
			document.location = delUrl;
		}
	}
	
	function remove_item(i)
	{
		var o = getID('i' + IMAGES[i-1][0]);
		remove_attr(o,'ii');
		reloading = true;
		init();
	}
	
	function clear_list()
	{
		i=1;
		while(getID('i' + i))
		{
			var o = getID('i' + i);
			remove_attr(o,'ii');
			i++;
		}
		init();
	}
	
	function get_code(i,type)
	{
		//name,link,type,resize
		//IMAGES[i-1][0],IMAGES[i-1][4],1,IMAGES[i-1][3]
		
		
	    var pos = IMAGE_LIST[i]['image'].lastIndexOf('.');
		
	    if(pos == -1)
		{
			return '';
		}
		
		if(IMAGE_LIST[i]['link'])
		{
			var url='http://www.'+base_url+'image.php?gallery='+IMAGE_LIST[i]['link'];
		}
		else
		{
			var url='http://www.'+base_url+'image.php?v='+pid[IMAGE_LIST[i]['server']]+IMAGE_LIST[i]['image'].substr(0,pos);
		}
		
		var thumb_url='http://'+IMAGE_LIST[i]['server']+'.'+base_url+IMAGE_LIST[i]['image'];
		
		var resize_url=url;
		
		if(IMAGE_LIST[i]['resize']==0)
		{
			resize_url='http://www.'+base_url;
		}
		
		if(show_gallery)
		{
			switch(type)
			{
				case 1:
					return '[url]'+url+'][/url]';
					break;
				case 2:
					return '[url='+url+'][/url]';
					break;
				case 3:
					return '<a href="'+url+'" target="_blank">';
					break;
				default:
					return url;
			}
		}
		
		switch(type)
		{
			case 5:
				return "\n[url="+resize_url+'][img]'+thumb_url+"[/img][/url]\n";
				break;
			case 1:
				return '[url='+resize_url+'][img]'+thumb_url+'[/img][/url]';
				break;
			case 2:
				return '[url='+resize_url+'][img='+thumb_url+'][/url]';
				break;
			case 3:
				return '<a href="'+resize_url+'" target="_blank"><img src="'+thumb_url+'" border="0" alt="Free image hosting powered by PostImage.org" /></a>';
				break;
			default:
				return url;
		}
	}
	
	function get_all_code(type)
	{
		var insert='';
		
		var i=0;
		
		while(IMAGES[i])
		{
			var pos = IMAGES[i][1].lastIndexOf('.');
			
	    	if(IMAGES[i][5])
			{
				var url='http://www.'+base_url+'image.php?gallery='+IMAGES[i][5];
			}
			else
			{
				var url='http://www.'+base_url+'image.php?v='+IMAGES[i][1].substr(0,pos);
			}
			
			var thumb_url='http://'+IMAGES[i][2]+'.'+base_url+IMAGES[i][1];
			
			var resize_url=url;
			
			if(IMAGES[i][4]==0)
			{
				resize_url='http://www.'+base_url;
			}
			
			if(show_gallery)
			{
				switch(type)
				{
					case 1:
						return '[url]'+url+'][/url]';
						break;
					case 2:
						return '[url='+url+'][/url]';
						break;
					case 3:
						return '<a href="'+url+'" target="_blank">';
						break;
					default:
						return url;
				}
			}
			
			switch(type)
			{
				case 5:
					insert+="\n[url="+resize_url+'][img]'+thumb_url+"[/img][/url]\n";
					break;
				case 1:
					insert+='[url='+resize_url+'][img]'+thumb_url+'[/img][/url]';
					break;
				case 2:
					insert+='[url='+resize_url+'][img='+thumb_url+'][/url]';
					break;
				case 3:
					insert+='<a href="'+resize_url+'" target="_blank"><img src="'+thumb_url+'" border="0" alt="Free image hosting powered by PostImage.org" /></a>';
					break;
				default:
					insert+=url;
			}
			
			i++;
		}
		
		return insert;
	}
	
	var mouse_over=true;
	var active_code;
	
	function prepare_show_codes(i)
	{
		mouse_over=true;
		
		if(active_code && active_code!=i)
		{
			//hide_codes(active_code,true);
			//show_codes(i);
		}
		else
		{
			//setTimeout('show_codes('+i+')',1000);
		}
	}
	
	function show_codes(i)
	{
		if(!mouse_over)
		{
			return false;
		}
		active_code=i;
		//getID('imagecode'+i).style.height='13px';
		//getID('imagecode'+i).style.border='1px solid #37587a';
		//getID('imagecode'+i).style.borderTop='0px';
		getID('imagebox'+i).style.display='';
		innerhtml('imagebox'+i,'<table border="0" cellpadding="0" cellspacing="4" class="bbcode_image">'+
		'<tr>'+
		'<td align="left"><input name="bbcode1" value="'+get_code(i,1)+'" onmouseover="this.focus()" onfocus="this.select()" type="text" /></td>'+
		'<td align="left">Forum BBCode (1)</td>'+
		'</tr><tr>'+
		'<td align="left"><input name="bbcode2" value="'+get_code(i,2)+'" onmouseover="this.focus()" onfocus="this.select()" type="text" /></td>'+
		'<td align="left">Forum BBCode (2)</td>'+
		'</tr><tr>'+
		'<td align="left"><input name="htmlcode" id="shareid" value=\''+get_code(i,3)+'\' onmouseover="this.focus()" onfocus="this.select()" type="text" /></td>'+
		'<td align="left">HTML</td>'+
		'</tr><tr>'+
		'<td align="left"><input name="directlink" value="'+get_code(i,4)+'" onmouseover="this.focus()" onfocus="this.select()" type="text" /></td>'+
		'<td align="left">Direct Link to Image</td>'+
		'</tr></table>'
		);
	}
	
	function mouse_codes(i)
	{
		mouse_over=true;
	}
	
	function prepare_hide_codes(i)
	{
		mouse_over=false;
		setTimeout('hide_codes('+i+',false)',500);
	}
	
	function hide_codes(i,hard)
	{
		if(!getID('imagebox'+i))
		{
			return false;
		}
		
		if(hard || !mouse_over)
		{
			if(!hard && !mouse_over)
			{
				active_code=false;
			}
			//getID('imagecode'+i).style.height='12px';
			//getID('imagecode'+i).style.border='1px solid #37587a';
			getID('imagebox'+i).style.display='none';
		}
	}
	
	/**** IMAGE SCRIPTS **************************/
	
	//// image navigation scripts /////////////////////////////////////////
	
	/****** HELPER FUNCTIONS *****************/
	
	function innerhtml(id, cont)
	{
		if (getID(id))
		{
			getID(id).innerHTML = cont;
		}
	}
	
	function display(id, flag)
	{
		if (getID(id)) getID(id).style.display = flag;
	}
	
	function thumbName(g)
	{
		var ds = .1;
		var name = '';
		var dw = (ds*thumbnail_max_size);
		name = g;
		return name;
	}
	
	//// return number to zero-leading string
	function zero(num)
	{
		if (num < 10) num = '0'+num;
		return num;
	}
	
	/**** adding single quote escaping
	 as a method to the String Object ****/
	
	String.prototype.sq = function()
	{
		return this.replace("'","\\'")
	}
	
	function getID(obj)
	{
		return document.getElementById(obj)
	}
	
