function Trim( str ) 
{
	var chr;
	chr = str.substring( 0, 1 ); 
	while( chr == " " )
	{
		str = str.substring( 1, str.length );
		chr = str.substring( 0, 1 );
	}	
	chr = str.substring( str.length - 1, str.length ); 
	while( chr == " " )
	{
		str = str.substring( 0, str.length - 1 );
		chr = str.substring( str.length - 1, str.length );
	}
	return str; 
 }

function CheckIsEmpty(Target, Message)
{
	if (Trim(Target) == '')
	{
		return Message;
	}
	else
	{
		return '';
	}
}

function ChangeVision(visibility, ID)
{
	if (ID == 1)
	{
		ID = "CCInfo";
	}
	if (getStyle(ID))
	{
		if (visibility == 0)
		{
			changeVisibility("hidden", ID);
		}
		else
		{
			changeVisibility("visible", ID);
		}
	}
}

function getStyle(ID) 
{
	if(document.getElementById && document.getElementById(ID)) 
	{
		return document.getElementById(ID).style;
	}
	else if (document.all && document.all(ID)) 
	{  
		return document.all(ID).style;
	} 
	else if (document.layers && document.layers[ID]) 
	{ 
		return document.layers[ID];
	} 
	else 
	{
		return false;
	}
}

function changeVisibility(Visibility, ID)
{
	var ID_style = getStyle(ID);
	if (ID_style)
	{
		ID_style.visibility = Visibility;
		return true;
	}
	else
	{
		return false;
	}
}

function ClearDefault(txt) 
{
	if (txt.value == txt.defaultValue) 
	{
		txt.value = '';
	}
}
 
function ReplaceDefault(txt, DefaultValue)
{
	if (txt.value == '')
	{
		txt.value = DefaultValue;
	}
}

function CheckEmail(email) 
{
	emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[a-zA-Z]$";
	var regex = new RegExp(emailReg);
	if(regex.test(email) == false)
	{
		alert('Please enter a valid email address!');
		return false;
	}
	return regex.test(email);
}