// JavaScript Document
var value = 205;
var TopValue;
var LeftValue;
var MyTopOffset;
var MyLeftOffset;
var intervalId;
var intervalId1; 
var divX;
var divY;
var op = 0;
var divSel;
function posizionaDiv(){
	MyArray = Array('img_4_hide_over', 'img_5_hide_over', 'img_6_hide_over');
	MyArray1 = Array('ThisId', 'ThisId01', 'ThisId03');
	for(i=0; i<MyArray.length; i++){
		myDiv = document.getElementById(MyArray[i]);
		MyLeftValue = document.getElementById('content').offsetLeft+document.getElementById(MyArray1[i]).offsetLeft;
		MyTopValue = document.getElementById('content').offsetTop+document.getElementById(MyArray1[i]).offsetTop;
		if(!isIE()){
			myDiv.style.marginTop = MyTopValue+"px";
			myDiv.style.marginLeft = MyLeftValue+"px";
		} else {
			myDiv.style.top = MyTopValue+"px";
			myDiv.style.left = MyLeftValue+"px";
		}
	}
}
function estractPos(id, v){
	switch(v){
		case 1:
			return document.getElementById('content').offsetLeft+document.getElementById(id).offsetLeft;
		break;
		case 2:
			return document.getElementById('content').offsetTop+document.getElementById(id).offsetTop;
		break;
	}
}
function executeAnimation(caso, id){
	
	switch(id){
		case 'ThisId':
			div = 'img_4_hide_over';
			divSel = div;
		break;
		case 'ThisId01':
			div = 'img_5_hide_over';
			divSel = div;
		break;
		case 'ThisId03':
			div = 'img_6_hide_over';
			divSel = div;
		break;
		case 'sel':
			div = divSel;
			id = div;
		break;
	}
	divId = document.getElementById(div);
	if(id!= 'sel'){
		cont = document.getElementById(id).innerHTML;
		divId.innerHTML = cont;
	}
	MyTopOffset = estractPos(id, 2);
	MyLeftOffset = estractPos(id, 1);
	switch(caso){
		case 1:
			if(value < 205){
				value = 205;
			}
			if(divId.style.top == 0){
				if(!isIE){
					divId.top = estractPos(id, 2)+"px";
					divId.left = estractPos(id, 1)+"px";
				}
			}
			clearInterval(intervalId1);
			clearInterval(intervalId);
			document.getElementById('grayHide').className = "grayShow";
			if(!isIE()){
				divId.className = "showAbs";
			} else {
				divId.className = "showAbsIE";
			}
			intervalId = setInterval('expande(\''+div+'\')', 10);
		break;
		case 2:
			clearInterval(intervalId);
			clearInterval(intervalId1);
			intervalId1 = setInterval('contract(\''+div+'\')', 10);
		break;
	}
	if(TopValue == undefined){
		TopValue = MyTopOffset;
		LeftValue = MyLeftOffset;
	}
}
function expande(id){
	divId = document.getElementById(id);
	value = value+4;
	TopValue = TopValue-2;
	LeftValue = LeftValue-2;
	if(value > 253){
		clearInterval(intervalId);
	} else {
		divId.style.width = value+"px";
		if(!isIE()){
			divId.style.marginTop = TopValue+"px";
			divId.style.marginLeft = LeftValue+"px";
		} else {
			divId.style.top = TopValue+"px";
			divId.style.left = LeftValue+"px";
		}
		divId.style.height = value+"px";
	}
}
function contract(id){
	divId = document.getElementById(id);
	value = value-4;
	TopValue = TopValue+2;
	LeftValue = LeftValue+2;
	if(value < 205){
	   clearInterval(intervalId1);
		if(!isIE()){
			divId.className = "hideAbs";
			TopValue = undefined;
			LeftValue = undefined;
		} else {
			divId.className = "hideAbsIE";
		}
		op = 0;
		TopValue = undefined;
		LeftValue = undefined;
		document.getElementById('grayHide').className = "grayHide";
	} else {
		divId.style.width = value+"px";
		if(!isIE()){
			divId.style.marginTop = TopValue+"px";
			divId.style.marginLeft = LeftValue+"px";
		} else {
			divId.style.top = TopValue+"px";
			divId.style.left = LeftValue+"px";
		}
		divId.style.height = value+"px";	
	}
}
function valOffset(id){
	divId = document.getElementById(id);
		MyLeftOffset = divId.offsetLeft;
		MyTopOffset = divId.offsetTop;
}
function isIE(){
	if(navigator.userAgent.indexOf("MSIE") == -1){
		return false;
	} else {
		return true;
	}
}
//*******FUNZIONE DEDICATA AL MENU' DELLA LINGUA**********//
var ValueHLang = 2;
var Misura = 150;
function mostraNascondiLingua(div)
{
    MyDiv = document.getElementById(div);
    if (MyDiv.style.display == "none" || MyDiv.style.display == '')
    {
        //20090614 added IE8 Fix
        if (!isIE() || (isIE && navigator.userAgent.indexOf("MSIE 8") != -1
) )
        {
            MyDiv.style.left =
document.getElementById('menu_top').offsetLeft + 398 + 'px';
        } 
        else
        {
            MyDiv.style.left = document.getElementById('header').offsetLeft
+ document.getElementById('menu_top').offsetLeft + 398 + 'px';
        }
        MyDiv.style.display = "block";
        setTimeout('expandDiv("' + div + '")', 5);
    } else
    {
        setTimeout('contractDiv("' + div + '")', 5);
        //MyDiv.style.display = "none";
    }
}
function expandDiv(div){
	HDiv = document.getElementById(div);
	if(ValueHLang < Misura){
		//document.getElementById('test').innerHTML = ValueHLang;
		HDiv.style.height = ValueHLang+'px';
		ValueHLang = ValueHLang+2;
		setTimeout('expandDiv("'+div+'")', 5);
	}
}
function contractDiv(div){
		HDiv = document.getElementById(div);
	if(ValueHLang > 0){
		//document.getElementById('test').innerHTML = ValueHLang;
		HDiv.style.height = ValueHLang+'px';
		ValueHLang = ValueHLang-2;
		setTimeout('contractDiv("'+div+'")', 5);
	} else {
		HDiv.style.display = "none";
	}
}
