﻿function getdanhmuccon(categoryID){var danhmuccon=document.getElementById("dlmuccon");var loaitin=document.getElementById("dlhinhthuc");var HttpRequest = false;if (window.XMLHttpRequest){HttpRequest = new XMLHttpRequest();}else{HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
if (!HttpRequest) return;
danhmuccon.options.length = 0;
loaitin.options.length = 0;
document.form1.hdmucconn.value="";
document.form1.hdmucconv.value="";
document.form1.hdmucconi.value="";
document.form1.hdltn.value="";
document.form1.hdltv.value="";
document.form1.hdlti.value="";
if (categoryID=="") return;
var url = "/" + categoryID + "/danh-muc-con.aspx";
HttpRequest.open("GET",url);
HttpRequest.onreadystatechange = function()
{
if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
{var a = HttpRequest.responseXML.documentElement.getElementsByTagName("item");var value;var name;var aa;var n="";var v="";var ac="";var i;for (i = 0; i < a.length; i++)
{
aa=a[i].getElementsByTagName("name");
name = aa[0].firstChild.nodeValue;
n= n + name + ";"
aa=a[i].getElementsByTagName("value");
value = aa[0].firstChild.nodeValue;
if (i==0) ac=value;
v= v+ value + ";";danhmuccon.options[i] = new Option(name, value);}document.form1.hdmucconn.value=n;
document.form1.hdmucconv.value=v;
document.form1.hdmucconi.value=ac;
if (i>1){danhmuccon.disabled=false;danhmuccon.focus();}else{danhmuccon.disabled=true;}
 n="";
 v="";
 ac="";
 a = HttpRequest.responseXML.documentElement.getElementsByTagName("tl");
 for (i = 0; i < a.length; i++)
 {
 aa=a[i].getElementsByTagName("tln");
 name = aa[0].firstChild.nodeValue;
 n= n + name + ";";
 aa=a[i].getElementsByTagName("tlv");
 value = aa[0].firstChild.nodeValue;
 if (i==0) ac=value;
 v= v+ value + ";";loaitin.options[i] = new Option(name, value);}document.form1.hdltn.value=n;document.form1.hdltv.value=v;document.form1.hdlti.value=ac;}};HttpRequest.send(null);}
function setmuccon(valueID){document.form1.hdmucconi.value= valueID}
function setloaitin(valueID){document.form1.hdlti.value= valueID}
function setngay(valueID){
var arr=valueID.split(";");
if (arr.length!=6) return;
if ((isNaN(arr[0]))|(isNaN(arr[3]))|(isNaN(arr[4])))return;document.form1.txtsongay.value= arr[0];document.getElementById("lbsongayrao").innerHTML=arr[1];document.getElementById("rvsongay").innerHTML=arr[2];
if (parseInt(arr[3])>=parseInt(arr[4])){rvsongay.maximumvalue = arr[3];rvsongay.minimumvalue = arr[4];rvsongay.errormessage="Số ngày rao từ " + arr[4] + " đến " + arr[3];}else{rvsongay.minimumvalue=0;rvsongay.maximumvalue=0; 
if (parseInt(arr[3])==0) rvsongay.errormessage = "Số tiền hiện có không đủ để đăng tin";else rvsongay.errormessage = "Tin rao đã hết hạn";}document.getElementById("rvsongay").style.display="none";document.getElementById("rqsongay").style.display="none";}
function SearchOnBlur(field){if(field.value==''){ field.value='Nhập nội dung cần tìm kiếm...';}}
function SearchOnFocus(field){if(field.value=='Nhập nội dung cần tìm kiếm...'){field.value = '';}}
function untieude(field){if(field.value==''){ field.value='Xin nhập Tiếng Việt có dấu, tối thiểu 10 ký tự, không nhập chữ IN HOA';}}
function tieude(field){if(field.value=='Xin nhập Tiếng Việt có dấu, tối thiểu 10 ký tự, không nhập chữ IN HOA'){field.value = '';}}
document.onkeypress = pressenter;function pressenter(e) {if (!e) var e = window.event; var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; var node = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null); if (keyCode == 13) {if ((node==null) || (typeof (node.type) == 'undefined')) {return false;} else {return true;}}}
function undisplaylt() {document.getElementById('rqhinhthuc').style.display='none';}
function untieubieu(field){if(field.value==''){ field.value='Đường dẫn ảnh tiêu biểu. Ảnh có kích thước rộng 200px, cao từ 100px đến 250px';}}
function encode(string){string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++){var c = string.charCodeAt(n);if (c < 128) {utftext += String.fromCharCode(c);} else if((c > 127) && (c < 2048)) {utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128);}else {utftext += String.fromCharCode((c >> 12) | 224);utftext += String.fromCharCode(((c >> 6) & 63) | 128);utftext += String.fromCharCode((c & 63) | 128);}}return escape(utftext);}
function twitter(u){window.open("http://twitter.com/home?status=" + encode(u))}
function facebook(u,t){window.open("http://www.facebook.com/share.php?u=" + encode(u) + "&t=" + encode(t));}
function buzz(u){window.open("http://buzz.yahoo.com/buzz?publisherurn=raovat30s.com&targetUrl=" + encode(u));}
function DisplayAlert(s){document.getElementById('mess').innerHTML=s;document.getElementById('AlertBox').style.display='block';document.getElementById('anhs').className='inbox';}
function unDisplayAlert(){document.getElementById('AlertBox').style.display='none';document.getElementById('anhs').className='';}
