var wH = window.innerHeight;
var wW = window.innerWidth;

function cleanEmail(text, id, mail) {
  var final = "";
  var let = 0;
  text = text.split("");

  while (let < text.length) {
    if ((let % 3) != 1) final+= text[let];
    let++;
  }
  (mail) ? $(id).href = "mailto:"+final : $(id).innerHTML = final;
  return "";
}

function ServerTime() {
  var xhr = new createXMLHttpRequest();
  var dummy = new Date().getTime();
  xhr.open("GET", "http://www.arts.usyd.edu.au/artsdigital/PHP/js_returns.php?TIME="+dummy, false);
  xhr.send(null);
  var time = xhr.responseText;
  xhr.close;
  return time;
}

function showTime(ID) {
  if ($(ID)) {
    if (ServerTime().length) $(ID).innerHTML = "The time in Sydney is "+ServerTime();
    t = setTimeout("showTime('"+ID+"')", 3000);
  }
  return;
}

function createXMLHttpRequest() {
  try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
  try { return new XMLHttpRequest(); } catch (e) {}
  alert ("XMLHttpRequest not Supported!");
  return null;
}     

function $(id) {
  return obj = document.getElementById(id);
}

function pageLoad() {
  var links = document.getElementById("foot-links").childNodes;
  for (x=0; x<links.length; x++) {
    if (links[x]) { if (links[x].tagName) { if (links[x].tagName.match(/^a$/i)) {
      if (links[x].innerHTML=="Comment on this Page") {
        links[x].href = "/artsdigital/?email=web&subject=Comment%20on%20"+window.location.href.replace(/\?/, "%3F").replace(/&/, "%26").replace(/=/, "%3D");
      }
    } } }
  }

//showTime('ServerTime');
//  pagetools('pagetools');
}
function openWorkspace() {
  var WStyle = $('WORKSPACE').style;
  WStyle.width = wW+"px";
  WStyle.height = wH+"px";
  WStyle.zIndex = 2000;
  WStyle.visibility = "visible";
  return; 
} 
function closeWorkspace() {
  var WStyle = $('WORKSPACE').style;
  WStyle.visibility = "hidden";
  WStyle.zIndex = -1;
  return;
} 


/*function pagetools(ID) {
  var p = "";
  if (location.href.match(/\?/)) var printHref = location.href+"&printable";
  else var printHref = location.href+"?printable";

//  p = "
//<img src=\"/images/nav/cws/lftbrkt.gif\" alt=\"spcr\" />
//<a href=\"#\" onClick=\"var printVersion=window.open('"+printHref+"','PrinterFriendly','toolbar=no,width=620,height=500,resizable=yes,menubar=yes,status=no,scrollbars=yes,left=100,top=100');printVersion.focus();return false;\" title=\"Printer Friendly Format\">
//<img src=\"/images/nav/cws/pix.gif\" height=\"20\" width=\"20\" alt=\"Print Friendly Version\" /><span>Printer format</span></a>
//<img src=\"/images/nav/cws/bar.gif\" alt=\"spcr\" />
//<a href=\"#\" onClick=\"var emailForm=window.open('/departs/english/mail.shtml','EmailForm','toolbar=no,menubar=no,width=500,height=500,resizable=no,status=no,scrollbars=yes,left=100,top=100');emailForm.focus();return false;\" title=\"Email a friend\">
//<img src=\"/images/nav/cws/pix.gif\" height=\"20\" width=\"20\" alt=\"Email a Friend\" /><span>Email to a friend</span></a>
//<img src=\"/images/nav/cws/bar.gif\" alt=\"spcr\" />
//<a href=\"#\" onclick=\"SetCookie('textsize','120',null,'/');location.reload(true);\" title=\"Large text size\"><img src=\"/images/nav/cws/pix.gif\" alt=\"Large text\" name=\"largeA\" width=\"20\" height=\"20\" onmouseover=\"swapImage('textsize','','/images/nav/cws/largertext.gif',1)\" onmouseout=\"swapImgRestore()\" /></a>
//<img src=\"/images/nav/cws/bar.gif\" alt=\"spcr\" />
//<a href=\"#\" onclick=\"SetCookie('textsize','100',null,'/');location.reload(true);\" title=\"Default text size\"><img src=\"/images/nav/cws/pix.gif\" alt=\"Default text\" name=\"smalla\" width=\"20\" height=\"20\" onmouseover=\"swapImage('textsize','','/images/nav/cws/defaulttext.gif',1)\" onmouseout=\"swapImgRestore()\"/></a>
//<img src=\"/images/nav/cws/rghtbrkt.gif\" alt=\"spcr\" />\r";
  if ($(ID)) $(ID).innerHTML = p;
  return;
}
*/
