// JavaScript Document
function displayDate(lang,a){
	cn=new Array('星期一','星期二','星期三','星期四','星期五','星期六','星期日');
	vn=new Array('Thứ Hai','Thứ Ba','Thứ Tư','Thứ Năm','Thứ Sáu','Thứ Bảy','Chủ Nhật');
	us=new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
	usSort=new Array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
	obj=document.getElementById(a);
	d=new Date()
	k=d.toString();
	k=k.split(' ');
	for(i=0;i<usSort.length;i++){
		if(k[0]==usSort[i]) k[0]=us[i];
	}
	odate=k[0]+', '+ k[1]+' '+k[2]+', '+k[5]
	// if(lang == 'vn'){
	t=d.toString().split(' ');
	for(var i=0;i<us.length;i++){
		if(t[0]==usSort[i]){
			switch(lang){
				case 'vn':
					t[0]=vn[i];
					break;
				case 'cn':
					t[0]=cn[i];
					break;
				default:
					t[0]=us[i];
					break;
			}
		}
		mon=d.getMonth()+1;
		odate=t[0]+', '+t[2]+'/'+mon+'/'+k[5];
		if(lang=='cn') odate=k[5]+"年 "+ mon+ "月 " + t[2]+ "日, " + t[0];
	}
	// }
	obj.innerHTML=odate;
}
function getdate(lang,id) {
	var this_month = new Array(12);
	this_month[0]  = "Tháng 1";
	this_month[1]  = "Tháng 2";
	this_month[2]  = "Tháng 3";
	this_month[3]  = "Tháng 4";
	this_month[4]  = "Tháng 5";
	this_month[5]  = "Tháng 6";
	this_month[6]  = "Tháng 7";
	this_month[7]  = "Tháng 8";
	this_month[8]  = "Tháng 9";
	this_month[9]  = "Tháng 10";
	this_month[10] = "Tháng 11";
	this_month[11] = "Tháng 12";
	var today_day = new Array(7);
	today_day[0] = "Chủ nhật";
	today_day[1] = "Thứ hai";
	today_day[2] = "Thứ ba";
	today_day[3] = "Thứ tư";
	today_day[4] = "Thứ năm";
	today_day[5] = "Thứ sáu";
	today_day[6] = "Thứ bảy";
	var today = new Date();
	var wday = today.getDay();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = today.getYear();
	if (year < 1900){
		year += 1900;
	}
	
	odate = (today_day[wday] + " " + day + " " + this_month[month] + " " + year);
	
	obj=document.getElementById(id);
	obj.innerHTML=odate;
}
function dateenglish(lang,id) {
	var this_month = new Array(12);
	this_month[0]  = "January";
	this_month[1]  = "February";
	this_month[2]  = "March";
	this_month[3]  = "April";
	this_month[4]  = "May";
	this_month[5]  = "June";
	this_month[6]  = "July";
	this_month[7]  = "August";
	this_month[8]  = "September";
	this_month[9]  = "October";
	this_month[10] = "November";
	this_month[11] = "December";
	var today_day = new Array(7);
	today_day[0] = "Sunday";
	today_day[1] = "Monday";
	today_day[2] = "Tuesday";
	today_day[3] = "Wednesday";
	today_day[4] = "Thursday";
	today_day[5] = "Friday";
	today_day[6] = "Saturday";
	var today = new Date();
	var wday = today.getDay();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = today.getYear();
	if (year < 1900){
		year += 1900;
	}
	
	odate = (today_day[wday] + ", " + this_month[month] + " " + day + " " + year);
	
	obj=document.getElementById(id);
	obj.innerHTML=odate;
}
function chkemail(email) {
	var re = /^(\w|[^_]\.[^_]|[\-])+(([^_])(\@){1}([^_]))(([a-z]|[\d]|[_]|[\-])+|([^_]\.[^_])*)+\.[a-z]{2,3}$/i 
	return re.test(email);
}
function chkform(frm){
	/*if(frm.user.value==''){
		alert("Mời bạn nhập tên đăng nhập.") ;
		frm.user.focus() ;
		return false ;
	}
	if(frm.pass.value==''){
		alert("Mời bạn nhập mật khẩu.") ;
		frm.pass.focus() ;
		return false ;
	}
	if(frm.pass.value!=frm.cfpass.value){
		alert("Xác nhận mật khẫu sai.") ;
		frm.cfpass.focus() ;
		return false ;
	}*/
	if((!chkemail(frm.yourEmail.value))||(frm.yourEmail.value=='')){
		alert("Mời bạn nhập đúng Email.") ;
		frm.yourEmail.focus() ;
		return false ;
	}
	/*if(frm.memkind.option.value==0){
		alert("Mời bạn chọn loại thành viên.") ;
		frm.cfpass.focus() ;
		return false ;
	}
	if(frm.agree.value!='on'){
		alert("Bạn chưa đồng ý điều lệ diễn đàn.") ;
		//frm.email.focus() ;
		return false ;
	}*/
	
	//return true ;
}
function openwin(url,w_title,width,height){
	var maxw = window.screen.availWidth;
	var maxh = window.screen.availHeight;
	var win = window.open(url,w_title,'screenX=0,screenY=0,left='+((maxw-width)/2)+',top=0,width=' + width + ',height=' + height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
	win.focus();
}
function chkall(chk,opt,len) {
	for (i=1;i<len+1;i++) {		
		document.all(opt+i).checked=chk;		
	}
}

function check_All(status) {
	var the_form	= window.document.shopping;
	for (i = 0; i < the_form.length; i++) {
		the_form.elements[i].checked = status;
	}
}
function count(id){
	var price = document.getElementById("price"+id);
	var num   = document.getElementById("num"+id);
	var total = document.getElementById("total"+id);
	
	price.value = repStr(price.value) ;
	total.value = price.value * num.value ;
	getTotal() ;
	getSoluong() ;
}
function getTotal(){
	var proid = document.getElementById("proid").value;
	var num =  proid.split(",") ;
	
	var thanhtien = 0 ;
	for(var i=0;i<num.length-1;i++){
		var id = "total"+ num[i] ;
		var total = document.getElementById(id).value;
		thanhtien = thanhtien + Math.round(total) ;
	}
	var tien = document.getElementById("thanhtien");
	tien.innerHTML = "$"+thanhtien ;
}
function getSoluong(){
	var proid = document.getElementById("proid").value;
	var num =  proid.split(",") ;
	
	var numpro = '' ;
	for(var i=0;i<num.length-1;i++){
		var id = "num"+ num[i] ;	
		var soluong = document.getElementById(id).value;
		numpro += soluong + "," ;//alert(numpro) ;
	}
	var listnum = document.getElementById("listnum");
	listnum.value = numpro ;
}
function repStr(str){
	str = str.replace(",","") ;
	str = str.replace(".","") ;
	str = str.replace(" ","") ;
	str = str.replace("$","") ;
	return str ;
}
function submitform(){
	var sendcart = document.getElementById("sendcart") ;
	sendcart.action = "index.php?act=lienhe" ;
	sendcart.method= "post" ;
	sendcart.submit() ;
}
