/****All Constant****/
// INDEX_PAGE : name of main page [default: index.php]
/******************************************************************************/
function send_data_login(id_form,fc_status){  if(!check_user('fields[user_name]',LIST_MESSAGE['err_username'][CURRENT_LANGUAGE])){
    document.getElementById('id_user_name').focus();
    return false;
  }
  if(!check_password('fields[user_pass]',LIST_MESSAGE['err_password'][CURRENT_LANGUAGE])){
    document.getElementById('id_user_pass').focus();
    return false;
	}
	//document.getElementById('id_button_login').disabled=true;
	//document.getElementById('id_button_login').value='Please wait...';
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=login&mf=db',m_data,fc_status);
}//--end function--

function status_login(m_txt){	//alert(m_txt);
	switch(m_txt){		case "err_login":
			window.alert(LIST_MESSAGE['err_login'][CURRENT_LANGUAGE]);
			document.forms['frm_login'].reset();
		break;
		case "logged_true":
			document.location.href=INDEX_PAGE;
		break;
		default:
			document.location.href=INDEX_PAGE + m_txt;
		break;	}//--end switch--
	//window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]);
}//--end function--
/******************************************************************************/

function send_data_getpass(id_form,fc_status){
  if(!check_user('fields[user_name]',LIST_MESSAGE['err_username'][CURRENT_LANGUAGE])){
    document.getElementById('id_user_name').focus();
    return false;
  }
  if(!check_email('fields[user_email]',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.getElementById('id_user_email').focus();
    return false;
  }
  //document.getElementById('id_get_pass').disabled=true;
  //document.getElementById('id_get_pass').value='Please wait...';
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=getpass&mf=db',m_data,status_get_pass);
}//--end function--
function status_get_pass(m_txt){	//alert(m_txt);
	if(m_txt=='err_get_pass'){		window.alert(LIST_MESSAGE['err_user_email'][CURRENT_LANGUAGE]);
		document.forms['frm_get_password'].reset();
	  //document.getElementById('id_get_pass').value='Lấy lại mật khẩu';
		//document.getElementById('id_get_pass').disabled=false;	}else{		if(m_txt=='new_pass'){			window.alert(LIST_MESSAGE['txt_newpass'][CURRENT_LANGUAGE]);
			document.forms['frm_get_password'].reset();		}else{			window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]);		}	}}
/******************************************************************************/

function send_data_changepass(id_form,fc_status){
  if(!check_user('fields[user_name]',LIST_MESSAGE['err_username'][CURRENT_LANGUAGE])){
	  document.getElementById('id_user_name').focus();
		return false;
	}
  if(!check_password('fields[user_pass]',LIST_MESSAGE['err_password'][CURRENT_LANGUAGE])){
		document.getElementById('id_user_pass').focus();
		return false;
	}
	document.getElementById('id_change_pass').disabled=true;
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=cpass&ms=up&mf=db',m_data,status_change_password);
	//frm.submit();
}//--end function--
function status_change_password(m_txt){ 	switch(m_txt){ 		case 'exist_acc':
 			window.alert('Tên truy cập này đã được sử dụng. Xin vui lòng chọn tên khác');
 			document.getElementById('id_change_pass').disabled=false;
 		break;
 		case 'acc_yes':
 			window.alert('Tài khoản của bạn đã được cập nhật');
 			document.forms['frm_change_pass'].reset();
 		break;
 		case 'err_change': window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]); break; 	}
}//--end function--
/******************************************************************************/

function send_data_register(id_form,fc_status){
  if(!check_user('fields[user_name]',LIST_MESSAGE['err_username'][CURRENT_LANGUAGE])){
    document.all['fields[user_name]'].focus();
    return false;
  }
  if(!check_password('fields[user_pass]',LIST_MESSAGE['err_password'][CURRENT_LANGUAGE])){
    document.all['fields[user_pass]'].focus();
    return false;
  }
  if(document.all['re_password'].value!=document.all['fields[user_pass]'].value){
  	window.alert(LIST_MESSAGE['err_repassword'][CURRENT_LANGUAGE]);
    document.all['re_password'].focus();
    return false;
  }
  if(!check_email('fields[user_email]',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.all['fields[user_email]'].focus();
    return false;
  }
  if(!check_user('confirm_code',LIST_MESSAGE['txt_confirm_code'][CURRENT_LANGUAGE])){
    document.getElementById('id_code_confirm').focus();
    return false;
  }
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=register&ms=in&mf=db',m_data,status_register_member);
}//--end function--
function status_register_member(m_txt){	//alert(m_txt);
 	switch(m_txt){
 		case 'reg_successful':
 			window.alert(LIST_MESSAGE['txt_register_yes'][CURRENT_LANGUAGE]);
 			window.location.href=INDEX_PAGE+"?n=login";
 			//show_customer_data('&n=login','id_center_pages');
 		break;
 		case 'exist_acc':
 			window.alert(LIST_MESSAGE['err_exist_user_email'][CURRENT_LANGUAGE]);
 		break;
 		case 'err_confirm':
 			window.alert(LIST_MESSAGE['txt_confirm_code'][CURRENT_LANGUAGE]);
 		break;
 		default:
 			window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]);
 		break;
 	}}//--end function--

function check_exists_username(){
  if(!check_user('fields[user_name]',LIST_MESSAGE['err_username'][CURRENT_LANGUAGE])){
    document.all['fields[user_name]'].focus();
    return false;
  }
  var m_data='type=user&user_name='+document.all['fields[user_name]'].value;
	postDataReturnText(INDEX_PAGE+'?n=checkdata&special=1',m_data,status_username);
}//--end function--
function status_username(m_txt){
	if(m_txt=='true'){
		window.alert(LIST_MESSAGE['err_existuser'][CURRENT_LANGUAGE]);
	}else{
		window.alert(LIST_MESSAGE['txt_yesuser'][CURRENT_LANGUAGE]);
	}
}//--end function--

/******************************************************************************/

function send_data_changeinfo(id_form,fc_status){
  if(!check_text('fields[ho_ten]','Bạn hãy nhập vào Họ và tên')){
    document.all['fields[ho_ten]'].focus();
    return false;
  }
  if(document.all['fields[ns_ngay]'].value==0){
  	window.alert('Bạn phải chọn Ngày');
    document.all['fields[ns_ngay]'].focus();
    return false;
  }
  if(document.all['fields[ns_thang]'].value==0){
  	window.alert('Bạn phải chọn Tháng');
    document.all['fields[ns_thang]'].focus();
    return false;
  }
  if(document.all['fields[ns_nam]'].value==0){
  	window.alert('Bạn phải chọn Năm');
    document.all['fields[ns_nam]'].focus();
    return false;
  }
  if(!check_text('fields[dia_chi]','Bạn hãy nhập vào Địa chỉ cư trú')){
    document.all['fields[dia_chi]'].focus();
    return false;
  }
  if(!check_email('fields[user_email]','Bạn nhập địa chỉ Email không chính xác')){
    document.all['fields[user_email]'].focus();
    return false;
  }
	document.getElementById('id_change_info').disabled=true;
	document.getElementById('id_change_info').value='Please wait...';
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=cinfo&ms=up&mf=db',m_data,fc_status);
  //frm.submit();
}//--end function--

function status_changeinfo(m_txt){ 	switch(m_txt){
 		case 'changed':
 			window.alert('Thông tin cá nhân của bạn đã được cập nhật thành công');
 			document.getElementById('id_change_info').value='Đã cập nhật';
 		break;
 		case 'err_global': window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]); break;
 	}}//--end function--
/******************************************************************************/

function send_data_hoso(id_form,fc_status){	if(!check_text('fields[ho_ten]','Vui lòng nhập vào Họ và tên')){
    document.all['fields[ho_ten]'].focus();
    return false;
  }
	if(!check_text('fields[nam_sinh]','Bạn hãy chọn năm sinh')){
    document.all['fields[nam_sinh]'].focus();
    return false;
  }
  if(!check_text('fields[dia_chi]','Vui lòng nhập vào Địa chỉ')){
    document.all['fields[dia_chi]'].focus();
    return false;
  }
  if(!check_email('fields[email]','Vui lòng nhập vào địa chỉ Email')){
    document.all['fields[email]'].focus();
    return false;
  }
  if(!check_text('fields[gioi_thieu]','Vui lòng nhập vào phần Giới thiệu bản thân')){
    document.all['fields[gioi_thieu]'].focus();
    return false;
  }
  if(document.all['fields[trang_thai]'].value==0){
  	window.alert('Bạn hãy chọn trạng thái hồ sơ');
  	return false;
  }
	document.getElementById('id_button_hoso').disabled=true;
	document.getElementById('id_button_hoso').value='Please wait...';
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=add_hoso&ms=up&mf=db',m_data,fc_status);
}//--end function--
function status_send_hoso(m_txt){	alert(m_txt);
 	switch(m_txt){
 		case 'send_successful':
 			window.alert('Hồ sơ của bạn đã cập nhật thành công');
 			document.getElementById('id_button_hoso').value='Đã cập nhật';
 			document.getElementById('id_button_hoso').disabled=false;
 		break;
 		default:
 			window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]);
 			document.getElementById('id_button_hoso').value='Server Disconnect';
 		break;
 	}//--end switch--}
/******************************************************************************/

function send_data_contact(id_form,fc_status,m_type){
  if(!check_text('fields[name]',"Bạn phải nhập vào Họ tên")){
    document.all['fields[name]'].focus();
    return false;
  }
  if(!check_email('fields[email]',"Bạn nhập địa chỉ Email không chính xác")){
    document.all['fields[email]'].focus();
    return false;
  }
  if(!check_text('fields[title]',"Bạn phải nhập vào Tiêu đề")){
    document.all['fields[title]'].focus();
    return false;
  }
  if(!check_text('fields[content]',"Bạn phải nhập vào nội dung liên hệ")){
    document.all['fields[content]'].focus();
    return false;
  }
	//document.getElementById('id_button_contact').disabled=true;
	//document.getElementById('id_button_contact').value='Please wait...';
	var m_data=get_all_data(id_form);
	if(m_type){		postDataReturnText(INDEX_PAGE+'?special=1&n=advcontact&ms=in&mf=db',m_data,fc_status);	}else{
		postDataReturnText(INDEX_PAGE+'?special=1&n=contact&ms=in&mf=db',m_data,fc_status);
	}
}//--end function--

function status_send_contact(m_txt){ 	switch(m_txt){
 		case 'send_successful':
 			window.alert("Nội dung liên hệ của bạn đã được gửi đi\nChúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất\nCảm ơn bạn đã ghé thăm website");
 			window.location.href=INDEX_PAGE;
 			//document.getElementById('id_button_contact').value='Đã gửi';
 		break;
 		default:
 			window.alert("Không thể kết nối với server vào thời điểm này\nXin bạn vui lòng thử lại");
 			//document.getElementById('id_button_contact').value='Server Disconnect';
 		break;
 	}//--end switch--}
/******************************************************************************/

function start_tim_ban(){
	var m_gtinh=document.getElementById('id_gioi_tinh').value;
	var m_nsinh=document.getElementById('id_nam_sinh').value;
	var m_tpho =document.getElementById('id_thanh_pho').value;
	if(m_nsinh==0){
		window.alert('Bạn hãy chọn năm sinh');
		return false;
	}
	var m_data="gioi_tinh="+m_gtinh+"&nam_sinh="+m_nsinh+"&thanh_pho="+m_tpho;
	//alert(m_data);
	post_customer_data('&n=ketban_search&pages=1',m_data,'id_hoso_lamquen');
}

/******************************************************************************/

function xem_ket_qua(){
  if(!check_number('can_nang','Bạn hãy nhập số cho cân nặng')){
    document.all['can_nang'].focus();
    return false;
  }
  if(isNaN(parseFloat(document.all['chieu_cao'].value))){
  	window.alert('Bạn nhập chiều cao không đúng');
		document.all['chieu_cao'].focus();
  	return false;
  }
	var m_data="can_nang="+document.all['can_nang'].value;
	m_data+="&chieu_cao="+document.all['chieu_cao'].value;
	postDataReturnText(INDEX_PAGE+'?special=0&n=tinhcannang',m_data,status_ket_qua);
}
function status_ket_qua(m_txt){
	document.getElementById('id_ket_qua').innerHTML=m_txt;
}

/******************************************************************************/

function send_data_cuahang(){
	if(!check_text('fields[ch_company]','Bạn hãy nhập vào Tên công ty / cửa hàng')){
    document.all['fields[ch_company]'].focus();
    return false;
  }
  if(!check_text('fields[ch_address]','Bạn hãy nhập vào Địa chỉ')){
    document.all['fields[ch_address]'].focus();
    return false;
  }
  if(!check_text('fields[ch_phone]','Bạn hãy nhập vào Số điện thoại')){
    document.all['fields[ch_phone]'].focus();
    return false;
  }
  frm.submit();
}//--end function--

/******************************************************************************/
if(document.getElementById('id_loi_nhan')){
	window.onLoad=setTypingMode(2);
}
function gui_thiep(){
	if(!check_text('nguoi_gui','Bạn hãy nhập vào Tên người gửi')){
    document.all['nguoi_gui'].focus();
    return false;
  }
  if(!check_email('email_nguoi_gui',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.all['email_nguoi_gui'].focus();
    return false;
  }
	if(!check_text('nguoi_nhan','Bạn hãy nhập vào Tên người nhận')){
    document.all['nguoi_nhan'].focus();
    return false;
  }
  if(!check_email('email_nguoi_nhan',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.all['email_nguoi_nhan'].focus();
    return false;
  }
	if(!check_text('chu_de','Bạn hãy nhập vào Tiêu đề thiệp')){
    document.all['chu_de'].focus();
    return false;
  }
	if(!check_text('loi_nhan','Bạn hãy nhập vào Lời nhắn')){
    document.all['loi_nhan'].focus();
    return false;
  }
  frm_guithiep.submit();
}//--end function--

/******************************************************************************/

function start_play_game(m_id){
	window.open(INDEX_PAGE+"?special=1&n=startgame&cid="+m_id,"PLAY_GAME","width=600,height=500,resizable=1");
}
function save_my_game(){
	getDataReturnText(INDEX_PAGE+'?n=savedata&special=0',status_save_game);
}
function status_save_game(m_txt){
	alert(m_txt);
}

/******************************************************************************/

function delete_my_data(m_id,m_type){
	var m_data="&cid="+m_id;
	var value=window.confirm('Bạn có chắc chắn muốn xóa thông tin này ?');
	if(value){
		getDataReturnText(INDEX_PAGE+'?n=deldata&special=0'+m_data,status_delete_mydata,m_type);
 	}
}//--end function--
function status_delete_mydata(m_txt,m_type){
	if(m_txt=='no'){
		window.alert('Không thể xóa được thông tin này. Xin vui lòng thử lại');
	}else{
		show_customer_data('&n=sh_mydata&my_data='+m_type,'id_center_member');
	}
}//--end function--

/******************************************************************************/

function gui_tinnhan(){
	if(!check_text('fields[nguoi_gui]','Bạn hãy nhập vào Tên người gửi')){
    document.all['fields[nguoi_gui]'].focus();
    return false;
  }
	if(!check_text('fields[nguoi_nhan]','Bạn hãy nhập vào Tên người nhận')){
    document.all['fields[nguoi_nhan]'].focus();
    return false;
  }
	if(!check_text('fields[description_vn]','Bạn hãy nhập vào Lời nhắn')){
    document.all['fields[description_vn]'].focus();
    return false;
  }
  frm_tinnhan.submit();
}//--end function--

/******************************************************************************/

function send_tu_van(){
  if(!check_text('fields[name]','Bạn phải nhập vào Họ tên')){
    document.all['fields[name]'].focus();
    return false;
  }
  if(!check_email('fields[email]',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.all['fields[email]'].focus();
    return false;
  }
  if(!check_text('fields[title_vn]','Bạn phải nhập vào Tiêu đề')){
    document.all['fields[title_vn]'].focus();
    return false;
  }
  if(!check_text('fields[tuvan_vn]','Bạn phải nhập vào Nội dung')){
    document.all['fields[tuvan_vn]'].focus();
    return false;
  }
	frm_tuvan.submit();
}//--end function--

/******************************************************************************/

function send_tuyen_dung(id_form,fc_status,type_db){
	if(document.all['fields[nganh_nghe]'].value==0){
		window.alert('Vui lòng Chọn ngành nghề');
		document.all['fields[nganh_nghe]'].focus();
		return false;
	}
  if(!check_text('fields[vitri_tuyendung]','Vui lòng nhập vào Vị trí tuyển dụng')){
    document.all['fields[vitri_tuyendung]'].focus();
    return false;
  }
	if(document.all['fields[trinh_do]'].value==0){
		window.alert('Vui lòng Chọn trình độ');
		document.all['fields[trinh_do]'].focus();
		return false;
	}
  if(!check_text('fields[soluong_cantuyen]','Vui lòng nhập vào Số lượng cần tuyển')){
    document.all['fields[soluong_cantuyen]'].focus();
    return false;
  }
  if(!check_text('fields[hannop_hoso]','Vui lòng chọn Hạn nộp hồ sơ')){
    document.all['fields[hannop_hoso]'].focus();
    return false;
  }

	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=dangky_td&ms='+type_db,m_data,fc_status);
}//--end function--

function status_send_tuyendung(m_txt,id_des){
	//alert(m_txt);
	if(m_txt=='true'){		window.alert('Hồ sơ của bạn đã được cập nhật thành công');
		click_dangky_vieclam('&n=timviec&mf=list',2,'name_tab_vieclam');
		//click_tab_vieclam('&n=ltuyendung',1,'name_tab_vieclam');
	}else window.alert('Không thể gửi được thông tin của bạn.\nXin vui lòng thử lại');
}

/******************************************************************************/

function send_tim_viec(id_form,fc_status,type_db){	if(document.all['fields[nganh_nghe]'].value==0){
		window.alert('Bạn phải Chọn ngành nghề');
		document.all['fields[nganh_nghe]'].focus();
		return false;
	}
	if(!check_text('fields[ten_cong_viec]','Bạn phải nhập tên công việc cần tìm')){
		document.all['fields[ten_cong_viec]'].focus();
		return false;
	}
	if(document.all['fields[trinh_do]'].value==0){
		window.alert('Bạn phải chọn trình độ');
		document.all['fields[trinh_do]'].focus();
		return false;
	}
	if(document.all['fields[thoigian_lamviec]'].value==0){
		window.alert('Bạn phải chọn Thời gian làm việc');
		document.all['fields[thoigian_lamviec]'].focus();
		return false;
	}
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=dangky_tv&ms='+type_db,m_data,fc_status);
}//--end function--

function status_send_timviec(m_txt,id_des){	//alert(m_txt);	if(m_txt=='true'){
		window.alert('Hồ sơ của bạn đã được cập nhật thành công');
		click_dangky_vieclam('&n=timviec&mf=list',2,'name_tab_vieclam');
	}else window.alert('Không thể gửi được thông tin của bạn.\nXin vui lòng thử lại');
}
/******************************************************************************/
function send_nguoilienhe(id_form,fc_status){
	if(!check_text('fields[cty_name]','Vui lòng nhập vào Nhà tuyển dụng')){
    document.all['fields[cty_name]'].focus();
    return false;
  }
  if(!check_text('fields[cty_gioi_thieu]','Vui lòng nhập vào thông tin Giới thiệu')){
    document.all['fields[cty_gioi_thieu]'].focus();
    return false;
  }
  if(!check_text('fields[cty_nguoi_lien_he]','Vui lòng nhập Người liên hệ')){
    document.all['fields[cty_nguoi_lien_he]'].focus();
    return false;
  }
  if(!check_text('fields[cty_dia_chi]','Vui lòng nhập vào Địa chỉ')){
    document.all['fields[cty_dia_chi]'].focus();
    return false;
  }
  if(!check_text('fields[cty_dien_thoai]','Vui lòng nhập vào Điện thoại')){
    document.all['fields[cty_dien_thoai]'].focus();
    return false;
  }
 	document.getElementById('id_button_nguoilienhe').value='Please wait...';
	document.getElementById('id_button_nguoilienhe').disabled=true;
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=nguoilienhe&ms=up&mf=db',m_data,fc_status);
}//--end function--
function status_nguoilienhe(m_txt){ 	switch(m_txt){
 		case 'successful':
 			window.alert('Thông tin của bạn được cập nhật');
			document.getElementById('id_button_nguoilienhe').value='Đã cập nhật';
 		break;
 		default:
 			window.alert('Không thể kết nối với Server vào thời điểm này.');
			document.getElementById('id_button_nguoilienhe').value='Cập nhật thông tin';
 			document.getElementById('id_button_nguoilienhe').disabled=false;
 		break;
 	}}
/******************************************************************************/

function send_data_guestbook(id_form,fc_status){
  if(!check_text('fields[name]',LIST_MESSAGE['msg_input_text'][CURRENT_LANGUAGE] + LIST_MESSAGE['txt_name'][CURRENT_LANGUAGE])){
    document.all['fields[name]'].focus();
    return false;
  }
  if(!check_email('fields[email]',LIST_MESSAGE['err_email'][CURRENT_LANGUAGE])){
    document.all['fields[email]'].focus();
    return false;
  }
  if(!check_text('fields[content]',LIST_MESSAGE['msg_input_text'][CURRENT_LANGUAGE] + LIST_MESSAGE['txt_comment'][CURRENT_LANGUAGE])){
    document.all['fields[content]'].focus();
    return false;
  }
	var m_data=get_all_data(id_form);
	postDataReturnText(INDEX_PAGE+'?special=1&n=question&ms=in&mf=db',m_data,fc_status);
}//--end function--

function status_send_guestbook(m_txt){
	//alert(m_txt);
 	switch(m_txt){
 		case 'send_successful':
 			window.alert(LIST_MESSAGE['txt_send_guestbook'][CURRENT_LANGUAGE]);
 			window.location.href=INDEX_PAGE;
 		break;
 		default:
 			window.alert(LIST_MESSAGE['err_server'][CURRENT_LANGUAGE]);
 		break;
 	}//--end switch--
}

/******************************************************************************/

var m_win_song=null;
function update_path(m_id,m_path){
	m_win_song=window.open(INDEX_PAGE+'?n=selpath&m_header=0&uid='+m_id+'&char='+m_path,'SelectSong',"width=400,height=350,resizable=yes");
	m_win_song.focus();
}//--end function--
function add_path(m_id,m_path){
	var tmp;
	if(tmp=document.getElementById(m_id)){
		tmp.value=m_path;
	}else{
		window.alert('Không thể thêm đường dẫn. Vui lòng thử lại');
	}
}//--end function--
function CloseMyPage(){
	if(m_win_song){
		m_win_song.close();
	}
}//--end function--

/******************************************************************************/


/******************************************************************************/


/******************************************************************************/


/******************************************************************************/

/******************************************************************************/
