// All right reserved Copyright @ 2009 MGVanCleef (MGVanCleef@yahoo.it)
// MENU version 2.37 (Ottimizzato per Internet explorer 8.0.6, Mozilla Firefox 3.0.8, Opera 9.63, Chrome 1.0.1, Safari 4 beta)



is = {};

is.agent = navigator.userAgent.toLowerCase();
is.win = (is.agent.indexOf("win") != -1);
is.exp = (is.agent.indexOf("msie")!= -1);
is.moz = (is.agent.indexOf("gecko")!= -1);
is.op = (is.agent.indexOf("opera")!= -1);
is.chr = (is.agent.indexOf("chrome")!= -1);
is.saf = (is.agent.indexOf("safari")!= -1);
is.istrict = (is.win && document.compatMode == "CSS1Compat");


var css_px = "px";
var SC_BAR = 16;
var SC_IS = 14;
var DIM_MENU = 748;
var MIN_LEFT_MENU = 8;
var MIN_LEFT_MENU_IE = 10;
var R_ROVER_ON = 45;
var R_ROVER_OFF = 50;


function menuObj(obj, par, nst) 
{
	page = new Object();
	page.width = (is.moz || is.op) ? (document.body.clientWidth-SC_BAR) : document.body.clientWidth;
	page.height = document.body.clientHeight;
	
	this.lyr = document.getElementById(obj);
	this.sty = this.lyr.style;
	if(par) 
		this.parent = par;
	this.obj = obj + "SwipeLayer";
	eval(this.obj + "= this");
}

menuObj.prototype.timer = null;
menuObj.prototype.wipe = 0;
menuObj.prototype.offX = Function('oX = this.lyr.offsetLeft; return oX');
menuObj.prototype.offY = Function('oY = this.lyr.offsetTop; return oY;');
menuObj.prototype.offW = Function('oW = this.lyr.offsetWidth; return oW;');
menuObj.prototype.offH = Function('oH = this.lyr.offsetHeight; return oH;');
menuObj.prototype.maxWipe = function() { return this.offH()+10; }

wipeMenu.prototype.addMain = function(name, hasSub, txt, url) 
{
	menuName = this.name;
	wipePos = this.pos;
	mAtt = this.mAtt, sAtt = this.sAtt;
	
	if(this.main[name]) 
		return;
		
	var mainMenu = document.createElement("DIV");
	var pf = Math.ceil(((mAtt.height-mAtt.font_size)/2)-2); 
	var wf = (is.moz || is.op) ? SC_IS : 0;
	var pf2 = (mAtt.height%2 == 0) ? 1 : 0;
	
	mainMenu.innerHTML = txt;
	mainMenu.id = name+menuName;

	var styStr = "position:absolute; width:" + (mAtt.width-wf) + "px; border:solid " + mAtt.border + "px " + mAtt.border_color + "; color:" + 
                     mAtt.fg_off + ";  text-align:" + mAtt.align + "; font-size:" + mAtt.font_size + "px; font-family:" + mAtt.font + "; padding:" + 
                     pf + "px 6px " + (pf+pf2) + "px 6px; background:" + mAtt.bg_off + "; cursor:pointer; cursor:hand;"

	mainMenu.style.cssText = styStr;
	mainMenu.setAttribute("style", styStr);
	document.body.appendChild(mainMenu);

	mainMenu.onmouseover = Function('if('+hasSub+')'+menuName+'.subs["'+name+'"].show("'+wipePos+'");over_out(this, "'+mAtt.bg_on+'", "'+mAtt.fg_on+'")');
	mainMenu.onmouseout = Function('if('+hasSub+')'+menuName+'.subs["'+name+'"].hide();over_out(this, "'+mAtt.bg_off+'", "'+mAtt.fg_off+'");');
	mainMenu.onmousedown = Function('location.href = "'+url+'"');

	this.main[name] = new menuObj(mainMenu.id);
	this.mainNum[this.mainNum.length] = this.main[name];

	if(!hasSub) 
		return;

	var subC = document.createElement("DIV");
	subC.id = name+menuName+"Sub";
	
	var styStr = "position:absolute; visibility:hidden; clip:rect(0px " + (sAtt.width+20) + "px 0px 0px); border:solid 1px " + sAtt.border_color +
	             "; border-width:" + sAtt.border + "px 0px 0px 0px; cursor:default;"
	subC.style.cssText = styStr;
	subC.setAttribute("style", styStr);
	document.body.appendChild(subC);

	this.subs[name] = new menuObj(subC.id, this.main[name]);
	subC.onmouseover = Function(menuName+'.subs["'+name+'"].show("'+wipePos+'");');
	subC.onmouseout = Function(menuName+'.subs["'+name+'"].hide();');
}

wipeMenu.prototype.addSub = function(name, parent, txt, url) 
{
	var tempsub = document.createElement("DIV");
	var pf = Math.ceil(((mAtt.height-mAtt.font_size)/2)-2); 
	var wf = (is.moz || is.op) ? SC_IS : 0;
	var pf2 = (mAtt.height%2 == 0) ? 1 : 0;
	tempsub.id = name+menuName+"SubItem";
	tempsub.innerHTML = txt;
		
	var styStr = "width:" + (sAtt.width-wf) + "px; border:solid " + sAtt.border + "px " + sAtt.border_color + "; border-top-width:0px; color:" + 
	             sAtt.fg_off + ";  text-align:" + sAtt.align + "; font-size:" + sAtt.font_size + "px; font-family:" + sAtt.font + "; padding:" + 
				 pf + "px 6px " + (pf+pf2) + "px 6px; background:" + sAtt.bg_off + "; cursor:pointer; cursor:hand;"
	tempsub.style.cssText = styStr;
	tempsub.setAttribute("style", styStr);
	this.subs[parent].lyr.appendChild(tempsub);

	tempsub.onmouseover = Function('over_out(this, "'+sAtt.bg_on+'", "'+sAtt.fg_on+'")');
	tempsub.onmouseout = Function('over_out(this, "'+sAtt.bg_off+'", "'+sAtt.fg_off+'")');
	tempsub.onmousedown = Function('location.href = "'+url+'"');
}

menuObj.prototype.show = function(p) 
{
	if(p == "h"){
		this.sty.left = this.parent.offX()+css_px;
		this.sty.top = this.parent.offY()+this.parent.offH()+css_px;
	} else{
		this.sty.left = this.parent.offX()+this.parent.offW()+css_px;
		this.sty.top = this.parent.offY()+css_px;
	}
	
	this.sty.visibility = "visible";
	this.sty.zIndex = "12";
	this.doShow();
}

menuObj.prototype.doShow = function() 
{
	clearTimeout(this.timer)
	this.clipIt(0, this.offW(), this.wipe, 0);
	this.wipe += 10;
	if(this.wipe <= this.maxWipe()) 
		this.timer = setTimeout(this.obj + ".doShow()", R_ROVER_ON)
}

menuObj.prototype.hide = function() 
{
	clearTimeout(this.timer)
	this.clipIt(0, this.offW(), this.wipe-10, 0);
	this.wipe -= 10;
	if(this.wipe >= 0) 
		this.timer = setTimeout(this.obj + ".hide()", R_ROVER_OFF);
	else 
		this.sty.visibility = "hidden";
}

function over_out(obj, bg, fg) 
{
	obj.style.background = bg;
	obj.style.color = fg;
}

menuObj.prototype.clipIt = function(t,r,b,l) 
{
	this.sty.clip = "rect(" + t + "px, " + r + "px, " + b + "px, " + l + "px)";
}

wipeMenu.prototype.buildMenu = function(x,y,spacing) 
{
	this.mainNum[0].sty.left = x+css_px;
	this.mainNum[0].sty.top = y+css_px;
	
	if(spacing == 0) 
		var spacing = -this.mAtt.border;
		
	for(i = 1; i < this.mainNum.length; i++){
		if(this.pos == "h"){
			this.mainNum[i].sty.left = this.mainNum[i-1].offX()+this.mainNum[i-1].offW()+spacing+css_px;
			this.mainNum[i].sty.top = this.mainNum[i-1].offY()+css_px;
		} else{
			this.mainNum[i].sty.left = this.mainNum[i-1].offX()+css_px;
			this.mainNum[i].sty.top = this.mainNum[i-1].offY()+this.mainNum[i-1].offH()+spacing+css_px;
		}
	}
}

function wipeMenu(menu,p,ma,sa)
{
	this.name = menu;
	this.pos = p;
	this.mAtt = ma;
	this.sAtt = (!sa) ?ma : sa;
	this.main = [];
	this.mainNum = [];
	this.subs = [];
}

wipeMenu.prototype.calculateposition = function() 
{
	if(document.body.clientWidth<DIM_MENU)
		menuAtt.left = (is.moz || is.op) ? MIN_LEFT_MENU : MIN_LEFT_MENU_IE;
	else if(document.body.clientWidth%2 && (is.exp || is.op || is.chr || is.saf))
		menuAtt.left = Math.ceil((document.body.clientWidth-DIM_MENU)/2-1);

	else
		menuAtt.left = Math.ceil((document.body.clientWidth-DIM_MENU)/2);
}

function LoadMenu() 
{
	menuAtt = new Array();
	menuAtt["Absolute_width"] = (is.moz) ? (document.body.clientWidth-SC_BAR) : document.body.clientWidth;
	menuAtt["Absolute_height"] = document.body.clientHeight;
	menuAtt["top"] = 205;
	menuAtt["left"] = 0;
	menuAtt["width"] = 123;
	menuAtt["height"] = 20;
	menuAtt["separator"] = 2;
	menuAtt["align"] = "center";
	menuAtt["font"] = "Verdana";
	menuAtt["font_size"] = 10;
	menuAtt["bg_off"] = "#BA8573";
	menuAtt["bg_on"] = "#DCC2BA";
	menuAtt["fg_off"] = "white";
	menuAtt["fg_on"] = "#AF2916";
	menuAtt["border"] = 1;
	menuAtt["border_color"] = "#000000";


	myMenu = new wipeMenu("myMenu", "h", menuAtt);

	myMenu.addMain("About", true, "Biografia", "biografia.html");
		myMenu.addSub("AboutSub1", "About", "Storia Clan", "storia_clan.html");
		myMenu.addSub("AboutSub2", "About", "Foto", "foto.html");
		
	myMenu.addMain("Project", true, "Progetto musicale", "progetto_musicale.html");
		myMenu.addSub("ProjectSub1", "Project", "Progetto Voce Maschile", "progetto_voce_maschile.html");
		myMenu.addSub("ProjectSub2", "Project", "Progetto Voce Femminile", "progetto_voce_femminile.html");
		myMenu.addSub("ProjectSub4", "Project", "Canzoni arrangiate", "canzoni_arrangiate.html");

	myMenu.addMain("Filters", true, "Chi e cosa cerco", "chi_e_cosa_cerco.html");
		myMenu.addSub("FiltersSub1", "Filters", "Requisiti dell'interprete", "requisiti_interprete.html");
        myMenu.addSub("FiltersSub5", "Filters", "Requisiti dell'arrangiatore", "requisiti_arrangiatore.html");
		myMenu.addSub("FiltersSub2", "Filters", "Requisiti dei musicisti", "requisiti_musicisti.html");
		myMenu.addSub("FiltersSub6", "Filters", "Ricerche future", "ricerche_future.html");

	myMenu.addMain("Partners", true, "Collaborazioni", "collaborazioni.html");
		myMenu.addSub("PartnersSub1", "Partners", "Interpreti", "interpreti.html");
		myMenu.addSub("PartnersSub1", "Partners", "Arrangiatori", "arrangiatori.html");
		myMenu.addSub("PartnersSub1", "Partners", "Musicisti", "musicisti.html");
		myMenu.addSub("PartnersSub1", "Partners", "Compositori", "compositori.html");
		myMenu.addSub("PartnersSub1", "Partners", "Autori di testi", "autori_di_testi.html");
		
	myMenu.addMain("Mail", true, "Contatti", "contatti.html");
	myMenu.addMain("Sms", true, "Link Utili", "link_utili.html");

	myMenu.calculateposition();
	myMenu.buildMenu(menuAtt.left, menuAtt.top, menuAtt.separator);
}


function Rebuild()
{

	myMenu.calculateposition();
	myMenu.buildMenu(menuAtt.left, menuAtt.top, menuAtt.separator);
}


