//FIREFOX STYLE TWEAK
var activeTooltipObjName='';

function $ (idString) {return document.getElementById(idString); }

var tempHeight = tooltipDefaultHeight + "px";

if(navigator.appName == "Netscape"){
	document.write("<style>.intellitextLink{padding-bottom: 1px;}</style>");
}

function changeStyle(objectID, propertyName, propertyValue){
	$(objectID).style[propertyName] = propertyValue;
}
function changeProperty(objectID, propertyName, propertyValue){
	$(objectID)[propertyName] = propertyValue;
}
function getStyleValue(objectID, propertyName){
	return $(objectID).style[propertyName];
}
function getPropertyValue(objectID, propertyName){
	return $(objectID)[propertyName];
}


function displayStatus(string){
	window.status = string;
	return true;
}

function clearStatus(){
	window.status = '';
	return true;
}

function getRealPos(ele,dir)
{
	(dir=="x") ? pos = ele.offsetLeft : pos = ele.offsetTop;
	tempEle = ele.offsetParent;
	while(tempEle != null)
	{
		pos += (dir=="x") ? tempEle.offsetLeft : tempEle.offsetTop;
		tempEle = tempEle.offsetParent;
	}
	return pos;
}

function getScrollY(){
	if(window.pageYOffset != null) {
		return window.pageYOffset;
	} else {
		return document.body.scrollTop;
	}
}

function getScrollX(){
	if(window.pageXOffset != null){
		return window.pageXOffset;
	} else {
		return document.body.scrollLeft;
	}
}

function adDelay(){
	//close box
	//changeStyle('tooltipBox', 'visibility', 'hidden');
	//changeStyle(activeTooltipObjName, 'visibility', 'hidden');
	changeStyle(activeTooltipObjName, 'display', 'none');
	activeTooltipObjName = '';
	//changeStyle('tooltipZ', 'display', 'none');
	//clear ID
	clearInterval(hideID);
	//clear status message
	displayStatus(' ');
	//clear ad content to turn off possible flash audio
	changeProperty('tooltipBox', 'innerHTML', "");
}

function clearAdInterval(){
	clearInterval(hideID);
}

function hideAd(){
	clearInterval(hideID);
	hideID = setInterval(adDelay, 10)//1250);

	//THIN DOUBLE UNDERLINE
	linkRefString = "link" + lastToolNum;
	changeStyle(linkRefString, 'borderBottomWidth', '1px');
}

function linkClick(indexNum){
	window.open(urlArray[indexNum]);
}

function turnSoundOff(){
	window.document.myFlashMovie.SetVariable("jsAudioAdjust", "AUDIO_OFF");
}
function turnSoundOn(){
	window.document.myFlashMovie.SetVariable("jsAudioAdjust", "AUDIO_ON");
}


function highlightAd(tooltipRef, idString){/*
	var browserType = navigator.appName;
	switch(browserType){
		case('Netscape'):
			tooltipRef.style.MozOpacity = .9999999;
			break;
		case('Microsoft Internet Explorer'):
			$(idString).style.filter = "alpha(opacity=100)";
			break;
		default:
			$(idString).style.opacity = 1;
	}
	for(var x=1;x<7;x++){
		var tempID = "cZn" + x;
		$(tempID).style.background = tooltipHighlightColor;
	}*/
}

function unHighlightAd(tooltipRef, idString){/*
	var browserType = navigator.appName;
	switch(browserType){
		case('Netscape'):
			tooltipRef.style.MozOpacity = .9;
			break;
		case('Microsoft Internet Explorer'):
			$(idString).style.filter = "alpha(opacity=90)";
			break;
		default:
			$(idString).style.opacity = .9;
	}
	for(var x=1;x<7;x++){
		var tempID = "cZn" + x;
		$(tempID).style.background = tooltipBkgColor;
	}*/
}


function displayAd(indexNum){
	if (activeTooltipObjName!='' && activeTooltipObjName!="tooltip"+indexNum) adDelay()
	var act = (activeTooltipObjName!="tooltip"+indexNum) ? 'expand':'contract'
	var linkRefString = "link" + indexNum;
	var linkRef =  $(linkRefString);
	var sign = 1;
	
	activeTooltipObjName = "tooltip"+indexNum
	var tooltipObj = $(activeTooltipObjName)

	//clear hide delay
	clearInterval(hideID);	

	//update global link number variable
	lastToolNum = indexNum;
	
	//POSITION TOOL TIP
	tooltipBoxWidth = parseFloat(getStyleValue(activeTooltipObjName, 'width').replace('px',''));
	tooltipBoxHeight = parseFloat(getStyleValue(activeTooltipObjName, 'height').replace('px',''));
	tooltipStartPosX = getRealPos(linkRef,'x');
	tooltipStartPosY = getRealPos(linkRef,'y')-tooltipBoxStartHeight;
	tooltipEndPosX = getRealPos(linkRef,'x') + tooltipXOffset;
	tooltipEndPosY = getRealPos(linkRef,'y') - tooltipBoxHeight + tooltipYOffset;
	
	if (act == 'expand')
	{
		changeStyle('tooltipZT', 'width', tooltipBoxStartWidth+'px')
		changeStyle('tooltipZT', 'height', tooltipBoxStartHeight+'px')
		changeStyle('tooltipZ', 'left', tooltipStartPosX+'px')
		changeStyle('tooltipZ', 'top', tooltipStartPosY+'px')
	}
	else
	{
		sign = -1;
		changeStyle('tooltipZT', 'width', tooltipBoxWidth+'px')
		changeStyle('tooltipZT', 'height', tooltipBoxHeight+'px')
		changeStyle('tooltipZ', 'left', tooltipEndPosX+'px')
		changeStyle('tooltipZ', 'top', tooltipEndPosY+'px')
	}

	shiftX = sign * Math.floor((tooltipEndPosX - tooltipStartPosX)/expandSteps)
	shiftY = sign * Math.floor((tooltipEndPosY - tooltipStartPosY)/expandSteps)
	shiftW = sign * Math.floor((tooltipBoxWidth-tooltipBoxStartWidth)/expandSteps);
	shiftH = sign * Math.floor((tooltipBoxHeight-tooltipBoxStartHeight)/expandSteps);

	//Account for page scrolling. Reposition tooltip as neccesary
	/*if((getScrollX() + document.body.clientWidth) < (linkPosX + tooltipBoxWidth)){
		var tempOffset = (linkPosX + tooltipBoxWidth) - (getScrollX() + document.body.clientWidth);
		linkPosX -= tempOffset + 6;
	}
	if(getScrollY() > linkPosY){
		var tempName = $("link" + lastToolNum);
		var tempOffset = tempName.offsetHeight;
		linkPosY += tooltipBoxHeight - (2*tooltipYOffset) + tempOffset + 4;
	}*/

	//Make it happen
	
	/*
	var linkPosXString = linkPosX + "px";
	var linkPosYString = linkPosY + "px";
	changeStyle(activeTooltipObjName, 'left', linkPosXString);
	changeStyle(activeTooltipObjName, 'top', linkPosYString);*/

	//THICK DOUBLE UNDERLINE
	//changeStyle(linkRefString, 'borderBottomWidth', '3px');

	//REVEAL TIP
	//changeStyle(activeTooltipObjName, 'visibility', 'visible');
	//changeStyle(activeTooltipObjName, 'display', 'inline');
	changeStyle('tooltipZ', 'display', 'inline');
	if (act == 'contract') adDelay()
	expandContractTooltip(act)
}


function expandContractTooltip(act)
{
	var w = parseFloat(getStyleValue('tooltipZT', 'width').replace('px',''));
	var h = parseFloat(getStyleValue('tooltipZT', 'height').replace('px',''));
	var x = parseFloat(getStyleValue('tooltipZ', 'left').replace('px',''));
	var y = parseFloat(getStyleValue('tooltipZ', 'top').replace('px',''));
	
	w += shiftW; h += shiftH; x += shiftX; y += shiftY;
	if ((act=='expand' && w<=tooltipBoxWidth && h<=tooltipBoxHeight && x<=tooltipEndPosX && y>=tooltipEndPosY) ||
			(act=='contract' && w>=tooltipBoxStartWidth && h>=tooltipBoxStartHeight && x>=tooltipStartPosX && y<=tooltipStartPosY))
	{
		changeStyle('tooltipZT', 'width', w+'px')
		changeStyle('tooltipZT', 'height', h+'px')
		changeStyle('tooltipZ', 'left', x+'px')
		changeStyle('tooltipZ', 'top', y+'px')
		setTimeout('expandContractTooltip("'+act+'")', expandTimout)
	}
	else
	{
		if (act=='expand')
		{
			changeStyle(activeTooltipObjName, 'left', tooltipEndPosX+'px')
			changeStyle(activeTooltipObjName, 'top', tooltipEndPosY+'px')
			changeStyle(activeTooltipObjName, 'display', 'inline');
		}
		changeStyle('tooltipZ', 'display', 'none');
	}
}

var tooltipBoxWidth, tooltipBoxHeight;
var tooltipBoxStartHeight=25, tooltipBoxStartWidth=30;
var tooltipStartPosX, tooltipStartPosY;
var tooltipEndPosX, tooltipEndPosY;
var shiftX, shiftY, shiftW, shiftH;
var expandSteps = 25, expandTimout=5;
