// // funzione per prendere la posizione del mouse
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

var IE7 = (navigator.appVersion.indexOf('7.')>0);


// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = viebi_getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s


function viebi_getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
      
        tempX = event.clientX + document.documentElement.scrollLeft
        tempY = event.clientY + document.documentElement.scrollTop
      
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  return true
}

function viebi_apri(categoria, codice, id, colonna) {   
    var iframe = document.getElementById("popup_iframe");
    iframe.src="dettaglioprodotto.jsp?categoria=" + categoria+ "&codice=" + codice;
    viebi_posiziona(id, colonna);
 }


function viebi_posiziona(id, colonna) {
    var pannello = document.getElementById("popup_dentro");   
    var immagine_element = window.parent.document.getElementById(id);
    var immagine = viebi_getLeft(immagine_element);
    var immagine_top = viebi_getTop(immagine_element);
    
    // se si trova nella prima colonna lo allinea a sinistra
    if (colonna == 1) {
        pannello.style.left = (immagine - 228) + 'px';
    }
    
    // se si trova nella prima colonna lo allinea al centro
    if (colonna == 2) {
        pannello.style.left = (immagine - 374) + 'px';
    }
    
    // se si trova nella prima colonna lo allinea a destra
    if (colonna == 3) {
        pannello.style.left = (immagine - 522) + 'px';
    }
    
    pannello.style.top = (immagine_top) + 'px';
    
    //pannello.style.top = (tempY) + 'px';
    //pannello.style.left = (tempX - 150) + 'px';
   
}

function viebi_mostra() {
    var pannello = window.parent.document.getElementById("popup_dentro")
    pannello.style.display = "block";
    
}

function viebi_nascondi() {
    var pannello = window.parent.document.getElementById("popup_dentro");
    pannello.style.display = "none";
}

function viebi_getLeft(elm)
{
    //set x to elm’s offsetLeft
    x = elm.offsetLeft;
    
    //set elm to its offsetParent
    elm = elm.offsetParent;

    
    while(elm != null)
     {

        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
     }
    return x;
}

function viebi_getTop(elm)
{
    //set x to elm’s offsetLeft
    x = elm.offsetTop;
    
    //set elm to its offsetParent
    elm = elm.offsetParent;

    
    while(elm != null)
     {

        x = parseInt(x) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
     }
    return x;
}

//alert (navigator.appVersion);	
// funzione che mi permette di scegliere il foglio di stile a seconda del browser utilizzato per la navigazione
// in particolare lo cambia nel caso in cui si utilizzi ie6
if ((navigator.appVersion.indexOf('MSIE 6.0')>0))   {
    document.write("<link rel='stylesheet' href='css/menu.css' type='text/css'>");
}  else {
    document.write("<link rel='stylesheet' href='css/menu_ie6.css' type='text/css'>");
}

var prodottoAggiuntoPreventivo = "Il prodotto e' stato aggiunto al tuo preventivo. Per poter visualizzare tutti i prodotti inseriti clicca sul box in basso a sinistra.";
var prodottoAggiuntoOrdine = "Il prodotto e' stato aggiunto al tuo ordine. Per poter visualizzare tutti i prodotti inseriti clicca sul box in basso a sinistra.";

var english = 0;
if('<%=lang%>'=='lang2') english = 1;

if(english==1){
    prodottoAggiuntoPreventivo = "The product has been added to your preventive. If you want to see all the inserted products click on the box in the bottom on the left.";
    prodottoAggiuntoOrdine = "The product has been added to your order. If you want to see all the inserted products click on the box in the bottom on the left.";
}

function Popup(apri) {
  window.open(apri,'','width=1022,height=600,toolbar=yes,menubar=yes,scrollbars=1')
}
