
function Cambia_src_img(id,path_new_img) {
	document.getElementById(id).src=path_new_img;
}


var sound3Embed = null;

function sound3Play(url_file) {
	sound3Stop();
	sound3Embed = document.createElement("embed");
	sound3Embed.setAttribute("src", url_file);
	sound3Embed.setAttribute("hidden", true);
	sound3Embed.setAttribute("autostart", true);
	sound3Embed.setAttribute("loop", true);
	document.body.appendChild(sound3Embed);
}

function sound3Stop() {
	if ( sound3Embed ) {
		document.body.removeChild(sound3Embed);
		sound3Embed = null;
	}
}

/*

  Author: Gabriele Maira (gambry) per Echidna SCARL (http://www.echidna.it)
  Thx to: Anti Avanti.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
function scroll_box(id_parent,id_child,vers) {
				var mychild = document.getElementById(id_child);
				var myparent = document.getElementById(id_parent);
				var a = 5;
				var y;

				if (window.getComputedStyle) {
					y = isNaN(parseInt(mychild.style.getPropertyValue('margin-top'))) ? 0 : parseInt(mychild.style.getPropertyValue('margin-top'));
				} else {
					y = isNaN(parseInt(mychild.currentStyle["marginTop"])) ? 0 : parseInt(mychild.currentStyle["marginTop"]);
				}
					
				var hmychild = parseInt(mychild.offsetHeight);
				var hmyparent = parseInt(myparent.offsetHeight);
				
				if (y < 0 && vers == 'up') {
					mychild.style.marginTop = mychild.style.styleMarginTop = ( y + a ) + 'px';
				}
				//if (y+a < parseInt(myparent.style.getPropertyValue('height')) && vers == 'down') {
				if (y > (hmyparent - hmychild) && vers == 'down') {
					mychild.style.marginTop = mychild.style.styleMarginTop = ( y - a ) + 'px';

				}
			}

function start_scroll(id_parent,id_child,vers){
  scroll_box(id_parent,id_child,vers);
  start=setTimeout("start_scroll('"+id_parent+"','"+id_child+"','"+vers+"')", 20);
}

function stop_scroll(id_parent,id_child,vers){
  clearTimeout(start);
}


function IEdetect(){
  if (navigator.userAgent.toLowerCase().indexOf("msie") != -1){
    return true;
  } 
}


//Per far COMPARIRE un elemento
function opacity_IN(id,op,duration){
 e = document.getElementById(id);
 e.style.display = 'block';
 e.style.visibility = 'visible';
 
 if(IEdetect()){
   e.style.filter='alpha(opacity='+op*10+')';
 }else{
   e.style.opacity = op/10;
 }
 op++;
 temp = duration/10;
 if(op <= 10){
  setTimeout("opacity_IN('"+id+"',"+op+","+duration+")", temp);
 }
}

//Per far SCOMPARIRE un elemento
function opacity_OUT(id,op,duration){
 e = document.getElementById(id);
 
 if(IEdetect()){
   e.style.filter='alpha(opacity='+op*10+')';
 }else{
   e.style.opacity = op/10;
 }
 op--;
 temp = duration/10;
 if(op >= 0){
  setTimeout("opacity_OUT('"+id+"',"+op+","+duration+")", temp);
  if(op == 0){
   e.style.display = 'none';
   e.style.visibility = 'hidden'; 
  }
 }
}



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_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_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];}

}
