// JavaScript Document
// lpvietnam co., ltd
// javascript common 
// v 1.0 ngay: 01/07/2006
// tuan anh nguyen ngoc
// tuananh.nguyenngoc@gmail.com

function showcurrentday(){
	var result ="Th&#7913; ";
	var today = new Date();
	//var date = today.get();
	var year = today.getYear();
	
	var wday = today.getDay() + 1;
	if(wday==1) result = "Chủ nhật, ";
	else result += wday + ", " ;
	
	var m = today.getMonth()+1;
	var month = (m < 10) ? '0' + m : m;
	
	var d  = today.getDate();
	var day = (d < 10) ? '0' + d : d;
	
	if(year<1000) year+=1900;
	result += " " + day + "/" + month + "/" + year ;
	return result;
}
function sendfriend(){
	var obj = window.document.formfriend;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(obj.name.value ==""){
		alert("Vui lòng cho biết tên của bạn!");
		obj.name.focus();
	}
	else if(obj.femail.value ==""){
		alert("Vui lòng cho biết địa chỉ email của bạn!");
		obj.femail.focus();
	}
	else if (!filter.test(obj.femail.value)){
		alert("Vui lòng kiễm tra lại địa chỉ email của bạn!\n địa chỉ email này không hợp lệ");
		obj.femail.select();
	}
	else if(obj.temail.value ==""){
		alert("Vui lòng cho biết địa chỉ email của người nhận!");
		obj.temail.focus();
	}
	else if (!filter.test(obj.temail.value)){
		alert("Vui lòng kiễm tra lại địa chỉ email của bạn!\n địa chỉ email này không hợp lệ");
		obj.temail.select();
	}
	else if(obj.title.value ==""){
		alert("Bạn phải nhập tiêu đề!");
		obj.title.focus();
	}
	else if(obj.content.value ==""){
		alert("Bạn phải nhập nội dung!");
		obj.content.focus();
	}
	else{
		obj.action = "sendfriend.jsp";
		obj.submit();
	}
}
function resetfriend(){
	var obj = window.document.formfriend;
	obj.reset();
}
function sendnews(){
	var obj = window.document.formpostnews;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(obj.name.value ==""){
		alert("Vui lòng cho biết tên của bạn!");
		obj.name.focus();
	}
	else if(obj.email.value ==""){
		alert("Vui lòng cho biết địa chỉ email của bạn!");
		obj.email.focus();
	}
	else if (!filter.test(obj.email.value)){
		alert("Vui lòng kiễm tra lại địa chỉ email của bạn!\n địa chỉ email này không hợp lệ");
		obj.email.select();
	}
	else if(obj.title.value ==""){
		alert("Bạn phải nhập tiêu đề!");
		obj.title.focus();
	}
	else if(obj.content.value ==""){
		alert("Bạn phải nhập nội dung!");
		obj.content.focus();
	}
	else{
		obj.action = "sendfriend.jsp";
		obj.submit();
	}
}
function resetnews(){
	var obj = window.document.formpostnews;
	obj.reset();
}
function sendcontact(){
	var obj = window.document.formcontact;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(obj.name.value ==""){
		alert("Vui lòng cho biết tên của bạn!");
		obj.name.focus();
	}
	else if(obj.tel.value ==""){
		alert("Vui lòng cho biết số điện thoại của bạn!");
		obj.tel.focus();
	}
	else if(obj.email.value ==""){
		alert("Vui lòng cho biết địa chỉ email của bạn!");
		obj.email.focus();
	}
	else if (!filter.test(obj.email.value)){
		alert("Vui lòng kiễm tra lại địa chỉ email của bạn!\n địa chỉ email này không hợp lệ");
		obj.email.select();
	}
	else if(obj.content.value ==""){
		alert("Vui lòng cho biết nội dung liên của bạn!");
		obj.content.focus();
	}
	else{
		obj.action = "?idx=contactthanks&mod=modcontact";
		obj.submit();
	}
}

function resetcontact(){
	var obj = window.document.formcontact;
	obj.reset();
}

function goback(){
	window.history.back();
}
