﻿//----------------------------------------------------------------------------
// NOTE
//----------------------------------------------------------------------------
// Place <div id="detailtooltip"></div> in the targeted HTML source
//----------------------------------------------------------------------------

//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
try {
	//If the Javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	//If not, then use the older active x object.
	try {
		//If we are using Internet Explorer.
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
		//Else we must be using a non-IE browser.
		xmlhttp = false;
	}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}

function requestPopDetail(itemID,theImg) {
	//var srcObj = document.getElementById(srcID);
	//var obj = document.getElementById(objID);
	var loadingStr = "<table width=\"320\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" bgcolor=\"#990000\"><tr><td bgcolor=\"#FFFFFF\" align=\"center\" class=\"th11black9\" height=\"235\"><img src=\"i/icn_loading.gif\" width=\"16\" height=\"16\" /> loading</td></tr></table>";
	tipobj.innerHTML = loadingStr;
	//var serverPage = "parse/getpopdetail.php?areaID=" + srcObj.value + "&destID=" + destID;
	var serverPage = "parse/getpopdetail.php?xyz=" + itemID + "&vImg=" + theImg;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			tipobj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=0 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["detailtooltip"] : document.getElementById? document.getElementById("detailtooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(itemID, theImg, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
//thetext = "<table width=\"320\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" bgcolor=\"#990000\"><tr><td bgcolor=\"#FFFFFF\" align=\"left\"><table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\"><tr><td><img src=\"" + theimage + "\" width=\"312\" height=\"235\" /></td></tr><tr><td class=\"th11black9\" align=\"left\" style=\"padding: 5px 5px 5px 5px\"><font color=\"#000000\"><strong>Bukit Cinere Indah, Jakarta Selatan, Siap Huni, Hook</strong></font><br>Taman Harapan Permai, Blok H4. No. 34A.<br>Luas: <font color=\"#000000\">115/85</font>.  Kamar tidur: <font color=\"#000000\">1</font>.  Kamar mandi: <font color=\"#000000\">2</font></td></tr><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#EEEEEE\"><tr><td class=\"th11black9\">#Kode: " + thecode + "</td><td align=\"right\" class=\"ge16black6\">Rp. <span class=\"ge16blue\"><strong>" + theprice + "</strong></span></td></tr></table></td></tr></table></td></tr></table>"
//tipobj.innerHTML=thetext
requestPopDetail(itemID,theImg)
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


