//----------------------------------------------------------------------------
function strTrim(tmpStr)
{
	var i;
	for (i=0; i < tmpStr.length; ++i)
		if (tmpStr.charAt(i) != " ") break;
	tmpStr = tmpStr.substring(i);
	for (i=tmpStr.length - 1; i >= 0; --i)
		if (tmpStr.charAt(i) != " ") break;
	tmpStr = tmpStr.substring(0, i + 1);
	return tmpStr;
}
//--------------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var i;
	var posAt = 0;
	var posDot = 0
	var count = 0;
	for(i=0;i<tmpStr.length;++i)
	{
		if(tmpStr.charAt(i) == "@")
		{
			posAt = i;
			count++;
		}
		if(tmpStr.charAt(i) == ".")
		{
			posDot = i;
		}
		if (!((tmpStr.charAt(i) >= "0" && tmpStr.charAt(i) <= "9")
				||(tmpStr.charAt(i) >= "a" && tmpStr.charAt(i) <= "z")
				|| (tmpStr.charAt(i)>= "A" && tmpStr.charAt(i) <= "Z")
				|| (tmpStr.charAt(i) == "-")
				|| (tmpStr.charAt(i) == "_")
				|| (tmpStr.charAt(i) == "@")
				|| (tmpStr.charAt(i) == ".")
			)) return false;
	}
	if(count>1) return false;
	if(eval(posAt) > 1 && posAt != tmpStr.length-1 && posDot > posAt && posDot != tmpStr.length-1) return true;
	return false;
}
//--------------------------------------------------------------------------------
function FeedBack()
{
	if(strTrim(obj.SuggestionDesign.value) == ""
		&& strTrim(obj.SuggestionNavigation.value) == ""
		&& strTrim(obj.SuggestionCategorization.value) == ""
		&& strTrim(obj.SuggestionContent.value) == ""
		&& strTrim(obj.SuggestionForms.value) == ""
		&& strTrim(obj.SuggestionOthers.value) == "")
	{
		alert("Please enter your suggestion relating to\nat least one of the above topics.");
		obj.SuggestionDesign.focus();
		return;
	}
	if(obj.Email.value != "")
	{
		if(chkEmail(obj.Email.value) == false)
		{
			alert("Please enter a valid Email address.");
			obj.Email.focus();
			obj.Email.select();
			return;
		}
	}
    obj.action = 'feedback_response.php';
	obj.submit();
}
//---------------------------------------------------
function ResetForm()
{
	obj.SuggestionDesign.value = "";
	obj.SuggestionNavigation.value = "";
	obj.SuggestionCategorization.value = "";
	obj.SuggestionContent.value = "";
	obj.SuggestionForms.value = "";
	obj.SuggestionOthers.value = "";
	return;
}
