

var CurrentFontSize = 12;
var CurrentShowRoom = false;

function FontSize(direction) {
	var newsize = direction > 0 ? CurrentFontSize+2 : CurrentFontSize-2;
	newsize = parseFloat(newsize.toFixed(2));
	if (newsize >= 12 && newsize <= 16) {
		$("FontSizeStylesheet").href = "/style/fontsize.asp?s=" + newsize;
		CurrentFontSize = newsize;
	}
}

var nCurrentMenuExpanded = false;
var nMenuCollapseTimeout = false;

String.prototype.AddBeforeFileExtention = function(str) { var s = this; return s.substr(0, s.lastIndexOf(".")) + str + s.substr(s.lastIndexOf(".")); }
String.prototype.RemoveMatch = function(str) { return this.replace(str, ""); }
String.prototype.Contains = function(str) {	return (this.indexOf(str) > -1); }

function MenuHover(nr, expand) {
	var m = $("mnu" + nr);
	if (nMenuCollapseTimeout) {
		clearTimeout(nMenuCollapseTimeout);
		nMenuCollapseTimeout = false;
	}
	if (nCurrentMenuExpanded) {
		MenuCollapse(nCurrentMenuExpanded);
	}
	if (expand) {
		MenuExpand(nr);
	}
	try {
		m.addClassName("Active");
		m.setStyle("zIndex", 1000);
	} catch(e) { }
	
}

function MenuOut(nr, expand) {
	var m = $("mnu" + nr);
	if (expand) {
		nMenuCollapseTimeout = setTimeout(function() { MenuCollapse(nr); }, 500);
	} else {
		if (!m.hasClassName("ActiveByServer")) {
			m.removeClassName("Active");
		}
	}
}

function MenuExpand(nr) {
	var e = $("ExpandBlock" + nr);
	var m = $("mnu" + nr);
	var mp = m.cumulativeOffset();
	e.show();
	nCurrentMenuExpanded = nr;
}

function MenuCollapse(nr) {
	var e = $("ExpandBlock" + nr);
	var m = $("mnu" + nr);
	e.hide();
	m.className = m.className.RemoveMatch("Expanded");
	if (!m.hasClassName("ActiveByServer")) {
		m.removeClassName("Active");
	}
	nCurrentMenuExpanded = false;
}

function InfoBubbleForMarker(idx, secondTime) {
	if (CurrentShowRoom !== false) {
		$("ShowRoom" + CurrentShowRoom).removeClassName("ShowRoomActive");
		CurrentShowRoom = false;
	}
	if (!Object.isUndefined(locations)) {
		var l = locations[idx];
		if (!Object.isUndefined(l)) {
			if (!Object.isUndefined(l.RefMarker)) {
				l.RefMarker.openInfoWindowHtml(l.Html);
				CurrentShowRoom = idx;
				$("ShowRoom" + idx).addClassName("ShowRoomActive");
				
				$("RouteToPage").show();
				$("ExtraInfoHolder").update("<h3>" + l.Name + "</h3>" + l.ExtraText.gsub("&lt;","<").gsub("&gt;",">").gsub("&quot;","\"") );
				$("RouteTitle").update(l.RouteText2);
				
				return true;
			}
		}
	}
	if (Object.isUndefined(secondTime)) {
		setTimeout(function() {
			InfoBubbleForMarker(idx, true);
		}, 2000);
	}
}

function AlignContent() {
	var o = $("ContentBlockContentPadding");
	if (o.getHeight() < 400) {
		o.style.height = "400px";
	}
}

function ChangeMainPhoto(url) {
	var o = $("MainPhoto");
	if (!Object.isUndefined(url)) {
		o.src = url;
	} else {
		o.src = MainPhotoURL;
	}
}
