// JavaScript Document

   /* getElementByClass
    /**********************/
function getElementsByClassName2(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

 
function imgChange( id, new_img )
  {
    element = document.getElementById(id);
    if(element)
      element.src = new_img ;
/*
per usarla
<img id="immagine" onmouseover="imgChange('immagine', '../tts_web/images/mail_out.png')"  onmouseout="imgChange('immagine', '../tts_web/images/product2.png')" src="../tts_web/images/product2.png" width="32" height="32" />
 */
 }

function cambia_classe( id, newclass )
{
	element = document.getElementById(id);
	if(element)
    element.className = newclass ;
	/*per usare questa funzione basta scrivere nel tag
 	onmouseover="cambia_classe('caption', 'classe1')"
   	onmouseout="cambia_classe('caption', 'classe2')"*/
}

function check_browser()	
{
	var browserName=navigator.appName; 
	if (browserName=="Netscape")
		{ 
		 return 'N';
		}
	 if (browserName=="Microsoft Internet Explorer")
		 {
		  return 'E';
		 }
		  return 'altro';
}

function apri_area_old( targetId ){
 if (document.getElementById){
		target = document.getElementById( targetId );
			if (target.style.display == "none"){
				if (check_browser() == "E") 
				{
					target.style.display = "block";//ci sono sia block che table-row perche explorer non capisce table row mentre firefox per block intende non tutta la riga
				}else
				{
					target.style.display = "table-row";
				}
			} else {
				target.style.display = "none";

			}
	}
}

/*function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}
*/

//questo serve a visualizzare o nascondere alternativamente
function apri_area(id){
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			//filter(("img"+id),'imgin');			
		} else {
			//filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				//filter(("img"+id),'imgin');
			} else {
				//filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				//filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}
//questo nasconde e basta
function nascondi_area(id){
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'none';			
	} else 
	{ 
		if (document.layers) 
		{	
				document.id.display = 'none';
		} else 
		{	
			document.all.id.style.display = 'none';
		}
	}
}
//questo visualizza e basta
function visualizza_area(id){
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6		
			document.getElementById(id).style.display = 'block';
	} else 
	{ 
		if (document.layers) 
		{				
				document.id.display = 'block';
		} else 
		{	
				document.all.id.style.display = 'block';
		}
	}
}

function seleziona(id_casella,id_riga )
{
 if (document.getElementById){
		casella = document.getElementById(id_casella);
		riga = document.getElementById(id_riga);
			if (casella.checked == true){
				riga.style.backgroundColor = "#FFFF99";
			} else {
				riga.style.backgroundColor = "#FFFFFF";

			}
	}
}
function spunta(id_casella,id_riga )
{
	casella = document.getElementById(id_casella);
	casella.checked = true;
	seleziona(id_casella,id_riga );
}

function apri_upload($url)
{
	finestra = window.open ($url, "upload","menubar=no,status=yes,scrollbars=yes,width=630,height=400,toolbar=no,resizable=yes");
	//finestra.moveTo(0,0);
}

function Chiudi(){

self.close()
}


  function ajax_load_dettaglio(divId,pathToFile){
	if(enableCache && jsCache[pathToFile]){
	  document.getElementById(divId).innerHTML = jsCache[pathToFile];
	  return;
	}
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	document.getElementById(divId).innerHTML = 'Loading...';
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = 
	function(){
	  ajax_showContent(divId,ajaxIndex,pathToFile);
	};
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();
  }



// -->

