
 
function setBgImg(imgref,cropval) {
srcimg=imgref+"&width=628";
ttop="0";
if (cropval>0) { ttop="-"+cropval;}
cstyle="url("+srcimg+") 0px "+ttop+"px no-repeat"
document.getElementById("page_int").style.background=cstyle;
}

function setVideoYouTube(ref) {

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="view_youtube_video.asp?ref="+ref;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function stateChanged1()
{
if (xmlHttp.readyState==4)
{
var respvid=xmlHttp.responseText;
document.getElementById("viewYouTube").innerHTML=respvid;
}
}

function change_image(ref,mode) {

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var viewnumber=document.getElementById("gallery_count").value;
actimg=document.getElementById("chng_img").src;
fromletter=actimg.indexOf('=')+1;
toletter=actimg.indexOf('&');
actimg=actimg.substring(fromletter,toletter)
url="get_image.asp?load="+ref+"&actimg="+actimg+"&mode="+mode+"&ccount="+viewnumber;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function stateChanged()
{
if (xmlHttp.readyState==4)
{
var respimg=xmlHttp.responseText;
toletter1=respimg.indexOf('#');
toletter2=respimg.indexOf('-');
toletter3=respimg.indexOf('x');
toletter4=respimg.indexOf('*');
fileresp=respimg.substring(0,toletter1);
widthresp=respimg.substring(toletter1+1,toletter2);
ccount=respimg.substring(toletter2+1,toletter3);
heightresp=respimg.substring(toletter3+1,toletter4);

if (fileresp.length>0) {
var setimg="immagine_res.asp?path="+fileresp+"&width="+widthresp;

$('chng_img').hide();
document.getElementById("chng_img").style.width=widthresp+"px";
document.getElementById("chng_img").style.height=heightresp+"px";
document.getElementById("gallery_container").style.width=widthresp+"px";
document.getElementById("gallery_container").style.height=heightresp+"px";
Effect.BlindDown ('gallery_container', {duration: 0.5});

document.getElementById("chng_img").src="./images/vuoto.gif";
setTimeout("app_img('"+setimg+"');",500);
dimnsions=getPageSize();
toletter=dimnsions.indexOf('#');
xScroll=dimnsions.substring(toletter+1);
document.getElementById("gallery_count").value=ccount;
}
}
}

function app_img(setimg) {
document.getElementById("chng_img").src=setimg;

Effect.Appear('chng_img', {duration: 0.8});

}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function view_gallery() {
Effect.Appear('gallery_set', {duration: 0.5});

dimnsions=getPageSize();
toletter=dimnsions.indexOf('#');
yScroll=dimnsions.substring(0,toletter);
xScroll=dimnsions.substring(toletter+1);
document.getElementById("gallery_bgset").style.display='inline';
document.getElementById("gallery_bgset").style.width=xScroll+'px';
document.getElementById("gallery_bgset").style.height=yScroll+'px';
}

function close_gallery() {
Effect.Fade('gallery_set', {duration: 0.5});
Effect.Fade('gallery_bgset', {duration: 0.5});
}

function adapt_bggallery() {
dimnsions=getPageSize();
toletter=dimnsions.indexOf('#');
yScroll=dimnsions.substring(0,toletter);
xScroll=dimnsions.substring(toletter+1);
document.getElementById("gallery_bgset").style.width=xScroll+'px';
document.getElementById("gallery_bgset").style.height=yScroll+'px';
}
 
function getPageSize(){
    var xScroll, yScroll;

if (document.documentElement.scrollHeight) {
yScroll=document.documentElement.scrollHeight;
xScroll=document.documentElement.scrollWidth;
if (document.documentElement.clientHeight>document.documentElement.scrollHeight) {
yScroll=document.documentElement.clientHeight;
xScroll=document.documentElement.clientWidth;
}
}
    else if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
        xScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
        yScroll = document.body.scrollHeight;
        xScroll = document.body.scrollWidth;
    } else {
        yScroll = document.body.offsetHeight;
        xScroll = document.body.offsetWidth;
    }

    return yScroll+"#"+xScroll;
}
