function SelectPic(num,page){
  ImgStr = "<img border=\"0\" src=\"http://www.leprejoly.com/images/"+page+"_big_0"+num+".jpg\">";
  ImgStrSmall = page+"_big_0"+num+".jpg";
//  document.getElementById("photoBig").innerHTML = ImgStr;
//  alert(ImgStr);
  OpenAjax("POST","http://www.leprejoly.com/opensmallpic.asp","F="+ImgStrSmall,"photoBig","");
//document.getElementById("BigPic").src = "http://www.leprejoly.com/images/"+page+"_big_0"+num+".jpg";
//document.body.focus();
}
function PreloadImages(page){
  if(page=="interni"){ TotImgs=7; }
  if(page=="esterni"){ TotImgs=7; }
  for(i=1;i<TotImgs;i++){
    var Imgs = new Array();
    Imgs[i] = new Image();
    Imgs[i].src = "images/"+page+"_big_0"+i+".jpg";
  }
}
function Rnd(wht){
  return (Math.round((Math.random()*wht)+1));
}
function OpenRandomImage(){
  RndGroup = Rnd(1);
  if(RndGroup==1){ TotImgs=7; SelPage = "interni"; }
  if(RndGroup==2){ TotImgs=7; SelPage = "esterni"; }
  RndImg = Rnd(TotImgs);
  if(RndGroup==1 && RndImg==6){  
    OpenRandomImage()
  } else {
    document.getElementById("BigPic").src = "images/"+SelPage+"_big_0"+RndImg+".jpg";
  }
}
function OpenPic(im){
  ll = (screen.width/2)-(700/2);
  tt = (screen.height/2)-(500/2);
  wo = window.open("openpic.htm?env_00"+im+".jpg","POP","width=700,height=500,left="+ll+",top="+tt);
}
function OpenAjax(strType,strURL,strArguments,strTarg,strExecAfter) {
    var Response = "";
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); }
    else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
    
    if (!self.xmlHttpReq) { alert("ERRORE: AJAX non supportato da questo browser!"); return false; }
    
    self.xmlHttpReq.open(strType, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1;');
    self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4) { 
        if (self.xmlHttpReq.status == 200) {
          Response = self.xmlHttpReq.responseText;
          if(strTarg=="alert"){
            if(Response!=""){ alert(Response); }
          } else if(strTarg!="null" && document.getElementById(strTarg)) {
            document.getElementById(strTarg).innerHTML = Response;
          }
        }
        if(strExecAfter!="" && strExecAfter!=null){ eval(strExecAfter); }
      }
    }
    self.xmlHttpReq.send(strArguments);
    if(document.all){ document.body.focus(); } else { window.focus(); }
}
