﻿var objSectionLink = null;
var intCurrentMenuNr = -1;
var intWantedPageID = -1;
var intStartSectionNr = -1;

function LoadFirstPage(strFrameName) {
	var objLink;
	var intIndex;
	
	if (strFrameName != '') {
		//
		// Check if the frame is already created
		//
		if (eval('window.top.' + strFrameName) == null) {
			window.setTimeout("LoadFirstPage('" + strFrameName + "');", 200);
			return;
		}
	}

	objSectionLink = document.getElementById("SectionLink");
	objLink = document.getElementById("G" + intStartSectionNr);
	if (objLink != null) {
		SectionClick(intStartSectionNr);
		objSectionLink.href = objLink.getAttribute("href");

		if (intWantedPageID > 0) {
			intIndex = objSectionLink.href.indexOf("&PageID=");
			if (intIndex > 0)
				objSectionLink.href = objSectionLink.href.substring(0, intIndex) + "&PageID=" + intWantedPageID;
			else
				objSectionLink.href += "&PageID=" + intWantedPageID;
		}
		clickLink(objSectionLink);
	}
	else {
		if (document.getElementById("FlexonyMenu_div") != null) {
			objSectionLink.href = "Page.aspx?PageID=" + intWantedPageID;
		}
		else {
			objSectionLink.href = "Menu.aspx?SectionID=-1&PageID=" + intWantedPageID;
		}
		clickLink(objSectionLink);
	}
}

function SectionOver(intMenuNr) {
	if (intCurrentMenuNr != intMenuNr) {
		document.getElementById("G" + intMenuNr).className = 'section_active';
		document.getElementById("GT" + intMenuNr).className = 'section_text_active';
	}
}

function SectionOut(intMenuNr) {
	if (intCurrentMenuNr != intMenuNr) {
		document.getElementById("G" + intMenuNr).className = 'section_idle';
		document.getElementById("GT" + intMenuNr).className = 'section_text_idle';
	}
}

function SectionSelected(intMenuNr) {
	document.getElementById("G" + intMenuNr).className = 'section_selected';
	document.getElementById("GT" + intMenuNr).className = 'section_text_selected';
}

function SectionClick(intMenuNr) {
	var objHtml;
	
	if (intCurrentMenuNr != -1) {
		document.getElementById("G" + intCurrentMenuNr).className = 'section_idle';
		document.getElementById("GT" + intCurrentMenuNr).className = 'section_text_idle';
	}
	
	objHtml = document.getElementById('GI' + intCurrentMenuNr);
	if (objHtml != null) objHtml.src = objHtml.src.replace(/Open/gi, 'Closed');
	objHtml = document.getElementById('GI' + intMenuNr);
	if (objHtml != null) objHtml.src = objHtml.src.replace(/Closed/gi, 'Open');
	
	(blnUseSectionSelectedStyle) ? SectionSelected(intMenuNr) : SectionOver(intMenuNr);
	intCurrentMenuNr = intMenuNr;
	
	objSectionLink.href = document.getElementById("G" + intCurrentMenuNr).getAttribute("href");
	clickLink(objSectionLink);
}

