
			function addslashes(str)
			{
				str=str.replace(/\'/g,'\\\'');
				str=str.replace(/\"/g,'\\"');
				str=str.replace(/\\/g,'\\\\');
				str=str.replace(/\0/g,'\\0');
				return str;
			}
			function stripslashes(str) 
			{
				str=str.replace(/\\'/g,'\'');
				str=str.replace(/\\"/g,'"');
				str=str.replace(/\\\\/g,'\\');
				str=str.replace(/\\0/g,'\0');
				return str;
			}
			function setView( key, val )
			{
				views[key] = val;
			}
			function setJSVar( var_var, val )
			{
				var temp_function = new Function( "return "+var_var+" = "+val+";" );
				temp_function();
			}
			function setGameIDs( var_game_id, var_player_id )
			{
				game_id = var_game_id;
				player_id = var_player_id;
			}
			function grabMouseCoords( e )
			{
				if( !e ) var e = window.event;
				mouseX = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
				mouseY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
			}

			function handleWheel(delta )
			{
			        if (delta <0)
			                scroll( 'up', 15, wheelWindow );
				else
					scroll('down', 15, wheelWindow );
			}
			function setWheelWindow( id )
			{
				wheelWindow = id;	
			}
			function wheel(event)
			{
			        var delta = 0;
			        if(!event)
					var event = window.event;

			        if(event.wheelDelta) 
				{
			                delta = event.wheelDelta/120; 
			                //if(window.opera)
						delta = -delta;
			        } 
				else if(event.detail)
			                delta = event.detail/3;

			        if (delta)
			                handleWheel(delta);

				if (event.preventDefault)
					event.preventDefault();
				event.returnValue = false;
			}

			function setFloatVars()
			{
				if( ! floatDiv )
					floatDiv = document.getElementById("floatDiv");
				if( ! floatTable )
					floatTable = document.getElementById("floatTable");
				if( ! floatBody )
					floatBody = document.getElementById("floatBody");
			}

			function displayFloatDiv( element, standard )
			{
				setFloatVars();
				clearElement( floatBody );

				floatDiv.style.backgroundColor = "#FFCC69"; 
				floatDiv.style.borderStyle = "dashed"; 
				floatDiv.style.borderColor = "black"; 
				floatDiv.style.borderWidth = "1px";
				floatDiv.style.visibility = "visible";

				floatBody.appendChild( oneCellRow( element, null, null, "standard_text" ) );

				if( standard )
				{
					floatDiv.style.left = ( document.body.offsetWidth / 2 ) - ( floatBody.offsetWidth / 2 );
					floatDiv.style.top = ( document.body.offsetHeight / 2 ) - ( floatBody.offsetHeight / 2 );
				}
				else
				{
					floatDiv.style.left = mouseX + parseInt(5);
					floatDiv.style.top = mouseY + parseInt(5);
				}
			}
			function killFloatDiv()
			{
				setFloatVars();

				floatDiv.style.backgroundColor = ""; 
				floatDiv.style.borderStyle = "none"; 
				floatDiv.style.visibility = "hidden";

				floatFocus = null;
				//floatDiv.className = "killFloat";
				clearElement( floatBody );
			}
			function clearElement( element )
			{
				if( element.id == "grid_body" )
				{
					var div = document.getElementById("mapHolderDiv");
					if( div )
					{
						var cell = div.parentNode;
						if( cell.id == "mapCell" )
						{
							var containDiv = document.getElementById("containerDiv");
							containDiv.appendChild( div );
						}
					}
				}

				if( element.hasChildNodes() )
				{
					while( element.childNodes.length > 0 )
					{
						element.removeChild( element.childNodes[0] );
					}
				}
			}
			function number_format(a, b, c, d) 
			{
				// number_format(number, decimals, comma, formatSeparator)
				a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
				e = a + '';
				f = e.split('.');
				if(!f[0]) f[0] = '0';
				if(!f[1]) f[1] = '';
				if(f[1].length < b)
				{
					g = f[1];
					for(i = f[1].length + 1; i <= b; i++) 
					{
						g += '0';
					}
					f[1] = g;
				}
				if(d != '' && f[0].length > 3) 
				{
					h = f[0];
					f[0] = '';
					for(j = 3; j < h.length; j += 3) 
					{
						i = h.slice(h.length - j, h.length - j + 3);
						f[0] = d + i +  f[0] + '';
					}
					j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
					f[0] = j + f[0];
				}
				c = (b <= 0) ? '': c;
				return f[0] + c + f[1];
			}
			function textarea( value, id, rows, cols, len, wrap )
			{
				var textarea = document.createElement( "textarea" );
				if( value )
					textarea.value = value;
				if( id )
				{
					textarea.id = id;
					textarea.name = id;
				}
				if( rows )
					textarea.rows = rows;
				if( cols )
					textarea.cols = cols;
				if( len )
					textarea.maxLength = len;
				if( wrap )
					textarea.wrap = wrap;

				return textarea;
			}
			function formInput( type, name, value, size, id, checked )
			{
				var input = document.createElement( "input" );
				if( type )
					input.type = type;
				if( name )
					input.name = name;
				if( value || value == 0 )
					input.value = value;
				if( size )
					input.size = size;
				if( id )
					input.id = id;
				if( checked )
				{
					if( type == "checkbox" || type == "radio" )
						input.checked = true;
				}

				return input;
			}
			function nCellRow()
			{
				var row = document.createElement( "tr" );

				for( var i = 0; i <= arguments.length; i++ )
				{
					if( typeof arguments[i]  == "string" )
						row.appendChild( document.createTextNode( arguments[i] ) );
					else if( typeof arguments[i] == "object" )
						row.appendChild( arguments[i] );
				}

				return row;
			}
			function twoCellRow( node1, node2, style1, style2, cells, id )
			{
				var row = document.createElement("tr");
				if( cells )
				{
					row.appendChild( node1 );
					row.appendChild( node2 );
				}
				else
				{
					row.appendChild( oneCell( node1, null, null, style1 ) );
					row.appendChild( oneCell( node2, null, null, style2 ) );
				}
				if( id )
					row.id = id;
				return row;
			}

			function oneCellRow( node1, onclick, span, style, id )
			{
				var row = document.createElement( "tr" );
				row.appendChild( oneCell( node1, onclick, span, style, id ) );

				return row;
			}

			function oneCell( node1, onclick, span, style, id )
			{
				var cell = document.createElement("td");

				if( node1 )
				{
					if( typeof node1  == "string" )
						cell.appendChild( document.createTextNode( node1 ) );
					else if( typeof node1 == "object" )
						cell.appendChild( node1 );
				}

				if( span )
					cell.setAttribute( "colSpan", span );
				if( style )
					cell.className = style;
				if( onclick )
				{
					cell.onclick = new Function( "return "+onclick );
					if( cell.className )
					{
						cell.className += " link";
					}
					else
						cell.className = "link";
				}
				if( id )
					cell.id = id;

				return cell;
			}
			function oneDiv( node1, onclick, span, style, id, bg_img, width, height, position, top, left )
			{
				var div = document.createElement("div");

				if( node1 )
				{
					if( typeof node1  == "string" )
						div.appendChild( document.createTextNode( node1 ) );
					else if( typeof node1 == "object" )
						div.appendChild( node1 );
				}
				if( onclick )
					div.onclick = new Function( "return "+onclick );
				if( span )
					div.setAttribute( "colSpan", span );
				if( style )
					div.className = style;
				if( id )
					div.id = id;
				if( bg_img )
					div.style.backgroundImage = "url( '"+bg_img+"' )";
				if( width )
					div.style.width = width;
				if( height )
					div.style.height = height;
				if( position )
					div.style.position = position;
				if( top )
					div.style.top = top;
				if( left )
					div.style.left = left;

				return div;
			}
			function oneNodeSpan( node, nodeId, onclick, style )
			{
				var span = document.createElement( "span" );

				if( node )
				{
					if( typeof node  == "string" )
						span.appendChild( document.createTextNode( node ) );
					else if( typeof node == "object" )
						span.appendChild( node );
				}
				if( nodeId )
					span.id = nodeId;
				if( style )
					span.className = style;
				if( onclick )
				{
					span.onclick = new Function( "return "+onclick );
					if( span.className )
					{
						span.className += " link";
					}
					else
						span.className = "link";
				}
				return span;
			}

			function nNodeSpan()
			{
				var span = document.createElement( "span" );

				for( var i = 0; i <= arguments.length; i++ )
				{
					if( arguments[i] != null )
					{
						if( typeof arguments[i]  == "string" )
							span.appendChild( document.createTextNode( arguments[i] ) );
						else if( typeof arguments[i] == "object" )
							span.appendChild( arguments[i] );
					}
				}

				return span;
			}
			function makeImg( src, width, height, id, alt, onclick, style )
			{
				var img = document.createElement("img");
				img.setAttribute( "src", src );

				if( width )
					img.setAttribute( "width", width );
				if( height )
					img.setAttribute( "height", height );
				if( id )
					img.setAttribute( "id", id );
				if( alt )
				{
					img.setAttribute( "alt", alt );
					img.setAttribute( "title", alt );
				}
				if( onclick )
					img.onclick = new Function( "return "+onclick );
				if( style )
					img.className = style;

				return img;
			}
			function parseMessage( message, len, rep, encode )
			{
				var mode = "[br]";
				if( rep )
					mode = "\n";
					//var message_array = message.split( "\n" );
				//else
					//var message_array = message.split( "[br]" );

				var msg_span = document.createElement( "span" );

				var mess_span = null;
				var msg = stripslashes( message );
				mess_span = bbencode2( msg );
				
				msg_span.appendChild( parseLines(mess_span,mode) );
				/*
				for( var l = 0; l < message_array.length; l++ )
				{
					var line_span = null;
					var line = stripslashes( message_array[l] );
					if( len )
					{
						var words = line.split( ' ' );
						if( words.length == 1 && line.length > len )
						{
							message_array.splice( l + 1, 0, line.substring( len ) );
							line = line.substring( 0, len );
						}
					}
					if( !encode || !( line.indexOf( '[' ) >= 0 && line.indexOf( ']' ) > 0 ) )
						line_span = oneNodeSpan( line );
					else
					{
						//line_span = bbencode2( line );
					}
					msg_span.appendChild( line_span );
					msg_span.appendChild( document.createElement( "br" ) );
				}
				*/
				return msg_span;
			}
			function parseLines(ele,mode)
			{
				var span = ele.cloneNode(true);
				if( ele.hasChildNodes() )
				{
					var children = ele.childNodes;
					clearElement(span);
					for( var c = 0, node; node = ele.childNodes[c]; c++ )
					{
						if( node.nodeType == 1 ) //element
							span.appendChild(parseLines(node,mode));
						else if( node.nodeType == 3 ) //text
						{
							var lines = node.nodeValue.split(mode);
							if( lines.length >= 1 )
							{
								for(var l = 0, line; line = lines[l]; l++)
								{
									if( l > 0 )
										span.appendChild(document.createElement('br'));
									span.appendChild(document.createTextNode(line));
								}
							}
						}
					}
				}
				return span;
			}
			function bbencode2( line )
			{
				var s1 = line.indexOf( '[' );
				var s2 = line.indexOf( ']' );
				var tag_parts = line.substring( s1 + 1, s2 ).match( /(\w+((\=\d+)|(\=\"([ _a-zA-Z0-9%#?!]*)?\")?)?)/g );

				if(tag_parts)
				{
					var tag_val = tag_parts[0].split( "=" );
					
					var tag = tag_val[0];
					if( tag )
					{
						var single_tags = {'hr':String,'line':String,'break':String,'headlines':String,'pictureList':String,'tagList':String};
						var e_tag = line.indexOf( '[/'+tag+']' );
						if( e_tag > 0 || single_tags[tag] )
						{
							if( e_tag > 0 )
							{
								var raw_content = line.substring( s2+1, e_tag );
								var tag_content = bbencode2(raw_content);
							}
							var encode_ele = null;
							switch( tag )
							{
								case 'b':
								case 'bold':
									encode_ele = oneNodeSpan( tag_content, null, null, 'bold' );
									break;
								case 'i':
								case 'italics':
									encode_ele = oneNodeSpan( tag_content, null, null, 'italic' );
									break;
								case 'u':
								case 'underline':
									encode_ele = oneNodeSpan( tag_content, null, null);
									encode_ele.style.textDecoration = 'underline';
									break;
								case 'strike':
									encode_ele = oneNodeSpan( tag_content, null, null );
									encode_ele.style.textDecoration = 'line-through';
									break;
								case 'border':
									encode_ele = oneNodeSpan( tag_content, null, null );
									encode_ele.className = 'solid';
									break;
								case 'hr':
								case 'line':
									encode_ele = document.createElement('hr');
									if(tag_parts[1])
									{
										var att = tag_parts[1].split('=');
										if(att[0] == 'width')
											encode_ele.style.width = att[1].replace(/"/gi,'');
									}
									break;
								case 'img':
								case 'image':
									var atts = {};

									for(var p=1,part; part = tag_parts[p];p++)
									{
										var att = part.split('=');
										if( att.length > 1 )
											atts[att[0]] = att[1].replace(/"/gi,'');
										else
											atts['mod'] = part;
									}
									
									var img = makeImg( raw_content, atts.width, atts.height, null, atts.alt );
									if(atts.mod)
									{
										var m = (atts.mod == 'FADE' ? './img/fade.png' : (atts.mod == 'SOFTBORDER' ? './img/soft_border.png' : ''));
										if(m)
										{
											encode_ele = document.createElement('div');
											encode_ele.style.position = 'relative';
											var mask = makeImg( m, atts.width, atts.height, null, atts.alt );
											mask.style.position = 'absolute';
											mask.style.top = 0;
											mask.style.left = 0;
											mask.style.zIndex = 2;
											
											img.style.zIndex = 1;
											//img.style.position = 'absolute';
											img.style.top = 0;
											img.style.left = 0;
											
											encode_ele.appendChild(img);
											encode_ele.appendChild(mask);
										}
										else
											encode_ele = img;
									}
									else
										encode_ele = img;
									break;
								case 'url':
								case 'link':
									encode_ele = document.createElement( "a" );
									if( tag_parts[1] )
										encode_ele.href = tag_parts[1].replace(/"/gi,'');
									else
										encode_ele.href = tag_content;
									if( typeof tag_content == "string" )
										encode_ele.appendChild( document.createTextNode( tag_content ) );
									else if( typeof tag_content == "object" )
										encode_ele.appendChild( tag_content );
									encode_ele.target = "_blank";
									encode_ele.className = "link";
									break;
								case 'size':
									encode_ele = oneNodeSpan( tag_content, null, null );
									encode_ele.style.fontSize = tag_val[1];
									break;
								case 'color':
									encode_ele = oneNodeSpan( tag_content, null, null );
									encode_ele.style.color = tag_val[1].replace(/"/gi,'');
									break;
								case 'align':
									encode_ele = oneDiv( tag_content, null, null );
									encode_ele.style.marginLeft = 'auto';
									encode_ele.style.marginRight = 'auto';
									if(tag_val[1])
									{
										var a = tag_val[1].replace(/"/gi,'')
										if( a == 'center' || a == 'left' || a == 'right' || a == 'justify')
											encode_ele.style.textAlign = a;
										if( a == 'left' || a == 'right')
										{
											encode_ele.style.cssFloat = a;
											encode_ele.style.styleFloat = a;
										}
									}
									break;
								case 'font':
									var font = tag_val[1].replace(/"/gi,'');
									if(tag_parts[1])
										font += ' '+tag_parts[1].replace(/"/gi,'');
									var f = '';
									
									switch(font)
									{
										case "arial":
											f="arial,helvetica,sans-serif";
											break;
										case "arial black":
											f="'arial black',gadget,sans-serif";
											break;
										case "comic sans":
											f="'comic sans MS',cursive";
											break;
										case "courier new":
											f="'courier new',courier,monospace";
											break;
										case "georgia":
											f="georgia,serif";
											break;
										case "impact":
											f="impact,charcoal,sans-serif";
											break;
										case "lucida":
											f="'lucida console',monaco,monospace";
											break;
										case "lucida sans unicode":
											f="'lucida sans unicode','lucida grande',sans-serif";
											break;
										case "palatino":
											f="'palatino linotype','book antiqua',palation,serif";
											break;
										case "tahoma":
											f="tahoma,geneva,sans-serif";
											break;
										case "times new roman":
											f="'times new roman',times,serif";
											break;
										case "trebuchet":
											f="'trebuchet MS',helvetica,sans-serif";
											break;
									}
									encode_ele = oneNodeSpan( tag_content, null, null );
									encode_ele.style.fontFamily = f;
									break;
								case 'list':
									var encode_ele = document.createElement('ul');
									var items = raw_content.split('[*]');
									for(var i = 1, item; item = items[i]; i++)
									{
										var li = document.createElement('li');
										li.appendChild(bbencode2(item));
										encode_ele.appendChild(li);
									}
									break;
								case 'quote':
									encode_ele = document.createElement('blockquote');
									encode_ele.appendChild(document.createElement('hr'));
									encode_ele.appendChild(tag_content);
									encode_ele.appendChild(document.createElement('hr'));
									break;
								case 'code':
									encode_ele = document.createElement('blockquote');
									var t = ''
									if(tag_parts[1])
										t = tag_val[1].replace(/"/gi,'');
										
									encode_ele.appendChild(document.createTextNode("Code: "+t));
									encode_ele.appendChild(document.createElement('hr'));
									var code_ele = document.createTextNode(raw_content);
									//alert(code_ele);
									//code_ele.style.color="red";
									
									//code.style.fontFamily = "'courier new',courier,monospace";
									encode_ele.appendChild(code_ele);
									encode_ele.appendChild(document.createElement('hr'));
									break;
								case 'box':
										encode_ele = document.createElement('table');
										encode_ele.cellPadding = 0;
										encode_ele.cellSpacing = 0;
										encode_ele.className = 'standard_text';
										var color = tag_val[1] ? tag_val[1].replace(/"/gi,''):'#FFE199';
										encode_ele.style.backgroundColor = color;
											var tbody = document.createElement('tbody');
												var tr = document.createElement('tr');
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_top_left.png',12,12));
														tr.appendChild(td);
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_top.png','100%',12));
														tr.appendChild(td);
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_top_right.png',12,12));
														tr.appendChild(td);
												tbody.appendChild(tr);
												var tr = document.createElement('tr');
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_left.png',12,'100%'));
														tr.appendChild(td);
													var td = document.createElement('td');
														td.appendChild(tag_content);
														td.width = '100%';
														td.height = '100%';
														tr.appendChild(td);
													var td = document.createElement('td');
													td.appendChild(makeImg('./img/border_right.png',12,'100%'));
													tr.appendChild(td);
												tbody.appendChild(tr);
												var tr = document.createElement('tr');
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_bottom_left.png',12,35));
														tr.appendChild(td);
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_bottom.png','100%',35));
														tr.appendChild(td);
													var td = document.createElement('td');
														td.appendChild(makeImg('./img/border_bottom_right.png',12,35));
														tr.appendChild(td);
												tbody.appendChild(tr);
										encode_ele.appendChild(tbody);
									break;
								case 'headlines':
								case 'map':
								case 'metaplace':
								case 'tagList':
								case 'pictureList':
								case 'youtube':
									encode_ele = oneNodeSpan('[[SERVER_CONTENT: CANNOT DISPLAY IN PREVIEW]]',null,null,'red');
									break;
								default:
									encode_ele = line.substring( s1, ( e_tag + 2 + tag.length + 1 ) );
									break;
							}
							line_span = nNodeSpan( line.substring( 0, s1 ), encode_ele, bbencode2( line.substring( ( e_tag > 0 ? ( e_tag + 2 + tag.length ) + 1 : s2 + 1 ) ) ) );
						}
						else
							line_span = oneNodeSpan( line );
					}
					else
						line_span = oneNodeSpan( line );
				}
				else
					line_span = oneNodeSpan( line );
					
				return line_span;
			}

			function bbencode( line )
			{
				var s1 = line.indexOf( '[' );
				var s2 = line.indexOf( ']' );
				var tag_parts = line.substring( s1 + 1, s2 ).split( "=" );
				var tag = tag_parts[0];
				if( tag )
				{
					var e_tag = line.indexOf( '[/'+tag+']' );
					if( e_tag )
					{
						var tag_content = line.substring( s2+1, e_tag );
						var encode_ele = null;
						switch( tag )
						{
							case 'b':
								encode_ele = oneNodeSpan( tag_content, null, null, 'bold' );
								break;
							case 'img':
								encode_ele = makeImg( tag_content );
								break;
							case 'url':
								encode_ele = document.createElement( "a" );
								if( tag_parts[1] )
									encode_ele.href = tag_parts[1];
								else
									encode_ele.href = tag_content;
								encode_ele.appendChild( document.createTextNode( tag_content ) );
								encode_ele.target = "_blank";
								encode_ele.className = "link";
								break;
							default:
								encode_ele = line.substring( s1, ( e_tag + 2 + tag.length ) );
								break;
						}
						line_span = nNodeSpan( line.substring( 0, s1 ), encode_ele, bbencode( line.substring( ( e_tag + 2 + tag.length ) + 1 ) ) );
					}
					else
						line_span = oneNodeSpan( line );
				}
				else
					line_span = oneNodeSpan( line );

				return line_span;
			}
			function scrollWindow( content, width, height, id )
			{
				id = ( id ? id : 'default' );
				scroll_offset[id] = 0;

				//width = ( width ? width : "100%" );
				//height = ( height ? height : "100%" );

				//make content window
				var outer_div = document.createElement( "div" );

				if( id )
					outer_div.id = id+"_scroll_parent";
				else
					outer_div.id = "scroll_parent";
				outer_div.style.position = "absolute";

				var clipSize = width - 8;
				outer_div.style.width = clipSize;
				outer_div.style.height = height;
				//outer_div.className = "tab_border";

				outer_div.style.maxWidth = clipSize;
				outer_div.style.maxHeight = height;

				outer_div.style.clip = "rect(0, "+clipSize+", "+height+", 0)";

				var inner_div = document.createElement( "div" );
				inner_div.style.position = "absolute";
				inner_div.style.width = clipSize;
				if( id )
					inner_div.id = id+"_scroll_window";
				else
					inner_div.id = "scroll_window";
				inner_div.style.top = 0;

				var table = document.createElement( "table" );
				table.appendChild( content );
				//table.border = 1;
				table.style.width = clipSize;
				//table.width = "100%";
				inner_div.appendChild( table );
				outer_div.appendChild( inner_div );

				//make scroll bars
				var scrollBars = document.createElement( "table" );
					var tbody = document.createElement( "tbody" );
						var row = document.createElement( "tr" );
							var cell = oneCell( makeImg( "./img/scroll_up0.gif", 11 , 9), null, 2, "tab_border center", ( id ? id+"_" : '' )+"scroll_up_max" );
							cell.onmouseup = new Function( "return stopScroll();" );
							cell.onmouseout = new Function( "return stopScroll();" );
							cell.style.height = 11;
							cell.style.width = 11;
						row.appendChild( cell );
					tbody.appendChild( row );
						var row = document.createElement( "tr" );
							var cell = document.createElement( "td" );
								var table1 = document.createElement( "table" );
									var tbody1 = document.createElement( "tbody" );
										var row1 = document.createElement( "tr" );
												var div = document.createElement( "div" );
												div.style.width = 2;
												div.style.height = 0;
												div.style.position = "relative";
												div.style.top = 0;
												div.className = "tab_grey";
												div.id = id+"_scroll_mark"
											var cell1 = oneCell( div, null, null, "solid" );
											cell1.style.verticalAlign = "top";
											cell1.valign = "top";
											cell1.setAttribute( "vAlign", "top");
											cell1.style.width = 1;
											cell1.style.height = (height/2 - 11)*2+2;
											cell1.id = id+"_scroll_mark_parent";
										row1.appendChild( cell1 );
									tbody1.appendChild( row1 );
								table1.appendChild( tbody1 );
								table1.cellPadding = 0;
								table1.CellSpacing = 0;
							cell.appendChild( table1 );
							cell.cellPadding = 0;
							cell.CellSpacing = 0;
							cell.style.width = 1;
							cell.style.height = height - 11;
						row.appendChild( cell );
							var cell = document.createElement( "td" );
								var table2 = document.createElement( "table" );
									var tbody2 = document.createElement( "tbody" );
										var row2 = document.createElement( "tr" );
											var cell2 = oneCell( makeImg( "./img/scroll_up0.gif", 10, 9), null, null, "center tab_border", ( id ? id+"_" : '' )+"scroll_up" );
											cell2.onmouseup = new Function( "return stopScroll();" );
											cell2.onmouseout = new Function( "return stopScroll();" );
											cell2.style.height = height/2 - 11;
											cell2.style.width = 10;
											cell2.cellPadding = 0;
											cell2.CellSpacing = 0;
											cell2.border=0;
										row2.appendChild( cell2 );
									tbody2.appendChild( row2 );
										var row2 = document.createElement( "tr" );
											var cell2 = oneCell( makeImg( "./img/scroll_down0.gif", 10, 9), null, null, "center tab_border", ( id ? id+"_" : '' )+"scroll_down" );
											cell2.onmouseup = new Function( "return stopScroll();" );
											cell2.onmouseout = new Function( "return stopScroll();" );
											cell2.style.height = height/2 - 11;
											cell2.style.width = 10;
											cell2.cellPadding = 0;
											cell2.CellSpacing = 0;
											cell2.border=0;
										row2.appendChild( cell2 );
									tbody2.appendChild( row2 );
								table2.appendChild( tbody2 );
								table2.cellPadding = 0;
								table2.CellSpacing = 0;
							cell.appendChild( table2 );
							cell.cellPadding = 0;
							cell.CellSpacing = 0;
						row.appendChild( cell );
						row.cellPadding = 0;
						row.CellSpacing = 0;	
					tbody.appendChild( row );
						var row = document.createElement( "tr" );
							var cell = oneCell( makeImg( "./img/scroll_down0.gif", 11 , 9), null, 2, "tab_border center", ( id ? id+"_" : '' )+"scroll_down_max" );
							cell.onmouseup = new Function( "return stopScroll();" );
							cell.onmouseout = new Function( "return stopScroll();" );
							cell.style.height = 11;
							cell.style.width = 11;
						row.appendChild( cell );
					tbody.appendChild( row );
				scrollBars.appendChild( tbody );
				scrollBars.cellPadding = 0;
				scrollBars.cellSpacing = 0;

				//throw it all together
				var tbody = document.createElement( "tbody" );
				
				cell1 = oneCell( outer_div );
				cell1.id = "scrollcontainer";
				cell1.style.width = width - 3;
				cell1.style.height = height;
				cell1.style.verticalAlign = "top";
				cell1.valign = "top";
				cell1.setAttribute( "vAlign", "top");

				if (cell1.addEventListener)
				{
					cell1.addEventListener('DOMMouseScroll', wheel, false);
					cell1.addEventListener('mousewheel', wheel, false);
				}

				cell1.onmousewheel = wheel;
				cell1.onmouseover = new Function( "return setWheelWindow( '"+id+"' );" );

				cell2 = oneCell( scrollBars, null, null, null, ( id ? id+"_" : '' )+"scrollUpDown" );
				cell2.style.width = 12;
				cell2.cellPadding = 0;
				cell2.cellSpacing = 0;

				tbody.appendChild( twoCellRow( cell1, cell2, "table_style", null, true ) );

				return tbody;				
			}
 

			function startScroll( dir, offset, id )
			{
				scroll_interval = setInterval( "scroll( '"+dir+"', "+offset+( id ? ", '"+id+"'": ' ' )+" )", 50 );
			}
			function stopScroll()
			{
				if( scroll_interval )
					clearInterval( scroll_interval );
			}

			function scrollBottom( id )
			{
				if( ! id )
					var id = "default";

				var scroll_parent = document.getElementById( id+"_scroll_parent");
				var scroll_window = document.getElementById( id+"_scroll_window");

				if( scroll_window.clientHeight >= scroll_parent.clientHeight )
				{
					var scroll_diff = scroll_window.clientHeight - scroll_parent.clientHeight;

					if( scroll_offset[id] <= -scroll_diff )
						return true;
				}
				
				return false;
			}
			function scroll( dir, offset, id )
			{
				if( ! offset )
					offset = 5;

				if( ! id )
					var id = "default";

				var scroll_parent = document.getElementById( id+"_scroll_parent");
				var scroll_window = document.getElementById( id+"_scroll_window");
				var mark = document.getElementById( id+"_scroll_mark");
				var mark_parent = document.getElementById( id+"_scroll_mark_parent");

				if( scroll_offset[id] == null )
					scroll_offset[id] = 0;

				if( scroll_window.clientHeight >= scroll_parent.clientHeight )
				{
					scroll_diff = scroll_window.clientHeight - scroll_parent.clientHeight;

					if( dir == 'top' )
						scroll_offset[id] = 0;
					if( dir == 'up' )
						scroll_offset[id] = scroll_offset[id] + offset;
					if( dir == 'down' )
						scroll_offset[id] = scroll_offset[id] - offset;
					if( dir == 'bottom' )
						scroll_offset[id] = -scroll_diff;

					if( scroll_offset[id] >= 0 )
					{
						scroll_offset[id] = 0;

						var img_up = 0;
						var onclick_up = null;
						var class_up = 'tab_border';

						var img_up_max = 0;
						var onclick_up_max = null;
						var class_up_max = 'tab_border';

						var img_down = 1;
						var onclick_down = "startScroll( 'down', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_down = "tab_border link";

						var img_down_max = 1;
						var onclick_down_max = "startScroll( 'bottom', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_down_max = "tab_border link";
					}
					else if( scroll_offset[id] <= -scroll_diff )
					{
						scroll_offset[id] = -scroll_diff;

						var img_up = 1;
						var onclick_up = "startScroll( 'up', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_up = 'tab_border link';

						var img_up_max = 1;
						var onclick_up_max = "startScroll( 'top', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_up_max = 'tab_border link';

						var img_down = 0;
						var onclick_down = null;
						var class_down = "tab_border";

						var img_down_max = 1;
						var onclick_down_max = "startScroll( 'bottom', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_down_max = "tab_border link";
					}
					else
					{
						var img_up = 1;
						var onclick_up = "startScroll( 'up', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_up = 'tab_border link';

						var img_up_max = 1;
						var onclick_up_max = "startScroll( 'top', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_up_max = 'tab_border link';

						var img_down = 1;
						var onclick_down = "startScroll( 'down', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_down = "tab_border link";

						var img_down_max = 1;
						var onclick_down_max = "startScroll( 'bottom', "+offset+( id ? ", '"+id+"'": ' ' )+" );";
						var class_down_max = "tab_border link";
					}

					scroll_window.style.top = scroll_offset[id];
				}
				else
				{
					var img_up = 0;
					var onclick_up = null;
					var class_up = 'tab_border';

					var img_up_max = 0;
					var onclick_up_max = null;
					var class_up_max = 'tab_border';

					var img_down = 0;
					var onclick_down = null;
					var class_down = 'tab_border';

					var img_down_max = 0;
					var onclick_down_max = null;
					var class_down_max = 'tab_border';
				}
				if( scroll_window.clientHeight >= scroll_parent.clientHeight )
				{
					mark.style.height = Math.round( (mark_parent.clientHeight * scroll_parent.clientHeight) / scroll_window.clientHeight );
					var pos_per = Math.round( ( scroll_offset[id] / scroll_window.clientHeight ) * 1000 ) / 1000;
					var pos = mark_parent.clientHeight * pos_per;
					mark.style.top = -pos;
				}
				var scroll_up = document.getElementById( ( id ? id+"_" : '' )+"scroll_up" );
				var scroll_down = document.getElementById( ( id ? id+"_" : '' )+"scroll_down" );
				var scroll_up_max = document.getElementById( ( id ? id+"_" : '' )+"scroll_up_max" );
				var scroll_down_max = document.getElementById( ( id ? id+"_" : '' )+"scroll_down_max" );


				var scroll_UpDown = document.getElementById( ( id ? id+"_" : '' )+"scrollUpDown" );

				if( onclick_up )
					scroll_up.onmousedown = new Function( "return "+onclick_up );
				scroll_up.className = class_up;
				clearElement( scroll_up );
				scroll_up.appendChild( makeImg( "./img/scroll_up"+img_up+".gif", 11, 9 ) );

				if( onclick_up_max )
					scroll_up_max.onmousedown = new Function( "return "+onclick_up_max );
				scroll_up_max.className = class_up_max;
				clearElement( scroll_up_max );
				scroll_up_max.appendChild( makeImg( "./img/scroll_up"+img_up+".gif", 11, 9 ) );

				if( onclick_down )
					scroll_down.onmousedown = new Function( "return "+onclick_down );
				scroll_down.className = class_down;
				clearElement( scroll_down );
				scroll_down.appendChild( makeImg( "./img/scroll_down"+img_down+".gif", 11, 9 ) );

				if( onclick_down_max )
					scroll_down_max.onmousedown = new Function( "return "+onclick_down_max );
				scroll_down_max.className = class_down_max;
				clearElement( scroll_down_max );
				scroll_down_max.appendChild( makeImg( "./img/scroll_down"+img_down+".gif", 11, 9 ) );

				if( scroll_UpDown.captureEvents )
					scroll_UpDown.captureEvents( Event.mousedown );
			}
			function fadeNewData( id, tag, timer, ele )
			{
				if( ele )
					var element = ele;
				else
					var element = document.getElementById( tag+"_"+id );

				if( element )
				{
					var string = element.style.backgroundColor;
					var yellowHex = null;
					if( agent == "firefox" )
					{
						var rgb_string = string.substring( 3, string.indexOf( ')' ) );
						var rgb = rgb_string.split( ',' );
	
						var yellowDec = parseInt( rgb[2] );
					}
					else
					{
						var yellowHex = string.substring( 5 );
						var yellowDec = parseInt( "0x"+yellowHex, 16 );
					}

					yellowDec = yellowDec + 2;

					if( yellowDec >= 255 )
					{
						yellowDec = 255;
						var c_id = tag+'_'+id;

						clearInterval( timer[c_id] );
					}
					yellowHex = yellowDec.toString( 16 );
					yellowHex = ( yellowHex.length == 1 ? yellowHex+"0" : yellowHex );

					yellowHex = "#ffff"+yellowHex;
					element.style.backgroundColor = yellowHex;			
				} else {
					var c_id = tag+'_'+id;
					clearInterval( timer[c_id] );
				}
			}
			function timerDisplay( timer )
			{
				if( timers[timer] )
				{
					var element = document.getElementById( "timer_display_"+timer );
					if( element )
					{
					}
				}
			}
			function xmlVal( element, key )
			{
				var val = null;

				if( element && key )
				{
					var child = element.getElementsByTagName( key )[0];
					if( child )
					{
						if( child.hasChildNodes() )
						{
							if( typeof child.firstChild.nodeValue == "string" )
								val = child.firstChild.nodeValue;
							else if( typeof child.firstChild.nodeValue == "object" )
								val = child;
						}
					}
				}
				return val;
			}
			function xmlList( element, key )
			{
				if( element && key )
				{
					var child = element.getElementsByTagName( key );
					if( child )
					{
						return child;
					}
				}
				return null;
			}
			function showDebug( debug_content )
			{
				var debug = document.getElementById("debug");
				clearElement( debug );		
				if( typeof debug_content  == "string" )
					debug.appendChild( document.createTextNode( debug_content ) );
				else if( typeof debug_content  == "object" )
					debug.appendChild( debug_content );
			}
			function calcTime()
			{
				var div = document.getElementById("timeDisplay");
				clearElement( div );
				var netTime = ( time2.getTime() - time1.getTime() ) / 1000;
				var ts = netTime.toString();
				var span1 = nNodeSpan( "Network Time: ", ts, "sec", " (incl. Server time: ", data.getElementsByTagName("serverTime")[0].firstChild.nodeValue, "sec)" );

				var proTime = ( time3.getTime() - time2.getTime() ) / 1000;
				var ts = proTime.toString();
				var span2 = nNodeSpan( "Processing Time: ", ts, "sec" );

				var totalTime = ( time3.getTime() - time1.getTime() ) / 1000;
				var ts = totalTime.toString();
				var span3 = nNodeSpan( "Total Time: ", ts, "sec" );
//alert(proTime);
				div.appendChild( oneCellRow( span1 ) );
				div.appendChild( oneCellRow( span2 ) );
				div.appendChild( oneCellRow( span3 ) );
			}

			function orderTabs( id, page_view )
			{
				if( id )
				{
					var row = document.getElementById( id );
					if( row )
					{
						var element = null;
						var bust = true;
						if( row.hasChildNodes() )
						{
							if( row.childNodes.length > 1 )
							{
								if( page_view )
								{
									for( var i = 0; i < row.childNodes.length; i++ )
									{
										var ele = row.childNodes[i];
										if( ele.getAttribute( "id" ) == page_view )
										{
											element = ele;
											var pos = i;
											break;
										}
									}
									if( pos )
										bust = false;
	
								}
								if( bust && row.childNodes.length >= 4 )
								{
									var element = row.childNodes[2];
									var pos = 2;
								}

								if( element )
								{
									if( pos == 2 )
									{
										clearElement( row.childNodes[1] );
										row.childNodes[1].appendChild( makeImg( './img/tab_left_1.gif', 15, 15 ) );
										row.childNodes[1].className = null;
									}
									else
									{
										clearElement( row.childNodes[pos-1] );
										row.childNodes[pos-1].appendChild( makeImg( './img/tab_middle_0_1.gif', 15, 15 ) );
										row.childNodes[pos-1].className = null;
									}
									if( row.childNodes.length > pos + 2 )
									{
										clearElement( row.childNodes[pos+1] );
										row.childNodes[pos+1].appendChild( makeImg( './img/tab_middle_1_0.gif', 15, 15 ) );
										row.childNodes[pos+1].className = null;
									}
									else
									{
										clearElement( row.childNodes[pos+1] );
										row.childNodes[pos+1].appendChild( makeImg( './img/tab_right_1.gif', 15, 15 ) );
										row.childNodes[pos+1].className = null;
									}
									element.className = " table_style tab_top";
									element.onclick = null;
								}
			
								row.appendChild( oneCell( makeImg( './img/blank.gif', 1, 1 ), null, null, "tab_bottom" ) );
							}
						}
					}
				}
			}

			function addTab( id, name, onclick, s_v )
			{
				var element = document.getElementById( id );

				if( element )
				{
					if( name )
					{

						var pos = (element.childNodes.length > 1 ? element.childNodes.length - 1 : 1 );

						if( pos > 0 )
						{
							if( pos == 1 )
								element.appendChild( oneCell( makeImg( './img/tab_left_0.gif', 15, 15 ), null, null, "tab_bottom" ) );
							else
							{
								var cell = element.childNodes[pos];
								if( cell )
								{
									clearElement( cell );
									cell.appendChild( makeImg( './img/tab_middle_0_0.gif', 15, 15 ) );
								}
							}
							var cell = oneCell( " "+name+" ", onclick, null, "tab_grey tab_top tab_bottom link standard_text", s_v );
							cell.cellPadding = 1;
							element.appendChild( cell );

							element.appendChild( oneCell( makeImg( './img/tab_right_0.gif', 15, 15 ), null, null, "tab_bottom" ) );
						}
					}
				}
			}
			function newTabs( id )
			{

				var table = document.createElement( "table" );
					var tbody = document.createElement( "tbody" );
						var row = document.createElement( "tr" );
						row.id = id;
							var cell = oneCell( makeImg('./img/blank.gif', 1, 1 ), null, null, "w100p tab_bottom" );
							cell.style.bgColor = '';
						row.appendChild( cell );
						row.style.bgColor = null;
					tbody.appendChild( row );
				table.appendChild( tbody );
				table.cellPadding = 0;
				table.cellSpacing = 0;
				table.className = 'w100p';

				return table;
			}
			function defaultDisplayTable( grid_body, header, body, link_function, no_pages, var_width, var_height, body_span )
			{
				grid_body.cellPadding = 0;
				body_span = ( body_span ? body_span : 2 );
				var top_row = document.createElement("tr");
				var top_cell = document.createElement("td");
				top_cell.cellPadding = 1;
				top_cell.vAlign = "top";
				top_cell.style.verticalAlign = "top";

					var table = document.createElement("table");
					table.className = "table_style";
					//table.style.borderWidth = "1";
					//table.style.borderStyle = "solid";
					//table.style.borderColor = "black";
					table.cellSpacing = 0;
					table.cellPadding = 0;
					table.style.height = "100%";
					table.vAlign = "top";
					table.style.verticalAlign = "top";
					table.border=0;

						var tbody = document.createElement("tbody");
	
						if( header )
							tbody.appendChild( header );

							var cell = oneCell( '', null, body_span, "table_style"  );
							var row = document.createElement( "tr" );
							row.appendChild( cell );
							if( body )
								body.appendChild( row );

							var table2 = document.createElement( "table" );

								var content_body = document.createElement( "tbody" );

								var table3 = document.createElement( "table" );

								if( body )
									table3.appendChild( body );
								table3.border=0;
								table3.cellPadding = 2;
								table3.cellSpacing = 0;
								table3.style.width = "100%";

								table3.style.height = "100%";
								table3.style.verticalAlign = "top";
								table3.vAlign = "top";
								content_body.appendChild( oneCellRow( table3 ) );
								content_body.appendChild( oneCellRow( '' ) );

							table2.className = "no_solid_100";
							table2.appendChild( content_body );

							table2.border=0;
							table2.cellPadding = 0;
							table2.cellSpacing = 0;
							table2.style.verticalAlign = "top";
							table2.vAlign = "top";
							if( var_height )
							{
								var body_height = var_height - 14;
								if( ! no_pages )
									body_height -= 14;

								table2.style.height = body_height;
							}
						tbody.appendChild( oneCellRow( table2, null, body_span, "table_style tab_left tab_right "+( no_pages ? 'tab_bottom' : '' )+" "+( header ? '' : 'tab_top' ) ) );
						var row = oneCellRow( '', null, body_span, "table_style" );
						row.style.height = "100%";
						tbody.appendChild( row );

						if( ! no_pages )
						{
							var pages = xmlVal( data, "pages" );
							if( pages )
							{
								tbody.appendChild( page_links( xmlVal( data, "page" ), pages, link_function, body_span, true ) );
							}
						}
					table.appendChild( tbody );
	
					if( var_width )
						table.style.width = var_width;

					if( var_height )
						table.style.height = var_height;

				top_cell.appendChild( table );
				top_row.appendChild( top_cell );

				grid_body.appendChild( top_row );				
			}
			function page_links( page, pages, link_function, body_span, border )
			{
				if( parseInt(page) > 1 && parseInt(pages) > 1 )
				{
					var temp_page = parseInt(page) - 1;
					onclickPrev = "defaultAJAX( '"+link_function[0]+"', new Array( "+parseArgs(link_function[1])+" ),  new Array( "+parseArgs(link_function[2])+" ), null, new Array( new Array( 'view1', '"+views['view1']+"' ), new Array( 'view2', '"+views['view2']+"' ) ), "+temp_page+" );";
					temp_style = "tab_closed link";
				}
				else
				{
					onclickPrev = null;
					temp_style = "tab_closed dead_link";
				}
				var cell1 = oneCell( "<--Prev Page", onclickPrev, null, temp_style );

				if( parseInt(page) < parseInt(pages) && parseInt(pages) > 1 && link_function )
				{
					var temp_page = parseInt(page) + 1;
					onclickNext = "defaultAJAX( '"+link_function[0]+"', new Array( "+parseArgs(link_function[1])+" ),  new Array( "+parseArgs(link_function[2])+" ), null, new Array( new Array( 'view1', '"+views['view1']+"' ), new Array( 'view2', '"+views['view2']+"' ) ), "+temp_page+" );";
					temp_style = "tab_closed link";
				}
				else
				{
					onclickNext = null;
					temp_style = "tab_closed dead_link";
				}
				var cell2 = oneCell( "Next Page-->", onclickNext, null, temp_style );

				tableB = document.createElement( "table" );
				tbodyB = document.createElement( "tbody" );
				tbodyB.appendChild( twoCellRow( cell1, cell2, null, null, true ) );
				tableB.appendChild( tbodyB );
				tableB.cellPadding = 0;
				tableB.border = 1;
				tableB.cellSpacing = 0;
				tableB.style.width = "250";
				//table.style.height = "100%";

				var row = oneCellRow( tableB, null, ( body_span ? body_span : null ), ( border ? "tab_bottom tab_left tab_right" : '' ) );
				row.align = "center";

				return row;
			}
			function parse_placement( min_rank, max_rank )
			{
				if( min_rank == max_rank || ! max_rank )
				{
					var pos = min_rank;
					if( parseInt( min_rank.substr( -1 ) ) == 1 && parseInt(min_rank) != 11 )
						pos += "st";
					else if( parseInt( min_rank.substr( -1 ) ) == 2 && parseInt(min_rank) != 12 )
						pos += "nd";
					else if( parseInt( min_rank.substr( -1 ) ) == 3 && parseInt(min_rank) != 13 )
						pos += "rd";
					else
						pos += "th";
				}
				else
				{
					var pos = min_rank;

					if( parseInt( min_rank.substr( -1 ) ) == 1 && parseInt(min_rank) != 11 )
						pos += "st";
					else if( parseInt( min_rank.substr( -1 ) ) == 2 && parseInt(min_rank) != 12 )
						pos += "nd";
					else if( parseInt( min_rank.substr( -1 ) ) == 3 && parseInt(min_rank) != 13 )
						pos += "rd";
					else
						pos += "th";

					pos += " - "+max_rank;

					if( parseInt( max_rank.substr( -1 ) ) == 1 && parseInt(max_rank) != 11 )
						pos += "st";
					else if( parseInt( max_rank.substr( -1 ) ) == 2 && parseInt(max_rank) != 12 )
						pos += "nd";
					else if( parseInt( max_rank.substr( -1 ) ) == 3 && parseInt(max_rank) != 13 )
						pos += "rd";
					else
						pos += "th";
				}

				return pos;
			}
			function selectBlinkElement( element )
			{
				var blink_off = false;
				if( blink_element instanceof Array && element instanceof Array )
				{
					if( blink_element[0].id == element[0].id )
						blink_off = true;
				}
				else if( element == blink_element )
					blink_off = true;

				blinkOn = false;
				blink();

				if( element && ! blink_off )
				{
					blink_element = element;
					if( blink_element instanceof Array )
					{
						for( var a = 0, element; element = blink_element[a]; a++ )
							blink_colour = element.style.backgroundColor;
					}
					else
						blink_colour = blink_element.style.backgroundColor;
					blinkOn = true;
		
					blink_interval = setInterval( "blink()", 500 );
				}
			}
			function blink()
			{
				if( blinkOn == false && blink_element != null )
				{
					clearInterval( blink_interval );
					if( blink_element instanceof Array )
					{
						for( var a = 0, element; element = blink_element[a]; a++ )
							element.style.backgroundColor = blink_colour;
					}
					else
						blink_element.style.backgroundColor = blink_colour;
					blink_element = null;
					blink_colour = null;
					return;
				}
				if( blinkOn )
				{
					if( blink_element instanceof Array )
					{
						for( var a = 0, element; element = blink_element[a]; a++ )
						{
							var bg_colour = element.style.backgroundColor;

							if( bg_colour == blink_colour )
								element.style.backgroundColor = "yellow";
							else
								element.style.backgroundColor = blink_colour;
						}
					}
					else
					{
						var bg_colour = blink_element.style.backgroundColor;
						if( bg_colour == blink_colour )
							blink_element.style.backgroundColor = "yellow";
						else
							blink_element.style.backgroundColor = blink_colour;
					}
				}
				else
					clearInterval( blink_interval );
			}
			function checkView()
			{
				if( arguments[0] && arguments.length >= 2 )
				{
					for( var a = 1, arg; arg = arguments[a]; a++ )
					{
						if( views[arguments[0]] == arg )
							return;

					}
					views[arguments[0]] = arguments[1];
				}
			}
