var isPossible = 0;
var docTypeByLayers = 0;
var docTypeByAll = 0;
var docTypeById = 0;

if (document.getElementById) {
	docTypeById = 1; isPossible = 1;
}
else {
	if (document.all) {
		docTypeByAll = 1; isPossible = 1;
	} 
	else {
	    browserVersion = parseInt(navigator.appVersion); 
		
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			docTypeByLayers = 1; isPossible = 1;
		}
	}
} 


function getDocumentItem(oi, wS) 
{
	if (docTypeById) 
		return wS ? document.getElementById(oi).style:document.getElementById(oi); 
	if (docTypeByAll) 
		return wS ? document.all[oi].style: document.all[oi]; 
	if (docTypeByLayers) 
		return document.layers[oi];
}

function width() 
{
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null?
		 document.body.clientWidth : null;
}

function mouseX(event) {
	if (event.pageX) 	
		return event.pageX; 
	else if (event.clientX)return event.clientX + (document.documentElement.scrollLeft ?  
		document.documentElement.scrollLeft : document.body.scrollLeft); 
		
	else return null;
}

function mouseY(event) {
	if (event.pageY) 
		return event.pageY; 
	else if (event.clientY)
		return event.clientY + (document.documentElement.scrollTop ? 
			document.documentElement.scrollTop : document.body.scrollTop); 
	else return null;
}

function openTT(event, divId) {	
	
	//for (var i = 0; i < 2222222; i++)
	//{
		
	//}

	if (isPossible) {
		var wp = width(); 
		ds = getDocumentItem(divId,1); 
		dm = getDocumentItem(divId,0); 
		style = ds.visibility; 
		
		if (dm.offsetWidth) ew = dm.offsetWidth; 
		else if (dm.clip.width) ew = dm.clip.width;
		 
		if (style == "visible" || style == "show") {
			 ds.visibility = "hidden"; 
		} else {
			 tv = mouseY(event) + 20; lv = mouseX(event) - (ew/4); 		
			 
			 if (lv < 2) lv = 2; 
			 else if (lv + ew > wp) lv -= ew/2; 
			 
			 if (!docTypeByLayers) {
			 	lv += 'px';tv += 'px';
			 } 
			 ds.left = lv; ds.top = tv; ds.visibility = "visible";
		}
	}
}

function writeTT(location, date, label, description, text, image, url, linkedText, left, top) {
	writeTTnoLink(location, date, label, description, text, image);	
	document.write("<a href=" + url + " onmouseout=openTT(event,'" + label + date + "') onmouseover=openTT(event,'" + label + date + "') >" + linkedText + "</a>"); 
}

function writeTTnoLink(location, date, label, description, text, image, left, top) {
	document.write("<div id=\"" + label + date + "\" class=tip");

	if (left != 0 || top != 0) {
			// alert("left != 0");
		document.write(" align: left; style=\"Z-INDEX: 888; POSITION: absolute; LEFT:0px; TOP:0px; float:right WORD-WRAP: normal\" ");
	}

	document.write(" >");
	
		document.write("<table  border=0 cellspacing=0 cellpadding=5 >");
			document.write("<tr  bgcolor=black >");
				document.write("<th valign=bottom align=center>");
					document.write("<font color=white>" + location);
				document.write("</font></th>");
				document.write("<th valign=bottom align=center>");
					document.write("<font color=white><i>" + date + "</i>");
				document.write("</font></th>");
			document.write("</tr>");
		
			document.write("<tr  >");
				document.write("<td valign=bottom align=center  colspan=2>");
					document.write("<font size=+1> " + label + " </font>");
				document.write("</font></td>");
			document.write("</tr>");
		
			document.write("<tr>");
				document.write("<td valign=top align=center>");
					if (image != "") {
		 				document.write("<img src=" + image + " />");
					}
				document.write("</td>");
				document.write("<td valign=bottom align=left>");
					document.write("<b><font size=-1>" + description + "</b></font>");
					document.write("<br><font size=-1>" + text + "</font>");
				document.write("</td>");
			document.write("</tr>");
	
		document.write("</table>");
	
	document.write("</div>"); 
}
