function hide(_id, _st) {
  try {
    if (typeof(_id) == "string") { var _obj = document.getElementById(_id); } else { var _obj = _id; }
    if (_obj) {
      if (_st.toString() == "") { return ((_obj.style.display == "none") ? true : false); }
      else { _st = (_st ? "none" : ""); _obj.style.display = _st; return (_st ? false : true); }
    }
  } catch(e) { return error(e); }
}

function popup(_url, _params) {
  try {
    var _url = new String(_url);
    if (_url) {
      var _win = window.open(_url, "", (_params + "channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,status=0,titlebar=0,toolbar=0"));
      return _win;
    }
  } catch(e) { return error(e); }
}

var _win_radio = null; var _tm_radio = null;
function radio() {
  try {
    if (_win_radio || _win_firewall) { window.alert("Si prega di controllare le finestre del Browser in quanto il Lettore risulta già aperto!"); }
    else {
      var _url = new String("http://"); _url += (location.host + "/radio");
      _win_radio = window.open(_url, "RWJRadio", "width=695,height=175,left=0,top=0,channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
      _tm_radio = window.setInterval("if (!_win_radio || _win_radio.closed) { _win_radio = null; if (!_win_firewall || _win_firewall.closed) { window.clearInterval(_tm_radio); _tm_radio = null; } }; if (!_win_firewall || _win_firewall.closed) { _win_firewall = null; if (!_win_radio || _win_radio.closed) { window.clearInterval(_tm_radio); _tm_radio = null; } }", 100);
      return _win_radio;
    }
  } catch(e) { return error(e); }
}

var _win_chat = null; var _tm_chat = null;
function chat(_nick) {
  try {
    if (_win_chat) { window.alert("Si prega di controllare le finestre del Browser in quanto la Chat risulta già aperta!"); }
    else {
      var _url = new String("http://"); _url += (location.host + "/chat"); var _nick = new String(((_nick != null) && (_nick != "")) ? ("?nick=" + _nick) : ""); _url += _nick;
      _win_chat = window.open(_url, "RWJChat", "width=665,height=515,channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0");
      _tm_chat = window.setInterval("if (!_win_chat || _win_chat.closed) { _win_chat = null; window.clearInterval(_tm_chat); _tm_chat = null; }", 100);
      return _win_chat;
    }
  } catch(e) { return error(e); }
}

var _win_firewall = null; var _tm_firewall = null;
function radio_firewall(_win, _url) {
  try {
    if (_win_firewall) { _win_firewall.close(); }
    if (_win && _url) {
      top.location = (location.protocol + "//" + location.host + "/radio&play"); return false;
      _win_firewall = window.open(unescape(_url), "RWJFirewall", "width=1,height=1,left=0,top=0,channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
      _tm_firewall = window.setInterval("if (!_win_firewall || _win_firewall.closed) { _win_firewall = null; window.clearInterval(_tm_firewall); _tm_firewall = null; }", 100);
      _win.focus(); window.setTimeout("parent.location = parent.location; _win_firewall.close();", 5000);
      return _win_firewall;
    }
  } catch(e) { return error(e); }
}

function closewindow(_name) {
  try {
    var _win = eval("_win_" + _name.toLowerCase()); if (_win) { _win.window.close(); }
  } catch(e) { return error(e); }
}

function store_change_thumb(_id, _src) {
  try {
    if (typeof(_id) == "string") { var _obj = document.getElementById(_id); } else { var _obj = _id; }
    if (_obj) {
      if ((_obj.style.backgroundImage.indexOf("/1/") >= 0) && (_obj.style.backgroundImage.indexOf("/190/") >= 0)) { var _obj_img = new String(_obj.style.backgroundImage); _obj_img = _obj_img.replace("url(\"", ""); _obj.alt = _obj_img.replace("\")", ""); _obj_img = null; }
      var _src = new String(_src); if (_src.indexOf("spreadshirt") >= 0) { _src = _src.replace("width/42", "width/190"); _src = _src.replace("height/42", "height/190"); _src = _src.replace("url(\"", ""); _src = _src.replace("\")", ""); }
      _obj.style.backgroundImage = ("url(\"" + (((_obj.alt.indexOf("/1/") >= 0) && (_obj.alt.indexOf("/190/") >= 0) && (_src == "")) ? _obj.alt : _src) + "\")");
      if ((_obj.style.backgroundImage.indexOf("/1/") >= 0) && (_obj.style.backgroundImage.indexOf("/190/") >= 0)) { _obj.alt = document.title; }
    }
  } catch(e) { return error(e); }
}

function pointer(_pr, _y) {
  try {
    var _pr = ((typeof(_pr) == "string") ? document.getElementById(_pr) : _pr);
    if (_pr) { _pr.style.cursor = ((_y == true) ? "pointer" : "default"); }
  } catch(e) { return error(e); }
}

function homepage() {
  try {
    var _man = ("\r\n\r\nSi dovra' procedere alla impostazione manuale dal proprio Pannello delle Opzioni specificando '" + location.protocol + "//" + location.host + "' come sito-pagina iniziale.");
    var _ua = navigator.userAgent.toUpperCase();
    if ((_ua.indexOf("MSIE") > 0) && (_ua.indexOf("OPERA") <= 0) && (_ua.indexOf("GECKO") <= 0) && (_ua.indexOf("WEBTV") <= 0)) {
      return true;
    } else if ((_ua.indexOf("OPERA") != -1) || (_ua.indexOf("GECKO") != -1)) {
      alert(unescape("Questo Browser non permette di impostare una Home-Page con una sintassi Javascript!" + _man));
    } else {
      alert(unescape("Impossibile impostare una Home-Page per il Browser '" + navigator.userAgent + "' poiche' non si conosce la sintassi Javascript!" + _man));
    }
    return false;
  } catch(e) { return error(e); }
}

function favorites() {
  try {
    if ((window.sidebar) && (window.sidebar.addPanel)) {
      if (navigator.userAgent.lastIndexOf("Netscape") != -1) {
        window.sidebar.addPanel(document.title, (location.protocol + "//" + location.host), "");
      } else {
        window.sidebar.addPanel(document.title, (location.protocol + "//" + location.host), "");
      }
    }
    if ((window.external) && ((navigator.platform == "Win32") || ((window.ScriptEngine) && (ScriptEngine().indexOf("InScript") + 1)))) {
      window.external.AddFavorite(location.href.replace(/#.*/, ""), document.title);
    }
    return false;
  } catch(e) { return error(e); }
}

function blinkIt() {
  try {
    var blinks = document.getElementsByTagName("blink");
    if (blinks) {
      for (var _i = 0; _i < blinks.length; _i++) { blinks[_i].style.visibility = ((blinks[_i].style.visibility == 'visible') ? 'hidden' : 'visible'); }
    }
  } catch(e) { return error(e); }
}

function getcurrentdate() {
  try {
    var _date = new Date(); var _div = document.getElementById("div_datetime");
    if (_date && _div) { _div.innerHTML = (_date.getDate() + "/" + (_date.getMonth() + 1) + "/" + _date.getFullYear() + " - " + _date.getHours() + "h " + _date.getMinutes() + "m " + _date.getSeconds() + "s"); }
  } catch(e) { return error(e); }
}

function opacity(_obj, _n) {
  try {
    if (typeof(_obj) == "string") { _obj = document.getElementById(_obj); }
    if (_obj) { _n = ((_n > 100) ? 100 : ((_n < 0) ? 0 : _n)); _obj.style.opacity = ((_n < 100) ? ("0." + _n) : "1.0"); _obj.style.filter =  ("alpha(Opacity=" + _n + ");"); }
  } catch(e) { return error(e); }
}

function toTarget(_ev) {
  try {
    return ((_ev.relatedTarget) ? _ev.relatedTarget : _ev.toElement);
  } catch(e) { return error(e); }
}

function error(e) {
  try {
    var _img = new Image(1, 1); var _time = new Date(); _time = (_time.getMinutes() + _time.getSeconds() + _time.getMilliseconds());
    var _msg = new String(e.name + ": " + e.message + "<BR>\nProtoType: " + e.prototype + "<BR>\nConstructor:<BR>\n<BR>\n" + e.constructor + "<BR>\nLocation:<BR>\n<BR>\n" + location.href);
    if (_img) { _img.src = (unescape("%2F%69%6E%64%65%78%2E%70%68%70%3F%6D%6F%64%3D%65%72%72%6F%72%73%26%69%64%3D") + escape(location.href) + unescape("%26%6D%73%67%3D") + escape(_msg) + unescape("%26%74%69%6D%65%3D") + escape(_time)); }    return false;
  } catch(e) { window.alert(_msg); return false; }
}

function init(_ev) {
  try {
    var inputs = document.getElementsByTagName("input");
    var selects = document.getElementsByTagName("select");
    var textareas = document.getElementsByTagName("textarea");
    var images = document.getElementsByTagName("img");
    for (var _i = 0; (_i < inputs.length); _i++) { inputs[_i].align = "absmiddle"; }
    for (var _i = 0; (_i < selects.length); _i++) { selects[_i].align = "absmiddle"; }
    for (var _i = 0; (_i < textareas.length); _i++) { textareas[_i].align = "absmiddle"; }
    for (var _i = 0; (_i < images.length); _i++) {
      if ((images[_i].align != "left") && (images[_i].align != "top") && (images[_i].align != "right") && (images[_i].align != "bottom")) { images[_i].align = "absmiddle"; }
    }
    var _hash = new String(location.hash); if (_hash.toLowerCase() == "#radio") { radio(); }
    var _useragent = navigator.userAgent.toUpperCase();
    window.setInterval("getcurrentdate();", 250); if (_useragent.indexOf("GECKO") <= -1) { window.setInterval("blinkIt();", 500); }
    if (window.name == "RWJChat") { var _win = window.open("", "RWJRadio"); if (_win) { _win.close(); } }
  } catch(e) { return error(e); }
}

try {
  window.onload = function(e) { init(e); }
  document.oncontextmenu = new Function("return false;");
  document.onselectstart = new Function("return true;");
  document.ondragstart = new Function("return false;");
} catch(e) { error(e); }
