// ========== Sito: img01.com ===========
//  IMG.ZEROUNO s.r.l. - Castel Madama - Rm - Italy
//	v. 2.0
//  2004
// ========================================


target = "_self"
nWorks = 1

nSlidespeed = 5; 
nNewsheight = 80;

nBetweendelay = 2000; 
nFont = 'verdana,arial,helvetiva';
nFontsize = 12;
nFadespeed = 100; 

nColor=new Array('#FFFFFF', '#EEEEEE','#CCCCCC','#999999','#666666','#333333','#000000');

function lib_bwcheck(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck();

function makeNewsObj(obj,nest,font,size,color,news,fadespeed,betweendelay,slidespeed,works,newsheight){
	nest=(!nest) ? "":'document.'+nest+'.'
   	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;	
   	this.writeref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj+".document"):0;
	if(font){this.color=new Array(); this.color=eval(color); this.news=new Array(); this.news=eval(news);
		this.font=font; this.size=size; this.speed=fadespeed; this.delay=betweendelay; this.newsheight=newsheight;
		this.fadeIn=b_fadeIn;this.fadeOut=b_fadeOut; this.newsWrite=b_newsWrite; this.y=1
		this.slideIn=b_slideIn; this.moveIt=b_moveIt; this.slideSpeed=slidespeed; this.works=works
		if(bw.dom || bw.ie4){this.css.fontFamily=this.font; this.css.fontSize=this.size; this.css.color=this.color[0]}
	}
	this.obj = obj + "Object"; 	eval(this.obj + "=this"); return this
}

var px = bw.ns4||window.opera?"":"px";

function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+px; this.css.top=this.y+px;}

function b_newsWrite(num,i){
	if (bw.ns4){
		this.writeref.write("<a href=\""+this.news[num]['link']+"\" target=\""+target+"\" style=\"text-decoration:none; font-size:"+this.size+"px\">"
			+"<font face=\""+this.font+"\" color=\""+this.color[i]+"\">"+this.news[num]['text']+"</font></a>")
		this.writeref.close()
	}else this.writeref.innerHTML = '<a id="'+this.obj+'link' +'" target="'+target+'"  style="font-size:'+this.size+'px; color:'+this.color[i]+'" href="'+this.news[num]['link']+'">'+this.news[num]['text']+'</a>'
}

function b_slideIn(num,i){
	if (this.y>0){
		if (i==0){this.moveIt(0,this.newsheight); this.newsWrite(num,this.color.length-1)}
		this.moveIt(this.x,this.y-this.slideSpeed)
		i ++
		setTimeout(this.obj+".slideIn("+num+","+i+");",50)
	}else setTimeout(this.obj+".fadeOut("+num+","+(this.color.length-1)+")",this.delay)
}

function b_fadeIn(num,i){
	if (i<this.color.length){
		if (i==0 || bw.ns4) this.newsWrite(num,i)
		else{
			obj = bw.ie4?eval(this.obj+"link"):document.getElementById(this.obj+"link")
			obj.style.color = this.color[i]
		}
		i ++
		setTimeout(this.obj+".fadeIn("+num+","+i+")",this.speed)
	}else setTimeout(this.obj+".fadeOut("+num+","+(this.color.length-1)+")",this.delay)
}

function b_fadeOut(num,i){
	if (i>=0){
		if (i==0 || bw.ns4) this.newsWrite(num,i)	
		else{
			obj = bw.ie4?eval(this.obj+"link"):document.getElementById(this.obj+"link")
			obj.style.color = this.color[i]
		}
		i --
		setTimeout(this.obj+".fadeOut("+num+","+i+")",this.speed)
	}else{
		num ++
		if(num==this.news.length) num=0
		works = !this.works?0:this.works==1?1:Math.round(Math.random())
		if(works==0) setTimeout(this.obj+".fadeIn("+num+",0)",500)
		else if (works==1){this.y=1; setTimeout(this.obj+".slideIn("+num+",0)",500)
		}
	}
}

function fadeInit(){
	oNews = new makeNewsObj('divNews','divNewsCont',nFont,nFontsize,"nColor","nNews",nFadespeed,nBetweendelay,nSlidespeed,nWorks,nNewsheight)
	oNewsCont = new makeNewsObj('divNewsCont')
	works = !oNews.works?0:oNews.works==1?1:Math.round(Math.random())
	if (works==0) oNews.fadeIn(0,0)
	else if (works==1) oNews.slideIn(0,0)
	oNewsCont.css.visibility = "visible"
}


function WinPop(url,w,h,scroll,resize,center) {
	if (center) {
	var winPos = ',top='+((screen.height - h) / 2)+',left='+((screen.width - w) / 2);
	}
	var scrollArg = (scroll == false) ? '' : ',scrollbars=1';
	var resizeArg = (resize == false) ? '' : ',resizable=1';
	flyout = window.open (url,"newin"+scroll+resize+center,"width=" + w + ",height=" + h + scrollArg + resizeArg + winPos);
	flyout.resizeTo(w,h);
	flyout.focus();
}


//stampa
function printit(){  
	if (window.print) {
		window.print() ;  
	} else {
		var WebBrowser = '<OBJECT id="WebBrowser1" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
	}
}
//--------------- funzione controllo form
// N.B. Utilizzare la sintassi seguente nell' onSubmit del form:
// Per rendere i campi opzionali:
// this.nomecampo.optional = true;
// Per rendere i campi numeric:
// this.nomecampo.numeric = true;
// Per definire il min di un campo numerico:
// this.nomecampo.min = 10;
// Per definire il max di un campo numerico:
// this.nomecampo.min = 100;
// Per definire un campo e.mail ed effettuare il controllo sul formato immesso:
// this.nomecampo.mail = true;
// Per definire un campo URL ed effettuare il controllo sul formato immesso:
// this.nomecampo.url = true;



	// controllo se il campo contiene solo spazi bianchi
	function isblank(str) {
		for(var i=0; i < str.length; i++) {
			var c = str.charAt(i);
			if ( (c != '') && (c != '\n') && (c != '\t'))
				return false
		}
		return true;
	}

	// controllo se il valore del campo e.mail ha un formato corretto
	function ValidateEmail(theinput) {
		var s = theinput;
		if(s.search)
			return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi")) >= 0);
		if(s.indexOf) {
			var at_character = s.indexOf('@');
			if(at_character <= 0 || at_character + 4 > s.length)
				return false;
		}
		if(s.length < 6)
			return false;
		else
			return true;
	}	
	
	// controllo il formato corretto di un URL
	function ValidateUrl(theinput) {
		var url = /([w]{3}).([\w]{3,}).([\w]{2,})/i;
		var result = theinput.match(url);
		if(result != null)
			return true;
		else
			return false;
	}
	
	// Passo il nome del form
	function ValidateForm(form) { //v.01
		var msg = "_____________________________________________\n\n";
		msg += "    Attenzione!  Il form non sarà inviato.\n";
		msg += "_____________________________________________\n";
		msg += "Controllare i seguenti campi:\n\n";
		var err = "";
		for (var i=0; i < form.length; i++) {
			var element = form.elements[i];
			//controllo campi select
			if( ((element.type == "select-one") || (element.type == "select-multiple")) && !element.optional ) {// aggiungere se campo opzionale
				for(var j=0; j < element.options.length; j++) {
					if(element.options[j].selected) {
						if(j)
							continue;
						else
							err += "- " + element.name + "\n";
					}
							
				}
			}
			//controllo campi input e text area
			if( ((element.type == "text") || (element.type == "textarea")) && !element.optional) {
				if( (element.value == null) ||  (element.value == "") || isblank(element.value) ) {
					err += "- " + element.name + "\n"; 
					continue;
				}
			}
			//controllo formato campi e.mail 
			if(element.mail) {
				if(ValidateEmail(element.value))
					continue;
				else {
					err += "- " + element.name + ": Controllare il formato inserito.\n";
					continue;
				}
			}
		}
		if(err) {
			alert(msg + err);
			return false;
		}else
			return true;
	}
//-------------- fine controllo form	


//--------Solution

function RuotaSolution(scrollercontent){

var scroller_width='180px';
var scroller_height='80px';
var pause=5000;

var ie4=document.all
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1

if (ie4||dom){
document.write('<div align="left" style="position:relative;width:'+scroller_width+';height:'+scroller_height+';overflow:hidden; "><div class="tabella"  id="canvas0" style="position:absolute;width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div><div class="tabella" id="canvas1" style="position:absolute;width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div></div>')
} else if(document.layers){
document.write('<ilayer id=tickernsmain visibility=hide width='+scroller_width+' height='+scroller_height+'><layer id=tickernssub width='+scroller_width+' height='+scroller_height+' left=0 top=0>'+scrollercontent[0]+'</layer></ilayer>')
}

var curpos=scroller_height*(1)
var degree=10
var curcanvas="canvas0"
var curindex=0
var nextindex=1

function moveslide(){
if (curpos>0){
curpos=Math.max(curpos-degree,0)
tempobj.style.top=curpos+"px"
}
else{
clearInterval(dropslide)
if (crossobj.filters)
crossobj.filters.alpha.opacity=100
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=1
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML=scrollercontent[curindex]
nextindex=(nextindex<scrollercontent.length-1)? nextindex+1 : 0
setTimeout("rotateslide()",pause)
}
}

function rotateslide(){
if (ie4||dom){
resetit(curcanvas)
crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
if (crossobj.filters)
document.all.canvas0.filters.alpha.opacity=document.all.canvas1.filters.alpha.opacity=5
else if (crossobj.style.MozOpacity)
document.getElementById("canvas0").style.MozOpacity=document.getElementById("canvas1").style.MozOpacity=0.2
var temp='setInterval("moveslide()",50)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
}
else if (document.layers){
crossobj.document.write(scrollercontent[curindex])
crossobj.document.close()
}
curindex=(curindex<scrollercontent.length-1)? curindex+1 : 0
}

function resetit(what){
curpos=parseInt(scroller_height)*(1)
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
crossobj.style.top=curpos+"px"
}

function startit(){
crossobj=ie4? eval("document.all."+curcanvas) : dom? document.getElementById(curcanvas) : document.tickernsmain.document.tickernssub
if (ie4||dom){
crossobj.innerHTML=scrollercontent[curindex]
rotateslide()
}
else{
document.tickernsmain.visibility='show'
curindex++
setInterval("rotateslide()",pause)
}
}

if (ie4||dom||document.layers)
window.onload=startit

//--------Solution

var scroller_width='180px';
var scroller_height='80px';
var pause=5000;


var ie4=document.all
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1

if (ie4||dom){
document.write('<div align="left" style="position:relative;width:'+scroller_width+';height:'+scroller_height+';overflow:hidden; "><div class="tabella"  id="canvas0" style="position:absolute;width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div><div class="tabella" id="canvas1" style="position:absolute;width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div></div>')
} else if(document.layers){
document.write('<ilayer id=tickernsmain visibility=hide width='+scroller_width+' height='+scroller_height+'><layer id=tickernssub width='+scroller_width+' height='+scroller_height+' left=0 top=0>'+scrollercontent[0]+'</layer></ilayer>')
}

var curpos=scroller_height*(1)
var degree=10
var curcanvas="canvas0"
var curindex=0
var nextindex=1

function moveslide(){
if (curpos>0){
curpos=Math.max(curpos-degree,0)
tempobj.style.top=curpos+"px"
}
else{
clearInterval(dropslide)
if (crossobj.filters)
crossobj.filters.alpha.opacity=100
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=1
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML=scrollercontent[curindex]
nextindex=(nextindex<scrollercontent.length-1)? nextindex+1 : 0
setTimeout("rotateslide()",pause)
}
}

function rotateslide(){
if (ie4||dom){
resetit(curcanvas)
crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
if (crossobj.filters)
document.all.canvas0.filters.alpha.opacity=document.all.canvas1.filters.alpha.opacity=5
else if (crossobj.style.MozOpacity)
document.getElementById("canvas0").style.MozOpacity=document.getElementById("canvas1").style.MozOpacity=0.2
var temp='setInterval("moveslide()",50)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
}
else if (document.layers){
crossobj.document.write(scrollercontent[curindex])
crossobj.document.close()
}
curindex=(curindex<scrollercontent.length-1)? curindex+1 : 0
}

function resetit(what){
curpos=parseInt(scroller_height)*(1)
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
crossobj.style.top=curpos+"px"
}

function startit(){
crossobj=ie4? eval("document.all."+curcanvas) : dom? document.getElementById(curcanvas) : document.tickernsmain.document.tickernssub
if (ie4||dom){
crossobj.innerHTML=scrollercontent[curindex]
rotateslide()
}
else{
document.tickernsmain.visibility='show'
curindex++
setInterval("rotateslide()",pause)
}
}

if (ie4||dom||document.layers)
window.onload=startit

}

//------fine solution


// funzione per popup-intro
function RedirectPage(page) {
	opener.location = page;
	self.close();
}


//Prodotti/Offerte
// cat: 0 - prodotti :: 1 - offerte
function ImgPrdOff(obj,cat) {
	var obj = Number(obj.options[obj.selectedIndex].value);
	if(obj) {
		var path = "http://www.img01.com/"; 
		path += (!Number(cat))?'prodotti/scheda.asp?id=' + obj:'offerte/scheda.asp?id=' + obj;
		window.location = path;
	}else return;
}


// funzione inserimento swf (effettua il test del plug-in)
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
var testplugin;

function embedflash(flash_name,flash_x,flash_y,img_name) {
	if ( plugin ) {
		testplugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4;
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('testplugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
		document.write('</SCRIPT\> \n');
	}
	var mainput = "";
	if ( !testplugin ) {
		mainput=mainput+('<img src="'+img_name+'" width="'+flash_x+'" height="'+flash_y+'" border="0" name="base">\n');
	} else {
		mainput=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+flash_x+'" height="'+flash_y+'"><param name=movie value="'+flash_name+'"><param name=quality value=high><embed src="'+flash_name+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+flash_x+'" height="'+flash_y+'"></embed></object>'); 
	}
	return(mainput);
}


// show-hide div
// ex: SHDiv('idDiv',true);
function CheckBrowser() {
	var browser="None";
	if( navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) {
		browser = "NS4";
		version = 4;
	}
	if( document.getElementById ) {
		browser = "NS6";
		if( navigator.userAgent.indexOf("6.01") != -1 || navigator.userAgent.indexOf("6.0") != -1 ) {
			version = 6;
		}else {
			version = 6.1;
		}
	}
	if( document.all ) {
		if( document.getElementById ) {
			version = 5;
		}else {
			version = 4;
		}
		browser = "IE";
	}
	return browser;
}
var browser = CheckBrowser();

function SHDiv(element,show){
	if(browser == "NS4") {
		if(document.layers[element]!= undefined) {
			if(show)
				document.layers[element].visibility="show";
			else
				document.layers[element].visibility="hide";
		}
	}
	if(browser == "IE") {
		if(document.all[element]!= null) {
			if(show)
				document.all[element].style.visibility="visible";
			else
				document.all[element].style.visibility="hidden";
		}
	}
	
	if(browser == "NS6") {
		if(document.getElementById(element)!= null) {
			if(show)
				document.getElementById(element).style.visibility="visible";
			else
				document.getElementById(element).style.visibility="hidden";
		}
	}
}