
loaded = 0;

ua   = navigator.userAgent.toLowerCase();
dda  = (document.all);
ie6  = (ua.indexOf("msie")      != -1 && ua.indexOf("netscape") == -1 && dda);
nnf  = (ua.indexOf("netscape")  != -1 && ua.indexOf("gecko")    != -1);
nni  = (ua.indexOf("netscape")  != -1 && ua.indexOf("msie")     != -1);
nn6  = (ua.indexOf("netscape")  != -1);
gek  = (ua.indexOf("gecko")     != -1);
ff1  = (ua.indexOf("firefox")   != -1);
opr  = (ua.indexOf("opera")     != -1);
mac  = (ua.indexOf("mac")       != -1);
web  = (ua.indexOf("webtv")     != -1);
saf  = (ua.indexOf("safari")    != -1);
kon  = (ua.indexOf("konqueror") != -1);
nn4  = (document.layers);

function err(mess){
	if(!loaded){ mess = pageNotLoaded; }
	alert(mess); 
}

function about(){
	popUpWin = window.open('$VAR{about}', 'popUpWin', 'height=300, width=300, location=0, statusbar=0, menubar=0, resizable=1, scrollbars=0, top='+ winy +', left='+ winx +'');
}

function showTT(t, event, keepIt, shiftX, shiftY){
	if(!loaded){ return; }
	
	if(!shiftX){ shiftX = 0; }
	if(!shiftY){ shiftY = 0; }
	
	if(document.getElementById("tt")){
		theTTDoc = document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	if(self.parent.document.getElementById("tt")){
		theTTDoc = self.parent.document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	yPlus = 0;
	xPlus = 0;
	ttScT = 0;
	if(self.name){
		ttScT   = parseInt(document.body.scrollTop, 10);
		
		yPlus = (getPageOffsetTop(self.parent.document.getElementById(self.name))) - ttScT;
		xPlus = (getPageOffsetLeft(self.parent.document.getElementById(self.name)));
	}
	
	shiftLeft = 0;
	
	if(theTTDiv){
		//ttScT   = parseInt(document.body.scrollTop, 10);
		
		if(event){
			if(ie6){
				ttX = getPageOffsetLeft(event.srcElement) + xPlus - 20; 
				ttY = getPageOffsetTop(event.srcElement) + yPlus + event.srcElement.offsetHeight + 1;
			} else {
				ttX = getPageOffsetLeft(event.target) + xPlus - 20; 
				ttY = getPageOffsetTop(event.target) + yPlus + event.target.offsetHeight + 1;
			}
			if(ttX > theTTDoc.body.clientWidth - 350){
				shiftLeft = theTTDoc.body.clientWidth - ttX;
				ttX = theTTDoc.body.clientWidth - shiftLeft - 300;
			}
		} else {
			keepIt = 1;
			ttX = theTTDoc.body.clientWidth / 2 - 175; 
			ttY = theTTDoc.body.clientHeight / 2;
		}
		
		theTTDiv.style.top     = ttY + ttScT + shiftY;
		theTTDiv.style.left    = ttX + shiftX;
		theTTDiv.style.display = "";
		
		theContent  = '';
		
		if(confUseCartImgs == 1){
			theContent += '<table cellpadding="0" cellspacing="0" width="350"><tr><td><img src="' + pathToImages + '/tt_1.gif" width="16" height="32" alt=""></td>';
			
			if(shiftLeft){
				theContent += '<td background="' + pathToImages + '/tt_3.gif" width="100%"><img src="' + pathToImages + '/tt_3.gif" width="1" height="32" alt=""></td><td><img src="' + pathToImages + '/tt_2.gif" width="32" height="32" alt=""></td>';
			} else {
				theContent += '<td><img src="' + pathToImages + '/tt_2.gif" width="32" height="32" alt=""></td><td background="' + pathToImages + '/tt_3.gif" width="100%"><img src="' + pathToImages + '/tt_3.gif" width="1" height="32" alt=""></td>';
			}
			
			theContent += '<td><img src="' + pathToImages + '/tt_4.gif" width="20" height="32" alt=""></td></tr><tr><td background="' + pathToImages + '/tt_5.gif"><img src="' + pathToImages + '/tt_5.gif" width="16" height="1" alt=""></td><td colspan="2"><table cellpadding="0" cellspacing="0" class="ttText">';
		} else {
			theContent += '<table border="0" bgcolor="white" cellpadding="5" cellspacing="0" style="border: ' + confBorderColor + ' solid 1px;" width="350" class="ttText">';
			theContent += '<tr>';
			theContent += '<td>';
		}
		
		if(keepIt){
			theContent += '<tr><td><img src="' + pathToImages + '/ico_info_16.gif" width="16" height="16" align="absmiddle" border="0"></td><td nowrap><b>&nbsp; ' + helpfulInfo + ' &nbsp;</b></td><td width="100%"><a href="javascript:hideTT();"><img src="' + pathToImages + '/off.gif" width="16" height="16" align="absmiddle" border="0"></a></td></tr><tr><td colspan="3"><br></td></tr><tr><td colspan="3"><div id="ttContent" style="display: block;">';
		} else {
			theContent += '<tr><td><img src="' + pathToImages + '/ico_info_16.gif" width="16" height="16" align="absmiddle" border="0"></td><td width="100%"><b>&nbsp; ' + helpfulInfo + '</b></td></tr><tr><td colspan="2"><br></td></tr><tr><td colspan="2"><div id="ttContent" style="display: block;">';
		}
		
		theContent += t + '</div>';
		
		if(confUseCartImgs == 1){
			theContent += '</td></tr></table></td><td background="' + pathToImages + '/tt_6.gif"><img src="' + pathToImages + '/tt_6.gif" width="20" height="1" alt=""></td></tr><tr><td><img src="' + pathToImages + '/tt_7.gif" width="16" height="20" alt=""></td><td background="' + pathToImages + '/tt_8.gif" colspan="2"><img src="' + pathToImages + '/tt_8.gif" width="1" height="20" alt=""></td><td><img src="' + pathToImages + '/tt_9.gif" width="20" height="20" alt=""></td></tr></table>';
		} else {
			theContent += '</td></tr></table>';
		}
		
		theTTDiv.innerHTML = theContent;
		
		if(theTTDoc.getElementById("ttContent").scrollHeight > 200){
			theTTDoc.getElementById("ttContent").style.height = 200 + "px";
			theTTDoc.getElementById("ttContent").style.overflow = "auto";
		}
		
		if(theTTDoc.getElementById("ttContent").scrollWidth > 300){
			theTTDoc.getElementById("ttContent").style.overflow = "auto";
		}
		
		theTTDiv.style.visibility = "visible";
	}
}

function hideTT(keepIt){
	if(!loaded){ return; }
	if(keepIt) return;
	if(document.getElementById("tt")){
		theTTDoc = document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	if(self.parent.document.getElementById("tt")){
		theTTDoc = self.parent.document;
		theTTDiv = theTTDoc.getElementById("tt");
	}
	
	if(theTTDiv){
		theTTDiv.style.visibility = "hidden";
		theTTDiv.style.height = "";
		theTTDiv.style.display = "none";
	}
}

function getPageOffsetLeft(el){
	var x = 0;
	
	if(el){
		if(el.offsetLeft != null){
			x = el.offsetLeft;
			if(el.offsetParent != null){
				x += getPageOffsetLeft(el.offsetParent);
			}
		}
	}
	return x;
}

function getPageOffsetTop(el){
	var y = 0;
	if(el){
		if(el.offsetTop != null){
			y = el.offsetTop;
			if(el.offsetParent != null){
				y += getPageOffsetTop(el.offsetParent);
			}
		}
	}
	return y;
}
