var error_message= new Array();
/*User login*/
error_message[0]="(*) Chiều dài khổ in phải là số";
error_message[1]="(*) Chiều rộng khổ in phải là số";
error_message[2]="(*) Nhập số lượng sản phẩm cần in";
error_message[3]="(*) Số lượng sản phẩm phải là số";
error_message[4]="(*) Chọn loại giấy in";
error_message[5]="(*) Nhập định lượng giấy";
error_message[6]="(*) Giá trị định lượng phải là số";
error_message[7]="(*) Chọn loại cán";
error_message[8]="(*) Nhập số màu cần in";
error_message[9]="(*) Số màu in phải là số";

error_message[10]="(*) Kết quả";
error_message[11]="(*) Mật khẩu sẽ gửi đến E-mail của bạn trong ít giây";
error_message[12]="(*) Nhập lại mật khẩu cũ";
error_message[13]="(*) Nhập mật khẩu mới";
error_message[14]="(*) Nhập lại mật khẩu mới";
error_message[15]="(*) Vui lòng nhập lại mật khẩu mới";
error_message[16]="(*) Mật khẩu cũ không đúng";
error_message[17]="(*) Mật khẩu đã được đổi";
/* news letter*/
function call_newsletter()
{
	var f 		= $('txtletter');

	agent.call('newsletter.php','newsletter','callback_newsletter',$H({email:f.value}));
}
function callback_newsletter(result)
{
	
	if(parseInt(result)!=-1)
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
	else
	document.frmnewletter.txtletter.value	= "";
}
/* Thanh vien dang nhap*/
function call_userlogin()
{
	var user 		= $('txtuser_login');
	var pass 		= $('txtpass_login');
	
	agent.call('user_login.php','user_login','callback_userlogin',$H({email:user.value, password:pass.value}));
}
function callback_userlogin(result)
{
	
	if(parseInt(result)!=-1)
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
	else
		window.location = "login.php";

}

/* Thanh vien dang nhap dat hang*/
function call_cuslogin()
{
	var user 		= $('txtuser_login');
	var pass 		= $('txtpass_login');
	var lang 		= $('language');
	agent.call('cus_login.php','cus_login','callback_cuslogin',$H({email:user.value, password:pass.value, language:lang.value}));
}
function callback_cuslogin(result)
{
	
	if(parseInt(result)!=-1)
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
	else
		window.location = "check_out.php";
	
}
/* Thanh vien dang nhap dat hang*/
function call_checkModule()
{
	var length		= $('txtlength');
	var width		= $('txtwidth');
	var amount		= $('txtamount');
	var paper		= $('cmbpaper');
	var quatify		= $('txtdinhluong');
	var laminate	= $('cmbheso');
	var color		= $('txtsomau');
	var printsite	= $('cmbprintsite');
	agent.call('index.php','checkModule','callback_checkModule',$H({m_length:length.value, m_width:width.value, m_amount:amount.value, m_paper: paper.value, m_quatify: quatify.value, m_laminate:laminate.value, m_color:color.value, m_printsite:printsite.value}));
}
function callback_checkModule(result)
{
	alert(result);
	if(parseInt(result)!=-1)
	{
		document.getElementById('div_checkmodule').innerHTML = error_message[parseInt(result)];
	
	}
	else
		document.getElementById('div_checkresult').innerHTML = error_message[parseInt(result)];
	
}
/* kiem tra quen mat khau*/
function call_forgotpass()
{
	var f 		= $('txtletter');

	agent.call('enter.php','forgotPass','callback_forgotpass',$H({email:f.value}));
}
function callback_forgotpass(result)
{
	var emailpass 		= $('txtletter');
	if(parseInt(result)!= -1 && parseInt(result)!= 11)
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
	else if(parseInt(result)== 11)
	{
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
		emailpass.value	= "";
	}
}
/* kiem tra doi mat khau*/
function call_changepass()
{
	var pass_old		= $('txtpassold');
	var pass_new		= $('txtpassnew');
	var confirm_new		= $('txtconfirm');
	
	agent.call('change_pass.php','changepass','callback_changepass',$H({passold:pass_old.value, passnew:pass_new.value, confirmnew:confirm_new.value}));
}
function callback_changepass(result)
{
	var pass_old_1		= $('txtpassold');
	var pass_new_1		= $('txtpassnew');
	var confirm_new_1	= $('txtconfirm');
	if(parseInt(result)!= -1 && parseInt(result)!= 17 )
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
	else if(parseInt(result)== 17)
	{
		document.getElementById('div_hello').innerHTML = error_message[parseInt(result)];
		pass_old_1.value	= "";
		pass_new_1.value	= "";
		confirm_new_1.value	= "";
	}
}