﻿
function Show_Menu(headIndex) {
    document.getElementById("hdg" + headIndex).className = "headingButtonHi";
    document.getElementById("cnt" + headIndex).style.display = "block";
}

function Hide_Menu(headIndex) {
    document.getElementById("hdg" + headIndex).className = "headingButton";
    document.getElementById("cnt" + headIndex).style.display = "none";
}

function Show_Hide_Content() {
	if (contentVisible) {
		Hide_Content();
		contentVisible = 0;
	}
	else {
		Show_Content();
		contentVisible = 1;
	}
	Set_Cookie();
}

function Show_Content() {

    if (contentWidth) {

        document.getElementById("layoutContent").style.display = "";

        var element = document.getElementById("layoutMain");
        element.style.width = mainWidth + "px";
        element.className = "Content " + element.className;

        element = document.getElementById("layoutPage");
        element.style.width = mainWidth + "px";

        element = document.getElementById("showHideContent")
        if (element) element.className = "hideContent";
    }
}

function Hide_Content() {

    if (contentWidth) {
    
        document.getElementById("layoutContent").style.display = "none";

        var element = document.getElementById("layoutMain");
        element.style.width = mainWidth + contentWidth + "px";
        element.className = element.className.substr(8);

        element = document.getElementById("layoutPage");
        element.style.width = mainWidth + contentWidth + "px";

        element = document.getElementById("showHideContent")
        if (element) element.className = "showContent";
    }
}

function Do_Heading(wID, hID)
{
 	if ( hID != headingID )
 	{
 		expandedItem = 0;
 		headingID = hID;
 		Set_Cookie();
 	}
 	if ( wID ) 
 	{
 		switch( wID )
 		{
 		case -2:
 			document.location = "../system/index.aspx";
 			break;
 		case -1:
 			if ( confirm( "Do you really want to log off?" )) document.location = "../system/logoff.aspx";
 			return;
 		default:
 			document.location = "../pages/" + wID + ".aspx";
 			break;
 		}
 	}
 	else
 	{
 		document.location.reload();
 	}
}

function Content_Click(x)
{
 	if ( expandedItem )
 	{
 		Collapse_Item( expandedItem );
 		if ( expandedItem == x )
 		{
 			expandedItem = 0;
 			Set_Cookie();
 			return;
 		}
 	}
 	Expand_Item( x );
 	expandedItem = x;
 	Set_Cookie();
}

var eintID = 0;
var cintID = 0;
var expandElement = null;
var collapseElement = null;

function Expand_Item(x)
{
	document.getElementById("ind" + x).className = "contentHeadExpand";
	expandElement = document.getElementById("ind" + x + "i").lastChild;
	eintID = window.setInterval("Do_Expand_Element();", 10 );
}

function Do_Expand_Element()
{
	expandElement.style.display = "block";
	expandElement = expandElement.previousSibling;
	if ( expandElement == null ) window.clearInterval(eintID);
}

function Collapse_Item(x)
{	
	document.getElementById("ind" + x).className = "contentHeadCollapse";
	collapseElement = document.getElementById("ind" + x + "i").firstChild;
	cintID = window.setInterval("Do_Collapse_Element();", 10 );
}

function Do_Collapse_Element()
{
	collapseElement.style.display = "none";
	collapseElement = collapseElement.nextSibling;
	if ( collapseElement == null ) window.clearInterval(cintID);
}

function Item_Click(id,newwnd)
{
	var url = "../pages/" + id + ".aspx";
	if ( newwnd ) window.open( url); else document.location = url;
}

function Do_Item_Click(mod, id) {
	document.location = "../system/redirect.aspx?ModuleID=" + mod + "&ID=" + id;
}

function Set_Cookie()
{
	document.cookie = "Layout=Heading=" + headingID + "&Content=" + contentVisible + "&Expand=" + expandedItem + ";path=/";
}

