function getObj(n){
	var s;
	with (document){
		s = getElementById ? getElementById(n) ? getElementById(n).style : null
		: all ? all[n] ? all[n].style : null
		:	layers ? layers[n] : null
		}
	return s;
	}

function toggleObj(s,b,d){
	if (!d) {d='block'}
	if (s) { s.visibility = b ? 'visible' : 'hidden'; s.display = b ? d : 'none' };
	}

function closeBox(n){
	toggleObj( getObj(n),false );
	return false;
	}

function useDefault(c,set){
	var f = c.form;
	var e;
	if (set == 'plc') e = new Array('DSPLC','DSIND','DSLOC','IDPRV');
	if (set == 'cnt') e = new Array('DSORG','DSTEL','DSFAX','DSCEL','DSMAIL','DSWEB','DSFBK','DSFBKN','DSMYS','DSTWT','DSSKP');
	if (c.checked){
		for (var i=0; i<e.length; i++){
			f[e[i]].chg = f[e[i]].value;
			f[e[i]].value = f[e[i]+'def'].value;
			f[e[i]].disabled = true;
			}
		c.chg = true;
		}
	else{
		for (var i=0; i<e.length; i++){
			f[e[i]].value = f[e[i]].chg ? f[e[i]].chg : '';
			f[e[i]].disabled = false;
			}
		}
	}

function checkDate(c){
	var hd1 = getObj('hidedata1');
	var hd2 = getObj('hidedata2');
	var hd3 = getObj('hidedata3');
	toggleObj(hd1,false)
	toggleObj(hd2,false)
	toggleObj(hd3,false)
	if      (c.value == 1) { toggleObj(hd1,true,'inline') }
	else if (c.value == 2) { toggleObj(hd2,true,'inline') }
	else if (c.value == 3) { toggleObj(hd3,true,'inline') }
	}

function share(a){
	window.location.href = a.href + encodeURIComponent(window.location) + '&t='+encodeURIComponent(document.title) + '&title='+encodeURIComponent(document.title);
	return false;
	}

function tip(c,l,lh){

	if (c._tip) return;

	var tip = l ? l.title : c.title;

	var d = document.createElement('div');
	d.className = 'ccmtip';
	c._tip = d;
	var p = document.createElement('p');
	p.innerHTML=tip;
	d.appendChild(p);
	document.body.appendChild(d);

	var o = l ? document : lh ? lh : c;
	var e = l ? 'mousedown' : lh ? 'mouseout' : 'blur';
	var cls = function(){
		if (c._tip) document.body.removeChild(c._tip);
		c._tip = null;
		if (o.removeEventListener) { o.removeEventListener(e,cls,false) }
		else if (o.detachEvent)    { o.detachEvent('on'+e,cls) }
		};
	if (o.addEventListener) { o.addEventListener(e,cls,true) }
	else if (o.attachEvent) { o.attachEvent('on'+e,cls) }

	var x = y = 0;
	var t = c;
	if (t.offsetParent) { do {
		x += t.offsetLeft;
		y += t.offsetTop;
		} while (t = t.offsetParent) }

	x = x-(lh ? 155 : 162);
	y = y+(lh ?  12 :  20);

	d.style.left = x+'px';
	d.style.top  = y+'px';

	}

function count(ta,l){

	var tc = ta.form[ta.name+'count'];
	//var tal = ta.value.replace(/[\n\r\n]+/g, ' ').length;
	var tal = ta.value.length;

	if (tal == l && tc.cut && ta.value == tc.old){
		tc.style.color = '#900';
		tc.value = 'ATTENZIONE: il testo è stato tagliato';
		}
	else if (tal > l){
		ta.value = ta.value.substring(0,l);
		tc.style.color = '#900';
		tc.value = 'ATTENZIONE: il testo è stato tagliato';
		tc.cut = true;
		tc.old = ta.value;
		}
	else {
		tc.style.color = '#789';
		tc.value = (l - tal)+' caratteri a disposizione';
		}

	}




