function trimString (str) 
{
  while (str.charAt(0) == ' ')
    str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
    str = str.substring(0, str.length - 1);
  return str;
}

function ResetContactForm()
{
	document.ContactForm.reset();
	document.ContactForm.Name.focus();
};

function _checkEmail(_value)
{
    _value = _value.replace(/^\s+/,'').replace(/\s+$/,'');

	if( _value.length == 0 )
	{
		return false;
	}

	return _checkregex(_value, /^[a-zA-Z_0-9-]+(\.[a-zA-Z_0-9-]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/);
};

function _checkregex(_value, regexPattern)
{
	return regexPattern.test(_value);
};

function ContactusCheckParam()
{
	var _obj = ContactForm.Email;
	if(!_checkEmail(_obj.value))
	{
		alert('Please enter a valid email address!');
		ContactForm.Email.focus();
		return false;
	}

	if (trimString(ContactForm.Comment.value)=="Enter your comment here..." || trimString(ContactForm.Comment.value)=="")
	{
		alert('Please enter your comment!');
		ContactForm.Comment.focus();
		return false;
	}	

	return true;
};

function SubjectCheckParam()
{
	var Result;
	Result=false;
	
	if (trimString(Subjectform.Subject.value)=='')
	{
		alert("Please enter the subject!");
		Subjectform.Subject.focus();
		return Result;
	}

	if (trimString(Subjectform.Comment.value)=='')
	{
		alert("Please enter your comment!");
		Subjectform.Comment.focus();
		return Result;
	}

	return true;
};

function AnswerCheckParam()
{
	send_to_html()
	Compose.Comment12.value=Compose.html_edit_area.value;

	return true;
};

function RegisterformReset()
{
	document.RegistrationForm.reset();
	document.RegistrationForm.FirstName.focus();
};

function RegistrationCheckParam()
{
	
	var Result;
	Result=false;

	if (trimString(RegistrationForm.FirstName.value)=='')
	{
		alert("Please enter the firstname!");
		RegistrationForm.FirstName.focus();
		return Result;
	}

	if (trimString(RegistrationForm.LastName.value)=='')
	{
		alert("Please enter the lastname!");
		RegistrationForm.LastName.focus();
		return Result;
	}

	var _obj = RegistrationForm.Email;
	if(!_checkEmail(_obj.value))
	{
		alert('Please enter a valid email address!');
		RegistrationForm.Email.focus();
		return false;
	}

	if (trimString(RegistrationForm.Username.value)=='')
	{
		alert("Please enter the username!");
		RegistrationForm.Username.focus();
		return Result;
	}

	if (trimString(RegistrationForm.Password.value)=='')
	{
		alert("Please enter the password!");
		RegistrationForm.Password.focus();
		return Result;
	}

	if (trimString(RegistrationForm.ConfirmPassword.value)=="")
	{
		alert('Please Enter Confirm Password!');
		RegistrationForm.ConfirmPassword.focus();
		return Result;
	}
	
	pass1=RegistrationForm.Password.value;
	pass2=RegistrationForm.ConfirmPassword.value;
	if(pass1 != pass2)
	{
		alert("Confirm Your password Again!");
		RegistrationForm.ConfirmPassword.focus();
		return Result;
	}

	if (trimString(RegistrationForm.NickName.value)=='')
	{
		alert("Please enter the nickname!");
		RegistrationForm.NickName.focus();
		return Result;
	}

	if (isNaN(RegistrationForm.Age.value))
	{
		alert("Please enter number for age!");
		RegistrationForm.Age.focus();
		return Result;
	}

	return true;
};


function FillNickName(_form)
{
	var form = document.all[_form];
	if (trimString(form.FirstName.value)!='')
		form.NickName.value = form.FirstName.value;
	
	return true;
};

function es_toplink_over(_td)
{
	_td.style.backgroundColor = "cee6f6";
};

function es_toplink_out(_td)
{
	_td.style.backgroundColor = "";
};

function es_links_goHref(_url)
{
	window.location = _url;
};

function es_leftlink_over(_td)
{
	_td.style.backgroundColor = "d1e0f5";
};

function es_leftlink_out(_td)
{
	_td.style.backgroundColor = "eff6ff";
};

function toggleSection(section,focusElement)
{
	var _section = document.getElementById(section);
	if(_section.style.display == "none")
	{
		_section.style.display = "block";
		if(focusElement)
		{
			var _focus = document.getElementById(focusElement);
			_focus.focus();
		}
	}
	else
		_section.style.display = "none";
};


function LoginFormCheckParam()
{
	var Result;
	Result=false;

	if (trimString(HomeLoginForm.Username.value)=='')
	{
		alert("Please enter the username!");
		HomeLoginForm.Username.focus();
		return Result;
	}

	if (trimString(HomeLoginForm.Password.value)=='')
	{
		alert("Please enter the password!");
		HomeLoginForm.Password.focus();
		return Result;
	}
	
	return true;
	
};

function ForgotPasswordFormCheckParam()
{

	var _obj = HomeForgotPasswordForm.fpEmail;
	if(!_checkEmail(_obj.value))
	{
		alert('Please enter a valid email address!');
		HomeForgotPasswordForm.fpEmail.focus();
		return false;
	}


	return true;
	
};

function ChangePassFormCheckParam()
{
	
	if (trimString(ChangePassForm.CurrentPassword.value)=="")
	{
		alert("Please Enter Current Password!");
		ChangePassForm.CurrentPassword.focus();
		return false;
	}
	
	if (trimString(ChangePassForm.NewPassword.value)=="")
	{
		alert("Please Enter New Password!");
		ChangePassForm.NewPassword.focus();
		return false;
	}
	if (trimString(ChangePassForm.ConfirmNewPassword.value)=="")
	{
		alert("Please Confirm Your New Password!");
		ChangePassForm.ConfirmNewPassword.focus();
		return false;
	}
	
	pass1=ChangePassForm.NewPassword.value;
	pass2=ChangePassForm.ConfirmNewPassword.value;
	if(pass1 != pass2)
	{
		alert("Confirm Your New password Again!");
		ChangePassForm.ConfirmNewPassword.focus();
		return false;
	}
	
return true;
};

function checkHomePageSearchForm()
{
	_obj = SearchForm.Search;
	if((trimString(_obj.value) == 'Enter your search here') || (trimString(_obj.value) == '') || (_obj.value.lenth) < 3)
	{
		alert("Search Keyword most be atleast 3 chr!");
		_obj.value="";
		_obj.focus();
		return false;
	}
	
	return true;
};

