/*
datei: js.js
author: Piero Chiussi
created: 09.08.2006
modified: 04.09.2006 -> Piero Chiussi
*/
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
  return this;
}

function swapImg(img,akt)
{
	theObj = getObj(img);
	akt=="on"? theImg = document[""+img+"DWN"].src : theImg = document[""+img+"UP"].src;
	theObj.obj.src = theImg;
}

//MAIL
function encode(str)
{
	nStr = "";
	for (var i = 0; i < str.length; i++)
	{
		nStr += "&#" + Number(str.charCodeAt(i)).toString() + ";";
	}
	return nStr;
}

function doMail(usr,dom,tld)
{
	prex = encode("mailto:");
	at = "@";
	dt = ".";
	ecMail = encode(usr+at+dom+dt+tld);
	document.write("<a href=\""+prex+ecMail+"\">"+ecMail+"</a>");
}

function OpenCata(page,id)
{
	Open(""+page+".asp?id="+id,"Catalogo Sarfatti",1000,740,"status=no,menubar=no,location=no,toolbar=no,resizable=no,scrollbars=yes");
}

function Open(url,name,w,h,string) {
  
  var str = "height=" + h + ",innerHeight=" + h;
  str += ",width=" + w + ",innerWidth=" + w;
  
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - w) / 2;
    var yc = (ah - h) / 2;
	
	if(yc>150) yc = "50px";
	
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
	str += ","+string+"";
  }
  window.open(url, "sarfatti",""+str+"");
}