
// alert('display related functions started');

function hideIt(inBut, inObj){
	var tmpBut = document.getElementById(inBut);
	var tmpClass = '.'+inObj;
	var styleSheet=document.styleSheets[0];
	if (styleSheet.cssRules) {
		var tmpRuleNumber = document.styleSheets[0].cssRules.length;
	}else{
		var tmpRuleNumber = document.styleSheets[0].rules.length;
	}
	if (getCSSRule(tmpClass)){
		killCSSRule(tmpClass);
	}
	var tmpRule = addCSSRule(tmpClass);
	tmpRule.style.display='none';
	var tmpID = inBut+'but';
	var tmp_a = document.getElementById(tmpID);
	tmp_a.blur;
	var tmp_s = document.getElementById(tmpBut.id+'span');
	var tmp_id = tmp_s.id
	var tmpStr = "javascript:showIt('"+tmpBut.id+"', '"+inObj+"');";
	tmp_a.setAttribute('href', tmpStr);
	tmpStr += "return false;";
	tmpBut.setAttribute('onclick', tmpStr);
	tmpBut.setAttribute('title','clicca per espandere [vedere maggior dettaglio]')
	var new_span = document.createElement('span');
	new_span.id = tmp_id+'2'
	var new_text = document.createTextNode('[+]');
	new_span.appendChild(new_text);
	tmp_s.replaceChild(new_text,tmp_s.firstChild)
}

function showIt(inBut, inObj){
	var tmpBut = document.getElementById(inBut);
	var tmpClass = '.'+inObj;
	var styleSheet=document.styleSheets[0];
	if (styleSheet.cssRules) {
		var tmpRuleNumber = document.styleSheets[0].cssRules.length;
	}else{
		var tmpRuleNumber = document.styleSheets[0].rules.length;
	}
	if (getCSSRule(tmpClass)){
		killCSSRule(tmpClass);
	}
	var tmpRule = addCSSRule(tmpClass);
	tmpRule.style.display='block';
	var tmpID = inBut+'but';
	var tmp_a = document.getElementById(tmpID);
	tmp_a.blur;
	var tmp_s = document.getElementById(tmpBut.id+'span');
	var tmpStr = "javascript:hideIt('"+tmpBut.id+"', '"+inObj+"');";
	tmp_a.setAttribute('href', tmpStr);
	tmpStr += "return false;";
	tmpBut.setAttribute('onclick', tmpStr);
	tmpBut.setAttribute('title','clicca per compattare [vedere minor dettaglio]')
	var new_span = document.createElement('span');
	new_span.id = tmp_s.id+'2';
	var new_text = document.createTextNode('[-]');
	tmp_s.replaceChild(new_text,tmp_s.firstChild)
}

function makeExpandLink(inBut, inObj){
	var tmpBut = document.getElementById(inBut);
	var new_a = document.createElement('a');
	var new_span = document.createElement('span');
	var new_text = document.createTextNode(' ');
	new_span.appendChild(new_text);
	new_span.id = tmpBut.id+'X';
	tmpBut.appendChild(new_span);
	new_a.id = tmpBut.id+'linkbut';
	var new_span = document.createElement('span');
	new_span.id = tmpBut.id+'linkspan';
	var tmpAtt = new_span.getAttribute('style');
	if (tmpAtt==null) {
		tmpAtt = 'font-size:70%;vertical-align:20%;'
	}else{
		tmpAtt = 'font-size:70%;vertical-align:20%;'+tmpAtt
	}
	new_a.setAttribute('style',tmpAtt);
	var tmpStr = "javascript:showIt('"+tmpBut.id+"link', '"+inObj+"');";
	new_text = document.createTextNode('[+]');
	new_a.setAttribute('href', tmpStr);
	tmpStr += 'return false;';
	tmpBut.setAttribute('onclick', tmpStr);
	tmpBut.appendChild(new_a);
	new_a.appendChild(new_span);
	new_span.appendChild(new_text);
}

function testIt(){
	alert('testIt');
}

function loadShrinks() {
	cycleLoadShrink('dl');
	cycleLoadShrink('dt');
	cycleLoadShrink('dd');
	cycleLoadShrink('ul');
	cycleLoadShrink('li');
	cycleLoadShrink('p');
	cycleLoadShrink('div');
	cycleLoadShrink('form');
	cycleLoadShrink('span');
	cycleLoadShrink('a');
}

function cycleLoadShrink(inTags) {
	if (!isArray(inTags)){
		inTags = Array(inTags)
	}
	for (j=0; j<inTags.length; j++) {
		var arrTitleList = document.getElementsByTagName(inTags[j]);
		for (i=0; i<arrTitleList.length; i++) {
			if( (arrTitleList[i].getAttribute('title')!='') && (arrTitleList[i].getAttribute('title')!=null) ){
				if(arrTitleList[i].getAttribute('title').substr(0,2)=='sh'){
					tmpTitle = arrTitleList[i].getAttribute('title');
					var tmpObj = arrTitleList[i]
					tmpObj.setAttribute('id',tmpTitle)
					tmpObj.setAttribute('title','clicca per espandere [vedere maggior dettaglio]')
					makeExpandLink(tmpObj.id, tmpTitle);
					tmpObj.setAttribute('id',tmpTitle+'link')
					hideIt(tmpObj.id,tmpTitle);
				}
			}
		}
	}
}

window.onload = function() {
	arrTmp = Array('dl', 'dt', 'dd', 'ul', 'li', 'p', 'div', 'form', 'legend', 'fieldset', 'span');
	cycleLoadShrink(arrTmp);
}



function getCSSRule(ruleName, deleteFlag) {
	ruleName=ruleName.toLowerCase();
	if (document.styleSheets) {
		for (var i=0; i<document.styleSheets.length; i++) {
			var styleSheet=document.styleSheets[i];
			var ii=0;
			var cssRule=false;
			do {
				if (styleSheet.cssRules) {
					cssRule = styleSheet.cssRules[ii];
				} else {
					cssRule = styleSheet.rules[ii];
				}
				if (cssRule) {
					if (cssRule.selectorText.toLowerCase()==ruleName) {
						if (deleteFlag=='delete') {
							if (styleSheet.cssRules) {
								styleSheet.deleteRule(ii);
							} else {
								styleSheet.removeRule(ii);
							}
							return true;
						} else {
							return cssRule;
						}
					}
				}
				ii++;
			} while (cssRule)
		}
	}
	return false;
} // end getCSSRule 

function killCSSRule(ruleName) {
	return getCSSRule(ruleName,'delete');
} // end killCSSRule

function addCSSRule(ruleName) {
	if (document.styleSheets) {
		if (!getCSSRule(ruleName)) {
			if (document.styleSheets[0].addRule) {
				document.styleSheets[0].addRule(ruleName, null,0);
			} else {
				document.styleSheets[0].insertRule(ruleName+' { }', 0);
			}
		}
	}
	return getCSSRule(ruleName);
} // end addCSSRule

/*

function hideDebito(objName) {
	if(document.all || document.getElementByID){
	debito.style.display = "none";
	showDeb.style.display = "block";
	showDeb.style.align = "left";
	hideDeb.style.display = "none";

	} else {
	tmpObj = document.getElementById("debito");
	tmpObj.setAttribute("style", "display:none;");
	tmpObj.setAttribute("class", "mSUB");
	tmpObj.className = "mSUB";
	tmpObj = document.getElementById("showDeb");
	tmpObj.setAttribute("style", "display:block;text-align:left;");
	tmpObj = document.getElementById("hideDeb");
	tmpObj.setAttribute("style", "display:none;");
	}
} // end Function hideDeb

function showDebito(objName) {
	if(document.all || document.getElementByID){
	debito.className = "mSUB";
	debito.style.display = "block";
	showDeb.style.display = "none";
	hideDeb.style.display = "block";
	} else {
	tmpObj = document.getElementById("debito");
	tmpObj.setAttribute("style", "display:block;margin:0;padding:0;");
	tmpObj.setAttribute("class", "mSUB");
	tmpObj.className = "mSUB";
	tmpObj = document.getElementById("showDeb");
	tmpObj.setAttribute("style", "display:none;");
	tmpObj = document.getElementById("hideDeb");
	tmpObj.setAttribute("style", "display:block;text-align:center;");
	} // End browser compat if
} // end Function hideDeb

function addListItems()
{
	if(document.all || document.getElementByID){

	var new_li = document.createElement('li');
	debito_fold.appendChild(new_li);
	new_li.style.display = "none";
	new_li.setAttribute("id", "showDeb");
	var new_a = document.createElement('a');
	var new_text = document.createTextNode('[+ vedi dettagli]');
	new_a.setAttribute("href", "javascript:showDebito(this);");
	new_li.appendChild(new_a);
	new_a.appendChild(new_text);

	var new_li2 = document.createElement('li');
	debito_fold.appendChild(new_li2);
	new_li2.style.display = "none";
	new_li2.setAttribute("id", "hideDeb");
	var new_a2 = document.createElement('a');
	txt2_cont = '[ -- nascondi dettagli]';
	var new_text2 = document.createTextNode(txt2_cont);
	new_a2.setAttribute("href", "javascript:hideDebito(this);");
	new_li2.appendChild(new_a2);
	new_a2.appendChild(new_text2);

	} else {
	var ul = document.getElementById('debito_fold');

	var new_li = document.createElement('li');
	new_li.setAttribute("id", "showDeb");
	new_li.setAttribute("style", "display:none;");
	var new_a = document.createElement('a');
	new_a.setAttribute("href", "javascript:showDebito(this);");
	new_a.setAttribute("id", "showDebLink");
	var new_text = document.createTextNode('[+ vedi dettagli]');
	ul.appendChild(new_li);
	new_li.appendChild(new_a);
	new_a.appendChild(new_text);

	var new_li2 = document.createElement('li');
	new_li2.setAttribute("id", "hideDeb");
	new_li2.setAttribute("style", "display:none;");
	var new_a2 = document.createElement('a');
	new_a2.setAttribute("href", "javascript:hideDebito(this);");
	new_a.setAttribute("id", "hideDebLink");
	txt2_cont = '[ -- nascondi dettagli]';
	var new_text2 = document.createTextNode(txt2_cont);
	ul.appendChild(new_li2);
	new_li2.appendChild(new_a2);
	new_a2.appendChild(new_text2);
	} // End browser compat if
}
window.onload = function() {
	addListItems();
	hideDebito("debito");
}


*/