var dragapproved=false;
var Iz,Ix,Iy;
var Iinitial = true;
var Iimgx, Iimgy;
var Wz,Wx,Wy;
var Winitial = true;
var Wimgx, Wimgy;
var moveobj;
var m_sCurrIBoxText="";
var m_sCurrWBoxText="";

var ENTITY_BOX_INFO = "BoxInformation";
var m_sXMLBoxInfo="IBoxInformation";
var m_sXMLBoxType="boxType";

/* ================================================================ */
/* These are the document events.
   If this code is used on a page that already uses these events
   there will be problems.                                          */
/* ================================================================ */

function document.onmousedown()
{
	var srcel = event.srcElement;
	if(srcel.id=="ibar")
	{
		dragapproved=true;
		Iz=event.srcElement;
		Ix=event.offsetX;
		Iy=event.offsetY;
		moveobj = "iBar";
		infoBox.style.zIndex = 200;
	}
	document.onmousemove=move;
}

function document.onmouseup()
{
	dragapproved=false
}

function ShowProjects()
{
	Iimgx = event.clientX;
	Iimgy = event.clientY;
	Iinitial = false;
	infoBox.style.display = "";
	infoBox.style.zIndex = 200;
	Icheckposition();
	infoBox.style.pixelLeft=Iimgx;
	infoBox.style.pixelTop=Iimgy;
			
	tdInfoText.innerHTML = "<b>North America</b><br/><a href=\"canada.php\" class=\"aVis\">Canada</a><br/><a href=\"usa.php\" class=\"aVis\">USA</a><br/><br/><br/>";
}

/* ================================================================ */
function move()
{
	if (event.button==1&&dragapproved){
		if (moveobj=="iBar"){
			Iimgx = event.clientX-Ix;
			Iimgy = event.clientY-Iy;
			Icheckposition()
			infoBox.style.pixelLeft=Iimgx;
			infoBox.style.pixelTop=Iimgy;
		}
		return false;
	}
}
/* ================================================================ */
function CreateIBox()
{
	var iboxhtml;

	iboxhtml = "<div id=\"infoBox\" style=\"display: none;position:absolute\">";
	iboxhtml += "<table width=\"150\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" ;
	iboxhtml += "<tr>" ;
	iboxhtml += "<td colspan=\"2\" align=\"right\"><img id=\"ibar\" src=\"images/information.gif\" usemap=\"#iboxclose\" align=\"absmiddle\" alt=\"\" width=\"131\" height=\"28\" border=\"0\"></td>" ;
	iboxhtml += "</tr>" ;
	iboxhtml += "<tr>" ;
	iboxhtml += "<td><img src=\"images/cleardot.gif\" alt=\"\" width=\"19\" height=\"1\"></td>" ;
	iboxhtml += "<td width=\"131\" style=\"font-family:verdana,arial;font-size:11px;background-color:#FFFFFF;padding:2px;border:1px solid #000000\" valign=\"top\" id=\"tdInfoText\">&nbsp;</td>" ;
	iboxhtml += "</tr>" ;
	iboxhtml += "</table>" ;
	iboxhtml += "<map name=\"iboxclose\">" ;
	iboxhtml += "<area style=\"cursor:hand;\" shape=\"circle\" coords=\"120,13,8\" href=\"javascript: HideProjects();\">" ;
	iboxhtml += "</map>";
	iboxhtml += "</div>";

	document.body.insertAdjacentHTML("afterBegin", iboxhtml);
									
}

/* These two function are used to check the position of I or W box. */
function Icheckposition()
{
	var maxwidth, maxheight;
	maxwidth = (document.body.offsetWidth - infoBox.offsetWidth) - 25;
	maxheight = (document.body.offsetHeight - 60);
	if(Iimgx<=0){Iimgx = 0;}
	if(Iimgx>=maxwidth){Iimgx = maxwidth;}
	if(Iimgy<=0){Iimgy = 0;}
	if(Iimgy>=maxheight){Iimgy = maxheight;}
}
function HideProjects()
{
	infoBox.style.display = "none";
	m_sCurrIBoxText="";
}

