﻿// File JScript

function startList() {
	StartMenu("menu_left");
	StartMenu("menu_right");
	if (typeof compactMenu=="function") {
		compactMenu('lista',true,'&plusmn; ');
	}
    if (typeof MostraBanner == "function") {
        setTimeout('MostraBanner()', 5000);
    }
    setBodyHeightToContentHeight();
    document.oncontextmenu = blocca_tasto_dx;
    //effectFadeIn('divchat');
}

function setBodyHeightToContentHeight() {
    document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";
}

function blocca_tasto_dx() {
    //alert('Tasto destro disabilitato');
    return (false);
}

function doPopup(url,nome,w,h) {
    l = (screen.width - w) / 2;
    t = (screen.height - h) / 2;
    popUp=window.open(url, nome, 'width='+w+',height='+h+',left='+l+',top='+t+',toolbar=0,status=0,scrollbars=yes,resizable=0');
}
    
function SetControlValue(controlID1, controlID2, newValue) {
    var pos = newValue.indexOf(')');
    document.forms[0].elements[controlID1].value = newValue.substring(pos+2,newValue.length);
    document.forms[0].elements[controlID2].value = newValue;
    //popUp.close();
}

function scroll_up(name) {
	document.getElementById(name).start();
	document.getElementById(name).direction="up";
}

function scroll_down(name) {
	document.getElementById(name).start();
	document.getElementById(name).direction="down";
}

function scroll_left(name) {
	document.getElementById(name).start();
	document.getElementById(name).direction="left";
}

function scroll_right(name) {
	document.getElementById(name).start();
	document.getElementById(name).direction="right";
}

function scroll_stop(name) {
	document.getElementById(name).stop();
}

function scroll_start(name) {
	document.getElementById(name).start();
}

function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100);
    var timer = 0; 
    
    document.getElementById(divid).style.visibility = "visible";
    
    //set the current image as background 
    //document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
}

function backImage(divid, imagefile) {
    document.getElementById(divid).style.backgroundImage = "url(" + imagefile + ")"; 
}

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function hideFoto() {
	document.getElementById('divfoto').style.visibility = "hidden";
}
		
function StartMenu(nomemenu) {
	if (document.all&&document.getElementById) {
		divobj = document.getElementById(nomemenu);
		if (!(divobj==null)) {
			navRoot = divobj.childNodes[0];
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}

	
	function showToolTip(e,text){
		if(document.all)e = event;
		
		var obj = document.getElementById('bubble_tooltip');
		var obj2 = document.getElementById('bubble_tooltip_content');
		obj2.innerHTML = text;
		obj.style.display = 'block';
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		var leftPos = e.clientX - 100;
		if(leftPos<0)leftPos = 0;
		obj.style.left = leftPos + 'px';
		obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
	}	
	
	function hideToolTip()
	{
		document.getElementById('bubble_tooltip').style.display = 'none';
	}

	// Infinite blink/fade
	function effectFadeIn(classname) {
	    $("#" + classname).fadeTo(200, 1, function () {
	        effectFadeOut(classname);
	    });
	}

	function effectFadeOut(classname) {
	    $("#" + classname).fadeTo(800, 0.5, function () {
	        effectFadeIn(classname)
	    });
	}

window.onload=startList;
