
// min width for applet
var MIN_WIDTH_APPLET = 640;

//
// Restiruisce il browser
//
function browserWeb() {
  if (document.layers) //Netscape 4.x 
    return "NS4"
  else if (document.all)  //explorer
    return "IE";
  else if (document.getElementById) // Netscape 6.x
    return "NS6";

  return NULL;
}

//
// cambia colore testo
//
function changeColor(id, id1, color) {
  if(document.getElementById) {
    document.getElementById(id).style.color = color; 
    document.getElementById(id1).style.color = color; 
  }
}

//
// controlla dimensioni video PC e ridimensiona per apertura popup
//
function ShowReg(url, resX, resY, delta_x, delta_y, width_adv) {
  var altezza = window.screen.height; // altezza schermo
  var larghezza = window.screen.width; //larghezza schermo

  var widthPopup = resX + delta_x + width_adv;
  var heightPopup = resY +  delta_y;
  var setRatio = 1;

  var tipoBrowser = browserWeb();

  //ingombri browser
  var hPadd = 90;
  //var hPadd = 85;
  var wPadd = 50;
  //var wPadd = 36;
  altezza -= hPadd;
  larghezza -= wPadd;

  // controllo se ridimensionare popup
  if (altezza < heightPopup || larghezza < widthPopup) {
    //maxWidth = larghezza*0.85;
    maxWidth = larghezza*0.90;
    //maxHeight = altezza*0.80;
    maxHeight = altezza*0.85;
    widthRatio = (maxWidth - delta_x - width_adv) / resX;
    heightRatio = (maxHeight - delta_y) / resY;
    setRatio = Math.min(widthRatio, heightRatio);
  }
  widthPopup = Math.floor(setRatio * resX) + delta_x + width_adv;
  widthPopup = Math.max(widthPopup, MIN_WIDTH_APPLET);
  heightPopup = Math.floor(setRatio * resY) + delta_y;
  objX = Math.floor(resX * setRatio) +  delta_x;
  objY = Math.floor(resY  * setRatio) +  delta_y;

  if (tipoBrowser == "IE") {
    widthPopup += 25;
    heightPopup += 15;
  } else {
    widthPopup += 10;
    heightPopup += 10;
  }

  url += "&widthPopup="+widthPopup+"&heightPopup="+heightPopup+"&objX="+objX+"&objY="+objY;
  popup(url, 'registrazione', widthPopup, heightPopup);
}
