window.onresize = windowResize;
window.onscroll = windowRelocation;
var xmlHttp;
var currentLayer = "";
var currentStockIndex = 0;
var currentFourInOneTitle = "";
var currentFourInOneIndex = 0;
var noOfAjaxTrial = 0;
var currentMapEstId = "";
var stockArray = new Array();
var fourInOneArray = new Array();
var fourInOneTitleArray = new Array();
var updateDateArray = new Array();
var bEmaileFlag = false;
var request, requestRegion, requestDist, requestDept;
var bControlFlagToDetailPage = true;
/* 2012-04-05*/
var ajax_loading_dist = false;
var ajax_loading_subReg = false;
var ajax_loading_detail = false;
var curr_dist_type="";
$(document).ready(function() {
$( "#sendertel" ).focus(function() {
if ( $(this).val() == null || $(this).val() == '' ){
$( this ).val( "(852)" );
}
});
});
function search_result_init() {
if (document.getElementById("divEstateList")) {
var ppc = document.getElementById("divPPCList");
var h_ppc = ppc.offsetHeight;
if (ppc.innerHTML == "") {
ppc.style.display = "none";
h_ppc = 0;
} else {
ppc.style.display = "";
}
var h = document.getElementById("tdSearchResult").offsetHeight - 1;
var el_h = h - h_ppc;
if (el_h < 0) el_h = 0;
document.getElementById("divEstateList").style.height = el_h;
}
var index = document.getElementById("displayDetailLayer");
if (index != null)
{
if (index.value != "") {
showDetailLayer(index.value);
index.value = "";
} else {
index = document.getElementById("displayFourInOneLayer");
if (index.value != "") {
showFourInOneLayer(index.value);
index.value = "";
}
}
}
}
function selectStockType(type) {
var frm = document.formAdvanceSearch;
frm.stockType.value = type;
frm.target = "";
//cannot remove action, will cause problem in search engine link e.g. http://proptx.midland.com.hk/advanceCS/%A4%F1%B5%D8%A7Q%A4s-beverly-hill
frm.action = "index.jsp";
frm.submit();
}
function selectPage(obj) {
var frm = document.formAdvanceSearch;
frm.page.value = obj.options[obj.selectedIndex].value;
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function selectPageByValue(value) {
var frm = document.formAdvanceSearch;
frm.page.value = value;
frm.target = "";
frm.action = "?deptId=" + dept_id + "&licenceNo=" + licence_no + "&referer=" + referer;
frm.submit();
}
//Add by Dan
function selectAgentPageByValue(value) {
var frm = document.formAdvanceSearch2;
frm.page.value = value;
frm.target = "";
frm.action = "agent_search_list_index.jsp" ;
frm.submit();
}
function goAgentBlog(dept_id, licence_no) {
if (!bEmaileFlag) {
//window.location.href="agent_blog_index.jsp?deptId=&licenceNo=" + licence_no;
window.location.href="agent_blog_index.jsp?deptId=" + dept_id + "&licenceNo=" + licence_no + '&lang=' + lang ;
}
else {
bEmaileFlag = false;
}
}
function goBranchBlog(dept_id) {
if (!bEmaileFlag) {
window.location.href="branch_blog_index.jsp?deptId=" + dept_id + '&lang=' + lang ;
}
else {
bEmaileFlag = false;
}
}
function goCsDetail(stockId, seq) {
if (!bEmaileFlag) {
window.location.href="/cs/detail_layer.jsp?stockId=" + stockId + '&lang=' + lang + '&seq=' + seq;
}
else {
bEmaileFlag = false;
}
}
function searchEmp() {
var ddRegion = document.getElementById('ddRegion');
var ddDist = document.getElementById('ddDist');
var ddDept = document.getElementById('ddDept');
var ddAgent = document.getElementById('ddAgent');
if (!bEmaileFlag) {
bEmaileFlag = false;
if (ddRegion.options[ddRegion.selectedIndex].value == "0")
{
alert(msg_select_region);
return false;
}
if (ddDist.options[ddDist.selectedIndex].value == "0")
{
alert(msg_select_district);
return false;
}
if (ddDept.options[ddDept.selectedIndex].value == "0")
{
alert(msg_select_dept);
return false;
}
if (ddAgent.options[ddAgent.selectedIndex].value == "0")
{
window.location.href="branch_blog_index.jsp?deptId=" + ddDept.options[ddDept.selectedIndex].value + '&lang=' + lang;
}
else
{
window.location.href="agent_blog_index.jsp?deptId=" + ddDept.options[ddDept.selectedIndex].value + "&licenceNo=" + ddAgent.options[ddAgent.selectedIndex].value + '&lang=' + lang;
}
}
else {
bEmaileFlag = false;
}
}
/*function stockSorting() {
var ddRegion = document.getElementById('ddRegion');
var ddDist = document.getElementById('ddDist');
var ddDept = document.getElementById('ddDept');
var ddAgent = document.getElementById('ddAgent');
var ddSortBy = document.getElementById('ddSortBy');
var ddOrderBy = document.getElementById('ddOrderBy');
var sortBy = "";
if (!bEmaileFlag) {
bEmaileFlag = false;
sortBy = '&sortBy=' + ddSortBy.options[ddSortBy.selectedIndex].value + '&orderBy=' + ddOrderBy.options[ddOrderBy.selectedIndex].value
window.location.href="agent_blog_index.jsp?deptId=" + ddDept.options[ddDept.selectedIndex].value + "&licenceNo=" + ddAgent.options[ddAgent.selectedIndex].value + sortBy;
}
else {
bEmaileFlag = false;
}
}*/
function stockSorting(sb, ob) {
var ddDept = document.getElementById('ddDept');
var ddAgent = document.getElementById('ddAgent');
if (!bEmaileFlag) {
if (ob == "") {
if (sortBy.value == sb) {
orderBy.value = (orderBy.value == "ASC" ? "DESC" : "ASC");
} else {
orderBy.value = "ASC";
}
} else {
orderBy.value = ob;
}
sortBy.value = sb;
bEmaileFlag = false;
window.location.href="?deptId=" + ddDept.options[ddDept.selectedIndex].value + "&licenceNo=" + ddAgent.options[ddAgent.selectedIndex].value + '&sortBy=' + sortBy.value + '&orderBy=' + orderBy.value + '&lang=' + lang + "&referer=" + referer;
}
else {
bEmaileFlag = false;
}
}
function goPageByDept(dept_id) {
if (!bEmaileFlag) {
if (dept_id != '')
{
window.location.href="agent_blog_index.jsp?deptId=" + dept_id;
}
}
else {
bEmaileFlag = false;
}
}
function createRequest2() {
try {
var request = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
request = false;
}
}
}
return request;
if (!request)
alert("Error initializing XMLHttpRequest!");
}
function changeRegion(region_id, lang, distId) {
if (region_id != '') {
//var request;
var url = "dist_list.jsp?regionId=" + region_id + '&lang=' + lang + '&distId=' + distId;
var divDept = document.getElementById('divDept');
var divAgent = document.getElementById('divAgent');
divDept.innerHTML="";
divAgent.innerHTML="";
requestRegion = createRequest2();
requestRegion.open("POST", url, true);
requestRegion.onreadystatechange = setDist;
requestRegion.send(null);
}
}
function setDist(){
var divDist = document.getElementById('divDist');
if (requestRegion.readyState == 4) {
if (requestRegion.status == 200) {
var dist = requestRegion.responseText;
if (dist.length > 0) {
divDist.innerHTML=dist;
}
else {
divDist.innerHTML="";
}
}
//else if(request.status == 500) {
//ShowAjaxError(request.responseText);
//}
}
}
function changeDist(dist_id, lang, deptId) {
if (dist_id != '') {
//var request;
var url = "dept_list.jsp?distId=" + dist_id + '&lang=' + lang + "&deptId=" + deptId + "&onChangeEvent=Y";
var divAgent = document.getElementById('divAgent');
divAgent.innerHTML="";
requestDist = createRequest2();
requestDist.open("POST", url, true);
requestDist.onreadystatechange = setDept;
requestDist.send(null);
}
}
function setDept(){
var divDept = document.getElementById('divDept');
if (requestDist.readyState == 4) {
if (requestDist.status == 200) {
var dept = requestDist.responseText;
if (dept.length > 0) {
divDept.innerHTML=dept;
}
else {
divDept.innerHTML="";
}
}
//else if(request.status == 500) {
//ShowAjaxError(request.responseText);
//}
}
}
function changeDept(dept_id, lang, licenceNo) {
if (dept_id != '') {
//var request;
var url = "agent_list.jsp?deptId=" + dept_id + '&lang=' + lang + "&licenceNo=" + licenceNo;
requestDept = createRequest2();
requestDept.open("POST", url, true);
requestDept.onreadystatechange = setAgent;
requestDept.send(null);
}
}
function setAgent(){
var divAgent = document.getElementById('divAgent');
if (requestDept.readyState == 4) {
if (requestDept.status == 200) {
var agent = requestDept.responseText;
if (agent.length > 0) {
divAgent.innerHTML=agent;
}
else {
divAgent.innerHTML="";
}
}
//else if(request.status == 500) {
//ShowAjaxError(request.responseText);
//}
}
}
function SetEmaileFlag(bFlag) {
bEmaileFlag = bFlag;
}
function setPageSize(value) {
var frm = document.formAdvanceSearch;
for(index = 0; index < frm.pageSize.length; index++) {
if(frm.pageSize[index].value == value)
frm.pageSize.selectedIndex = index;
}
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function previousPage() {
var frm = document.formAdvanceSearch;
frm.page.value--;
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function nextPage() {
var frm = document.formAdvanceSearch;
frm.page.value++;
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function selectEstate(est_id) {
var frm = document.formAdvanceSearch;
frm.reset();
frm.page.value = 1;
frm.sortBy.value = frm.selectSort.options[frm.selectSort.selectedIndex].value;
frm.orderBy.value = "DESC";
frm.stockId.value = "";
frm.estId.value = est_id;
frm.target = "";
frm.action = "/cs/index.jsp";
frm.submit();
}
function selectEstate(est_name, lang) {
var frm = document.formAdvanceSearch;
frm.reset();
frm.method = "get";
frm.target = "";
if (lang == 'en')
{
frm.action = "//en.hkp.com.hk/find-property/" + est_name;
}
else if (lang == 'gb')
{
frm.action = "//sc.hkp.com.hk/find-property/" + est_name;
}
else
{
frm.action = "//www.hkp.com.hk/find-property/" + est_name;
}
frm.submit();
}
function selectTopEst(ele, est_id, distIdHK, distIdKN, distIdNT, pick_dist_hk, pick_dist_kn, pick_dist_nt) {
var frm = document.formAdvanceSearch;
frm.page.value = 1;
frm.sortBy.value = frm.selectSort.options[frm.selectSort.selectedIndex].value;
frm.orderBy.value = "DESC";
// frm.distIdHK.value = distIdHK;
// frm.distIdKN.value = distIdKN;
// frm.distIdNT.value = distIdNT;
// frm.pick_dist_hk.value = pick_dist_hk;
// frm.pick_dist_kn.value = pick_dist_kn;
// frm.pick_dist_nt.value = pick_dist_nt;
frm.estId.value = est_id;
// frm.estName.value = ele.innerHTML;
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function sort(sb, ob) {
var frm = document.formAdvanceSearch;
frm.page.value = "1";
frm.sortBy.value = sb;
if (ob=="") ob = (frm.orderBy.value == "ASC" ? "DESC" : "ASC");
frm.orderBy.value = ob;
frm.target = "";
frm.action = "index.jsp";
frm.submit();
}
function openMap(est_id, lon, lat) {
// window.open("//www.midlandmap.hk/map_hk/index.jsp?pisEstId=" + est_id);
showMapLayer(est_id, lon, lat);
}
function openEbook(est_id) {
window.open("//app2.hkp.com.hk/residential_ebook/index.jsp?estId=" + est_id);
}
function openTX(est_id) {
window.open("//app2.hkp.com.hk/tx/index.jsp?estateId=" + est_id);
}
function previousStock() {
if (currentStockIndex == 0) {
document.getElementById("displayDetailLayer").value = finder_pageSize - 1;
previousPage();
} else {
document.getElementById('mapframe').src = "images/spacer.gif";
setTimeout("showDetailLayer("+(currentStockIndex-1)+");",500);
}
}
function nextStock() {
if (currentStockIndex == stockArray.length-1) {
document.getElementById("displayDetailLayer").value = 0;
nextPage();
} else {
document.getElementById('mapframe').src = "images/spacer.gif";
setTimeout("showDetailLayer("+(currentStockIndex+1)+");",500);
}
}
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function showDetailLayer(i) {
noOfAjaxTrial = 0;
showDetailLayerLoad(i);
}
function showDetailLayerLoad(i) {
if (isNaN(i)) return false;
if (i > stockArray.length-1) return false;
currentStockIndex = i;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
return false;
} else {
noOfAjaxTrial++;
currentLayer = "detail";
document.body.style.overflow = "hidden";
document.body.className = "hide";
if (document.getElementById("div_dist_hk")) hideAllPickList();
document.getElementById("maskLayer").className = "maskLayer_detail";
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
document.getElementById("maskLayer").style.opacity = "0.60";
document.getElementById("maskLayer").style.display = "block";
document.getElementById("detailLayer").style.height = document.body.offsetHeight - 50;
document.getElementById("detailLayer").style.top = document.body.scrollTop+document.body.offsetHeight/2 - 50;
document.getElementById("detailLayer").innerHTML = "

";
document.getElementById("detailLayer").style.display = "block";
xmlHttp.onreadystatechange = detailStateChanged;
xmlHttp.open("GET",stockArray[currentStockIndex][1],true);
xmlHttp.send(null);
}
return false;
}
function hideDetailLayer() {
document.getElementById("detailLayer").innerHTML = "";
document.getElementById("detailLayer").style.display = "none";
document.getElementById("maskLayer").className = "maskLayer";
document.getElementById("maskLayer").style.display = "none";
document.body.className = "";
document.body.style.overflow = "auto";
}
function detailStateChanged() {
if (xmlHttp.readyState==4) {
if (xmlHttp.status==200 && xmlHttp.responseText.indexOf("divStockInfoHeader")>-1) {
finder_page = eval(finder_page);
finder_pageSize = eval(finder_pageSize);
finder_noOfStock = eval(finder_noOfStock);
currentStockIndex = eval(currentStockIndex);
var innerHTML = "";
innerHTML += "";
if ((finder_page-1)*finder_pageSize+1+currentStockIndex > 1) innerHTML += " ";
innerHTML += " | ";
innerHTML += "";
innerHTML += "";
innerHTML += "  | ";
innerHTML += "更新日期: " + updateDateArray[currentStockIndex] + " | ";
innerHTML += " | ";
innerHTML += "
";
innerHTML += xmlHttp.responseText;
innerHTML += " | ";
innerHTML += "";
if ((finder_page-1)*finder_pageSize+1+currentStockIndex < finder_noOfStock) innerHTML += " ";
innerHTML += " | ";
innerHTML += "
";
//document.getElementById("detailLayer").filters[0].apply();
document.getElementById("detailLayer").innerHTML = innerHTML;
//document.getElementById("detailLayer").filters[0].play();
detailReLocation();
resizeDetailLayerHeight();
document.getElementById("detailBody").style.backgroundColor = "#FFFFFF";
} else if (noOfAjaxTrial<5) {
setTimeout("showDetailLayerLoad(currentStockIndex)",10000);
/*
var innerHTML = "";
innerHTML += "";
innerHTML += "";
innerHTML += "";
innerHTML += " | ";
innerHTML += "
";
document.getElementById("detailLayer").innerHTML = innerHTML;
*/
} else {
hideDetailLayer();
}
}
}
function showFourInOneLayer(i) {
noOfAjaxTrial = 0;
showFourInOneLayerLoad(i);
}
function showFourInOneLayerLoad(i) {
if (isNaN(i)) return false;
currentFourInOneIndex = i;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null){
alert ("Your browser does not support AJAX!");
return false;
}else{
noOfAjaxTrial++;
currentLayer = "fourInOne";
currentFourInOneTitle = fourInOneTitleArray[currentFourInOneIndex][0];
document.body.style.overflow = "hidden";
document.body.className = "hide";
if (document.getElementById("div_dist_hk")) hideAllPickList();
// document.getElementById("spanSuperBanner").style.display = "none";
document.getElementById("maskLayer").className = "maskLayer_detail";
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
document.getElementById("maskLayer").style.opacity = "0.60";
document.getElementById("maskLayer").style.display = "block";
document.getElementById("fourInOneLayer").style.height = document.body.offsetHeight - 50;
document.getElementById("fourInOneLayer").style.top = document.body.scrollTop+document.body.offsetHeight/2 - 50;
document.getElementById("fourInOneLayer").innerHTML = "";
document.getElementById("fourInOneLayer").style.display = "block";
xmlHttp.onreadystatechange = fourInOneStateChanged;
xmlHttp.open("GET",fourInOneArray[currentFourInOneIndex][0],true);
xmlHttp.send(null);
}
return false;
}
function hideFourInOneLayer() {
document.getElementById("fourInOneLayer").innerHTML = "";
document.getElementById("fourInOneLayer").style.display = "none";
document.getElementById("maskLayer").className = "maskLayer";
document.getElementById("maskLayer").style.display = "none";
// document.getElementById("spanSuperBanner").style.display = "block";
document.body.className = "";
document.body.style.overflow = "auto";
}
function fourInOneStateChanged() {
if (xmlHttp.readyState==4) {
if (xmlHttp.status==200) {
var innerHTML = "";
innerHTML += "";
innerHTML += "";
innerHTML += " ";
innerHTML += "單位綜合資訊 - " + currentFourInOneTitle + " | ";
innerHTML += " | ";
innerHTML += "
";
innerHTML += xmlHttp.responseText;
innerHTML += " | ";
innerHTML += "
";
//document.getElementById("detailLayer").filters[0].apply();
document.getElementById("fourInOneLayer").innerHTML = innerHTML;
//document.getElementById("detailLayer").filters[0].play();
fourInOneReLocation();
resizeFourInOneLayerHeight();
document.getElementById("detailBody").style.backgroundColor = "#FFFFFF";
} else if (noOfAjaxTrial<5) {
setTimeout("showFourInOneLayerLoad(currentFourInOneIndex)",10000);
/*
} else if (xmlHttp.status==500) {
var innerHTML = "";
innerHTML += "";
innerHTML += "";
innerHTML += "";
innerHTML += " | ";
innerHTML += "
";
document.getElementById("detailLayer").innerHTML = innerHTML;
*/
} else {
hideFourInOneLayer();
}
}
}
function showMapLayer(est_id, lon, lat) {
noOfAjaxTrial = 0;
showMapLayerLoad(est_id, lon, lat);
}
function showMapLayerLoad(est_id, lon, lat) {
if (est_id == null || est_id == "") return false;
currentMapEstId = est_id;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
return false;
} else {
noOfAjaxTrial++;
currentLayer = "map";
document.body.style.overflow = "hidden";
document.body.className = "hide";
if (document.getElementById("div_dist_hk")) hideAllPickList();
document.getElementById("maskLayer").className = "maskLayer_detail";
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
document.getElementById("maskLayer").style.opacity = "0.60";
document.getElementById("maskLayer").style.display = "block";
document.getElementById("mapLayer").style.height = document.body.offsetHeight - 50;
document.getElementById("mapLayer").style.top = document.body.scrollTop+document.body.offsetHeight/2 - 50;
document.getElementById("mapLayer").innerHTML = "";
document.getElementById("mapLayer").style.display = "block";
xmlHttp.onreadystatechange = mapStateChanged;
xmlHttp.open("GET","map_layer.jsp?estId="+est_id+"&lon="+lon+"&lat="+lat,true);
xmlHttp.send(null);
}
return false;
}
function hideMapLayer() {
document.getElementById("mapLayer").innerHTML = "";
document.getElementById("mapLayer").style.display = "none";
document.getElementById("maskLayer").className = "maskLayer";
document.getElementById("maskLayer").style.display = "none";
document.body.className = "";
document.body.style.overflow = "auto";
}
function mapStateChanged() {
if (xmlHttp.readyState==4) {
if (xmlHttp.status==200 && xmlHttp.responseText.indexOf("divMap")>-1) {
var innerHTML = "";
innerHTML += " | ";
innerHTML += "";
innerHTML += "";
innerHTML += " 屋苑位置 | ";
innerHTML += " | ";
innerHTML += "
";
innerHTML += xmlHttp.responseText;
innerHTML += " | ";
innerHTML += " | ";
innerHTML += "
";
document.getElementById("mapLayer").innerHTML = innerHTML;
mapReLocation();
resizeMapLayerHeight();
document.getElementById("detailBody").style.backgroundColor = "#FFFFFF";
} else if (noOfAjaxTrial<5) {
setTimeout("showMapLayerLoad(currentMapEstId)",10000);
} else {
hideMapLayer();
}
}
}
function windowResize() {
if (currentLayer == "detail") {
resizeDetailLayerHeight();
}
if (currentLayer == "fourInOne") {
resizeFourInOneLayerHeight();
}
if (currentLayer == "map") {
resizeMapLayerHeight();
}
}
function resizeDetailLayerHeight() {
if (document.getElementById("detailBody")) {
document.getElementById("div_detail_container").style.height = document.body.clientHeight - 110 - document.getElementById("divStockInfoHeader").clientHeight;
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
}
}
function resizeFourInOneLayerHeight(){
if (document.getElementById("detailBody")){
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
document.getElementById("fourInOneLayer").style.width = document.body.clientWidth;
}
}
function resizeMapLayerHeight(){
if (document.getElementById("detailBody")){
document.getElementById("maskLayer").style.height = document.body.scrollHeight;
document.getElementById("maskLayer").style.width = document.body.scrollWidth + 20;
document.getElementById("mapLayer").style.width = document.body.clientWidth;
}
}
function windowRelocation() {
if (currentLayer == "detail") {
detailReLocation();
}
if (currentLayer == "fourInOne") {
fourInOneReLocation();
}
if (currentLayer == "map") {
mapReLocation();
}
}
function detailReLocation() {
document.getElementById("detailLayer").style.top = document.body.scrollTop + 20;
}
function fourInOneReLocation(){
if (document.getElementById("fourInOneLayer").style.display == "block") {
var detailTableHeight = document.getElementById("IntegratedDetailTable").style.height;
detailTableHeight = eval(detailTableHeight.replace(/px/i, ""));
var bodyTop;
if(typeof(window.pageYOffset)=='number') {
bodyTop = window.pageYOffset;
} else {
bodyTop = document.body.scrollTop;
}
var space = (document.body.clientHeight - detailTableHeight) / 2 - 50;
if (space < 20) space = 20;
document.getElementById("fourInOneLayer").style.top = bodyTop + space;
}
}
function mapReLocation() {
document.getElementById("mapLayer").style.top = document.body.scrollTop + 20;
}
function resetEstDivheight() {
var divDeptEst = document.getElementById("divDeptEst");
var divStock = document.getElementById("divStock");
var txPadding = document.getElementById("divOffset");
var toDivOffsetHeight;
if (divStock && divDeptEst && txPadding) {
toDivOffsetHeight = divStock.offsetHeight - 25 - ((divStock.offsetHeight - 25) % 153);
divDeptEst.style.height = toDivOffsetHeight + 'px';
txPadding.style.height = ((divStock.offsetHeight - 33) % 153) + 'px';
}
//alert(toDivOffsetHeight + ',' + divStock.offsetHeight + ',' + divDeptEst.style.height + txPadding.style.height);
}
function SetInputText(id, action, lang)
{
var inputText = document.getElementById(id);
if (action == 'onfocus')
{
inputText.style.color = '#000000';
switch(id){
case 'sendername':
if (inputText.value == im_name)
inputText.value = '';
break;
case 'sendertel':
if (inputText.value == im_tel)
inputText.value = '';
break;
case 'senderemail':
if (inputText.value == im_email)
inputText.value = '';
break;
case 'senderstockid':
if (inputText.value == im_stock_id)
inputText.value = '';
break;
case 'senderemailcontent':
if (inputText.value == im_content)
inputText.value = '';
break;
default:
}
}
else
{
if (inputText.value == ''){
inputText.style.color = '#aaaaaa';
switch(id){
case 'sendername':
inputText.value = im_name;
break;
case 'sendertel':
inputText.value = im_tel;
break;
case 'senderemail':
inputText.value = im_email;
break;
case 'senderstockid':
inputText.value = im_stock_id;
break;
case 'senderemailcontent':
inputText.value = im_content;
break;
default:
}
}
}
}
function check_SendIM_Empty(lang)
{
var sendername = document.getElementById("sendername");
var sendertel = document.getElementById("sendertel");
var senderemail = document.getElementById("senderemail");
var senderstockid = document.getElementById("senderstockid");
var senderemailcontent = document.getElementById("senderemailcontent");
if (sendername.value == "" || (sendername.value == im_name))
{
alert(im_name_alert);
sendername.focus();
return false;
}
if ((sendertel.value == "" || (sendertel.value == im_tel)) && (senderemail.value =="" || (senderemail.value == im_email)) )
{
alert(im_tel_email_alert);
sendertel.focus();
return false;
}
if (senderemail.value!= "" && ((senderemail.value != im_email)))
{
emailPattern = /.*\@.*\..*/;
if (senderemail.value != "" && !emailPattern.test(senderemail.value))
{
alert(im_email_alert);
senderemail.focus();
return false;
}
}
if (senderstockid.style.display != "none" && (senderstockid.value == "" || (senderstockid.value == im_stock_id)))
{
/*
alert(im_stock_alert);
senderstockid.focus();
return false;
*/
}
if (senderemailcontent.value == "" || (senderemailcontent.value == im_content))
{
alert(im_content_alert);
senderemailcontent.focus();
return false;
}
return true;
}
function createRequest() {
try {
request = new XMLHttpRequest();
// request = new XDomainRequest();
// request.contentType="text/plain"
//response.addHeader("document.domain", ".midland.com.hk");
//response.addHeader("Access-Control-Allow-Origin", "proptx.midland.com.hk");
// request.setrequestheader ( "Content-Type", "application / x-www-form-urlencoded");
// request.setrequestheader ( "contentType", "text / html; charset = uft-8")
}
catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
request = false;
}
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
}
function sendIM(lang){
var sendername = document.getElementById("sendername");
var sendertel = document.getElementById("sendertel");
sendertel.value = sendertel.value.replace(sendertel.defaultValue, '');
var senderemail = document.getElementById("senderemail");
senderemail.value = senderemail.value.replace(senderemail.defaultValue, '')
var senderstockid = document.getElementById("senderstockid");
var senderemailcontent = document.getElementById("senderemailcontent");
var stockinfo = document.getElementById("stockinfo");
var chkbooking = document.getElementById("chkbooking");
var subject = document.getElementById("subject").value;
var empid= document.getElementById("empid");
var empName= document.getElementById("empName");
var booking="N";
if (chkbooking.checked)
{ booking="Y"; }
//if (senderstockid.style.display == "none")
//{ senderstockid.value = "";}
//else
if (senderstockid.style.display != "none")
{
if (senderstockid.value == "" || senderstockid.value == im_stock_id)
{
senderstockid.value = "";
}
else
{
subject = subject + senderstockid.value;
}
}
//var empemail = document.getElementById("empemail").value.replace('midland.com.hk', 'im.midland.com.hk'); //for IM
//var empemail = 'alexli@im.midland.com.hk'; //for IM Dev
//var url = "/branch_agent/sendIM.jsp?name=" + sendername.value + "&from=" + senderemail.value + "&to=imsend@midland.com.hk"
// + "&subject=" + empemail + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&stockinfo=" + stockinfo.value + "&booking=" + booking + "&lang=" + lang; //for IM
var empemail = document.getElementById("empemail").value; //for email
//alert(empemail);
//var empemail = 'alexli@midland.com.hk'; //for email Dev
var url = "/branch_agent/sendIM.jsp?" + encodeURI("name=" + sendername.value + "&from=" + senderemail.value + "&to=" + empemail
+ "&subject=" + subject + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&stockinfo=" + stockinfo.value + "&booking=" + booking + "&lang=" + lang +"&empid="+empid.value +"&empName=" +empName.value); //for Email
// console.log(url);
// return;
if (check_SendIM_Empty(lang))
{
document.getElementById("btnSend").style.display='none';
document.getElementById("divImSending").style.display='';
createRequest();
request.open("POST", url, true);
request.onreadystatechange = returnMessage;
request.send(null);
}
}
/*
function sendIM_al(lang){
var sendername = document.getElementById("sendername");
var sendertel = document.getElementById("sendertel");
sendertel.value = sendertel.value.replace(sendertel.defaultValue, '');
var senderemail = document.getElementById("senderemail");
senderemail.value = senderemail.value.replace(senderemail.defaultValue, '')
var senderstockid = document.getElementById("senderstockid");
var senderemailcontent = document.getElementById("senderemailcontent");
var stockinfo = document.getElementById("stockinfo");
var chkbooking = document.getElementById("chkbooking");
var subject = document.getElementById("subject").value;
var booking="N";
if (chkbooking.checked)
{ booking="Y"; }
if (senderstockid.style.display == "none")
{ senderstockid.value = ""; }
else
{ subject = subject + senderstockid.value;}
//var empemail = document.getElementById("empemail").value.replace('midland.com.hk', 'im.midland.com.hk'); //for IM
//var empemail = 'alexli@im.midland.com.hk'; //for IM Dev
//var url = "/branch_agent/sendIM.jsp?name=" + sendername.value + "&from=" + senderemail.value + "&to=imsend@midland.com.hk"
// + "&subject=" + empemail + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&stockinfo=" + stockinfo.value + "&booking=" + booking + "&lang=" + lang; //for IM
//var empemail = document.getElementById("empemail").value; //for email
//alert(empemail);
var empemail = 'alexli@midland.com.hk'; //for email Dev
//var url = "/branch_agent/sendIM_al.jsp?name=" + sendername.value + "&from=" + senderemail.value + "&to=" + empemail
// + "&subject=" + subject + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&stockinfo=" + stockinfo.value + "&booking=" + booking + "&lang=" + lang; //for Email
var url = "/branch_agent/sendIM_al.jsp?" + encodeURI("name=" + sendername.value + "&from=" + senderemail.value + "&to=" + empemail
+ "&subject=" + subject + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&stockinfo=" + stockinfo.value + "&booking=" + booking + "&lang=" + lang); //for Email
window.open(url);
// if (check_SendIM_Empty(lang))
// {
// createRequest();
// request.open("POST", url, true);
// request.onreadystatechange = returnMessage;
// request.send(null);
// }
}
*/
function returnMessage(){
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
//var estate = request.responseText;
//if (estate.length > 0) {
alert(send_success);
document.getElementById('im_dtl').style.display= 'none';
//}
//else {
//alert("未能送出信息");
//}
}
else
alert(send_fail);
}
}
function showIM(){
var im_dtl = document.getElementById('im_dtl');
// im_dtl.style.visibility='visible';
document.getElementById("btnSend").style.display='';
document.getElementById("divImSending").style.display='none';
im_dtl.style.display='';
}
function setDetailPageControlFlag(bFlag) {
bControlFlagToDetailPage = bFlag;
}
function gotoAgent(dept_id, licence_no)
{
if (bControlFlagToDetailPage)
location.href='agent_blog_index.jsp?deptId=' + dept_id + '&licenceNo=' + licence_no + '&lang=' + lang;
else
bControlFlagToDetailPage = true;
}
function showIMBySearch(elem){
var im_dtl = document.getElementById('im_dtl');
im_dtl.style.visibility='visible';
positionTip(elem, false);
}
function sendIMBySearch(Email){
var sendername = document.getElementById("sendername");
var sendertel = document.getElementById("sendertel");
var senderemail = document.getElementById("senderemail");
var senderstockid = document.getElementById("senderstockid");
var senderemailcontent = document.getElementById("senderemailcontent");
// var empemail = document.getElementById("empemail").value.replace('midland.com.hk', 'im.midland.com.hk'); //for IM
var empemail = 'danli@im.midland.com.hk'; //for IM Dev
var url = "/branch_agent/sendIM.jsp?name=" + sendername.value + "&from=" + senderemail.value + "&to=imsend@hkp.com.hk"
+ "&subject=" + empemail + "&tel=" + sendertel.value + "&stockid=" + senderstockid.value + "&content=" + senderemailcontent.value + "&lang=" + lang; //for IM
if (check_SendIM_Empty(lang))
{
createRequest();
request.open("POST", url, true);
request.onreadystatechange = returnMessage;
//request.open("get", url);
request.send(null);
}
}
/////////////////////////////////////////////////////////////
// positionTip function
// If tipFollowMouse set false, so trackMouse function
// not being used, get position of mouseover event.
// Calculations use mouseover event position,
// offset amounts and tooltip width to position
// tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(elem) {
var tipcss = document.getElementById('im_dtl');
var IE = false;
if (navigator.appName.indexOf('Microsoft') != -1)
IE = true;
else
IE = false;
var selectedPosY = 0;
var selectedPosX = 0;
while(elem != null){
selectedPosY += elem.offsetTop;
selectedPosX += elem.offsetLeft;
elem = elem.offsetParent;
}
tipcss.style.left = (selectedPosX + 300) + 'px';
tipcss.style.top = (selectedPosY + 25) + 'px';
}
function checksalesform()
{
var frm = document.formAdvanceSearch_sales;
if (trim(frm.searchKey.value) == '' || trim(frm.searchKey.value) == frm.searchKey.defaultValue)
{
alert(msg_search_agent);
return false;
}
if (trim(frm.searchKey.value).length == 1)
{
if (isChn(frm.searchKey.value))
{
alert(msg_search_agent);
return false;
}
}
return true;
}
function isChn(str){
var reg = /^[u4E00-u9FA5]+$/;
if(!reg.test(str)){
return false;
}
return true;
}
function submitForm_sales(lang) {
var frm = document.formAdvanceSearch_sales;
if (checksalesform())
{
frm.target = "_top";
frm.action = "agent_search_list_index.jsp?lang=" + lang;
frm.submit();
}
}
function clearText(elem){
if (elem.defaultValue==elem.value)
elem.value = ""
}
function lostfocus(elem){
if (elem.value == '')
{
elem.value = elem.defaultValue;
}
}
function setArrowDisplay(Id, type) {
var img = document.getElementById(Id);
if (img != null) {
if (type=='Show')
{
img.style.visibility='visible';
}
else if (type=='Hide')
{
img.style.visibility='hidden';
}
}
}
function changeRegion_Branch(region_id, lang, distId) {
if (region_id != '') {
//var request;
var url = "dist_list.jsp?regionId=" + region_id + '&lang=' + lang + '&distId=' + distId;
requestRegion = createRequest2();
requestRegion.open("POST", url, true);
requestRegion.onreadystatechange = setDist;
requestRegion.send(null);
}
}
function update_title_name(name)
{
if (lang == "en")
{
document.title = document.title + " " + name;
}
else
{
document.title = name + " " + document.title;
}
}
function trim(s) {
return s.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
}
function Load_District (type, id, value)
{
if (ajax_loading_dist || ajax_loading_subReg || ajax_loading_detail)
{
return;
}
curr_dist_type = type;
switch(type)
{
case 'R':
$('#region_list_all').removeClass('focus');
$('#region_list_hk').removeClass('focus');
$('#region_list_kln').removeClass('focus');
$('#region_list_nt').removeClass('focus');
$('#' + id).addClass('focus');
$('#div_navigation_subregion').html('');
$('#div_navigation_district').html('');
$('#div_navigation_region').html(' > ' + $('#' + id).html());
/* Copy click event to navigation bar */
$('#div_navigation_region').unbind("click");
$('#div_navigation_region').bind("click", function(){$('#' + id).click();});
Bind_Sub_Region(value, '');
Load_Detail(value,'','');
break;
case 'S':
var strSplit = '';
$('#subregion_list').find('.sub').each(
function()
{
if (id != $(this).attr('id'))
$(this).removeClass('focus');
else
$(this).addClass('focus');
}
);
$('#div_navigation_district').html('');
$('#div_navigation_subregion').html(' > ' + $('#' + id).html());
/* Copy click event to navigation bar */
$('#div_navigation_subregion').unbind("click");
$('#div_navigation_subregion').bind("click", function(){$('#' + id).click();});
strSplit = value.split("||")
Bind_District(strSplit[0],strSplit[1],'')
Load_Detail(strSplit[0],strSplit[1],'');
break;
case 'D':
var strSplit = '';
$('#district_list').find('.sub').each(
function()
{
if (id != $(this).attr('id'))
$(this).removeClass('focus');
else
$(this).addClass('focus');
}
);
$('#div_navigation_district').html(' > ' + $('#' + id).html());
/* Copy click event to navigation bar */
$('#div_navigation_district').unbind("click");
$('#div_navigation_district').bind("click", function(){$('#' + id).click();});
strSplit = value.split("||");
Load_Detail(strSplit[0],strSplit[1],strSplit[2]);
break;
default:
break;
}
}
function init_top_agent(region,subRegion,DistId)
{
$('#region_list_all').attr('value','').bind("click", function(){Load_District('R', $(this).attr('id'), $(this).attr('value'));});
$('#region_list_hk').attr('value','10').bind("click", function(){Load_District('R', $(this).attr('id'), $(this).attr('value'));});
$('#region_list_kln').attr('value','20').bind("click", function(){Load_District('R', $(this).attr('id'), $(this).attr('value'));});
$('#region_list_nt').attr('value','30').bind("click", function(){Load_District('R', $(this).attr('id'), $(this).attr('value'));});
Bind_Region(region);
Bind_Sub_Region(region, subRegion);
Bind_District(region, subRegion,DistId);
Load_Detail(region,subRegion,DistId);
}
/* Region Search */
function Bind_Region(region)
{
switch(region)
{
case "":
$('#region_list_all' ).addClass('focus');
$('#div_navigation_region').html(' > ' + $('#region_list_all' ).html());
break;
case "10":
$('#region_list_hk' ).addClass('focus');
$('#div_navigation_region').html(' > ' + $('#region_list_hk' ).html());
break;
case "20":
$('#region_list_kln' ).addClass('focus');
$('#div_navigation_region').html(' > ' + $('#region_list_kln' ).html());
break;
case "30":
$('#region_list_nt' ).addClass('focus');
$('#div_navigation_region').html(' > ' + $('#region_list_nt' ).html());
break;
}
}
/* Sub Region Search */
function Bind_Sub_Region(region, subRegion)
{
$('#subregion_list').fadeOut(200);
$('#district_list').fadeOut(200);
$('#subregion_list').html("");
$('#district_list').html("");
if (region != "")
{
/* Reset */
//$('#subregion_list').height(0);
//$('#district_list').height(0);
ajax_loading_subReg = true;
$.ajax({ type: "GET",
url: "//app2.hkp.com.hk/cs/search_service/district.jsp?lang=" + lang +"&sortBy=SUB_REGION®ionId=" + region,
dataType: "xml",
crossDomain: true,
success: Get_Sub_Region(subRegion, region)
});
}
}
function Get_Sub_Region(subRegion, region)
{
return function (xmlData) {
var t_sub_region = '';
var sub_focus = '';
x=xmlData.documentElement.getElementsByTagName("district");
for (var i = 0; i < x.length; i++)
{
if (x[i].getElementsByTagName("sub_region")[0].firstChild)
{
sub_region = x[i].getElementsByTagName("sub_region")[0].firstChild.nodeValue;
}
else
{
sub_region = "";
}
if (x[i].getElementsByTagName("sub_region_name")[0].firstChild)
{
sub_region_name = x[i].getElementsByTagName("sub_region_name")[0].firstChild.nodeValue;
}
else
{
sub_region_name = "";
}
if (i == 0 )
{
if (subRegion == '')
{
sub_focus = ' focus';
}
if (region == '10')
{
all_sub_region = $('#region_list_hk' ).html();
}
else if (region == '20')
{
all_sub_region = $('#region_list_kln' ).html();
}
else
{
all_sub_region = $('#region_list_nt' ).html();
}
$('#subregion_list').append( "" + caption_all + all_sub_region + "
");
$('#subregion_list_all').attr('value',region + "||").bind("click", function(){Load_District('S', $(this).attr('id'), $(this).attr('value'));});
}
if (t_sub_region != sub_region)
{
if (subRegion == sub_region)
sub_focus = ' focus';
else
sub_focus = '';
$('#subregion_list').append( "" + sub_region_name + "
");
$('#subregion_list_' + sub_region).attr('value',region + "||" + sub_region).bind("click", function(){Load_District('S', $(this).attr('id'), $(this).attr('value'));});
t_sub_region = sub_region;
}
}
//$('#subregion_list').animate({height:'28px'},200);
$('#subregion_list').fadeIn(500);
ajax_loading_subReg = false;
}
}
/* District Search */
function Bind_District(region, subRegion, DistId)
{
$('#district_list').fadeOut(200);
$('#district_list').html("")
if (region != "" && subRegion != "")
{
//$('#district_list').height(0);
ajax_loading_dist = true;
$.ajax({ type: "GET",
url: "//app2.hkp.com.hk/cs/search_service/district.jsp?lang=" + lang +"&sortBy=SUB_REGION®ionId=" + region,
dataType: "xml",
crossDomain: true,
success: Get_District(subRegion, DistId, region)
});
}
}
function Get_District(subRegion, DistId, region)
{
return function (xmlData) {
var t_sub_region = '';
var sub_focus = '';
var y= 0;
x=xmlData.documentElement.getElementsByTagName("district");
for (var i = 0; i < x.length; i++)
{
if (x[i].getElementsByTagName("dist_id")[0].firstChild)
{
dist_id = x[i].getElementsByTagName("dist_id")[0].firstChild.nodeValue;
}
else
{
dist_id = "";
}
if (x[i].getElementsByTagName("dist_name")[0].firstChild)
{
dist_name = x[i].getElementsByTagName("dist_name")[0].firstChild.nodeValue;
}
else
{
dist_name = "";
}
if (x[i].getElementsByTagName("sub_region")[0].firstChild)
{
sub_region = x[i].getElementsByTagName("sub_region")[0].firstChild.nodeValue;
}
else
{
sub_region = "";
}
if (subRegion == sub_region)
{
if (y == 0 )
{
if (DistId == '')
{
sub_focus = ' focus';
}
$('#district_list').append( "" + caption_all + $('#subregion_list_' + subRegion).html() + "
");
$('#district_list_all').attr('value',region + "||" + sub_region + "||").bind("click", function(){Load_District('D', $(this).attr('id'), $(this).attr('value'));});
}
if (DistId == dist_id)
sub_focus = ' focus';
else
sub_focus = '';
$('#district_list').append( "" + dist_name + "
");
$('#district_list_' + dist_id).attr('value', region + "||" + sub_region + "||" + dist_id).bind("click", function(){Load_District('D', $(this).attr('id'), $(this).attr('value'));});
y++;
}
}
$('#district_list').append('');
//$('#district_list').animate({height:'28px'},200);
$('#district_list').fadeIn(500);
ajax_loading_dist = false;
}
}
/* Load Detail Search */
function Load_Detail(region, subRegion,distId)
{
ajax_loading_detail = true;
$('#top_sales_detail').html('
');
// 20160630 - support IE 8 start
jQuery.support.cors = true;
// 20160630 - support IE 8 end
$.ajax({ type: "GET",
url: "top_online_agent_detail.jsp?lang=" + lang +"®ionId=" + region + "&subRegionId=" + subRegion + "&distId=" + distId,
dataType: "html",
crossDomain: true,
success: Get_Top_sales(),
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
}
function Get_Top_sales()
{
return function (xmlData) {
showtxt = xmlData;
$('#top_sales_detail').html(showtxt);
switch(curr_dist_type)
{
case 'R':
if ($('.sub.focus').attr('id') != 'region_list_all')
{
$('.dist_name').html($('.sub.focus').html().replace(' > ','') + "
");
}
else
$('.dist_name').html();
break;
case 'S':
$('.dist_name').html($('#div_navigation_subregion').html().replace(' > ','') + "
");
break;
case 'D':
$('.dist_name').html($('#div_navigation_district').html().replace(' > ','') + "
");
break;
}
/*
if ($('.stock').html().length > 7)
{
$('.stock').each(function() {
var strhtml_first = $(this).html().substring(0, $(this).html().indexOf('" + strhtml_last);
});;
}
*/
$('img.pre-load').hide();
$('img.pre-load').each( function(){
$(this).bind('load', function () {
$(this).fadeIn();
});
$(this).bind('error', function () {
$(this).attr('src','//resources.hkp.com.hk/images/branch_agent/zh_HK/nopix.jpg');
});
/* if($.browser.msie && $.browser.version == 7){ */ /*old version jquery 1.8 or below*/
/* 2016 - 06 - 24*/
if (navigator.userAgent.match(/msie [7]/i)) {
$(this).bind('click', function () {
window.location = $('#a_' + $(this).attr('id')).attr('href');
});
}
});
BindAgentClick();
ajax_loading_detail = false;
}
}
/* Bind on click function to each agent button*/
function BindAgentClick()
{
$('.contact').find('.mail').each(
function()
{
$(this).bind("click",
function(){
//void(0);
var url = "mailto:" + $(this).attr('value');
window.top.location = url;
return false;
});
}
);
$('.contact').find('.IM').each(
function()
{
$(this).bind("click",
function(){
showIM_ag(this, $(this).attr('value'));
return false;
});
}
);
}
/* Send Mail*/
function showIM_ag(elem, Id){
var im_dtl = document.getElementById('im_dtl');
var img = elem;
var empemail = document.getElementById("empemail");
var divEmpList = document.getElementById("top_sales_detail");
empemail.value=Id;
var position = findPositionWithScrolling_ag(img, 'top_sales_list');
im_dtl.style.left = position[0] + 425 + "px";
im_dtl.style.top = position[1] + 20 + "px";
im_dtl.style.display='';
document.getElementById("btnSend").style.display='';
document.getElementById("divImSending").style.display='none';
}
function browser_detect() {
var browser='';
var browser_detect = navigator.userAgent.toLowerCase();
if ((browser_detect.indexOf("msie") + 1)) { browser = 'msie'; }
else if ((browser_detect.indexOf("safari") + 1)) { browser = 'safari'; }
else if ((browser_detect.indexOf("firefox") + 1)) { browser = 'firefox'; }
else if ((browser_detect.indexOf("chrome") + 1)) { browser = 'chrome'; }
return browser;
}
/* Find position */
function findPositionWithScrolling_ag( oElement, tableId ) {
if (typeof( oElement.offsetParent ) != 'undefined' ) {
var originalElement = oElement;
var parentElement;
var browser = browser_detect();
var posX = 0;
var posY = 0;
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
//posX += $(oElement).width();
//posY += $(oElement).height();
/*
for(var posX = 0, posY = 0; oElement ; oElement = parentElement) {
if (oElement.tagName!='TR'){
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
if( oElement != originalElement && oElement != document.body && oElement != document.documentElement ) {
if (oElement.tagName!='TR'){
posX -= oElement.scrollLeft;
posY -= oElement.scrollTop;
}
}
alert(oElement.id + ' - ' + posY);
if (oElement.id == tableId)
{break;}
if (browser == 'firefox'){
parentElement = oElement.offsetParent;
}
else
{
parentElement = oElement.parentElement;
}
}
*/
return [ posX, posY ];
} else {
return [ oElement.x, oElement.y ];
}
}