// Cambia il contenuto di una zona di testo DCOM
var Nomi = Array();
var consolles = Array();
	
function change_text(area,text,pic,pos) {
	var theTable=document.createElement('table');  	// - start by creating the table element
	var tb=document.createElement('tbody');  	// - create a tbody element 
	// - !! YOU MUST INCLUDE THE TBODY TAG FOR THIS EXAMPLE TO WORK IN WIN IE5+ !! 
	theTable.style.border='0';
	theTable.style.width='100%';
	
	var tr=document.createElement('tr');  	// - now create the tr and td elements
	
	var theTD1=document.createElement('td');
	theTD1.setAttribute('width','100%');
	theTD1.setAttribute('vAlign','top');
	
	var row=text.split('#-#');
	
	var theText=document.createElement('span');
	theText.setAttribute('class','unnamed1');
	
	for (i=0; i<row.length; i++) {
		theText.appendChild( document.createTextNode(row[i]) );
		theText.appendChild( document.createElement('BR') ) ;
	}
	
	theTD1.appendChild(theText);
	
	tr.appendChild(theTD1);
	
	if (pic != '') {
		var theTD2=document.createElement('td');
		theTD2.setAttribute('width','0');
		
		var img=document.createElement('img'); 
		img.setAttribute('src','../../pic/'+pic);
		theTD2.appendChild(img);
		
		tr.appendChild(theTD2);
	}
	
	tb.appendChild(tr);
	theTable.appendChild(tb);
	
	if (!Nomi[pos]) {
		Nomi[pos] = true;
		document.getElementById(area).appendChild( theTable );
		//theNewParagraph.onclick = function () {document.getElementById(area).removeChild(this); Nomi[pos] = false; };
	}
	else {
		 Nomi[pos] = false;
		 document.getElementById(area).removeChild(document.getElementById(area).lastChild);
	}
}

function change_consolle(area,text,pic) {
	var theTable=document.createElement('table');  	// - start by creating the table element
	var tb=document.createElement('tbody');  	// - create a tbody element 
	// - !! YOU MUST INCLUDE THE TBODY TAG FOR THIS EXAMPLE TO WORK IN WIN IE5+ !! 
	theTable.style.border='0';
	theTable.style.width='100%';
	
	var tr=document.createElement('tr');  	// - now create the tr and td elements
	
	var theTD1=document.createElement('td');
	theTD1.setAttribute('width','100%');
	theTD1.setAttribute('align','left');
	
	var row=text.split('#-#');
	
	var theText=document.createElement('span');
	theText.setAttribute('class','unnamed1');
	
	for (i=0; i<row.length; i++) {
		theText.appendChild( document.createTextNode(row[i]) );
		theText.appendChild( document.createElement('BR') ) ;
	}
	
	theTD1.appendChild(theText);
	theTD1.setAttribute('vAlign','top');
	
	tr.appendChild(theTD1);
	
	if (pic != '') {
		var theTD2=document.createElement('td');
		theTD2.setAttribute('width','0');
		
		var img=document.createElement('img'); 
		img.setAttribute('src','../../images/'+pic);
		theTD2.appendChild(img);
		
		tr.appendChild(theTD2);
	}
	
	tb.appendChild(tr);
	theTable.appendChild(tb);
	
	if (!consolles[1]) {
		document.getElementById(area).appendChild( theTable );
		consolles[1] = true;
	}
	else {
		document.getElementById(area).removeChild(document.getElementById(area).lastChild);
		document.getElementById(area).appendChild( theTable );
	}
}

function mostra_pic(area,pic) {
	// faccio piazza pulita
	place = document.getElementById(area);
	while (place.hasChildNodes())
		place.removeChild(place.lastChild);
	
	// metto un immagine
	var img=document.createElement('img'); 
	img.setAttribute('src','../../'+pic);
	place.appendChild(img);
}


function gallery(title,text,pic) {
	// titolo
	place = document.getElementById("title");
	while (place.hasChildNodes())
		place.removeChild(place.lastChild);
	
	var titolo = document.createTextNode(title);
	place.appendChild(titolo);
	
	// immagine
	place = document.getElementById("img");
	while (place.hasChildNodes())
		place.removeChild(place.lastChild);
		
	var img=document.createElement('img'); 
	img.setAttribute('src','../../pic/'+pic);
	place.appendChild(img);

	// testo
	place = document.getElementById("text");
	while (place.hasChildNodes())
		place.removeChild(place.lastChild);

	var row=text.split('#-#');
	var theText=document.createElement('p');
	
	for (i=0; i<row.length; i++) {
		theText.appendChild( document.createTextNode(row[i]) );
		theText.appendChild( document.createElement('BR') ) ;
	}
	
	var testo = document.appendChild(theText);
	place.appendChild(testo);
	

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function show_pic(pic,title) {
	i1 = new Image;
	i1.src = pic;
	html = '<HTML>\n<HEAD>\n<TITLE>'+title+'</TITLE>\n</HEAD>\n<BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0>\n<CENTER><IMG SRC="'+pic+'" BORDER=0 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+14,document.imageTest.height+32)"></CENTER>\n</BODY>\n</HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
}

// Chained Menu

// Copyright Xin Yang 2004
// Web Site: www.yxScripts.com
// EMail: m_yangxin@hotmail.com
// Last Updated: 2004-08-23

// This script is free as long as the copyright notice remains intact.

var _disable_empty_list=false;
var _hide_empty_list=false;

// ------

///// DynamicDrive.com added function/////////////

//var onclickaction="alert"

function goListGroup(){
	for (i=arguments.length-1;i>=0; i--){
		if (arguments[i].selectedIndex!=-1){
			var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value;
			if (selectedOptionvalue!=""){
				if (onclickaction=="alert")
					alert(selectedOptionvalue)
				else if (newwindow==1)
					window.open(selectedOptionvalue)
				else
					window.location=selectedOptionvalue
				break
			}
		}
	}
}

///// END DynamicDrive.com added function//////


if (typeof(disable_empty_list)=="undefined") { disable_empty_list=_disable_empty_list; }
if (typeof(hide_empty_list)=="undefined") { hide_empty_list=_hide_empty_list; }

var cs_goodContent=true, cs_M="M", cs_L="L", cs_curTop=null, cs_curSub=null;

function cs_findOBJ(obj,n) {
  for (var i=0; i<obj.length; i++) {
    if (obj[i].name==n) { return obj[i]; }
  }
  return null;
}
function cs_findContent(n) { return cs_findOBJ(cs_content,n); }

function cs_findM(m,n) {
  if (m.name==n) { return m; }

  var sm=null;
  for (var i=0; i<m.items.length; i++) {
    if (m.items[i].type==cs_M) {
      sm=cs_findM(m.items[i],n);
      if (sm!=null) { break; }
    }
  }
  return sm;
}
function cs_findMenu(n) { return (cs_curSub!=null && cs_curSub.name==n)?cs_curSub:cs_findM(cs_curTop,n); }

function cs_contentOBJ(n,obj){ this.name=n; this.menu=obj; this.lists=new Array(); this.cookie=""; }; cs_content=new Array();
function cs_topmenuOBJ(tm) { this.name=tm; this.items=new Array(); this.df=0; this.addM=cs_addM; this.addL=cs_addL; }
function cs_submenuOBJ(dis,link,sub) {
  this.name=sub;
  this.type=cs_M; this.dis=dis; this.link=link; this.df=0;

  var x=cs_findMenu(sub);
  this.items=x==null?new Array():x.items;

  this.addM=cs_addM; this.addL=cs_addL;
}
function cs_linkOBJ(dis,link) { this.type=cs_L; this.dis=dis; this.link=link; }

function cs_addM(dis,link,sub) { this.items[this.items.length]=new cs_submenuOBJ(dis,link,sub); }
function cs_addL(dis,link) { this.items[this.items.length]=new cs_linkOBJ(dis,link); }

function cs_showMsg(msg) { window.status=msg; }
function cs_badContent(n) { cs_goodContent=false; cs_showMsg("["+n+"] Not Found."); }

function cs_optionOBJ(text,value) { this.text=text; this.value=value; }
function cs_emptyList(list) { for (var i=list.options.length-1; i>=0; i--) { list.options[i]=null; } }
function cs_refreshList(list,opt,df) {
  cs_emptyList(list);

  for (var i=0; i<opt.length; i++) {
    list.options[i]=new Option(opt[i].text, opt[i].value);
  }

  if (opt.length>0) {
    list.selectedIndex=df;
  }
}
function cs_getOptions(menu) {
  var opt=new Array();
  for (var i=0; i<menu.items.length; i++) {
    opt[i]=new cs_optionOBJ(menu.items[i].dis, menu.items[i].link);
  }
  return opt;
}
function cs_updateListGroup(content,idx,sidx,mode) {
  var i=0, curItem=null, menu=content.menu;

  while (i<idx) {
    menu=menu.items[content.lists[i++].selectedIndex];
  }

  if (menu.items[sidx].type==cs_M && idx<content.lists.length-1) {
    var df=cs_getIdx(mode,content.cookie,idx+1,menu.items[sidx].df);

    cs_refreshList(content.lists[idx+1], cs_getOptions(menu.items[sidx]), df);
    if (content.cookie) {
      cs_setCookie(content.cookie+"_"+(idx+1),df);
    }

    if (idx+1<content.lists.length) {
      if (disable_empty_list) {
        content.lists[idx+1].disabled=false;
      }
      if (hide_empty_list) {
        content.lists[idx+1].style.display="";
      }

      cs_updateListGroup(content,idx+1,df,mode);
    }
  }
  else {
    for (var s=idx+1; s<content.lists.length; s++) {
      cs_emptyList(content.lists[s]);

      if (disable_empty_list) {
        content.lists[s].disabled=true;
      }
      if (hide_empty_list) {
        content.lists[s].style.display="none";
      }

      if (content.cookie) {
        cs_setCookie(content.cookie+"_"+s,"");
      }
    }
  }
}
function cs_initListGroup(content,mode) {
  var df=cs_getIdx(mode,content.cookie,0,content.menu.df);

  cs_refreshList(content.lists[0], cs_getOptions(content.menu), df);
  if (content.cookie) {
    cs_setCookie(content.cookie+"_"+0,df);
  }

  cs_updateListGroup(content,0,df,mode);
}

function cs_updateList() {
  var content=this.content;
  for (var i=0; i<content.lists.length; i++) {
    if (content.lists[i]==this) {
      if (content.cookie) {
        cs_setCookie(content.cookie+"_"+i,this.selectedIndex);
      }

      if (i<content.lists.length-1) {
        cs_updateListGroup(content,i,this.selectedIndex,"");
      }
    }
  }
}

function cs_getIdx(mode,name,idx,df) {
  if (mode) {
    var cs_idx=cs_getCookie(name+"_"+idx);
    if (cs_idx!="") {
      df=parseInt(cs_idx);
    }
  }
  return df;
}

function _setCookie(name, value) {
  document.cookie=name+"="+value;
}
function cs_setCookie(name, value) {
  setTimeout("_setCookie('"+name+"','"+value+"')",0);
}

function cs_getCookie(name) {
  var cookieRE=new RegExp(name+"=([^;]+)");
  if (document.cookie.search(cookieRE)!=-1) {
    return RegExp.$1;
  }
  else {
    return "";
  }
}

// ----
function addListGroup(n,tm) {
  if (cs_goodContent) {
    cs_curTop=new cs_topmenuOBJ(tm); cs_curSub=null;

    var c=cs_findContent(n);
    if (c==null) {
      cs_content[cs_content.length]=new cs_contentOBJ(n,cs_curTop);
    }
    else {
      delete(c.menu); c.menu=cs_curTop;
    }
  }
}

function addList(n,dis,link,sub,df) {
  if (cs_goodContent) {
    cs_curSub=cs_findMenu(n);

    if (cs_curSub!=null) {
      cs_curSub.addM(dis,link||"",sub);
      if (typeof(df)!="undefined") { cs_curSub.df=cs_curSub.items.length-1; }
    }
    else {
      cs_badContent(n);
    }
  }
}

function addOption(n,dis,link,df) {
  if (cs_goodContent) {
    cs_curSub=cs_findMenu(n);

    if (cs_curSub!=null) {
      cs_curSub.addL(dis,link||"");
      if (typeof(df)!="undefined") { cs_curSub.df=cs_curSub.items.length-1; }
    }
    else {
      cs_badContent(n);
    }
  }
}

function initListGroup(n) {
  var _content=cs_findContent(n), count=0;
  if (_content!=null) {
    content=new cs_contentOBJ("cs_"+n,_content.menu);
    cs_content[cs_content.length]=content;

    for (var i=1; i<initListGroup.arguments.length; i++) {
      if (typeof(arguments[i])=="object" && arguments[i].tagName && arguments[i].tagName=="SELECT") {
        content.lists[count]=arguments[i];

        arguments[i].onchange=cs_updateList;
        arguments[i].content=content; arguments[i].idx=count++;
      }
      else if (typeof(arguments[i])=="string" && /^[a-zA-Z_]\w*$/.test(arguments[i])) {
        content.cookie=arguments[i];
      }
    }

    if (content.lists.length>0) {
      cs_initListGroup(content,content.cookie);
    }
  }
}

function resetListGroup(n) {
  var content=cs_findContent("cs_"+n);
  if (content!=null && content.lists.length>0) {
    cs_initListGroup(content,"");
  }
}
// ------
