﻿
var offsetfromcursorX = 5;
var offsetfromcursorY = 5;
var offsetdivfrompointerX =2;
var offsetdivfrompointerY = 15;

/**
document.write('<div id="dhtmltooltip"></div>');
document.write('<img id="dhtmlpointer" src="images/Pacific/icon/fly_icon.gif">');
**/

var ie = document.all;
var ns6 = document.getElementById && ! document.all;
var enabletip = false;

if (ie || ns6)
	var tipobj = document.all ? document.all["dhtmltooltip"] : document.getElementById ? document.getElementById("dhtmltooltip") : "";

var pointerobj = document.all ? document.all["dhtmlpointer"] : document.getElementById ? document.getElementById("dhtmlpointer") : "";


function ietruebody() {
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

function showtip(thetext, thewidth, thecolor) {
	if (ns6 || ie) {
		if (typeof thewidth != "undefined")
			tipobj.style.width = thewidth + "px";
			
		if (typeof thecolor != "undefined" && thecolor != "")
			tipobj.style.backgroundColor = thecolor;
		tipobj.innerHTML = thetext;		
		enabletip = true;
		return false;
	}
}

function positiontip(e) {
	if (enabletip) {		
		var nondefaultpos = false;
		var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
		var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
		
		var winwidth = ie && ! window.opera ? ietruebody().clientWidth : window.innerWidth - 20;
		var winheight = ie && ! window.opera ? ietruebody().clientHeight : window.innerHeight - 20;

		var rightedge = ie && ! window.opera ? winwidth - event.clientX - offsetfromcursorX : winwidth - e.clientX - offsetfromcursorX;
		var bottomedge = ie && ! window.opera ? winheight - event.clientY - offsetfromcursorY : winheight - e.clientY - offsetfromcursorY;

		var leftedge = (offsetfromcursorX < 0) ? offsetfromcursorX * (- 1) : - 1000;

		if (rightedge < tipobj.offsetWidth) {
			tipobj.style.left = curX - tipobj.offsetWidth + "px";
			nondefaultpos = true;
		}
		else if (curX < leftedge)
			tipobj.style.left = "5px";
		else {
			tipobj.style.left = curX + offsetfromcursorX - offsetdivfrompointerX + "px";
			pointerobj.style.left = curX + offsetfromcursorX + "px";
		}

		if (bottomedge < tipobj.offsetHeight) {
			tipobj.style.top = curY - tipobj.offsetHeight - offsetfromcursorY + "px";
			nondefaultpos = true;
		}
		else {
			tipobj.style.top = curY + offsetfromcursorY + offsetdivfrompointerY + "px";
			pointerobj.style.top = curY + offsetfromcursorY + "px";
		}

		tipobj.style.visibility = "visible";

		if (! nondefaultpos)
			pointerobj.style.visibility = "visible";
		else
			pointerobj.style.visibility = "hidden";
	}
}

function hidetip() {
	if (ns6 || ie) {
		enabletip = false;
		tipobj.style.visibility = "hidden";
		pointerobj.style.visibility = "hidden";
		tipobj.style.left = "-1000px";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
	}
}

if ( typeof window.addEventListener != "undefined" )
document.addEventListener( "mousemove", positiontip, false );
else if ( typeof window.attachEvent != "undefined" )
document.attachEvent( "onmousemove", positiontip );
else {
if ( document.onmousemove != null ) {
var oldOnmousemove = document.onmousemove;
document.onmousemove = function ( e ) {
oldOnmousemove( e );
positiontip(e);
};
}
else
document.onmousemove = positiontip;
}



function Pop(text,width,height)
  {

  var name = 'window' + width + '' + height;
  var attrib = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + width + ',height=' + height;
  pop = window.open('',name,attrib);
  pop.document.open();
  pop.document.write("<HTML><HEAD><TITLE>Child and Infant Rules</TITLE>");
  pop.document.write("</HEAD><BODY BGCOLOR=FFFFFF><center>");
  pop.document.write(text);
  pop.document.write("<br/><br/></table><tr><td><a href=\"/html/vi-VN/CHD_INF_Rules.pdf\">Tờ cam kết bằng Tiếng Việt</a></td><td>--*--</td><td><a href=\"/html/en-US/CHD_INF_Rules_en.pdf\">Waiver form in English</a></td></tr><br/>");
  pop.document.write("<BR><A HREF=\"javascript\:self.close\(\)\">Đóng cửa sổ này - Close Window</A>");
  pop.document.write("</CENTER></BODY></HTML>");
  }

function Po(text,width,height)
  {

  var name = 'window' + width + '' + height;
  var attrib = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + width + ',height=' + height;
  po = window.open('',name,attrib);
  po.document.open();
  po.document.write("<HTML><HEAD><TITLE>Child and Infant Rules</TITLE>");
  po.document.write("</HEAD><BODY BGCOLOR=FFFFFF><center>");
  po.document.write(text);
  po.document.write("<BR><A HREF=\"javascript\:self.close\(\)\">Đóng cửa sổ này - Close Window</A>");
  po.document.write("</CENTER></BODY></HTML>");
  }
  
  


//Hints javascript
var defaultXOffset	= 0;
var defaultYOffset	= 0;
var hintDiv	= "cssHint"
function showHint(obj)
{
	showHint(obj,null,null, null);
}
function showHint(obj, xOffset, yOffset)
{
    showHint(obj, xOffset, yOffset, null)
}
function showHintWithReference(obj, referenceObject)
{
    showHint(obj, null, null, referenceObject)
}
function showHint(obj, xOffset, yOffset, referenceObject)
{
    var x = 0;
    var y = 0;
     
    if (!referenceObject)
    {
	    x 							= getX(obj);
	    y 							= getY(obj);
	    
	    if (xOffset == null)
	    {
    		x += obj.offsetWidth + 5;
	    }
	}
	else
	{
	    x = getX(referenceObject);
	    y = getY(referenceObject);
	    
	    if (xOffset == null)
	    {
    		x += referenceObject.offsetWidth + 5;
	    }
	}
	
	var hintHtml = '';
	
	//Get culture XML hint
	if (obj.getAttribute('hint') != null)
		hintHtml += obj.getAttribute('hint');
	
	//Get server hint
	if (obj.getAttribute('serverHint') != null)
	{
		if (obj.getAttribute('hintPriority') != null)
		{
			if (obj.hintPriority == 'server')
			{
				hintHtml = obj.getAttribute('serverHint') + hintHtml; 
			}
			else
			{
				hintHtml += obj.getAttribute('serverHint');
			}
		}
		else
		{
			hintHtml += obj.getAttribute('serverHint');
		}
	}
	getObject(hintDiv).innerHTML = hintHtml;
	getStyle(hintDiv).visibility 	= 'visible';
	xOffset	= (xOffset != null) ? xOffset : defaultXOffset;
	yOffset	= (yOffset != null) ? yOffset : defaultYOffset;
	getStyle(hintDiv).left 			= xOffset + x + 'px';
	getStyle(hintDiv).top 			= yOffset + y + 'px';
	//getStyle(hintDiv).height = 50;
	
}

function hideHint(obj)
{
	getStyle(hintDiv).visibility 	= 'hidden';
}

function getX(obj)
{
	var pos = 0;
	if (obj.x)	// N4
	{
		pos += obj.x;
	}
	else if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
		    pos += obj.offsetLeft;
			obj	 = obj.offsetParent;
		}
	}
	return pos;
}

function getY(obj)
{
    var count = 0;
	var pos = 0;
	if (obj.y) // netscape 4
		pos += obj.y;
	else if (obj)
	{
	     while(obj){		
	     pos+=obj.offsetTop;
		 obj=obj.offsetParent;
 	    }
	}
	return pos;
}

function getObject(name)
{
	if (document.getElementById) return document.getElementById(name);
	if (document.all) return document.all[name];
	if (document.layers)
	{
		if (document.layers[name]) return document.layers[name];
		else return document.layers[name].layers[name];
	}
}

function getStyle(name)
{
	if (document.getElementById) return document.getElementById(name).style;
	if (document.all) return document.all[name].style;
	if (document.layers)
	{
		if (document.layers[name]) return document.layers[name];
		else return	this.style = document.layers[name].layers[name];
	}
}

//End of hints

