  /**
   * Funtion Open/Close Error Message
   */
  function openErrMsg(title, text)  {

   win_op = findElement('errmsg_op');
   win	 = findElement('errmsg');
   if ((!win) || (title == '') || (text == '')) return false;
   
   findElement('emTitle').innerHTML = title;
   findElement('emText').innerHTML  = text + '<br>' + '<br>';

   win.style.visibility = 'visible';

   if (!win_op) return;
		win_op.style.visibility = 'visible';

   return false;
  }

  function closeErrMsg() {
    win_op   = findElement('errmsg_op');
	 win   	 = findElement('errmsg');

	 if (!win) return;
	 win.style.visibility = 'hidden';

    if (!win_op) return;
	 win_op.style.visibility = 'hidden';
  }
  
    /**
   * Funtion Open/Close Div
   */
  function openDiv(div_name)  {
   var oDiv 	= getElem(div_name);
   var oWin	 	= getElem('errmsg_op');
   
   if (!oDiv || !oWin) return false;

   oWin.style.visibility = 'visible';
   oDiv.style.visibility = 'visible';
   
  // return false;
  }

  function closeDiv(div_name) {
   oDiv 	= getElem(div_name);
   oWin	 	= getElem('errmsg_op');
   
   if (!oDiv || !oWin) return false;

   oDiv.style.visibility = 'hidden';
   oWin.style.visibility = 'hidden';
   
   return false;
  }
  
	function findElement(item) {
		if (document.all) return(document.all[item]);
		if (document.getElementById) return(document.getElementById(item));
		return(false);
	}
	
	/**
	 * Send Contact E-mail
	 */
	function cContactTo(contact) {
		if (contact && contact != "" && document.forms[0] && findElement('contact_to')) {
			findElement('contact_to').value = contact;
			findElement('send_contact').submit();
		}
		
		return false;			
	}
	
// ---------------------------------------------------------------------- //
// -- Rende compatibile con tutti i browser la funzione getElementById -- //
// ---------------------------------------------------------------------- //
function getElem(pID) 
{
	if ( pID == "" ) return false;
		
	var tObj = null;
	if(document.getElementById)     tObj = document.getElementById(pID)
	else if(document.all)           tObj = document.all[pID]
	else if(document.layers)        tObj = document.layers[pID]
	
	if (tObj == null){
	    for (var i = 0; i<document.forms.length; i++){
	            var tForm = document.forms[0];
	            for (var j = 0; j<tForm.elements.length; j++){
	                    var tElem = tForm.elements[j];
	                    if (tElem.name == pID){
	                            tObj = tElem;
	                            break;
	                    }
	            }
	           if (tObj != null) break;
	    }
	}
	return tObj;
}
// ---------------------------------------------------------------------- //

// ---------------------------------------------------------------------- //
// -- visualizza una immagine data in dimensioni ridotte stabilite ------ //
// ---------------------------------------------------------------------- //
function resizeCover ( img, iwidth, iheight )
{	
	getElem(img).style.display='none';
	
	/**
	 * prende i dati da una immagine esistente 
	 * e setta le dimensioni massime da darle
	 */
	var image     = getElem(img);
	// var width     = Math.round(image.width);
	// var height 	  = Math.round(image.height);
	var width     = image.width;
	var height 	  = image.height;
	var maxWidth  = 530; // larghezza massima della copertina
	var maxHeight = 350; // altezza massima della copertina
	
	if ( width > height )
	{
		// -- calcolo la percentuale di riduzione sulla larghezza -- //
		//alert("riduzione in larghezza con larghezza immagine: " + width);
		var percRiduzione = maxWidth * 100 / width;
		var percRiduzione = Math.round( 100 - percRiduzione );
	}
	else
	{
		// -- calcolo la percentuale di riduzione sull'altezza -- //
		//alert("riduzione in altezza con larghezza altezza: " + height);
		var percRiduzione = maxHeight * 100 / height;
		var percRiduzione = Math.round( 100 - percRiduzione );		
	}	
	
	// -- applico la percentuale di riduzione ai due lati -- //
	var newWidth  = width  - (width  * percRiduzione / 100);
	var newHeight = height - (height * percRiduzione / 100);
	
	// -- applico il resize all'immagine -- //
	//document.write('<img src="' + img + '" width="' + newWidth + '" height="' + newHeight + '" />');
	image.setAttribute("width",  newWidth);
	image.setAttribute("height", newHeight);	
	
	/*
	if (getElem(img)) {
		getElem(img).style.display='inline';
		//alert('if '+image.width+' == '+Math.round(newWidth)+' && '+image.height+' == '+Math.round(newHeight));
	} else {
		sInt = setInterval(resizeCover ( ''+img+'', ''+iwidth+'', ''+iheight+'' ),1000);
		//alert('else '+image.width+' == '+Math.round(newWidth)+' && '+image.height+' == '+Math.round(newHeight));		
	}	
	*/
}
// ---------------------------------------------------------------------- //