var dir = 1;
maxTop = 820;
minTop = 360;

window.onresize = buildDivUADOnResize;

function buildDivUAD(){

	document.write('<div id ="UADdiv" style="display: none; width: 30px; height: 30px; position: absolute; top: 360px; left: 30px;">');
	document.write('<img src="../img/iconaNew.gif" width="30" height="30">');
	document.write('</div>');

	document.getElementById('UADdiv').style.left = calcolaLeft() + 'px';
	document.getElementById('UADdiv').style.display = '';

}

function buildDivUADOnResize(){

	document.getElementById('UADdiv').style.left = calcolaLeft() + 'px';
	document.getElementById('UADdiv').style.display = '';

}

    function calcolaLeft(){

            /*if(navigator.appName.indexOf("Netscape")!=-1){
                    if(window.innerWidth < 980)
                            return 0;
                    else
                            return ((window.innerWidth - 980)/2) - 7;
            }
            else{
                    if(window.innerWidth < 980)
                            return 10;
                    else
                            return ((document.body.offsetWidth - 980)/2) - 2;

            }*/

            return 40;

    }

function runUAD(){

	actualTop = document.getElementById('UADdiv').style.top.substr(0,document.getElementById('UADdiv').style.top.indexOf('p'));
	if(dir == 1)
		newTop = parseInt(actualTop) + 5;
	else if (dir == 2)
		newTop = parseInt(actualTop) - 5;

	if(dir == 1 && (newTop >= maxTop)){
		dir = 2;
	}else if(dir == 2 && (newTop <= minTop)){
		dir = 1;
	}

	document.getElementById('UADdiv').style.top = newTop + 'px';
	setTimeout('runUAD()', 70);

}

