function LTrim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}
	return iStr;
}

function RTrim(iStr)
{
	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}
	return iStr;
}

function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}
function CheckEmailAddress(Email)
{
	Email = Trim(Email);

	while (Email != '')
	{
		c = Email.charAt(0);	
		if (c==' ' || c=='<' || c==39 || c==':' || c=='.')
		{
			Email = Email.substr(1);
		}
		else
		{
			break;
		}
	}

	i = Email.indexOf('>');
	if (i==-1)
	{
		while (Email != '')
		{
			c = Email.charAt(Email.length - 1);
			if (c==' ' || c==39 || c=='.')
			{
				Email = Email.substr(0, Email.length - 1);
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		Email = Email.substr(0, i);
	}

	if (Email.length > 96)
		return '';

	i = Email.lastIndexOf('@');
	j = Email.lastIndexOf('.');
	if (i < j)
		i = j;

	switch (Email.length - i - 1)
	{
	case 2:
		break;
	case 3:
		switch (Email.substr(i))
		{
		case '.com':
		case '.net':
		case '.org':
		case '.edu':
		case '.mil':
		case '.gov':
		case '.biz':
		case '.pro':
		case '.int':
			break;
		default:
			return '';
		}
		break;
	default:
		switch (Email.substr(i))
		{
		case '.name':
		case '.info':
			break;
		default:
			return '';
		}
		break;
	}

	Email = Email.toLowerCase();

	if (Email == '')
		return '';

	if (Email.indexOf(' ') != -1)
		return '';

	if (Email.indexOf('..') != -1)
		return '';

	if (Email.indexOf('.@') != -1)
		return '';

	if (Email.indexOf('@.') != -1)
		return '';

	if (Email.indexOf(':') != -1)
		return '';

	for (i=0; i < Email.length; i++)
	{
		c = Email.charAt(i);

		if (c >= '0' && c <= '9')
			continue;
		
		if (c >= 'a' && c <= 'z')
			continue;
		
		if ('`~!#$%^&*-_+=?/\\|@.'.indexOf(c) != -1)
			continue;

		return '';
	}

	if ((i=Email.indexOf('@'))==-1)
		return '';

	if (Email.substr(i + 1).indexOf('@')!=-1)
		return '';

	if (Email.charAt(0)=='.' || Email.charAt(Email.length - 1)=='.')
		return '';

	return Email;
}
function popUpContent(url, x, y) {

	if (!x){x=800;}

	if (!y){y=600;}

	if (x>400 && y>300){

		var popUpWin = window.open(url,'','height='+y+',width='+x+', location=no, scrollbars=yes, menubars=no,toolbars=no,resizable=yes');

	}else{

		var popUpWin = window.open(url,'','height='+y+',width='+x+', location=no, scrollbars=no, menubars=no,toolbars=no,resizable=yes');

	}

	width=screen.width;

	height=screen.height;

	width_x = width/2;

	height_x = height/2;

	popUpWin.moveTo(200,100);



	if (!popUpWin.opener) 

	popUpWin.opener = self;

}
function popUpImage(theURL, width, height) 

{
	width = width;
	height=height;
	if (width > screen.width) width=screen.width;
	if (height > screen.height) height=screen.height-60;
	popUpWin = window.open(theURL,'ViewFullImage',"toolbar=no,width="+ width+",height="+ height+ ",directories=no,status=no,scrollbars=yes,resizable=yes, menubar=no");
	popUpWin.moveTo(200,10);
	if (!popUpWin.opener) popUpWin.opener = self;
	with (popUpWin.document) {
		write('<HTML><HEAD><TITLE>View Full Image</TITLE>');
		write('</head>');
		write('<BODY bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
		write('<center><br><IMG SRC="' + theURL + '" alt="Click on image to close window" onclick="window.close()"></center>');
		write('</BODY></HTML>');
		close();
	}
}