function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//-------------------------------------------------------------------------
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}
//-------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}
//-------------------------------------------------------------------------
function refreshCaptcha(imgid)
{
	var newimg = new Image();
	document.getElementById('refresher').innerHTML = 'Please Wait';
	newimg.src = 'captcha.php?hash='+parseInt(Math.random() * 10000000000);
	newimg.onload = function(){
		document.getElementById(imgid).src = newimg.src;
		document.getElementById('refresher').innerHTML = 'Can&rsquo;t Read?';
	}
}

//Highlight or unhighlight form element onfocus/onblur
function hilite(ele)
{
	ele.className = (ele.className == 'tbox')?'tbox_o':'tbox';
}

//-------------------------------------------------------------------------
//Generic AJAX object for all get/post work
var ajax;
ajax = new Object();
ajax.httpRequest = null; //Initialize
ajax.callbackFunc = null; //Initialize

//Creates http request object
function __createHttpRequest()
{
	var httpRequest = false;
	if(window.XMLHttpRequest) //Mozilla, Safari etc
	{
		httpRequest =new XMLHttpRequest();
	}
	else if(window.ActiveXObject) //IE
	{
		try
		{
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	return httpRequest;
}

//GET method request
ajax.getRequest = function(url, parameters, callbackFunc)
{
	this.httpRequest = __createHttpRequest() //recreate ajax object to defeat cache problem in IE
	this.callbackFunc = callbackFunc;
	if(this.httpRequest)
	{
		this.httpRequest.onreadystatechange = __handleResponse;
		this.httpRequest.open('GET', url+"?hash="+Math.random()+'&'+parameters, true);
		this.httpRequest.send(null)
	}
}

//POST method request
ajax.postRequest = function(url, parameters, callbackFunc)
{
	this.httpRequest = __createHttpRequest() //recreate ajax object to defeat cache problem in IE
	this.callbackFunc = callbackFunc;
	if(this.httpRequest)
	{
		this.httpRequest.onreadystatechange = __handleResponse;
		this.httpRequest.open('POST', url, true);
		this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.httpRequest.setRequestHeader("Content-length", parameters.length);
		this.httpRequest.setRequestHeader("Connection", "close");
		this.httpRequest.send(parameters);
	}
}

//Handle response, pass the result to callbackFunc
function __handleResponse()
{
	if(ajax.httpRequest.readyState == 4)
	{
		ajax.callbackFunc(ajax.httpRequest.responseText);
	}
}

//Function for embeding flash
function writeFlash(swfPath, width, height)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="'+swfPath+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="bgcolor" value="#00000" />\n');
	document.write('<embed src="'+swfPath+'" quality="high" bgcolor="#000000" width="'+width+'" height="'+height+'" wmode="transparent"\n');
	document.write('align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"\n');
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>');
}
//-------------------------------------------------------------------------
function putEmail(email)
{
	document.write('<a href="mailto:'+email+'@webtenet.com" class="foo">'+email+'@webtenet.com</a>');
}
