function checkdaugia(form){
	if(form.daugia[1].checked){
		alert('Ban phai chon dau gia')
		form.Giatang.blur();
		form.Khoidiem.blur();
	}
}
function DangTin(f) {
	var fullName = trim(f.TieuDe.value);
	if (fullName == "") {
		alert('Nhap vap tieu de');
		f.TieuDe.focus();
		return false;
	}
	
	var mucrao=f.MucRao.value;
	if(mucrao=="-1"){
		alert("Chon muc rao tin");
		f.MucRao.focus();
		return false;
	}
	var body = trim(f.NoiDung.value);

	if (body == "") {
		alert('Nhap vao noi dung');	
		f.NoiDung.focus();
		return false;
	}
	//f.action="dangtin.php";
	//f.submit();
	SubmitDangTin('save');
}
function checknumber(num){
	strnum=trim(num.value);
	if(!isInteger(strnum)){
		alert('vui long nhap ky tu so');
		num.focus();
	}
}

function checkvipform(f) {
	var fullName = f.full_name.value;
	if (fullName == "") {
		alert('Nhap vao ho ten');
		f.full_name.focus();
		return false;
	}
	if (!checkEmail(f.vip_email)) {
		return false;
	}
	var body = f.body_str.value;

	if (body == "") {
		alert('Nhap vao noi dung');	
		f.body_str.focus();
		return false;
	}
	SubmitDangKyVIP('send');	
}
function CheckFormLienHeTin(f)
{
	var fullName = f.full_name.value;
	if (fullName == "") {
		alert('Nhap vap ho ten');
		f.full_name.focus();
		return false;
	}
	if (!checkEmail(f.vip_email)) {
		return false;
	}
	var body = f.body_str.value;

	if (body == "") {
		alert('Nhap vao noi dung');	
		f.body_str.focus();
		return false;
	}
	var makhachhang=document.getElementById("khachhang");
	
	LienHeTin(makhachhang.value,'send',0);
}
function changeVip(form) {	

	
	var a = form.type_of_vip.options[form.type_of_vip.selectedIndex].value;
	var tmp = a;
	if (tmp=="3") {
		tmp = " 1 tin VIP";
	}
	//form.number_vip.value = tmp;
	var b = form.month.options[form.month.selectedIndex].value	;

	if (a == 1) {
		a=90000;
	}else 	if (a == 2) {
		a = 120000;
	}else if(a==3) {
		a = 120000;
	}else if(a==4){
		a=150000;
	}
	
	var c = parseInt(a) *  parseInt(b);
	form.money.value = c;
		
	}

function ViewMessage(page){
	document.content.curpage.value=page;
	document.content.action="home.php";
	document.content.submit();
}
if (top.location != document.location)
	top.location = document.location;

function checkform(f) {
	
	var fullName = f.full_name.value;
	if (fullName == "") {
		alert('Nhap vap ho ten');
		f.full_name.focus();
		return false;
	}
	if (!checkEmail(f.vip_email)) {
		return false;
	}
	var body = f.body_str.value;

	if (body == "") {
		alert('Nhap vao noi dung');	
		f.body_str.focus();
		return false;
	}
	SubmitLienHe('send');
}

function CheckFormDangKy(form){
	form.HoTen.value=trim(form.HoTen.value);
	if(form.HoTen.value==""){
		alert('Vui long nhap Ho ten');
		form.HoTen.focus();
		return false;
	}
	form.Email.value=trim(form.Email.value);
	if(form.Email.value==""){
		alert('Vui long nhap Email');
		form.Email.focus();
		return false;
	}else if(!checkEmail(form.Email)){
		return false;
	}
	form.txtUsername.value=trim(form.txtUsername.value);
	if(form.txtUsername.value==""){
		alert('Vui long nhap Username');
		form.txtUsername.focus();
		return false;
	}
	form.txtPassword.value=trim(form.txtPassword.value);
	form.CPassword.value=trim(form.CPassword.value);
	if(form.txtPassword.value==""){
		alert('Vui long nhap Password');
		form.txtPassword.focus();
		return false;
	}else if(form.CPassword.value!=form.txtPassword.value){
		alert('Password chua dung, vui long nhap lai');
		form.txtPassword.focus();
		return false;
	}
	SubmitDangKy('save');
}

var xmlHttpContent;
function LoadContentList(str,curpage)
{ 
	var result=document.getElementById("txtContenList");
	result.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	var detaildiv=document.getElementById("txtContentChitiet");
	detaildiv.innerHTML="";
	var divCustomer=document.getElementById("txtContenListByCustomer");
	if(divCustomer!=null){
		divCustomer.innerHTML="";
	}
	xmlHttpContent=GetXmlHttpObject()
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url="loadcontentlist.php"
	url=url+"?MaLoai="+str + "&curpage="+curpage;
	url=url+"&sid="+Math.random()
	xmlHttpContent.onreadystatechange=stateChanged 
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}

var xmlHttpMatkhau;
function QuenMatKhau(task)
{ 
	var detaildiv=document.getElementById("txtContentChitiet");
	var email=document.getElementById("divEmail");
	//var result=document.getElementById("txtContenList");
	detaildiv.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	//result.innerHTML="";
	var divCustomer=document.getElementById("txtContenListByCustomer");
	if(divCustomer!=null){
		divCustomer.innerHTML="";
	}
	xmlHttpMatkhau=GetXmlHttpObject()
	if (xmlHttpMatkhau==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var file = 'quenmatkhau.php';
	var params;
	
	xmlHttpMatkhau.open("POST", file);	
	xmlHttpMatkhau.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task!=""){
		
		params="task=" + task + "&Email=" +email.value ;
		
	}else{
		params="task=" + task ;
	}
	
		xmlHttpMatkhau.onreadystatechange = function(){if((xmlHttpMatkhau.readyState==4)||(xmlHttpMatkhau.readyState=="complete")){			
			
			detaildiv.innerHTML = xmlHttpMatkhau.responseText;	
			
		}	
		}	
	xmlHttpMatkhau.send(params);
}
function XemTinChiTiet(str)
{ 
	
	var chitiet=document.getElementById("txtContentChitiet");
	var googletag=document.getElementById("googleTag");
	chitiet.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var file = 'xemchitiet.php';
	var params;
	
	xmlHttpContent.open("POST", file);	
	xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	
	params="MaRao=" + str ;
		xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){			
			
			chitiet.innerHTML = xmlHttpContent.responseText;
			
			
		}	
		}	
	xmlHttpContent.send(params);

}

function XemTinChiTietAdmin(str)
{ 
	
	var chitiet=document.getElementById("txtContentChitiet");
	chitiet.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var file = 'xemchitietadmin.php';
	var params;
	
	xmlHttpContent.open("POST", file);	
	xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	
	params="MaRao=" + str ;
		xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){			
			
			chitiet.innerHTML = xmlHttpContent.responseText;	
			
		}	
		}	
	xmlHttpContent.send(params);

}
function SubmitDangTin(param)
{ 
	/*
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var result=document.getElementById("txtContenList");

	var tieude = document.getElementById("TieuDe");
	var noirao=document.getElementById("NoiRao");
	var mucrao=document.getElementById("MucRao");
	var vip=document.getElementById("hiddenVIP");
	var noidung=document.getElementById("NoiDung");
	var thoigian=document.getElementById("Thoigian");
	var marao=document.getElementById("hiddenMaRao");

	
	var detaildiv=document.getElementById("txtContentChitiet");
	
	var task=param;
	var file = 'dangtin.php';
	var params;
	xmlHttpContent.open("POST", file);	
	xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task=="save"){
			
		params="TieuDe=" + tieude.value + "&NoiRao=" + noirao.value + "&MucRao=" + mucrao.value + "&vip=" + vip.value + "&NoiDung=" + noidung.value + "&Thoigian=" + thoigian.value  + "&task=" + task + "&MaRao=" + marao.value;
		 
		
	}else{
		params="task=" + task;
	}
		result.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){	
			if(xmlHttpContent.responseText=="100"){
				alert('Ban chua dang nhap vao he thong. Xin vui long dang nhap vao he thong de dang tin');
				LoadContentList('',0);
			}else{
				//alert(xmlHttpContent.responseText);
				//result.innerHTML = xmlHttpContent.responseText;	
				//detaildiv.innerHTML="";
				window.open('wysiwyg/dangtinwys.php?task=@URLTASK@&MaRao=@MARAO@','_blank','Width=830px,Height=670px,scrollbars=1');
			}
		}	
		}
		
	xmlHttpContent.send(params);
	*/
	window.open('wysiwyg/dangtinwys.php?task=new','_blank','Width=830px,Height=670px,scrollbars=1');
}

function CapNhatTin(param,maso)
{ 
	
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	
	var tieude = document.getElementById("TieuDe");
	var noirao=document.getElementById("NoiRao");
	var mucrao=document.getElementById("MucRao");
	var vip=document.getElementById("vip");
	var noidung=document.getElementById("NoiDung");
	var thoigian=document.getElementById("Thoigian");
	var marao=document.getElementById("hiddenMaRao");

	
	
	var task=param;
	var file = 'dangtin.php';
	var params;
	xmlHttpContent.open("POST", file);	
	xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task=="save"){
			
		params="TieuDe=" + tieude.value + "&NoiRao=" + noirao.value + "&MucRao=" + mucrao.value + "&vip=" + vip.value + "&NoiDung=" + noidung.value + "&Thoigian=" + thoigian.value  + "&task=" + task + "&MaRao=" + marao.value;
		 
		
	}else{
		params="task=" + task + "&MaRao="+maso;
	}
	result.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){	
			if(xmlHttpContent.responseText=="100"){
				alert('Ban chua dang nhap vao he thong. Xin vui long dang nhap vao he thong de dang tin');
				//LoadContentList('',0);
			}else{
				//alert(xmlHttpContent.responseText);
				
				result.innerHTML = xmlHttpContent.responseText;				
				detaildiv.innerHTML="";
			}
		}	
		}	
	xmlHttpContent.send(params);
	
}
function LienHeTin(makh,task,marao)
{ 
	
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	
	var fullname = document.getElementById("full_name");
	var body_str=document.getElementById("body_str");
	var email=document.getElementById("vip_email");
	var phone=document.getElementById("phone");
	var address=document.getElementById("address");
	var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var file = 'lienhetin.php';
	var params;
	xmlHttpContent.open("POST", file);	
		xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task!=""){
			
		params="khachhang=" + makh + "&full_name=" + fullname.value + "&body_str=" + body_str.value + "&vip_email=" + email.value + "&phone=" + phone.value + "&address=" + address.value + "&task=" + task;
		 
		
	}else{
		params="khachhang=" + makh + "&task=" + task + "&MaRao=" + marao;
	}
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
			//result.innerHTML =""; 
			detaildiv.innerHTML=xmlHttpContent.responseText;
		}	
		}	
	xmlHttpContent.send(params);
	
}
function XemThemTin(makh)
{ 
	
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	
	var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var url = 'xemthemtin.php';
	var params;
	
	url=url+"?khachhang="+makh;
	url=url+"&sid="+Math.random()
	
			xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){	
			result.innerHTML = xmlHttpContent.responseText;	
			detaildiv.innerHTML="";
			
		}	
		}	
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
	
}
var xmlLoginHttp;
function GetLogin()
{ 
	
	xmlLoginHttp=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlLoginHttp==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	
	var result=document.getElementById("divLogin");
	var url = 'getlogin.php?';
	var params;
	
	url=url+"sid="+Math.random()
	
			xmlLoginHttp.onreadystatechange = function(){if((xmlLoginHttp.readyState==4)||(xmlLoginHttp.readyState=="complete")){	
			result.innerHTML = xmlLoginHttp.responseText;	
			
			
		}	
		}	
	xmlLoginHttp.open("GET",url,true)
	xmlLoginHttp.send(null)
	
}
function stateChangedDetail() 
{ 
	
if ((xmlHttpContent.readyState==4) || (xmlHttpContent.readyState=="complete"))
 { 
	var content=document.getElementById("txtContentChitiet");
 content.innerHTML=xmlHttpContent.responseText;
  window.scroll(0,100);
 } 
}
function SubmitHoiDap()
{ 
	
	xmlHttpContent=GetXmlHttpObject()
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	 var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var customerlist=document.getElementById("txtContenListByCustomer");
	var url="hoidap.php";
	url=url+"?sid="+Math.random()
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
				result.innerHTML = xmlHttpContent.responseText;	
				detaildiv.innerHTML="";
				if(customerlist!=null){
					customerlist.innerHTML="";
				}
			}	
			}
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}
function XemTinDaDang()
{ 
	
	xmlHttpContent=GetXmlHttpObject()
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	 var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var url="xemtin.php";
	url=url+"?sid="+Math.random()
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
				result.innerHTML = xmlHttpContent.responseText;	
				detaildiv.innerHTML="";
			}	
			}
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}
function XemTinDaDangAdmin()
{ 
	
	xmlHttpContent=GetXmlHttpObject()
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	 var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var contentlist=document.getElementById("txtContenListByCustomer");

	var url="xemtinuser.php";
	url=url+"?sid="+Math.random()
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
				result.innerHTML = xmlHttpContent.responseText;	
				detaildiv.innerHTML="";
				if(contentlist!=null){
					contentlist.innerHTML="";
				}
			}	
			}
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}
function XoaTinCu(tinID)
{ 
	if(confirm('Ban co thuc su muon xoa tin nay?')){
		xmlHttpContent=GetXmlHttpObject()
		if (xmlHttpContent==null)
		 {
			 alert ("Browser does not support HTTP Request")
			 return
		 }
		 var result=document.getElementById("txtContenList");
		var detaildiv=document.getElementById("txtContentChitiet");
		var url="xoatin.php";
		url=url+"?MaRao="+tinID;
		url=url+"&sid="+Math.random()
		xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){			
					result.innerHTML = xmlHttpContent.responseText;	
					detaildiv.innerHTML="";
				}	
				}
		xmlHttpContent.open("GET",url,true)
		xmlHttpContent.send(null)
	}
		return;
}
function submitSearch(page)
{ 

	var marao=document.getElementById("txtMaLoai");
	var noirao=document.getElementById("txtnoirao");
	var keyword=document.getElementById("txtkeyword");

	var result=document.getElementById("txtContenList");
	result.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	var detaildiv=document.getElementById("txtContentChitiet");
	detaildiv.innerHTML="";
	xmlHttpContent=GetXmlHttpObject();
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url="tim.php"
	url=url+"?MaLoai=" + marao.value + "&keyword="+ keyword.value + "&noirao=" +noirao.value ;
	if(page!=""){
		url=url+"&curpage="+page;
	}else{
		url=url+"&curpage=0";
	}
	url=url+"&sid="+Math.random()
	xmlHttpContent.onreadystatechange=stateChanged 
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}

function SearchPage(curpage)
{ 

	var marao=document.getElementById("hiddenMaLoai");
	var noirao=document.getElementById("hiddenNoiRao");
	var keyword=document.getElementById("hiddenKeyword");
	
	var result=document.getElementById("txtContenList");
	result.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	var detaildiv=document.getElementById("txtContentChitiet");
	detaildiv.innerHTML="";
	xmlHttpContent=GetXmlHttpObject();
	if (xmlHttpContent==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url="tim.php"
	url=url+"?MaLoai=" + marao.value + "&keyword="+ keyword.value + "&noirao=" +noirao.value ;
	if(curpage!=""){
		url=url+"&curpage="+curpage;
	}else{
		url=url+"&curpage=0";
	}
	url=url+"&sid="+Math.random()
	xmlHttpContent.onreadystatechange=stateChanged 
	xmlHttpContent.open("GET",url,true)
	xmlHttpContent.send(null)
}


function SubmitLienHe(param)
{
	xmlHttpContent=GetXmlHttpObject() // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var fullname = document.getElementById("full_name");
	var body_str=document.getElementById("body_str");
	var email=document.getElementById("vip_email");
	var phone=document.getElementById("phone");
	var address=document.getElementById("address");
	var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var customerlist=document.getElementById("txtContenListByCustomer");
	var task=param;
	var file = 'lienhe.php';
	var params;
	xmlHttpContent.open("POST", file);	
		xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task!=""){
			
		params="?full_name=" + fullname.value + "&body_str=" + body_str.value + "&vip_email=" + email.value + "&phone=" + phone.value + "&address=" + address.value + "&task=" + task;
		 
		
	}else{
		params="?task=" + task;
	}
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
			result.innerHTML = xmlHttpContent.responseText;	
			detaildiv.innerHTML="";
			if(customerlist!=null){
				customerlist.innerHTML="";
			}
		}	
		}	
	xmlHttpContent.send(params);
}
function LoadFirstPhoto()
{
	var photo = document.getElementById("hidfirstphoto");
	if(((photo!=null)&&(photo.value!=""))&&(photo.value!="@FIRSTPHOTO@")){
		GetPhoto(photo.value);
	}
}
function GetPhoto(param)
{
	xmlHttpContent=GetXmlHttpObject() // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var photo = document.getElementById("PhotoDetail");
		photo.innerHTML="<center><img src='images/Loading.gif'><br><font color=#0000FF><b>Đang tải ...</b></font></center>";
	var file = 'getphoto.php';
	var params;
	xmlHttpContent.open("POST", file);	
		xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay		
		params="photo=" + param;
	
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4){			
			photo.innerHTML = xmlHttpContent.responseText;	
			
		}	
		}	
	xmlHttpContent.send(params);
}
function SubmitLogin()
{
	xmlHttpContent=GetXmlHttpObject() // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var username = document.getElementById("Username");
	var password=document.getElementById("Password");
	var remember=document.getElementById("Remember");
	if((username.value=="")||(password.value=="")){
		alert('Vui long nhap ten truy cap va mat khau.');
		return;
	}
	var result=document.getElementById("divLogin");
	
	var file = 'login.php';
	var params;
	xmlHttpContent.open("POST", file);	
		xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
		params="Username=" + username.value + "&Password=" + password.value + "&Remember=" + remember.value;
		 
	xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){			
		
			result.innerHTML = xmlHttpContent.responseText;	
			
		}	
		}	
	xmlHttpContent.send(params);
}
function SubmitDangKyVIP(param)
{
	xmlHttpContent=GetXmlHttpObject(); // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var hoten = document.getElementById("full_name");
	var diachi=document.getElementById("address");
	var email=document.getElementById("vip_email");
	var phone=document.getElementById("phone");
	var type_of_vip=document.getElementById("type_of_vip");
	var number_vip=document.getElementById("number_vip");
	var month=document.getElementById("month");
	var username=document.getElementById("Username");
	var money=document.getElementById("money");
	var body=document.getElementById("body_str");
	var result=document.getElementById("txtContenList");
	var detaildiv=document.getElementById("txtContentChitiet");
	var customerlist=document.getElementById("txtContenListByCustomer");
	var task=param;
	var file = 'dangkyvip.php';
	var params;
	xmlHttpContent.open("POST", file);	
	xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task!=""){
			
		params="full_name=" + hoten.value + "&address=" + diachi.value + "&vip_email=" + email.value + "&phone=" + phone.value + "&type_of_vip=" + type_of_vip.value + "&number_vip=" + number_vip.value + "&month=" + month.value +"&Username=" + username.value + "&task=" + task + "&money=" + money.value + "&body_str=" + body.value;
		 
		
	}else{
		params="task=" + task;
	}
	xmlHttpContent.onreadystatechange = function(){if((xmlHttpContent.readyState==4)||(xmlHttpContent.readyState=="complete")){	
			
			result.innerHTML = xmlHttpContent.responseText;	
			detaildiv.innerHTML="";
			if(customerlist!=null){
				customerlist.innerHTML="";
			}
			
		}	
		}	
	xmlHttpContent.send(params);
}

function SubmitDangKy(param)
{
	xmlHttpContent=GetXmlHttpObject() // Creates a new Xmlhttp object.	
	if (xmlHttpContent==null){ // If it cannot create a new Xmlhttp object.	
		alert ("Browser does not support HTTP Request") // Alert Them!	return // Returns.	
	} 	
	var hoten = document.getElementById("HoTen");
	var diachi=document.getElementById("DiaChi");
	var email=document.getElementById("Email");
	var myusername=document.getElementById("txtUsername");
	var mypassword=document.getElementById("txtPassword");
	var yahoo=document.getElementById("YahooID");
	var result=document.getElementById("txtContenList");

	var detaildiv=document.getElementById("txtContentChitiet");
	var customerlist=document.getElementById("txtContenListByCustomer");
	var task=param;
	var file = 'dangky.php';
	var params;
	xmlHttpContent.open("POST", file);	
		xmlHttpContent.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	// okay
	if(task!=""){
			
		params="HoTen=" + hoten.value + "&DiaChi=" + diachi.value + "&Email=" + email.value + "&Username=" + myusername.value + "&Password=" + mypassword.value + "&task=" + task + "&YahooID=" + yahoo.value;
		 
		
	}else{
		params="?task=" + task;
	}
	xmlHttpContent.onreadystatechange = function(){if(xmlHttpContent.readyState==4||xmlHttpContent.readyState=="complete"){			
			result.innerHTML = xmlHttpContent.responseText;	
			detaildiv.innerHTML="";
			if(customerlist!=null){
				customerlist.innerHTML="";
			}
			
		}	
		}	
	xmlHttpContent.send(params);
}


function UploadBangGia(param)
{
	popup('uploadbanggia.php',500,240);
}
function stateChanged() 
{ 
	if (xmlHttpContent.readyState==4 || xmlHttpContent.readyState=="complete")
	 { 
		var content=document.getElementById("txtContenList");
		content.innerHTML=xmlHttpContent.responseText;
	 
	 } 
}

function GetXmlHttpObject()
{
	var xmlHttpContent=null;
	try
	 {
		// Firefox, Opera 8.0+, Safari
		xmlHttpContent=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
		 try
		  {
			xmlHttpContent=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
			xmlHttpContent=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	}
	return xmlHttpContent;
}

var uploader="";
var uploadDir="";
var dirname="";
var filename="";
var timeInterval="";
var idname="";
/*
function createRequestObject() {
    var obj;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    	return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
    	return new XMLHttpRequest();
    }   
}
*/
function traceUpload() {
   xmlHttpContent.onreadystatechange = handleResponse;
   xmlHttpContent.open("GET", 'imageupload.php?uploadDir='+uploadDir+'&dirname='+dirname+'&filename='+filename+'&uploader='+uploader); 
   xmlHttpContent.send(null);   
}
function handleResponse() {
	if(xmlHttpContent.readyState == 4){
		var response=xmlHttpContent.responseText; 
		if(response.indexOf("File uploaded") != -1){
			clearInterval(timeInterval);
			//document.getElementById('loading'+idname).innerHTML="";
		}
        document.getElementById(uploaderId).innerHTML=response;
    }
    else {
    	document.getElementById(uploaderId).innerHTML="Uploading File. Please wait...";
    }
}
function uploadFile(obj, dname) {
	uploadDir=obj.value;
	idname=obj.name;
	dirname=dname;
	filename=uploadDir.substr(uploadDir.lastIndexOf('\\')+1);
	//document.getElementById('loading'+idname).innerHTML="<img src='loading.gif' alt='loading...' />";
	uploaderId = 'uploader'+obj.name;
	uploader = obj.name;
	document.getElementById('formName'+obj.name).submit();
	timeInterval=setInterval("traceUpload()", 1500);
}