/*
var bn = navigator.appName;
var ie = (bn=="Microsoft Internet Explorer");
var nn = (bn=="Netscape");
var d = document;
*/



function rollTile(id,status,type)
{
  if(type=='sx')
  {
   type = "_sx";
  }
  else
  {
    type = "";
  }
  if(status=="on")
	{
    eval("imgTemp = document."+id+".src");
    eval("document."+id+".src='comuni/img/arrow"+type+".gif';");
    //eval("document."+id+".src='comuni/img/arrow_sx.gif';");
	}
	else
	{
    eval("document."+id+".src=imgTemp;");
	}
}

var arrTemp=self.location.href.split("?"); 
var picUrl = (arrTemp.length>0)?arrTemp[1]:""; 
var NS = (navigator.appName=="Netscape")?true:false; 

function FitPic() { 
 iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
 iHeight = (NS)?window.innerHeight:document.body.clientHeight; 
 iWidth = document.images['imgRef'].width - iWidth + 20; 
 iHeight = document.images['imgRef'].height - iHeight + 130; 
 window.resizeBy(iWidth, iHeight); 
 self.focus();
};

function calc_left (w)
{
 var left = (screen.availWidth / 2) - (w / 2);
 return (left);
}
   
function calc_top (h)
{
 var top = (screen.availHeight / 2) - (h / 2);
 return (top);
}


function openSearch(url)
{
  what   = document.getElementById('whatFind').value;
  //alert(document.getElementById('categ').value)
  if(document.getElementById('categ'))
  {
    categ  = "&categ="+document.getElementById('categ').value;
  }
  else
  {
    categ  = '';
  }
    url += '&what='+what;
    open_page(url+'&kw='+what+categ, '480', '400', 'no','no','no','no','no','no','find');
}


function open_page(url, w, h, scrollbar,location,toolbar,status,menubar,resizable,id,target)
{
  if(!target){target = '';}
  if(!scrollbar){scrollbar = 'no'}
  if(!toolbar){toolbar = 'no'}
  if(!status){status = 'no'}
  if(!menubar){menubar = 'no'}
  if(!location){location = 'no'}
  if(!id){id = ''}

  var top = calc_top (h);
  var left = calc_left (w);
  //alert(target);
  if(target =='opener')
  {
    opener.window.location.href = url;
  }
	else if(w && h)
	{
	//alert('width='+w+',height='+h+',left=0,top=0,screenX=0,screenY=0,status='+status+', menubar='+menubar+', toolbar='+toolbar+',location='+location+', scrollbars='+scrollbar+',resizable='+resizable)
  popup = window.open (url,id,'width='+w+',height='+h+',left=0,top=0,screenX=0,screenY=0,status='+status+', menubar='+menubar+', toolbar='+toolbar+',location='+location+', scrollbars='+scrollbar+',resizable='+resizable);
  popup.focus();
	}
	else
	{
	  document.location.href = url;
	  //alert(url)
	}	
  return false;
}

function findPosX(objName)
{
var posx = 0;

obj= document.getElementById(objName);

if (obj.offsetParent)
    {
    while (obj.offsetParent)
        {
        posx += obj.offsetLeft
        obj = obj.offsetParent;
        }
    }
else if (obj.x)
    {
    posx += obj.x;
    }
return posx;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function hideProdSelect()
{
  //alert('hide')
  obj= document.getElementById('prodSelect');
  if(obj)
  {
    obj.style.display='none';
  }
}

function showProdSelect()
{
  //alert('show')
  obj= document.getElementById('prodSelect');
  if(obj)
  {
    obj.style.display='block';
  }
}

function hideLayer(objId) {
	document.getElementById(objId).style.display = 'none';
}

// Show a layer
function showLayer(objId) {
	document.getElementById(objId).style.display = '';
}



function init() {
	//loaderId = 'Photo_Loading';
	photoId = 'photoSlide';
	//loader = document.getElementById(loaderId);
	photo = document.getElementById(photoId);
	//setOpacity(loader, 100);
	setOpacity(photo, 0);
	photo.style.visibility = 'visible';
	fadeIn(photoId,0);
	//fadeOut(loaderId,100);
}


function fadeOut(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 0) {
		  setOpacity(obj, opacity);
		  opacity -= 15;
		  window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);
		} else {
			hideLayer(objId);
		}
	}
}

// Fade in
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
		  setOpacity(obj, opacity);
		  opacity += 10;
		  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
		}
	}
}

function printHTML(objName,slide) {
		obj = document.getElementById(objName);
		//alert(slide)
		//alert(obj)
		obj.innerHTML = slide;
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

