
//-- Author: Echinus (www.echinus.it) Marco R.
function getLayer(layerID){
return document.getElementById?document.getElementById(layerID):document.all?document.all[layerID]:document.layers[layerID];
}
if (document.body.clientHeight>590 && document.body.clientWidth>970) document.body.style.overflow = "hidden";
//----------------
var pause = 5000;
var ImgP = new Array(11);
var x_img = 0;
var b_img = false;
var T_img;
var F_img;
var Img0;
var Img1;
var TopImg;

function setOpacity(obj, value){
obj.opacity = 0.01*value;
obj.filter = 'alpha(opacity='+value+')';
}

function imgFade(){
F_img += 2;
if (F_img>99){
F_img = 100;
clearInterval(T_img);
}
setOpacity(TopImg, F_img);
}

function rotateimage(){
b_img = !b_img;
x_img++;
F_img = 0;

var Img = b_img?Img1:Img0;
setOpacity(Img.style, F_img);
Img.style.zIndex = 2;
TopImg.zIndex = 0;
TopImg = Img.style;
Img.src = ImgP[x_img%ImgP.length].src;

T_img = setInterval("imgFade()", 20);
}

function init(){
getLayer("q2").innerHTML = getLayer("q2").innerHTML+'<br><img src="Immagini/p.jpg" width="1" height="1" alt="Immagini della zona" name="Img1">';
Img1 = document.images["Img1"]; setOpacity(Img1.style, 0);
Img0 = document.images["Img0"];
Img1.width = 360;
Img1.height = 324;
Img1.src = Img0.src;

Img0 = Img0.style;
Img0.position = "absolute";Img0.left=(document.body.clientWidth-360)/2;Img0.top=0;Img0.zIndex=2;
Img1 = Img1.style;
Img1.position = "absolute";Img1.left=(document.body.clientWidth-360)/2;Img1.top=0;Img1.zIndex=0;

Img0 = getLayer("qq1").style;
Img0.position = "absolute";Img0.left=(document.body.clientWidth-560)/2;Img0.top=0;Img0.zIndex=0;

Img0 = document.images["Img0"];
Img1 = document.images["Img1"];
TopImg = Img0.style;

for (x_img=0; x_img<ImgP.length; x_img++){
ImgP[x_img]=new Image();
ImgP[x_img].src="Immagini/"+x_img+".jpg";
}
x_img = 0;

setTimeout("setInterval(\"rotateimage()\", pause)",pause+1000);
}
//----------------
function open1(src,width,height){
win = window.open("", "popup_img", "width="+width+",height="+height+",resizable=no,scrollbars=yes,toolbar=no,top="+((screen.height - height)/2)+", left="+((screen.width-width)/2));
win.document.write("<html>");
win.document.write("<body>");
win.document.write("<img src=\""+src+"\">");
win.document.write("</body>");
win.document.write("</html>");
win.document.close();
win.focus();
}
function g_spt(diff){
var a1 = new String(document.images["p0"].src);
var a2 = a1.lastIndexOf('/')+1;
if (a2==-1) return;
var a3 = parseInt(a1.substr(a2, a1.length-a2-4));
a3 += g_NImg+diff;
a3 %= g_NImg;
a1 = a1.substr(0, a2);

for(a2=0;a2<5;a2++){
document.images["p"+a2].src = a1+((a3+a2)%g_NImg)+".jpg";
}
}
function g_set(obj){
var a1 = new String(document.images[obj].src);
var a2 = a1.substr(0, a1.length-4)+"d.jpg";
document.images["d0"].src = a2;
}
function g_show(){
var a1 = new String(document.images["d0"].src);
var a2 = a1.substr(0, a1.length-5)+"dd.jpg";
open1(a2, 680, 520);
}
function init2(){
if (document.images["p0"]){
g_spt(+1);
g_set('p0');
}
}
//----------------
var add_cost = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

function ch_com(){
var obj = document.forms["Form1"].elements["a"];
var bo;
if (obj.options[obj.selectedIndex].value==0) bo = true;
else bo = false;

var obj2 = obj.form.elements["b"];
while (obj2.options.length) obj2.remove(0);

var n_opt = document.createElement("option");
if (bo) n_opt.text = "qualsiasi";
else n_opt.text = "scegli ...";
n_opt.value = "0";
obj2.add(n_opt, add_cost);

if (bo) return;

var this_db = db_com[obj.options[obj.selectedIndex].value];
var i;
for (i=0;i<this_db.length;i++) {
n_opt = document.createElement("option");
n_opt.text = this_db[i].text;
n_opt.value = this_db[i].value;
obj2.add(n_opt, add_cost);
}
}
function init3(){
var where_cod = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

var obj = document.forms["Form1"].elements["a"];

for (var k in db_pro){
  if (db_pro[k][0].text!=undefined) {
    var n_opt = document.createElement("option");
    n_opt.text = db_pro[k][0].text;
    n_opt.value = db_pro[k][0].value;
    obj.add(n_opt, add_cost);
  }
}

ch_com();
}
//----------------
