﻿var sTimeCache = 14400;
var _d = (new Date()).getTime()+ sTimeCache;
function LoadListPIOther(pg){				
	var url=$("hdfListPIOther").value+"&maxpg=10&pindex="+pg+nocacheAjax();	

	//Element.hide("dvPaging");	
	new Ajax.Request(url, {   
		method: 'get',					
		onSuccess: function(transport) {						
			var sResult=transport.responseText.split('<-#->');
			if(sResult[0]!="" )
			{
				Element.setInnerHTML("divListPIRelate", sResult[0]);
			}
			else
			{
			Element.hide("divListPIRelate");
			}
			if(sResult[1]!="" )
			{
				Element.setInnerHTML("DivPINextPre", sResult[1]);
			}
			else
			{
				Element.hide("DivPINextPre");
			}
			},
		onFailure: function(e){ //alert(e.responseText)
		return false;
		}
		}
	)
}
function LoadCurrentPriceQuyDoi()
{
	var gchuan = $("hdGChuan").value;
	var ltien = $("hdlTien").value;
	var url=pathClient+"handler/getcurrentPrice.aspx?act=giaBDSDetail&gc="+gchuan+"&ltien="+ltien;
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {
			Element.setInnerHTML("dvPriceBoard",transport.responseText);
 			PriceClick(0);
			},
		onFailure: function(e){ alert(e.responseText);
		}
		}
	);	
}
Event.observe(window, 'load', LoadCurrentPriceQuyDoi, false);

function TKPropertyDetail()
{
	var id = $("hdpi").value;
	var act = "act=tkpropertydetail";
	act += "&id="+id;
	var url = pathClientAjax+"handler/Handler.aspx?"+ act+"&d="+(new Date()).getTime();
	new Ajax.Request(url, {   
		method: 'get',					
		onSuccess: function(transport) {
			if (transport.responseText != ""){
			}
			
			},
		onFailure: function(e){return false;
		}
		}
	);
}
Event.observe(window, 'load', TKPropertyDetail, false);

function View()
{
	if(document.getElementById("txt_Namsinh").value=="")
	{
		alert("Bạn phải nhập năm sinh!");
		document.getElementById("txt_Namsinh").focus();
		return false;
	}
	if(!isAllDigit(trim(document.getElementById("txt_Namsinh").value,' ')))
	{
		alert("Bạn nhập năm sinh chưa đúng!");
		document.getElementById("txt_Namsinh").focus();
		return false;
	}
	
	if(document.getElementById("select_Gioitinh").value=="")
	{
		alert("Bạn phải chọn giới tính!");
		document.getElementById("select_Gioitinh").focus();
		return false;
	}
	var namsinh="&namsinh="+document.getElementById("txt_Namsinh").value;
	var huong="&huong="+document.getElementById("select_huong").value;
	var gioitinh="&gioitinh="+document.getElementById("select_Gioitinh").value;
	path = document.getElementById('hdpath').value;
	document.getElementById('txtHint').innerHTML = "<div style='text-align:center'><IMG alt=''src="+ pathClientAjax + "images/loading6.gif></div>";
	var url = pathClientAjax+"handler/ViewDirectionHomeHandler.aspx?act=View"+namsinh+huong+gioitinh+"&d="+ (new Date()).getTime();
	new Ajax.Request(url, {   
		method: 'get',					
		onSuccess: function(transport) {				
			document.getElementById('txtHint').innerHTML = transport.responseText;					
			},
		onFailure: function(e){ return false;
		}}
	)		
}

function ViewDetail()
{
	if(document.getElementById("txt_Namsinh").value=="")
	{
		alert("Bạn phải nhập năm sinh!");
		document.getElementById("txt_Namsinh").focus();
		return false;
	}
	if(!isAllDigit(trim(document.getElementById("txt_Namsinh").value,' ')))
	{
		alert("Bạn nhập năm sinh chưa đúng!");
		document.getElementById("txt_Namsinh").focus();
		return false;
	}
	
	if(document.getElementById("select_Gioitinh").value=="")
	{
		alert("Bạn phải chọn giới tính!");
		document.getElementById("select_Gioitinh").focus();
		return false;
	}
	var namsinh="&namsinh="+document.getElementById("txt_Namsinh").value;
	var huong="&huong="+document.getElementById("select_huong").value;
	var gioitinh="&gioitinh="+document.getElementById("select_Gioitinh").value;
	path = document.getElementById('hdpathImage').value;
	document.getElementById('txtHint').innerHTML = "<div align='center' style='padding-top:10px;'><IMG alt=''src="+ pathClientAjax + "images/loading6.gif></div>";
	var url = pathClientAjax+"handler/ViewDirectionHomeHandler.aspx?act=ViewDetail"+namsinh+huong+gioitinh+"&d="+ (new Date()).getTime();
	new Ajax.Request(url, {   
		method: 'get',					
		onSuccess: function(transport) {
			document.getElementById('txtHint').style.display = 'block';				
			document.getElementById('txtHint').innerHTML = transport.responseText;
			document.getElementById('outerPhongThuyContainer').style.height='1050px';
			document.getElementById('overlayPhongThuy').style.height='2500px';	
			},
		onFailure: function(e){ return false;
		}}
	)		
	
}
function isDigit (c)
{	return ((c >= "0") && (c <= "9"))
}

function isAllDigit (s)
{   
  var i;
  if (isEmpty(s)) 
     if (isAllDigit.arguments.length == 1) return false;
     else return (isDigital.arguments[1] == true);
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if (isDigit(c)==false)
    return false;
  }
  return true;
}
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

/*--------------------Detail--------------------*/
function ShowformXemHuong()
{
	document.getElementById('phongthuypopups').style.top='68%';	
	document.getElementById('txtHint').style.display = 'none';
	document.getElementById('phongthuypopups').style.height='160px';
	document.getElementById('phongthuypopups').style.display = 'block';
	document.getElementById("txt_Namsinh").focus();
}

function ShowPhongThuy()
{
	var act = "act=ShowPhongThuy";
	var url = pathClientAjax+"handler/ViewDirectionHomeHandler.aspx?"+ act+"&d="+(new Date()).getTime();
	new Ajax.Request(url, {   
		method: 'get',					
		onSuccess: function(transport) {
			if (transport.responseText != ""){
				Element.setInnerHTML("login_box_popup_header", "Xem phong thủy");
				Element.setInnerHTML("contentlogin", transport.responseText);
				Element.show('login_box');
				document.getElementById("txt_Namsinh").focus();
			}	
			else
				Element.hide('login_box');			
			},
		onFailure: function(e){return false;
		}
		}
	);
}
function KeyPressPhongThuy(e, type)
{
	var unicode=e.charCode? e.charCode : e.keyCode;	
	if (unicode == 13)
	{
		switch(type) {
		case "ViewDetail":
			ViewDetail();
			break;
		}
	}
}