function retrieveURL(url,pars) {
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChange;
		try {
			req.open("POST", 'function/'+url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		} catch (e) {
			alert(e);
		}
		req.send(pars);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processStateChange;
			req.open("POST", 'function/'+url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(pars);
		}
	}
}

function retrieveURLp(url,pars) {
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChange;
		try {
			req.open("POST", url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		} catch (e) {
			alert(e);
		}
		req.send(pars);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processStateChange;
			req.open("POST", url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(pars);
		}
	}
}

function retrieveURLmain(url,pars) {
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChangeMain;
		try {
			req.open("POST", url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		} catch (e) {
			alert(e);
		}
		req.send(pars);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processStateChangeMain;
			req.open("POST", url+'.php'+pars);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(pars);
		}
	}
}

function processStateChangeMain() {
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			document.getElementById(Object_show).innerHTML = req.responseText;
			//self.status=statuscomp;
			//hide_Loading();
		} else {
			alert("Thông báo lỗi: " + req.statusText);
		}
	}
}

function processStateChange() {
			if (loadingtext!=''){
				document.getElementById(Object_show).innerHTML = loadingtext;
			}else{
			//self.status=statusload;
			show_Loading();
			}
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			document.getElementById(Object_show).innerHTML = req.responseText;
			self.status=statuscomp;
			//hide_Loading();
		} else {
			alert("Thông báo lỗi: " + req.statusText);
		}
	}
}

function StatusClick(url,pars,DivMainID){
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" style="margin:0px 5px 0px 0px;" align="absmiddle" />  Xin vui lòng chờ trong giây lát ...</div>';
	loadingtext='&nbsp;';
	statusload='noiket.com.vn';
	statuscomp='noiket.com.vn';
	Object_show = DivMainID;
	retrieveURL(url,pars);
}

function maso(url,pars,DivMainID){
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" style="margin:0px 5px 0px 0px;" align="absmiddle" />  Xin vui lòng chờ trong giây lát ...</div>';
	loadingtext='&nbsp;';
	statusload='noiket.com.vn';
	statuscomp='noiket.com.vn';
	Object_show = DivMainID;
	retrieveURLp(url,pars);
}

function tv(url,pars,DivMainID){
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" style="margin:0px 5px 0px 0px;" align="absmiddle" />  Xin vui lòng chờ trong giây lát ...</div>';
	loadingtext='&nbsp;';
	statusload='noiket.com.vn';
	statuscomp='noiket.com.vn';
	Object_show = DivMainID;
	retrieveURLmain(url,pars);
}

function editealbum(DivMainID,string,idalbum,idpic){
	
     var poststr = "?string="+encodeURIComponent(string)+"&idalbum="+(idalbum)+"&idpic="+(idpic); 
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" align="absmiddle" />  Mở chỉnh sửa ...</div>';
	statusload='Mở chỉnh sửa ...';
	statuscomp='Sửa tại đây';
	Object_show = DivMainID;
	retrieveURL('edit_namepic',poststr);
}

function updatealbum(DivMainID,string,idalbum,idpic){
	
     var poststr = "?string="+encodeURIComponent(string.value)+"&idalbum="+(idalbum)+"&idpic="+(idpic); 
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" align="absmiddle" />  Mở chỉnh sửa ...</div>';
	statusload='Đang cập nhật';
	statuscomp='Đã cập nhật xong';
	Object_show = DivMainID;
	retrieveURL('submit_namepic',poststr);
}

function updatehitpic(DivMainID,idalbum,idpic){
	
     var poststr = "?idalbum="+(idalbum)+"&idpic="+(idpic); 
	loadingtext='&nbsp;';
	statusload='';
	statuscomp='';
	Object_show = DivMainID;
	retrieveURL('update_hitpic',poststr);
}

function update(DivMainID,string){
   //  var poststr = "?idalbum="+(idalbum)+"&idpic="+(idpic); 
	loadingtext='&nbsp;';
	statusload='';
	statuscomp='';
	Object_show = DivMainID;
	document.getElementById(Object_show).innerHTML = string.value;
	//retrieveURL('update_hitpic',poststr);
}


function viewpet(){
     var poststr = "?pet="+encodeURIComponent(document.frm_dangkytv.pet.value)+"&name_pet="+encodeURIComponent(document.frm_dangkytv.name_pet.value)+"&bg_pet="+encodeURIComponent(document.frm_dangkytv.bg_pet.value)+"&color_pet="+encodeURIComponent(document.frm_dangkytv.color_pet.value); 
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="../img/load.gif" width="10" height="14" alt="" border="0" style="margin:0px 5px 0px 0px;" align="absmiddle" />  Xin vui lòng chờ trong giây lát ...</div>';
	statusload='';
	statuscomp='';
	Object_show = 'showpet';
	retrieveURLp('../pet/select_pet',poststr);
}

function viewanimal(){
     var poststr = "?pet="+encodeURIComponent(document.frm_dangkytv.pet.value)+"&name_pet="+encodeURIComponent(document.frm_dangkytv.name_pet.value)+"&bg_pet="+encodeURIComponent(document.frm_dangkytv.bg_pet.value)+"&color_pet="+encodeURIComponent(document.frm_dangkytv.color_pet.value); 
	loadingtext='<div align="center" style="margin:0px; padding:0px; font-size:8pt; font-weight:normal;"><img src="./img/load.gif" width="10" height="14" alt="" border="0" style="margin:0px 5px 0px 0px;" align="absmiddle" />  Xin vui lòng chờ trong giây lát ...</div>';
	statusload='';
	statuscomp='';
	Object_show = 'showpet';
	retrieveURLp('./animal/select_pet',poststr);
}
