function splitString(theString, theSeparator)
{
	var retval = new Array();
	a = theString.indexOf(theSeparator);
	var i = 0;
	while (a != -1) {
		retval[i++] = theString.substring(0, a);
		theString = theString.substring(a + 1, theString.length);
		a = theString.indexOf(theSeparator);
	}
	retval[i] = theString;
	return retval;
}

function writeSectionTab(linkTo, aname, adesc)
{
	if (
		(aname == "home" && 
			(
			loclist[sectidx].toLowerCase() == "www.csenartimarziali.com" 
			|| 
			loclist[sectidx].toLowerCase() == "index.php"
			||
			loclist[sectidx].toLowerCase() == "main.php"
			)
		)
		||
		(loclist[sectidx] == aname)
	) {
		document.write('<td><center>');
		document.write('<img style="border: solid black 1px; margin: 0" ');
		document.write('src="' + baseurl + 'img/' + aname + '.jpg" name="' + aname + '"/>');
		document.write('</center></td>');
	}
	else {
		var image_name = aname.substring(0, 1).toUpperCase() + aname.substring(1, aname.length);
		document.write('<td style="padding: 0; margin: 0; border-bottom: none; width: auto"><center>');
		document.write('<a href="' + baseurl + linkTo + '" ');
		document.write('onMouseOver="img' + image_name + '.src=\'' + baseurl + 'img/' + aname + '_down.jpg\'" ');
		document.write('onMouseOut="img' + image_name + '.src=\'' + baseurl + 'img/' + aname + '.jpg\'">');
		document.write('<img name="img' + image_name + '" ');
		document.write('style="text-decoration: none; border: none; margin: 0;" ');
		document.write('src="' + baseurl + 'img/' + aname + '.jpg" name="' + aname + '" />');
		document.write('</a></center></td>');
	}
}

function writeSectionSep()
{
	document.write('<td style="padding: 0; margin: 0; border-bottom: none; width: auto">');
	document.write('&nbsp;');
	document.write('</td>');
}

var loclist = splitString(document.location.href, "/");
var innerval = 0;
var baseurl = "";
var sectidx = loclist.length - 2;
for (var i = loclist.length - 2; i > 0; i--) {
	if (loclist[i].toLowerCase() == "www.csenartimarziali.com") break;
	baseurl = baseurl + "../";
	sectidx--;
}
sectidx++;

document.write('<center>');
document.write('<table border="0" cellspacing="20"><tr>');
document.write('<td>');
document.write('<img style="border: none" valign="middle" src="' + baseurl + 'csen-logo.gif"/>');
document.write('</td><td>');
document.write('<div style="font-family: serif; font-size: 24pt; font-weight: bold; text-align: center">CSEN Arti Marziali</div>');
document.write('<center>Sito ufficiale nazionale del settore arti marziali<br/>');
document.write('e sport di combattimento CSEN</center>');
document.write('</td><td>');
document.write('<img style="border: none" valign="middle" src="' + baseurl + 'csen-logo.gif"/>');
document.write('</td></tr></table>');
document.write('</center>');

document.write('<table style="border: none; padding: 0; margin: 0" width="100%">');
document.write('<tr style="border: none; margin: 0; padding: 0">');

writeSectionTab("main.php", "home", "Homepage");
writeSectionSep();
writeSectionTab("csen/index.html", "csen", "Il CSEN");
writeSectionSep();
writeSectionTab("http://62.101.83.213/csen.it/default.asp?cpage=reg_resp", "org", "Organigramma delle Arti Marziali");
writeSectionSep();
//writeSectionTab("comunicati/index.html", "comunicati", "Comunicati");
//writeSectionSep();
writeSectionTab("photodiaries/index.html", "photodiaries", "Diari Fotografici");
writeSectionSep();
writeSectionTab("sponsor/index.html", "sponsor", "Sponsor");
writeSectionSep();
writeSectionTab("links/index.html", "links", "Links");
writeSectionSep();
writeSectionTab("associations/index.html", "associations", "Associazioni");
document.write('</tr></td></table>');

//document.write('<br/>');
//document.write('<br/>');

document.write('<table border="0" cellspacing="10" width="100%">');
document.write('<tr><td width="150" valign="top" class="left">');
//document.write('<tr><td width="150" valign="top" style="background-repeat: no-repeat; background-attachment: fixed; background-image: url(' + baseurl + 'img/bamboo.jpg)">');

function menuItem(page, text)
{
	document.write('<a href="' + page + '">');
	document.write(text);
	document.write('</a>');
}

function thumbnail(path, imagename, caption)
{
	document.write('<center><a href="' + path + '/' + imagename + '">');
	document.write('<img src="' + path + '/t_' + imagename + '" border="0"/>');
	document.write('</a><br/>' + caption + '</center>');
}

function thumbnailn(path, imagename, caption)
{
	document.write('<center>');
	document.write('<img src="' + path + '/t_' + imagename + '" border="0"/>');
	document.write('<br/>' + caption + '</center>');
}

var thumbcount = 0;

function thumbtd(folder, imgname, desc)
{
	if (thumbcount > 0 && thumbcount % 3 == 0) {
		document.write('</tr><tr>');
	}
	document.write('<td>');
	thumbnail(folder, imgname, desc);
	document.write('</td>');
	thumbcount++;
}

function thumbtdn(folder, imgname, desc)
{
	if (thumbcount > 0 && thumbcount % 3 == 0) {
		document.write('</tr><tr>');
	}
	document.write('<td>');
	thumbnailn(folder, imgname, desc);
	document.write('</td>');
	thumbcount++;
}

var mnucnt = 0;

function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}

function hideDiv(divID_as_a_string) {
    //get a reference as above ...
    getRefToDiv(divID_as_a_string).style.display = 'none';
    return true;
}

function showDiv(divID_as_a_string) {
    //get a reference as above ...
    if (getRefToDiv(divID_as_a_string).style.display == 'none') {
	getRefToDiv(divID_as_a_string).style.display = 'block';
    }
    else {
	getRefToDiv(divID_as_a_string).style.display = 'none';
    }    
    return true;
}

function startMenu(caption)
{
    var div_id = "mnu" + mnucnt;
    document.write('<a class="level2" href="javascript://" onClick="showDiv(\'' + div_id + '\');">' + caption + '</a>');
    document.write('<div id="' + div_id + '" style="display: none">');
    mnucnt = mnucnt + 1;
}

function endMenu()
{
    document.write('</div>');
}

function makeSubMenu(caption, href)
{
    document.write('<a class="level3" href="' + href + '">' + caption + '</a>');
}
