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));
}
//------------------------------------------------------------------------------------
//Checks URL against pattern
function chkURL(tmpStr)
{
	var url_pat = /^(http|https|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&amp;,=#@\/:]*)?/;
	return(url_pat.test(tmpStr));
}
//=====================================================================
//=========Open a new window pop up with specific height and width=====
//=====================================================================
function showWindow(pageName)
{
	window.open(pageName, '', 'width=520,height=300,left=200,scrollbars=1,top=50,toolbar=0,menubar=0,location=0');
}

//==========================================
//=========Fade in and Fade out effects=====
//==========================================
var op = 0;
var delay = 10;

function fadeIn()
{
	if(op == 0) ad.style.visibility = 'visible';
	op += 2;
	ad.style.filter = 'alpha(opacity=' + op + ')';
	ad.style.opacity = op / 100;
	if(op < 100)
		setTimeout('fadeIn()', delay);
}

function fadeOut()
{
	op -= 2;
	ad.style.filter = 'alpha(opacity=' + op + ')';
	ad.style.opacity = op / 100;
	if(op > 0)
		setTimeout('fadeOut()', delay);
	else
		ad.style.visibility = 'hidden';
}

/*After the latest IE update, FLASH objects require spacebar/enter/click to get activated */
//-------------------------------------------------------------------------
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="#000000" />\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>');
}
