var currentPopupElement;

function popUp(evt,currElem,devX, devY) {
	if (mouseOverPopup == true) {
		currentPopup = getElementById(currentPopupElement)
		if(currentPopup) {
			currentPopup.style.visibility = "hidden";
		}
		popUpWin = getElementById(currElem).style;
		popUpWin.visibility = "visible";
		//rectzoom = false;
		currentPopupElement = currElem;
	}
}

function popDown(currElem) {
    if (mouseOverPopup == true) {
	    popUpWin = getElementById(currElem).style;
	    popUpWin.visibility = "hidden";
    }
    rectzoom = true;
}

function popUpMouseOver(currElem) {
	rectzoom = false;
}

function popUpMouseOut(currElem) {
	rectzoom = true;
}

function closePopUp(currElem) {
	var popup = getElementById(currElem);
	if(popup) {
		popup.style.visibility = "hidden";
		//rectzoom = true;
	}
}

function poiSelected(poiId, type, info) {
	
}

// replace images onmouseover 
function mapOver(name, status, img) {
	var newClassName = (status == 0 ? "navOff" : "navOn");
    var newBgColor = (status == 0 ? "#EEF0F0" : "#999999");
    if (name.length > 1) {
        getElementById("td_" + name + "_l").style.backgroundColor = newBgColor;
        getElementById("td_" + name + "_r").style.backgroundColor = newBgColor;
    }
    getElementById("td_" + name).style.backgroundColor = newBgColor;
    getElementById("img_" + name).src = img;
}

//display 'inactive' gif over map
function inactiveMap() {

	clearPageRefreshTimeout();
	
	var refTable = getElementById("innertable");
	var inactivemap = getElementById("inactivemap");
	if(inactivemap != null && refTable != null) {
		inactivemap.style.width = refTable.offsetWidth;
		inactivemap.style.height = refTable.offsetHeight;
		inactivemap.style.textAlign = "center";
		inactivemap.style.verticalAlign = "middle";
		if (isFirefox()){
			inactivemap.style.display='table-row';
		} else {
			inactivemap.style.display='block';
		}
	}
	rectzoom = false;
}

function activeMap() {

	var tabActual = getElementById("tabActual");

	// Set Timeout only if current traffic situation is selected
	//Warning: the decision is based on the class of the embedded <a> element
	if (tabActual != null && tabActual.className =="selected") {
		
		setPageRefreshTimeout();
	}

	var inactivemap = getElementById("inactivemap");
	if(inactivemap != null) {
		inactivemap.style.display='none';
	}
	rectzoom = true;
}

function getAllowedMapWidth(availableWidth) {
	// alert("AllowedMapWidth: " + availableWidth);
	if (availableWidth < 500) {
		return 500;
	}
	else if (availableWidth > 1024) {
		return 1024;
	}
	return availableWidth;
}

function getAllowedMapHeight(availableHeight) {
	// alert("AllowedMapHeight: " + availableHeight);
	if (availableHeight < 400) {
		return 400;
	}
	else if (availableHeight > 1024) {
		return 1024;
	}
	return availableHeight;
}

function hideContextMenu() {
	var contextMenu = getElementById("contextMenu");
	if(contextMenu != null) {
		contextMenu.style.visibility = "hidden";
		rectzoom = true;
	}
}