var ie = (document.all?1:0);

var LABEL_SEL = '#fadab6';	//#eacaa6

var BORDER_SEL = 'solid 1 #c8a884';



function clickLabel(cell) {

	var tbl = ie?cell.parentNode.parentNode:cell.parentNode.parentNode.parentNode;

	for (i=0; i < tbl.rows.length; i++) {

		c = tbl.rows.item(i).cells.item(1);

		c.style.backgroundColor = 'transparent';

		c.style.fontWeight = 'normal';

		c.style.borderLeftWidth = 0;

		c.style.borderTopWidth = 0;

		c.style.borderBottomWidth = 0;

		c.style.textAlign = 'left';

	}

	cell.style.backgroundColor = LABEL_SEL;

	cell.style.fontWeight = 'bold';

	cell.style.borderStyle = 'solid';

	cell.style.borderColor = '#c8a884';

	cell.style.borderLeftWidth = 1;

	cell.style.borderTopWidth = 1;

	cell.style.borderBottomWidth = 1;

	cell.style.borderRightWidth = 0;

	cell.style.textAlign = 'right';

}



function mouseOverLabel(cell) {

	cell.style.cursor = ie ? 'hand' : 'pointer';

}



function mouseOutLabel(cell) {

	cell.style.cursor = ie ? 'default' : '';

}



function openFrame(url) {

	if (ie) 

		frameDoc.document.location = url;

	else

		top.frames[1].frames[1].frames[0].location = url;

}



function getObj(n, d) {

  	var p,i,x;

	if (!d) d = document; 

	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {

		d = parent.frames[n.substring(p+1)].document; 

		n = n.substring(0,p);

	}

	if (!(x = d[n]) && d.all) x = d.all[n]; 

	for (i = 0; !x && i < d.forms.length; i++) {

		x = d.forms[i][n];

	}

	for (i = 0; !x && d.layers && i < d.layers.length; i++) {

		x = getObj(n, d.layers[i].document);

    	}

	return x;

}



function getStyle(o) {

	if (o.style) return o.style;

	return o.document;

}



var g_isIE = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);

var g_isNS = (navigator.appName.toLowerCase().indexOf("netscape") != -1);

var g_isOP = (navigator.appName.toLowerCase().indexOf("opera") != -1);



function getObject(name) {

	if (g_isIE) {

		return document.all[name];

	}

	if (g_isNS) {

//		return document.layers[name];

		return getLayer(name);

	}

}



function writeDiv(id, text) {

	var div = getLayer(id);

	if (g_isNS) {

		div.open();

		div.write(text);

		div.close();

	}

	else if (g_isIE) div.innerHTML = text;

}



function getStyle2(strId, top) {

//

// Restituisce il riferimento allo style dell'oggetto avente id='strId'

//

	var o = getLayer(strId, top);

	if (document.layers) {

		return o.document;

	} 

	else {

		return o.style;

	}

}



function getLayer(strId, top){

//

// Funzione per NS: ricava il riferimento all'oggetto a partire

// dal nome (strId) e a qualunque livello annidato.

//

	var objElm = "";

	if (document.layers) {

		if( top == null) top = document.layers;

		for (var a=0; top.length > a; a++) {

//			alert("id=" + top[a].id + ", " + top[a].document);

			if (top[a].id == strId) {

				return top[a];

				break;

			}

			else {

				objElm = GetLayer(strId, top[a].document.layers);

			}

		}

	} 

	else {

		if( top == null) top = document;

		objElm = (top.all) ? top.all(strId) : top.getElementById(strId);

	}

	return objElm;

}



function musica(brano) {

	var page = 'musica' + brano + '.html';

	window.open(page, '_blank', 'width=400,height=300');

}







function getCss() {

	if (screen.width > 1024) document.write('<link rel="stylesheet" href="script/cssH.css">');

	else if (screen.width == 1024) document.write('<link rel="stylesheet" href="script/cssM.css">');

	else document.write('<link rel="stylesheet" href="script/cssL.css">');

}





function oggi() {

	var gNome = new Array("domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato");

	var mNome = new Array("gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre");

	var now = new Date();

	var y = now.getYear();

	if (y<1900) {y+=1900};

	var m = now.getMonth();

	var g = now.getDate();

	var gset = now.getDay();

	return gNome[gset] + " " + g + " " + mNome[m] + " " + y;

}



function onClickProposta(index) {
/*
	var tbl = document.getElementById('tblProposte');

	for (i=0; i < tbl.rows.length/2; i++) {

		var td = tbl.rows.item(i*2 + 1).cells.item(0);

		//var s = getStyle(td.firstChild);
		var s = td.firstChild.style;
		if (i == index) {

			s.display = (s.display == 'block') ? 'none' : 'block';

		}

		else {

			s.display = 'none';

		}

	}
*/
	for (i=0; i < 4; i++) {
    	var div = document.getElementById('divProposta'+i);
        var s = div.style;
		if (i == index) {
			s.display = (s.display == 'block') ? 'none' : 'block';
		}
		else {
			s.display = 'none';
		}
	}

}



function loadImg() {

// 

// Precarica le immagini specificate negli argomenti

//

	alert(args.length);

	var args = loadImg.arguments;

	var img;



	for (i = 0; i < args.length; i++) {

		img = new Image();

		img.src = args[i];

	}

}
