



function SetDragObjTd( tdObj, ptr )
{
	var obj = tdObj;
	do
	{
		obj = obj.parentNode;	
		if( obj.tagName.toLowerCase() == 'table' )
			break;
	}
	while( true );

	if( obj.tagName.toLowerCase() == 'table' )
	{
		gDragObj = obj.rows[0].cells[tdObj.cellIndex-1];
		gDragObj.setAttribute('cookieTdPtr', gCookie_TdWidthStr + ptr);
		gDragObj.setAttribute('tblWidth', obj.offsetWidth);
		obj.onmousemove = DragObjMoveTr;
		obj.onmousedown = DragObjMoveFocus;
		obj.onmouseup = DragObjMoveLoseFocus;
	}
}



function DragObjMoveTr( evt )
{
	if( gDragObj != null )
	{
		if( typeof(evt) == 'undefined' )
			evt = window.event||window.Event;
		var cookieTdPtr = gDragObj.getAttribute('cookieTdPtr');
		var tblWidth = gDragObj.getAttribute('tblWidth')|0;
		var oriX = gDragObj.getAttribute('originalDragX')|0;
		var oriWidth = gDragObj.getAttribute('originalDragW')|0;
		var x = evt.pageX || evt.clientX+document.body.scrollLeft-document.body.clientLeft;
		var w = oriWidth+x-oriX;

		if( w >= gCookie_TdMinWidth )
		{
			gDragObj.style.width = w;

			var obj = gDragObj;
			do
			{ obj = obj.parentNode; }
			while( obj.tagName.toLowerCase() != 'table' );

			while( obj.offsetWidth > tblWidth )
			{
				gDragObj.style.width = (--w);
			}

			document.cookie = cookieTdPtr+'='+w;
		}
	}
}



function DragObjMoveFocus( evt )
{
	if( gDragObj )
	{
		if( typeof(evt) == 'undefined' )
			evt = window.event||window.Event;
		if( evt.pageX )
			gDragObj.setAttribute('originalDragX', evt.pageX);
		else
			gDragObj.setAttribute('originalDragX', evt.clientX+document.body.scrollLeft-document.body.clientLeft);
		gDragObj.setAttribute('originalDragW', gDragObj.offsetWidth);
	}
}



function DragObjMoveLoseFocus()
{
	gDragObj = null;
}










function InputNum()
{
	var c = event.keyCode
	if( 
		c==8  || // back delete
		c==46 || // delete
		c==9  || // tab
		c==13 || // enter
		c==35 || // home
		c==36 || // end
		c==37 || // left arrow
		c==39 || // right arrow
		(c>=48&&c<=57) || // upper key 0 to 9
		(c>=96&&c<=105)   // num key 0 to 9
	)
		return true;
	return false;
}

function InputDouble()
{
	var c = event.keyCode
	if( 
		c==8   || // back delete
		c==46  || // delete
		c==9   || // tab
		c==13  || // enter
		c==35  || // home
		c==36  || // end
		c==190 || // char key .
		c==110 || // num key .
		c==37  || // left arrow
		c==39  || // right arrow
		(c>=48&&c<=57) || // upper key 0 to 9
		(c>=96&&c<=105)   // num key 0 to 9
	)
		return true;
	return false;
}



String.prototype.trim = function()
{ return this.replace(/(^\s*)|(\s*$)/g,""); }










/*
Browser Detecter 1.0
Written by David NG @ http://dwin.net ( 2004-08-16 )
Copyright(c) 1998-2004 dwin.net all rights reserved
*/
function BrowserDetectClass()
{
	this.Agent           = navigator.userAgent.toLowerCase();
	this.appName         = navigator.appName.toLowerCase();
	this.RTPass          = false;
	this.Version         = 0;
	this.Gecko_Version   = 0;

	this.Is_Windows      = this.Agent.indexOf("window") != -1;
	this.Is_Linux        = this.Agent.indexOf("linux") != -1;
	this.Is_Mac          = this.Agent.indexOf("mac") != -1;

	this.Is_appNascape   = this.appName.indexOf("netscape") != -1;
	this.Is_appIE        = this.appName.indexOf("internet explorer") != -1;
	this.Is_appKonqueror = this.appName.indexOf("konqueror") != -1;

	this.Is_DHTML        = document.getElementById?true:false || document.all?true:false || document.layers?true:false;
	this.Is_DOM          = document.getElementById?true:false && document.createElement?true:false;

	this.Is_IE           = false;
	this.Is_Opera        = false;
	this.Is_Netscape     = false;
	this.Is_Firebird     = false;
	this.Is_Mozilla      = false;
	this.Is_Konqueror    = false;
	this.Is_Gecko        = false;
	this.Is_HTMLEditor   = false;

	this.IE_PassVersion        = 4.01;
	this.Opera_PassVersion     = 7.21;
	this.Netscape_PassVersion  = 7.0;
	this.Firebird_PassVersion  = 0.6;
	this.Mozilla_PassVersion   = 1.6;
	this.Konqueror_PassVersion = 3.2;
	this.Gecko_PassVersion     = 20030312;
	this.IE_Editor_PassVersion = 5.5;



	if( this.Is_appIE )
	{
		this.Is_IE    = this.Agent.indexOf("msie") != -1;
		this.Is_Opera = this.Agent.indexOf("opera") != -1;
		if( this.Is_Opera )
			this.Version = GetVersion( "opera" );
		else
		{
			this.Version       = GetVersion( "msie" );
			this.Is_HTMLEditor = this.Version >= this.IE_Editor_PassVersion;
		}

		this.RTPass = ( ( this.Is_Opera && this.Version>=this.Opera_PassVersion ) || ( this.Is_IE && this.Version>=this.IE_PassVersion ) );
	}

	else if( this.Is_appNascape )
	{
		this.Is_Netscape = this.Agent.indexOf("netscape") != -1;
		if( this.Is_Netscape )
			this.Version = GetVersion( "netscape" );

		this.Is_Firebird = this.Agent.indexOf("firebird") != -1;
		if( this.Is_Firebird )
			this.Version = GetVersion( "firebird" );

		this.Is_Mozilla = this.Agent.indexOf("debian") != -1;
		if( this.Is_Mozilla )
			this.Version = GetVersion( "debian" );

		this.RTPass = ( ( this.Is_Firebird && this.Version>=this.Firebird_PassVersion ) || ( this.Is_Netscape && this.Version>=this.Netscape_PassVersion ) || ( this.Is_Mozilla && this.Version>=this.Mozilla_PassVersion )  );

		this.Is_Gecko = this.Agent.indexOf("gecko") != -1;
		if( this.Is_Gecko )
		{
			this.Gecko_Version = GetVersion( "gecko" );
			this.Is_HTMLEditor = this.Gecko_Version >= this.Gecko_PassVersion;
		}
	}

	else if( this.Is_appKonqueror )
	{
		this.Is_Konqueror = this.Agent.indexOf("konqueror") != -1;
		if( this.Is_Konqueror )
			this.Version = GetVersion( "konqueror" );

		this.RTPass = ( this.Is_Konqueror && this.Version>=this.Konqueror_PassVersion );
	}



	function GetVersion( str )
	{
		var iAgent     = navigator.userAgent.toLowerCase();
		var i          = iAgent.indexOf( str );
		var iLen       = iAgent.length;
		var iTemp      = 0;
		var iVersion   = "";

		for( ; i<iLen; i++ )
		{
			iTemp = iAgent.charAt(i);
			//if( ( iTemp>=0 && iTemp<=9 ) || ( iTemp=="." && iVersion.indexOf(".")==-1 ) )
			if( iTemp=="." && iVersion.indexOf(".")!=-1 )
				continue;
			if( ( iTemp>=0 && iTemp<=9 ) || iTemp=="." )
				iVersion += iTemp;
			else if( iVersion != "" )
				return iVersion;
		}
		return iVersion;
	}
}
var BrowserObj = new BrowserDetectClass();










// clear all <select> -> <option>
function Clear_All_Select_Option( SelectObj )
{
	while( SelectObj.length > 0 )
		Clear_Select_Option( SelectObj, 0 );
}

// clear one <select> -> <option>
function Clear_Select_Option( SelectObj, index )
{
	if( BrowserObj.Is_Firefox || BrowserObj.Is_Firebird ) // for FireFox
		SelectObj.remove(index);
	else // default for IE
		SelectObj.options.remove(index);
}



function GetNewValidImage( ID )
{
	if( document.getElementById )
	{
		var obj = document.getElementById(ID)
		obj.alt = "Loading...";
		obj.src = "#";

		window.setTimeout( 'SetValidImage("'+ID+'")', 100 );
	}
	else
		alert("Feature does not support.");		
}



function SetValidImage( ID )
{
	if( document.getElementById )
	{
		var newSessionValue = Math.round(Math.random()*100000);
		document.getElementById(ID).src = 'validImage.php?s='+newSessionValue;
	}
}










function FocusSelet( obj )
{
	obj.focus();
	if( obj.value.length > 0 )
		obj.select();
}



function BlurObj( obj )
{
	if( obj.value.length > 0 )
	{
		iValue    = obj.value;
		obj.value = "";
		obj.value = iValue;
	}
	obj.blur();
}



function BlankBlock( iHeight, ClassName )
{
	if( typeof ClassName=="undefined" || ClassName=="" )
		document.write('<div style="width:5;height:'+ iHeight +';background:transparent;overflow:hidden"></div>');
	else
		document.write('<div style="width:100%;height:'+ iHeight +';overflow:hidden" class='+ ClassName +'></div>');
}










function CreatePostFaceIMG( )
{
	var str = "";

	for( var i=1; i<=58; i++ )
	{
		str += "<a href='javascript:/**/' onfocus='this.blur()'><img src='"+ Forum_IconFacePath + i +".gif' onmouseover='this.className=\"EditorFaceOver\"' onmouseout='this.className=\"EditorFaceNormal\"' onmousedown='ChangePostFaceURL("+ i +");this.className=\"EditorFaceDown\"' onmouseup='this.className=\"EditorFaceOver\"' class='EditorFaceNormal' /></a>";
	}

	document.write( str );
}



function CreatePostFaceBase( iValue )
{
	if( iValue )
		document.write( "<a href='javascript:/**/' onfocus='this.blur()'><img id='IconFace' src='"+ Forum_IconFacePath + iValue +".gif' style='display:block' onmousedown='ChangePostFaceURL(0)' onmouseover='this.className=\"EditorFaceOver\"' onmouseout='this.className=\"EditorFaceNormal\"' class='EditorFaceNormal' /></a>" );

	else
		document.write( "<a href='javascript:/**/' onfocus='this.blur()'><img id='IconFace' style='display:none' onmousedown='ChangePostFaceURL(0)' onmouseover='this.className=\"EditorFaceOver\"' onmouseout='this.className=\"EditorFaceNormal\"' class='EditorFaceNormal' /></a>" );
}



function ChangePostFaceURL( iValue )
{
	var iVisi = "none";

	if( iValue > 0 )
	{
		iVisi = "block";
		document.images["IconFace"].src = Forum_IconFacePath+iValue+".gif";
	}
		


	try
	{
		if( BrowserObj.Is_DOM )
		{
			document.getElementById("IconFace").style.display = iVisi;
			document.getElementById("IconFaceValue").value = iValue;
		}
		else
		{
			IconFace.style.display = iVisi;
			IconFaceValue.value = iValue;
		}
	}
	catch(e){};
}









/*
http://dwin.net
Copyright(c) 1998-2004 dwin.net all rights reserved

Start  2004-04-01 18:15
Finish 2004-04-02 02:05
Last Edit 2004-04-10 02:52

URLEncode and URLDecode in JS
*/

function URLEncode( Str )
{
	if( Str==null || Str=="" )
		return "";
	var newStr = "";

	for(var i=0,icode,len=Str.length; i<len; i++ )
	{
		icode = Str.charCodeAt(i);
		if( icode<0x10 )
			newStr += "%0"+icode.toString(16).toUpperCase();
		else if( icode<0x80 )
		{
			if( icode==0x20 )
				newStr += "+";
			else if( (icode>=0x30 && icode<=0x39) || (icode>=0x41 && icode<=0x5A) || (icode>=0x61 && icode<=0x7A) )
				newStr += Str.charAt(i);
			else
				newStr += "%"+icode.toString(16).toUpperCase();
		}
		else if( icode<0x800 )
		{
			newStr += "%"+(0xC0+(icode>>6)).toString(16).toUpperCase();
			newStr += "%"+(0x80+icode%0x40).toString(16).toUpperCase();
		}
		else
		{
			newStr += "%"+(0xE0+(icode>>12)).toString(16).toUpperCase();
			newStr += "%"+(0x80+(icode>>6)%0x40).toString(16).toUpperCase();
			newStr += "%"+(0x80+icode%0x40).toString(16).toUpperCase();
		}
	}
	return newStr;
}


function URLDecode( Str )
{
	if( Str==null || Str=="" )
		return "";
	var newStr = "";

	for(var i=0,ichar,len=Str.length; i<len;  )
	{
		if( Str.charAt(i)=="%" )
		{
			ichar = Str.charAt(i+1);
			if( ichar.toLowerCase()=="e" )
			{
				newStr += String.fromCharCode((parseInt("0x"+Str.substr(i+1,2))-0xE0)*0x1000+(parseInt("0x"+Str.substr(i+4,2))-0x80)*0x40+parseInt("0x"+Str.substr(i+7,2))-0x80);
				i += 9;
			}
			else if( ichar.toLowerCase()=="c" || ichar.toLowerCase()=="d" )
			{
				newStr += String.fromCharCode((parseInt("0x"+Str.substr(i+1,2))-0xC0)*0x40+parseInt("0x"+Str.substr(i+4,2))-0x80);
				i += 6;
			}
			else
			{
				newStr += String.fromCharCode(parseInt("0x"+Str.substr(i+1,2)));
				i += 3;
			}
		}
		else
		{
			newStr += Str.charAt(i).replace(/\+/," ");
			i++;
		}
	}
	return newStr;
}
