function setMsg(msg)
{
	window.status = msg;
	return true;
}

function ServerRequest( url, data )
{
	if( navigator.appName == "Microsoft Internet Explorer") 
		response = new ActiveXObject("Microsoft.XMLHTTP"); //IE
	else
		response = new XMLHttpRequest();	//Netscape and others
	response.open("POST", url, false );
	response.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	response.send( data );
	return response.responseText;
}

//Set visibility with transition
function SetVisibility( id, vis )
{
	obj = document.getElementById( id )
	if( document.all ) //if explorer
	{		
		obj.filters[0].Apply();
		obj.style.visibility = vis;	 
		obj.filters[0].Play(); 
	}
	else
		obj.style.visibility = vis;		      
}

function popup( page, args )
{
  window.open(page, null, args);
}

function newBrowserWindow( page )
{
  window.open(page, null, "scrollbars, resizable, status, toolbar, menubar");
}

function popupWindow( page, name, args )
{
  win = window.open(page, name, args);
  win.focus();
}

function ShowPosting( postCode, fromSection )
{
  popupWindow("/index.php?Popup=1&Page="+postCode+"&From="+fromSection, "CIPosting", "width=810,height=700,resizable,scrollbars,status");
}

//Expand text area for editing
var Expanded = null;
var ExpandedPrev = 0;
function ExpandEdit( numRows )
{
	source = event.srcElement;
	if( source == Expanded )
		return;
	if( Expanded != null )
		Expanded.rows = ExpandedPrev;
	Expanded = source;
	ExpandedPrev = source.rows;
	source.rows = (typeof numRows == "undefined") ? 10 : numRows;	
}

function ExpandClear()
{
	if( Expanded == null )
		return;
	Expanded.rows = ExpandedPrev;
	Expanded = null;
}

//Additional String Methods
//Trim whitespace from beginning and end of string
String.prototype.trim = function()
{
	return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}

//Remove passed characters from end of string
String.prototype.rtrim = function( chars )
{
	rexp = "";
	for( i=0;i<chars.length;i++)
		rexp += "\\"+chars.charAt( i );
	var r = new RegExp( "["+rexp+"]+$" );	
	return this.replace(r,"");
}

//Remove passed characters from beginning of string
String.prototype.ltrim = function( chars )
{
	rexp = "";
	for( i=0;i<chars.length;i++)
		rexp += "\\"+chars.charAt( i )
	var r = new RegExp( "^["+rexp+"]+" );	
	return this.replace(r,"");
}
	
String.prototype.isNumeric = function()
{
	var r = new RegExp( "^\\d+$");
	return r.test( this );
}

//Remove passed characters from string
String.prototype.remove = function( chars )
{
	rexp = "";
	for( i=0;i<chars.length;i++)
		rexp += "\\"+chars.charAt( i )
	var r = new RegExp( rexp );	
	return this.replace(r,"");
}

String.prototype.isTime = function()
{
	var r = new RegExp( "([0-1][0-9]|2[0-3]):[0-5][0-9]");
	return r.test( this );
}

String.prototype.isURL = function()
{
	var r = new RegExp( "^http://([a-zA-Z0-9_\\-]+)([\\.][a-zA-Z0-9_\\-]+)+([/][a-zA-Z0-9\~\\(\\)_\\-]*)+([\\.][a-zA-Z0-9\\(\\)_\\-]+)*$");
	return r.test( this );
}

String.prototype.isEmail = function()
{
	var r = new RegExp( "^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");
	return r.test( this );
}

String.prototype.isDate = function()
{
	var r = new RegExp( "^((((0?[13578])|(1[02]))[\\/|\\-]?((0?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\\/|\\-]?((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\\/\\-]?(0?[1-9]|[0-2][0-9])))[\\/\\-]?\d{2,4}$");
	return r.test( this );
}				
