
//URL = new String(Request.ServerVariables('URL'));

URL = new String(location.href);
URL = URL.substring(URL.indexOf('/',7), URL.lastIndexOf('/') + 1);

var RootSection = '';
var root = null;

// template functions ==========================================================

function title(full_mode) {
	var struct = Structure.element(URL);
	var title = struct.title;
	while (struct) {
		struct = struct.parent;
		if (struct && (struct.parent || full_mode))
			title = struct.short_title + ((title) ? ' | ' + title : '');
	}
	return title;
}

// navigation classes ==========================================================

function SectionItem(code, title, childs) {
	this.code = code;
	this.title = title.replace(/[\[\]]/g, '');
	this.short_title = title.replace(/\[(.*)\]/, '');
	this.sub_title = '';
	if (this.short_title != this.title)
		this.sub_title = title.replace(/.*\[(\s\/\s)?(.*)\]/, '$2');
	this.childs = childs;
	this.onclick = null;
	this.init = SectionItemInit;
}

function SectionItemInit(parent, root) {
	this.parent = parent;
	this.url = this.code.match(/^http:/) ? this.code : (parent.url + this.code + '/');
	root.index[this.url] = this;
	if (this.childs) {
		for (var i = 0; i < this.childs.length; i++) {
			this.childs[i].init(this, root);
		}
	}
}

function SiteStructure(args) {
	this.title = '';
	this.short_title = '';
	this.parent = null;
	this.url = '/';
	this.sections = new Array();
	this.index = new Array();
	for (var i = 0; i < arguments.length; i++) {
		this.sections[i] = arguments[i];
		this.sections[i].init(this, this);
	}
	this.path = SiteStructurePath;
	this.element = SiteStructureElement;
}

function SiteStructurePath(url) {
	var point = this.element(url).parent;
	var path_str = '';
	while (point && point != this) {
		path_str = ' / ' + PathElement(point.short_title, point.url) + path_str;
		point = point.parent;
	}
	return '<a href="/">Home</a>' + path_str;
}

function SiteStructureElement(url) {
	var element = this.index[url];
	return (element) ? element : this;
}

function PathElement(title, url) {
	return (url == URL) ? '<nobr>' + title + '</nobr>' : '<a href="' + url + '"><nobr>' + title + '</nobr></a>';
}

// main menu classes ===========================================================

function BuildMenu()
{
	document.write('			<ul id="menu">\n');
	if(URL=='/')
		document.write('				<li><a href="/" class="act">' + Structure.sections[0].title + '</a></li>\n');
	else		
		document.write('				<li><a href="/">' + Structure.sections[0].title + '</a></li>\n');
	for (var i = 1; i < MenuItemsNumber; i++)
	{
	    if (URL.indexOf(Structure.sections[i].url) == 0) {
	        document.write('				<li><a href="' + Structure.sections[i].url + '" class="act">' + Structure.sections[i].title + '</a></li>\n');
	        }
	    else {

            if (Structure.sections[i].title == 'REGISTER')
	            document.write('				<li><a href="https://fasttrack.gobigevent.com/prothos/onware.x/conference/web/index.p?!=public=13100755495637=9=23210389&Conference=9255" target="_blank">' + Structure.sections[i].title + '</a></li>\n');
	        else
	             document.write('				<li><a href="' + Structure.sections[i].url + '">' + Structure.sections[i].title + '</a></li>\n');

	       
	    }
	}
	document.write('			</ul>\n');
}


