function openWebsite() {
//$('viewNews').hide();
$('cover_home').hide();
changeBg();
setTimeout("Effect.SlideDown('contenuto');",250);
}

function changeBg() {
document.getElementById("bgmain").style.background="url(./images/bginner.png) top left repeat-y";
}

function viewSection(ref,catalog) {
var isopen=document.getElementById("section"+ref).style.display;
//alert(isopen);
if (isopen=='none') {
if (catalog=='True') { showBasket(); } else { hideBasket(); }
	for (x=1;x<=4;x++) {
//$('section'+x).hide();
}
//$('viewCatalog').hide();
Effect.Appear('section'+ref, { from: 0.7, to: 1.0, duration: 0.2 });
ttop=document.getElementById("abc").value;
ttop=parseInt(ttop)-60;
if (ttop>100) setTimeout("window.scroll(0,"+ttop+");",150);
} else {
$('section'+ref).hide();
}
}


function getProduct(ref) {
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="get_product.asp?load="+ref;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChangedBasket;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}



function blankOrder() {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="del_basket.asp"
url=url+"?sid="+Math.random();
xmlHttp.onreadystatechange=stateBlankBasket;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateBlankBasket()
{
if (xmlHttp.readyState==4)
{
document.getElementById('viewBasket').innerHTML="";
document.getElementById('viewBasket').style.display='none';
}
}

function hideBasket() {
document.getElementById('viewBasket').style.display='none';
}

function showBasket() {
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="load_basket.asp";
url=url+"?sid="+Math.random();
xmlHttp.onreadystatechange=stateChangedBasket;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function delProduct(ref) {

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="del_product.asp?load="+ref;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChangedBasket;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function upd_quantity(ref,quant) {
if (quant>0) {
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="upd_product.asp?load="+ref+"&quant="+quant;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChangedBasket;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}}



function stateChangedBasket()
{
if (xmlHttp.readyState==4)
{
var Txt=xmlHttp.responseText;
if (Txt.length>1) {
document.getElementById('viewBasket').innerHTML=Txt;
document.getElementById('viewBasket').style.display='inline';
var hc=getPageHeight();
var hbasket=document.getElementById('viewBasket').offsetHeight;
var ftop=(parseInt(hc)-parseInt(hbasket))/2;
ftop1=document.body.scrollTop ;
//alert(ftop1);
ftop=ftop+ftop1;
document.getElementById('viewBasket').style.top=ftop+'px';
document.getElementById('viewBasket').style.border="solid 3px #FFFFFF"; 
} else {
document.getElementById('viewBasket').style.display="none"; 

}
}
}

function loadCatalog(ref) {
document.getElementById('viewCatalog').style.display='inline';
document.getElementById('viewCatalog').innerHTML="<center><img src='images/loading.gif' align='center'/></center>";

var arrLinks=document.getElementsByName("menuCatalog");

for (var i = 0; i < arrLinks.length; i++) {
    founddiv = arrLinks[i].getAttribute("id");
    if ( founddiv == "linkCatalog"+ref) {
    document.getElementById(founddiv).style.color= "#fc7b48";
    } else {
    document.getElementById(founddiv).style.color= "#d51e00";
 }
}


xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="get_catalog.asp?load="+ref;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChangedCatalog;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function stateChangedCatalog()
{
if (xmlHttp.readyState==4)
{
var Txt=xmlHttp.responseText;
document.getElementById('viewCatalog').innerHTML=Txt;
document.getElementById('viewCatalog').style.display='inline';
}
}

function sendOrder() {
document.getElementById('viewBasket').style.display='none';

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
url="send_ordine.asp";
url=url+"?sid="+Math.random();

xmlHttp.onreadystatechange=stateChangedCatalog;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);


}

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 getPageHeight(){
    var xScroll, yScroll;

if (document.documentElement.scrollHeight) {
yScroll=document.documentElement.scrollHeight;
if (document.documentElement.clientHeight>document.documentElement.scrollHeight) {
yScroll=document.documentElement.clientHeight;
}
}
    else if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
        yScroll = document.body.scrollHeight;
    } else {
        yScroll = document.body.offsetHeight;
    }

    return yScroll;
}

function divResize(div) {
img1="iimg"+div;
img2="pimg"+div;
img3="ppimg"+div;
img4="contimg"+div;
div="vimg"+div;
wn=70;
wn1=120;
hn=70;
tinterval=20;
while(wn<231) {
setTimeout("setWidth('"+div+"',"+wn+");",tinterval)
wn++;
tinterval=tinterval+2;
}

tinterval=20;
var img2a=document.getElementById(img1).src;
img2a=img2a.replace("&width=110","&width=240");
document.getElementById(img1).src=img2a;

while(wn1<241) {
setTimeout("setWidth('"+img1+"',"+wn1+");",tinterval)
wn1++;
tinterval=tinterval+2;
}


tinterval=20;
while(hn<163) {
setTimeout("setHeight('"+div+"',"+hn+");",tinterval)
hn++;
tinterval=tinterval+3;
}
document.getElementById(img2).style.display='none';
document.getElementById(img3).style.display='inline';

document.getElementById(img4).style.left='-5px';
document.getElementById(img4).style.top='-2px';

}

function divResize1(div) {
img1="iimg"+div;
img2="pimg"+div;
img3="ppimg"+div;
img4="contimg"+div;

div="vimg"+div;
setWidth(div,70);
setHeight(div,70);
setWidth(img1,110);
document.getElementById(img2).style.display='inline';
document.getElementById(img3).style.display='none';
document.getElementById(img4).style.left='-7px';
document.getElementById(img4).style.top='-5px';

}

function setWidth(div,val) {
document.getElementById(div).style.width=val+'px';
}

function setHeight(div,val) {
document.getElementById(div).style.height=val+'px';
}