/**
 * YTH SlideShow
 * @Author: Francesco rabottini <dev@webzone.it>
 * @Copyright: 2006 (C) Webzone srl Pescara Italy
 */
var slideShowA = new Array();
var slideShowCounter = 0;
var sliceShowCounterNextTime = 0;
var is_started_slide_show = false;

function starSlideShow()	{

	if (is_started_slide_show)	{
		clearInterval(is_started_slide_show);
		is_started_slide_show = false;
		document.images['playButton'].src = '/images/play.gif';
	} else {
		is_started_slide_show = setInterval('slideShowNext()', 2000);
		document.images['playButton'].src = '/images/stop.gif';
	}
}

function slideShowNext()	{

	sliceShowCounterNextTime++;
	if (sliceShowCounterNextTime > 50)	{
		if (is_started_slide_show)	{
			clearInterval(is_started_slide_show);
			is_started_slide_show = false;
		}
		alert("\n\n!!!Mi sta girando la testa d['_*]b!!!\n\n");
		sliceShowCounterNextTime = 0;
		return;
	}

	if (slideShowA.length == 0)	{
		document.images['slideShowImage'].style.display='none';
		document.getElementById('slideShowTr').style.display='none';
		return;
	}

	if (slideShowA.length == 1 && document.getElementById('slideShowTr'))	{
		document.getElementById('slideShowTr').style.display='none';
	}

	if (++slideShowCounter < slideShowA.length)	{
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	} else {
		slideShowCounter = 0;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	}

	if (document.getElementById('innerCounter'))	{
		document.getElementById('innerCounter').innerText = (slideShowCounter +1 ) + " / " + slideShowA.length;
	}
}

function slideShowPrev()	{
	if (slideShowA.length == 0)	{ document.images['slideShowImage'].style.display='none'; return; }
	if (--slideShowCounter > -1)	{
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	} else {
		slideShowCounter = slideShowA.length - 1;
		document.images['slideShowImage'].src = slideShowA[slideShowCounter].src;
	}
	if (document.getElementById('innerCounter'))	{
		document.getElementById('innerCounter').innerText = (slideShowCounter +1 ) + " / " + slideShowA.length;
	}
}


/**
 * NE Data stile Italia
 * es: giovedì 23 giugno 2005
 */
function it_data()      {
var giorno=new Array(8);
giorno[1]="domenica";
giorno[2]="luned&igrave;";
giorno[3]="marted&igrave;";
giorno[4]="mercoled&igrave;";
giorno[5]="gioved&igrave;";
giorno[6]="venerd&igrave;";
giorno[7]="sabato";
var mese=new Array(13);
mese[1]="gennaio";
mese[2]="febbraio";
mese[3]="marzo";
mese[4]="aprile";
mese[5]="maggio";
mese[6]="giugno";
mese[7]="luglio";
mese[8]="agosto";
mese[9]="settembre";
mese[10]="ottobre";
mese[11]="novembre";
mese[12]="dicembre";
var dateObj=new Date();
var giorno=giorno[dateObj.getDay()+1];
var mese=mese[dateObj.getMonth()+1];
var data=dateObj.getDate();
var anno=dateObj.getYear();
anno = anno < 1900? anno + 1900 : anno;
document.writeln(giorno+" "+data+" "+mese+" " + anno) ;
}

function uk_data()      {
var giorno=new Array(8);
giorno[1]="Sunday";
giorno[2]="Monday";
giorno[3]="Tuesday";
giorno[4]="Wednesday";
giorno[5]="Thursday";
giorno[6]="Friday";
giorno[7]="Saturday";
var mese=new Array(13);
mese[1]="January";
mese[2]="February";
mese[3]="March";
mese[4]="April";
mese[5]="May";
mese[6]="June";
mese[7]="July";
mese[8]="August";
mese[9]="September";
mese[10]="October";
mese[11]="November";
mese[12]="December";
var dateObj=new Date();
var giorno=giorno[dateObj.getDay()+1];
var mese=mese[dateObj.getMonth()+1];
var data=dateObj.getDate();
var anno=dateObj.getYear();
anno = anno < 1900? anno + 1900 : anno;
document.writeln(giorno+" "+mese+" "+data+" "+anno);
}
/** end data **/


// ##########################################
// * Flash Sniffer * Version Date: 12/02/02 *
// ##########################################

var FLASH_MAX = 15; // the latest Flash plug-in version or higher
var FLASH_VERSION = 0;

var agent = navigator.userAgent.toLowerCase();
if(navigator.plugins != null && navigator.plugins.length > 0){
	var plugin = navigator.plugins['Shockwave Flash'];
	if(typeof plugin == 'object'){
		for(i=3; i<= FLASH_MAX; i++){
			if(plugin.description.indexOf(i+'.') != -1){
				FLASH_VERSION = i;
			}
		}
	}
}else if(document.all && agent.indexOf('win') != -1 && agent.indexOf('16bit') == -1){
	document.write('<'+'script language="VBScript"'+'> \n');
		document.write('set FlashObj = Nothing \n');
		document.write('on error resume next \n');
		document.write('For i = '+FLASH_MAX+' to 3 step -1 \n');
			document.write('set FlashObj = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n');
			document.write('If (Not(FlashObj is Nothing)) Then \n');
				document.write('FLASH_VERSION = i \n');
				document.write('Exit For \n');
			document.write('End If \n');
		document.write('Next \n');
	document.write('<'+'\/script'+'> \n');
}else if(agent.indexOf('webtv/2.5') != -1){
	FLASH_VERSION = 3;
}else if(agent.indexOf('webtv') != -1){
	FLASH_VERSION = 2;
}else{
	FLASH_VERSION = -1;
}
function writeFlash(version, name, width, height, bgcolor, quality, menu, wmode, noflash, flashvars){
	flashvars = flashvars!=null ? flashvars : '';
	if(FLASH_VERSION >= version){
		var swf = '';
		swf += '<object';
		swf += ' width="'+width+'"';
		swf += ' height="'+height+'"';
		swf += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		swf += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+',0,0,0">';
		swf += '<param name="movie" value="'+name+'?'+flashvars+'" />';
		swf += '<param name="FlashVars" value="'+flashvars+'" />'
		swf += '<param name="bgcolor" value="'+bgcolor+'" />';
		swf += '<param name="quality" value="'+quality+'" />';
		swf += '<param name="menu" value="'+menu+'" />';
		swf += '<param name="wmode" value="transparent" /> ';
			swf += '<embed src="'+name+'?'+flashvars+'"';
			swf += ' Flashvars="'+flashvars+'"';
			swf += ' width="'+width+'"';
			swf += ' height="'+height+'"';
			swf += ' bgcolor="'+bgcolor+'"';
			swf += ' quality="'+quality+'"';
			swf += ' menu="'+menu+'"';
			swf += ' type="application/x-shockwave-flash"';
			swf += ' wmode="'+wmode+'"'
			swf += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
			swf += '<\/embed>';
		swf += '<\/object>';
		document.write(swf);
	}else{
		document.write(noflash);
	}
}


function go(url)	{document.location.href= url;}

function selectOption(form_name,select_name,myvalue)
{
	var options = document.forms[form_name].elements[select_name].options;
	for(i=0;i< options.length;i++)
		if(options[i].value == myvalue) {
			options[i].selected = true;
			break;
		}
}

function checkRadio(myform, myradio, myvalue)
{
	for (i=0;i<document.forms[myform].elements[myradio].length;i++)
		if (document.forms[myform].elements[myradio][i].value == myvalue) {
			document.forms[myform].elements[myradio][i].checked = true;
			break;
		}
}
/**
 * Apre e centra un popup nella finestra del borwser
 * @param	string	url	indirizzo della pagina da aprire
 * @param	int	_width	larghezza della finestra
 * @param	int	_height	altezza della finestra
 */
function openpopup(url, _width, _height)	{
	_top  = (screen.height - _height ) / 2
	_left = (screen.width  - _width  ) / 2;
	option = "top="+_top+",left="+_left+",width="+_width+",height="+_height+","+
	"status  =no,"+ // barra di stato
	"toolbar =no,"+ // barra dei bottoni del browser
	"menubar =no,"+ // barra menu della finestra
	"location=no";	// barra degli indirizzi

	win = window.open(url,'',option);
	win.focus();
}

function openDivUp(id, _width, _height)	{
	elem = document.getElementById(id);
	if(elem)	{
		elem.style.position = 'absolute';
		elem.style.left = (screen.width  - _width  ) / 2;
		elem.style.top	= (screen.height - _height ) / 2;
		elem.style.zIndex = 5000;
		elem.style.display = 'block';
	}
}

function closeDivUp(id)	{
	elem = document.getElementById(id);
	if(elem) elem.style.display = 'none';
}


function help(id, show)	{
	if (helpItem = document.getElementById( id )) {
		helpItem.style.display = show ? "block" :" none";
	}
}

var menuTime = 0;
function displayMenu(show)	{
	window.clearTimeout(menuTime);
	lay = "menuLevel";
	if(document.layers) {
		document.layers[lay].style.display = show ? "block" : "none";
	} else if(document.getElementById) {
		var obj = document.getElementById(lay);
		obj.style.display = show ? "block" : "none";
	} else if(document.all)	{
		document.all[lay].style.display = show ? "block" : "none";
	}
}


var menuTime2 = 0;
function displayMenu2(show)      {
        window.clearTimeout(menuTime2);
        lay = "menuLevel2";
        if(document.layers) {
                document.layers[lay].style.display = show ? "block" : "none";
        } else if(document.getElementById) {
                var obj = document.getElementById(lay);
                obj.style.display = show ? "block" : "none";
        } else if(document.all) {
                document.all[lay].style.display = show ? "block" : "none";
        }
}


function conf(uri)	{
	if( confirm('Sei sicuro di voler eliminare questo elemento?'))
		go(uri);
}
