
// JavaScript Document

// JavaScript Document

var XHR;
var XHR2;
var XHRC;

var S_DEBUG="";


function cerca_FOTO(marchio, gruppo) {

var URL = "/cms/xml/xml-foto.asp?gruppo=" + document.getElementById("GRUPPO_CODICE").innerHTML + "&marchio=" + document.getElementById("BRAND_ATTIVO").innerHTML + "&lingua_attiva=" + document.getElementById("LINGUA_ATTIVA").innerHTML;

// alert(URL);

	XHR=null;
	if (window.XMLHttpRequest) {
    	XHR = new XMLHttpRequest(); XHR.onreadystatechange = ricevi_FOTO; XHR.open("GET", URL, true); XHR.send(null);
    } else if (window.ActiveXObject) {  // IE
        XHR = new ActiveXObject("Microsoft.XMLHTTP");
        if (XHR) { XHR.onreadystatechange = ricevi_FOTO; XHR.open("GET", URL, true); XHR.send(); }
    }
}

function ricevi_FOTO() {   
	if (XHR.readyState == 4) { document.getElementById("BLOCCO_RISPOSTA_FOTO").innerHTML = XHR.responseText; }
}


function cerca_PREZZI(marchio, gruppo) {

var URL = "/cms/xml/xml-prezzi.asp?gruppo=" + document.getElementById("GRUPPO_CODICE").innerHTML + "&marchio=" + document.getElementById("BRAND_ATTIVO").innerHTML  + "&lingua_attiva=" + document.getElementById("LINGUA_ATTIVA").innerHTML;  

// alert(URL);

	XHR=null;
	if (window.XMLHttpRequest) {
    	XHR = new XMLHttpRequest(); XHR.onreadystatechange = ricevi_PREZZI; XHR.open("GET", URL, true); XHR.send(null);
    } else if (window.ActiveXObject) {  // IE
        XHR = new ActiveXObject("Microsoft.XMLHTTP");
        if (XHR) { XHR.onreadystatechange = ricevi_FOTO; XHR.open("GET", URL, true); XHR.send(); }
    }
}

function ricevi_PREZZI() {   
	if (XHR.readyState == 4) { document.getElementById("BLOCCO_RISPOSTA_PREZZI").innerHTML = XHR.responseText; }
}



function cerca_TROVA(CERCA) {

var URL = "/cms/xml/xml-cerca.asp?cerca=" + CERCA + "&lingua_attiva=" + document.getElementById("LINGUA_ATTIVA").innerHTML; 

// alert(URL);


	XHR=null;
	if (window.XMLHttpRequest) {
    	XHR = new XMLHttpRequest(); XHR.onreadystatechange = ricevi_CERCA; XHR.open("GET", URL, true); XHR.send(null);
    } else if (window.ActiveXObject) {  // IE
        XHR = new ActiveXObject("Microsoft.XMLHTTP");
        if (XHR) { XHR.onreadystatechange = ricevi_FOTO; XHR.open("GET", URL, true); XHR.send(); }
    }
}

function ricevi_CERCA() {   
	if (XHR.readyState == 4) { document.getElementById("BLOCCO_RISPOSTA_TROVA").innerHTML = XHR.responseText; }
}


function Z() { for(var i=1; i < e.length; i++) { document.write("<div class='picx'><a href='#' onClick='sp("+i+");'><img src='../../pic/x1/"+collezione+"/"+e[i].b[0]+".jpg'></a></div>"); } }
function AGG_DETTAGLI (indice, testo) { J[indice]=testo; }
function AVANTI (){ if (-y<misuramax) { y=y-incremento; document.getElementById("foto").style.left =y+"px"; } PDEBUG(); }
function INIZIO (){ y=0; document.getElementById("foto").style.left =y+"px"; PDEBUG(); }
function FINE (){ y=-misuramax; document.getElementById("foto").style.left =y+"px"; PDEBUG(); }
function INDIETRO () { if (y<0) { y=y+incremento; document.getElementById("foto").style.left =y+"px"; } PDEBUG(); }
function PDEBUG () { document.getElementById("DESCRIZIONE").innerHTML=y + "px" + " Misuramax" + misuramax + " y " + y; }
function CHIUDIBIGD () { document.getElementById("BIGD").style.display="none"; }


function SHOW_CERCA () { 
	document.getElementById("CERCA").style.visibility="visible";
}

function NASCONDI_CERCA() { 
	document.getElementById("CERCA").style.visibility="hidden";
}

function SHOW_PREZZI () { 
	document.getElementById("PREZZI").style.visibility="visible";
}

function NASCONDI_PREZZI() { 
	document.getElementById("PREZZI").style.visibility="hidden";
}

function RESIZE(){  
	var frame = document.getElementById("BIGD");
	var htmlheight = document.body.parentNode.scrollheight;  
	var windowheight = window.innerheight;  
	if ( htmlheight > windowheight ) { 
		document.body.style.height = windowheight + "px";
		frame.style.height = windowheight + "px"; }
	else { 
		document.body.style.height = htmlheight + "px"; 
		frame.style.height = htmlheight + "px";
	 }  
} 


function MOSTRA_SCHEDA () { document.getElementById("ELENCO_PARTICOLARI").style.visibility="visible"; }

function NASCONDI_SCHEDA () { document.getElementById("ELENCO_PARTICOLARI").style.visibility="hidden"; }

function MOSTRA_PREZZI () { document.getElementById("ELENCO_DETTAGLI").style.visibility="visible"; }

function NASCONDI_PREZZI () { document.getElementById("ELENCO_DETTAGLI").style.visibility="hidden"; }



function SHOW_SCHEDA () { 
document.getElementById("ELENCO_DETTAGLI").style.visibility="visible"; 
document.getElementById("ELENCO_PARTICOLARI").style.visibility="visible"; 
document.getElementById("FOTOX2").style.visibility="visible"; 
}

function SHOW_PARTICOLARI () { 
document.getElementById("ELENCO_DETTAGLI").style.visibility="visible"; 
document.getElementById("ELENCO_PARTICOLARI").style.visibility="visible"; 
document.getElementById("FOTOX2").style.visibility="visible"; 
}

function SHOW_FOTO () { 
document.getElementById("ELENCO_DETTAGLI").style.visibility="visible"; 
document.getElementById("ELENCO_PARTICOLARI").style.visibility="visible"; 
document.getElementById("FOTOX2").style.visibility="visible"; 
}



function FOTOX3 (marchio, codice) {
var CODICE

	var o=document.getElementById("BIGD");
	CODICE="<div><a href=\"javascript:CHIUDIBIGD();\"><img src='/foto/x3/" + marchio + "/" + codice + ".jpg'></div>";
	CODICE+="<div style=\"position:absolute; top:20px; right:50px;\"><a href=\"javascript:CHIUDIBIGD();\"><img src=\"/images/cmd-chiudi.gif\" border=0></a></div>";
	o.innerHTML=CODICE;
	o.style.display="block";
	RESIZE;

}

function FOTOX2 (id) {

if (id==0)
{ return; } /* INTERROMPO PER ARTICOLO NON TROVATO */
else
{ /* alert("falso"); */ }

/*
if(typeof(document.getElementById(id).innerHTML) != 'undefined' && document.getElementById(id).innerHTML != null) 
{ alert("vero"); } 
else
{ alert("falso"); }
*/

var ARR = document.getElementById(id).innerHTML;

	ARR=ARR.split(";");

	document.getElementById("DESCRIZIONE").innerHTML = ARR[1]; 
	document.getElementById("DESCRIZIONE2").innerHTML = " DESIGN " + ARR[5] + " - " + ARR[4]; 

	// alert (escape(ARR[1]));

	document.getElementById("GRUPPO_ATTIVO").innerHTML = ARR[1]; 
	document.getElementById("BRAND_ATTIVO").innerHTML = ARR[0]; 
	document.getElementById("GRUPPO_CODICE").innerHTML = ARR[6]; 

	document.getElementById("BLOCCO_RISPOSTA_FOTO").innerHTML = ""; 
	document.getElementById("BLOCCO_RISPOSTA_PREZZI").innerHTML = ""; 
	document.getElementById("BLOCCO_RISPOSTA_TROVA").innerHTML = "";

	document.getElementById("FOTOX2").innerHTML="<a onclick=\"return hs.expand(this);\" href=\"/foto/x3/" + ARR[0] + "/" + ARR[2] + ".jpg\"><img src=\"/foto/x2/" + ARR[0] + "/" + ARR[2] + ".jpg\"></a>";


/* 	
	<a onclick="return hs.expand(this);" href="/foto/x3/<%=rs1.fields("marchio")%>/<%=rs1.fields("foto")%>.jpg">
	<img style=\"cursor:pointer;\" onclick=\"return FOTOX3('" + ARR[0] + "','" + ARR[2] + "')\" src=\"/foto/x2/" + ARR[0] + "/" + ARR[2] + ".jpg\"></a>";
*/

}







function CONTROLLO(F) {
	if(F.CERCA.value=="") { 
		alert("INSERIRE ARTICOLO");
		return false; 
	}  
	/* alert(F.CERCA.value); */
	document.getElementById("IF").style.display="block";
	return true; 
}


function SDIV(dd) {
	//	alert (dd);
	var d = document.getElementById(dd);
	if (d.style.display !="block" ){ // DOM3 = IE5, NS6
		d.style.visibility="visible";// show/hide
		d.style.display="block"; }
	else {
		d.style.visibility="hidden";
		d.style.display="none";
	}
}

function ZX3(foto) { document.getElementById('X3').innerHTML="<img src='/<%=PATH_FOTO%>/x3/<%=MARCHIO%>/" + foto + ".jpg'>" }

function TABELLA_PREZZI(id) { document.getElementById('TABELLA_PREZZI').innerHTML = document.getElementById(id).innerHTM }


function Scroll(id,ud,spd){
	var obj=document.getElementById(id);
	clearTimeout(obj.to);
	if (ud){
		obj.scrollTop=obj.scrollTop+ud;
		obj.to=setTimeout(function(){ Scroll(id,ud,spd); },spd||10)
	}
}


function hookEvent(element, eventName, callback) {
if(typeof(element) == "string") element = document.getElementById(element);
if(element == null) return;
if(element.addEventListener) { if(eventName == 'mousewheel') element.addEventListener('DOMMouseScroll', callback, false);  
    element.addEventListener(eventName, callback, false); }
else if(element.attachEvent) element.attachEvent("on" + eventName, callback);
}

function cancelEvent(e) { e = e ? e : window.event;
if(e.stopPropagation) e.stopPropagation(); if(e.preventDefault) e.preventDefault();
e.cancelBubble = true; e.cancel = true; e.returnValue = false;
return false;
}

function SHOW_TITOLO(id, dove) {
document.getElementById(dove).innerHTML=document.getElementById(id).alt;
}

function CLEAR_TITOLO(dove) {
document.getElementById(dove).innerHTML="";
}




var startpos=200 //
var stoppos=0 // left stop position
var Last=""
var previous="yourID_One"
var scrolling=0
var L_Timer=""

function Init(layernum){
if(scrolling==1){return} // prevent 2 layers scrolling
if(previous==layernum){return} 
else{
scrollLeft(layernum)
Sim_Return() // simultaneous scrollback
}
}

function scrollLeft(layernum){
scrolling=1 // running
Last=previous // previous layernum
posnow=parseInt(document.getElementById(layernum).style.left) // current left position
if(posnow<stoppos+30){
posnow-=2;}
else{
if(stoppos<posnow){
posnow-=5;}
}
document.getElementById(layernum).style.left=posnow //new left position

L_Timer=setTimeout("scrollLeft('"+layernum+"')",50);

if(posnow<=stoppos){
posnow==stoppos
scrolling=0
clearTimeout(L_Timer);
previous=layernum //
}
}

startpos2=startpos
posnow2=stoppos

function Sim_Return(){
scrolling=1
if(Last==0){
scrolling=0
return}

if(document.getElementById(Last).style.left==startpos){return}
if(posnow2>=startpos2-30){
posnow2+=3}
else{
posnow2+=5;}
document.getElementById(Last).style.left=posnow2 // current right position
R_Timer=setTimeout("Sim_Return('"+Last+"')",50);

if(posnow2>=startpos2){
scrolling=0
clearTimeout(R_Timer);
document.getElementById(Last).style.left=startpos2 // prevent overshoot and ensure return to original position
posnow2=stoppos
}
}



function ADD_WHEEL() {
if(window.addEventListener) {

document.addEventListener('DOMMouseScroll', moveObject2, false); //adding the event listerner for Mozilla
}
document.onmousewheel = moveObject; //for IE/OPERA etc
}

function moveObject(event){
var delta = 0;
if (!event) event = window.event;  
if (event.wheelDelta) // normalize the delta
{ delta = event.wheelDelta / 120; } // IE & Opera
else if (event.detail) {// W3C
	delta = -event.detail / 3;
}
var currPos=document.getElementById('mappe').offsetTop;
currPos=parseInt(currPos)+(delta*10); //calculating the next position of the object
document.getElementById('mappe').style.top=currPos+"px";//moving the position of the object 
}


function moveObject2(event){
var delta = 0;
if (!event) event = window.event;  
if (event.wheelDelta) // normalize the delta
{ delta = event.wheelDelta / 120; } // IE & Opera
else if (event.detail) {// W3C
	delta = -event.detail / 3;
}
var currPos=document.getElementById('mappe').scrollTop;
currPos=parseInt(currPos)+(delta*10); //calculating the next position of the object
document.getElementById('mappe').scrollTop=currPos+"px";//moving the position of the object 
}




function hookEvent(element, eventName, callback) {
if(typeof(element) == "string") element = document.getElementById(element);
if(element == null) return;
if(element.addEventListener) { if(eventName == 'mousewheel') element.addEventListener('DOMMouseScroll', callback, false);  
    element.addEventListener(eventName, callback, false); }
else if(element.attachEvent) element.attachEvent("on" + eventName, callback);
}

/* VELOCITA' SCORRIMENTO */
 
function FX(e) { e = e ? e : window.event; var raw = e.detail ? e.detail : e.wheelDelta;
if (raw < 0) { Scroll('ELENCO_PRODOTTI',121,1);} else { Scroll('ELENCO_PRODOTTI',-121,1);} Scroll('ELENCO_PRODOTTI'); cancelEvent(e);  
}

function FY(e) { e = e ? e : window.event; var raw = e.detail ? e.detail : e.wheelDelta;
if (raw < 0) { Scroll('BLOCCO_MENU_PRODOTTI',20,1);} else { Scroll('BLOCCO_MENU_PRODOTTI',-20,1);} Scroll('BLOCCO_MENU_PRODOTTI'); cancelEvent(e);  
}


