/**
 * Top City Application Framework JavaScript
 *
 * @package Application
 * @category JavaScript
 * @subpackage Registeration
 * @author Rick
 * @version $0.3$
 * @copyright 2006-11-22 9:23:32
 */
function infotip(ow,cw,msg)
{	ow.className=cw;
	ow.innerHTML=msg;
	return (cw == 'p_tip') ? true:false;
}
function mailexist(mailaddress)
{	var error = false;
	if (this.lastcheck!=mailaddress)	this.lastcheck=mailaddress;
	else	return this.laststatus;
	if (request = getRequest())
	{	$.get('?'+trigger+"=Checkin.ExistMail&mail=" + mailaddress);
		request.setRequestHeader("If-Modified-Since", "0");
		request.setRequestHeader("Content-Type", "text/html;charset=utf-8");
		request.send(null);
		error = request.responseText=='r0'?true:false;
	}
	this.laststatus=error;
	return error;
}
var partten = /[`~@_#,%-;"\<\>\(\)\[\]\{\}\!\?\:\$\^&\*\+\|\=\d\/]/g;
// /* " */
function chk_fname(force)
{	if (force)
	{	getx('i_firstname').value=getx('i_firstname').value.strim().ucfirst();	}
	else if (getx('i_firstname').value.trim() != getx('i_firstname').value.strim())
	{	getx('i_firstname').value=getx('i_firstname').value.strim();	}
	if (getx('i_firstname').value.trim() == '' || getx('i_firstname').value.search(partten) > -1)
	{	return infotip(getx('w_firstname'),'f_tip',getJs(1899));	}
	return infotip(getx('w_firstname'),'p_tip',getJs(1890));
}
function chk_lname(force)
{	if (force)
	{	getx('i_lastname').value=getx('i_lastname').value.strim().ucfirst();	}
	else if (getx('i_lastname').value.trim() != getx('i_lastname').value.strim())
	{	getx('i_lastname').value=getx('i_lastname').value.strim();	}
	if (getx('i_lastname').value.trim() == '' || getx('i_lastname').value.search(partten) > -1)
	{	return infotip(getx('w_lastname'),'f_tip',getJs(1884));	}
	return infotip(getx('w_lastname'),'p_tip',getJs(1890));
}
function chk_email(force)
{	getx('i_email').value=getx('i_email').value.trim();
	if (getx('i_email').value.trim() == '')
 	{	return infotip(getx('w_email'),'f_tip',getJs(1885));	}
	else if (getx('i_email').value.length < mailminlen)
	{	return infotip(getx('w_email'),force?'f_tip':'i_tip',getJs(1886));	}
	else if (getx('i_email').value.length > mailmaxlen)
	{	return infotip(getx('w_email'),force?'f_tip':'i_tip',getJs(1887));	}
	else if (!/^\w+(\.[\w-]+)*@([a-z0-9]+\.)+[a-z0-9]{2,4}$/i.test(getx('i_email').value))
	{	return infotip(getx('w_email'),force?'f_tip':'i_tip',getJs(1888));	}
	else if (mailexist(getx('i_email').value))
	{	return infotip(getx('w_email'),'f_tip',getJs(1889));	}
	return infotip(getx('w_email'),'p_tip',getJs(1890));
}
function chk_pass(force)
{	var rtn = chk_cfmpass(force);
	if (getx('i_password').value == '')
	{	return infotip(getx('w_password'),'f_tip',getJs(1891)) && rtn;	}
	else if (getx('i_password').value.length < passminlen)
	{	return infotip(getx('w_password'),force?'f_tip':'i_tip',getJs(1892)) && rtn;	}
	else if (getx('i_password').value.length > passmaxlen)
	{	return infotip(getx('w_password'),force?'f_tip':'i_tip',getJs(1893)) && rtn;	}
	return infotip(getx('w_password'),'p_tip',getJs(1890)) && rtn;
}
function chk_cfmpass(force)
{	if (getx('i_password').value == '' && force)
	{	return infotip(getx('w_passwordConfirm'),'f_tip',getJs(1894));	}
	else if (getx('i_password').value == '' && !force && getx('i_passwordConfirm').value!='')
	{	return infotip(getx('w_passwordConfirm'),'i_tip',getJs(1894));	}
	else if (getx('i_password').value == '' && !force && getx('i_passwordConfirm').value=='')
	{	return infotip(getx('w_passwordConfirm'),'e_tip',getJs(1895));	}
	else if (getx('i_passwordConfirm').value != getx('i_password').value)
	{	return infotip(getx('w_passwordConfirm'),force?'f_tip':'i_tip',getJs(1896));	}
	else
	{	return infotip(getx('w_passwordConfirm'),'p_tip',getJs(1890));	}
}
function checkCaptcha(force)
{	if (getx('i_captcha').value.trim() == '')
	{	return infotip(getx('w_captcha'),'f_tip',getJs(1897));	}
	else if (getx('i_captcha').value.length !== 8)
	{	return infotip(getx('w_captcha'),force?'f_tip':'i_tip',getJs(1898));	}
	else
	{	return infotip(getx('w_captcha'),'p_tip',getJs(1890));	}
}
function checkForm(o)
{	var ck_fname = chk_fname(true);
	var ck_lname = chk_lname(true);
	var ck_mail = chk_email(true);
	var ck_pass = chk_pass(true);
	if (ck_fname && ck_lname && ck_mail && ck_pass)
	{	o.submit();	}
}