var xmlHttp
var targElement
var siteInfo = 0;
var ie7 = 0;
// for the IOTD pic
var d = new Date();
td = d.getDate();
//td = 17; 

var iotd = new Array();
iotd[0]="";
iotd[1]="horse render - by shane nakamura";
iotd[2]="roadster";
iotd[3]="used hands";
iotd[4]="a fish girl - by chris achilleos";
iotd[5]="3d wrapped ball";
iotd[6]="hand on wet glass";
iotd[7]="fighting girl";
iotd[8]="gimmee a close up";
iotd[9]="winter night";
iotd[10]="true elimination mud wrestling";
iotd[11]="poster neuromancere - by oscar chichoni";
iotd[12]="chinese sculpture";
iotd[13]="fruit by frankenstein";
iotd[14]="virgo - by doronina tanja";
iotd[15]="cat eyes";
iotd[16]="cover for minotauro magazine - by oscar chichoni";
iotd[17]="by chris foss";
iotd[18]="mr and mrs pump";
iotd[19]="plane of the dead";
iotd[20]="squirrel on the bench";
iotd[21]="jodphur warriors - by doug chiang";
iotd[22]="a hand imprint";
iotd[23]="by christian lassen";
iotd[24]="by takuhito kusanagi";
iotd[25]="remains of the tree demon";
iotd[26]="cartographer - by donato giancola";
iotd[27]="but i dont believe in you - by nick harris";
iotd[28]="milk into coffee - by sancho";
iotd[29]="by artist unknown";
iotd[30]="the end";
iotd[31]="biomechanical 01 - by hr giger";

//  What browser is it - warn visitor if we dont code to it
function chkBrowser() {
  var bver;
  var version;
  var bname;
  var bua, buau;
  var warnmsg;
  var x=navigator;
  bua=x.userAgent;
  buau=bua.toUpperCase();
  if (buau.indexOf("WINDOWS") > 0) {
  	if (buau.indexOf("MSIE") > 0) {
  	  if (buau.indexOf("MSIE 7") > 0) {
  		ie7 = 1;
  	  } else {
  	    warnmsg = "Sorry, Internet Explorer 7 is the only Microsoft browser currently ";
  	    warnmsg = warnmsg + "supported at this site - you will have issues.<br /><br >";
  	    document.getElementById("thetop").innerHTML=warnmsg;
  	  }
  	}
  }
}

//
function initHome() {
//  alert("td = "+td);
  var iotdlink = "<img src=\'galleries/iotd/" + td + "-fullth.jpg\' width=\'120\' onclick=\'popImage()\' />"; //
  document.getElementById("tiotd").innerHTML = iotdlink;
  chkBrowser();
}

function showLocs() {
  var smsg;
  smsg = 'host = '+location.host+'\n';
  smsg = smsg+'hostname = '+location.hostname+'\n';
  smsg = smsg+'href = '+location.href+'\n';
  smsg = smsg+'search = '+location.search+'\n';
  smsg = smsg+'pathname = '+location.pathname+'\n';
  smsg = smsg+'port = '+location.port+'\n';
  smsg = smsg+'protocol = '+location.protocol+'\n';
  smsg = smsg+'search = '+location.search+'\n';
  alert(smsg);
}
// open and close front page content boxes
function togOC(boxid) {
//alert(document.getElementById(boxid+"h").src);
if ((document.getElementById(boxid+"h").src).indexOf("ruc-arrow-down-13hb.png") > -1) {
  document.getElementById(boxid).style.visibility="visible";
  document.getElementById(boxid).style.height="";
  document.getElementById(boxid).style.padding="8px 12px 8px 12px";
  document.getElementById(boxid+"h").src="statics/ruc-arrow-up-13hb.png";
  } else {
  document.getElementById(boxid).style.visibility="hidden";
  document.getElementById(boxid).style.height="0px";
  document.getElementById(boxid).style.padding="0px";
  document.getElementById(boxid+"h").src="statics/ruc-arrow-down-13hb.png";
  }
}
// hideIt - make an HTML goodie invisible
function hideIt(trg) {
  document.getElementById(trg).style.visibility="hidden";
}

// showIt - make an HTML goodie visible
function showIt(trg) {
document.getElementById(trg).style.visibility="visible";
}

// changeThis - change the content of a named HTML element
function changeThis(trg,news) {
  document.getElementById(trg).innerHTML=news;
}

// put up a Tip at the cursor with the message
function sayThis(amsg) {
var tMsg;
tMsg = "<span class=\'txt8\'>"+amsg+"</span>";
Tip(tMsg, ABOVE, true, BGCOLOR, '#585858', BORDERCOLOR, '#000000', BORDERSTYLE, 'solid', BORDERWIDTH, 1, CENTERMOUSE, true, CLOSEBTN, false, DURATION, 2500, FOLLOWMOUSE, false, PADDING, 4, STICKY, true, TEXTALIGN, 'center');
}


// clearThis - clear a named HTML element
function clearThis(trg) {
  document.getElementById(trg).innerHTML="";
}

function dmClear() {
  clearThis('dm');
}

// set color on links for mouse on / off
function setLink(sw,what) {
if (sw > 0) {
  document.getElementById(what).style.color='#000080';
  } else {
  document.getElementById(what).style.color='#FFFFFF';
  }
}

// throw up a gallery image
function showGalleryImage(picdata) {
var pid
var pdesc
var ph
var pw
var i1
var tMsg;
var p1;
//alert(">>"+picdata+"<<");
// galleries/art01/w001-Gossett_Christian-RedStar2.jpg#christian gossett {red star}#822#1200
i1 = picdata.indexOf("#",0);
pid = picdata.substring(0,i1);
picdata = picdata.substring(i1+1);
i1 = picdata.indexOf("#",0);
pdesc = picdata.substring(0,i1);
picdata = picdata.substring(i1+1);
i1 = picdata.indexOf("#",0)
ph = picdata.substring(0,i1);
picdata = picdata.substring(i1+1);
pw = picdata;
if (pw > 984) {
  p1 = 5;
  } else {
  p1 = ((984 - pw) / 2) + 30;
  }
//alert(pid+"<br />"+pdesc+"<br />"+ph+"<br />"+pw);
tMsg = "<img src=\'";
tMsg = tMsg + pid;
tMsg = tMsg + "\' width=\'" + pw + "\' height=\'" + ph +"\' /><br />";
tMsg = tMsg + "<center><span class=\'txt8\'>" + pdesc + "</span></center>"; 
//alert(tMsg);
Tip(tMsg, BGCOLOR, '#585858', BORDERCOLOR, '#000000', BORDERSTYLE, 'solid', BORDERWIDTH, 1, CLICKCLOSE, true, CLOSEBTN, false, FIX, [ p1, 5]);
}

// throw up the image of the day
function popImage() {
var tMsg;
tMsg = "<img src=\'galleries/iotd/"+td+"-full.jpg\' />"; //'
if (iotd[td].length > 0) {
  tMsg = tMsg + "<center><img class=\'imgnb\' src=\'statics/ruc-spacer-v11x15.png\' />"; //'
  tMsg = tMsg + "<span class=\'txt8\'>"+iotd[td]+"</span>"; // '
  tMsg = tMsg + "<img class=\'imgnb\' src=\'statics/ruc-spacer-v11x15.png\' /></center>"; //'
}
Tip(tMsg, BGCOLOR, '#585858', BORDERCOLOR, '#000000', BORDERSTYLE, 'solid', BORDERWIDTH, 1, CLICKCLOSE, true, CLOSEBTN, false, DELAY, 500, FADEIN, 500, FADEOUT, 500, WIDTH, 902, FIX, ['iotdmark', 44, 30] );  //
}

//  called from pic page to do the actual navigation
function setGalNavBar(whereto,p1,p2,p3,p4) {
  var s1;
//  alert(whereto+" "+p1+" "+p2+" "+p3+" "+p4);
  switch (whereto) {
    case "p":
      showThis("ruc-gallery.php?libid="+p1+"&galid="+p2+"&picid="+p3,p4);
      break;
    case "n":
      showThis("ruc-gallery.php?libid="+p1+"&galid="+p2+"&picid="+p3,p4);
      break;
    case "i":
      window.location.href="index.php?wher="+p1;
      break;
    case "h":
      window.location.href="index.php";
//      window.location.href="index.php?wher="+p1;
      break;
    default:
      alert("setGalNavBar - broken!");
  }
}

function jump(trg) {
//  trg=trg+"&sid="+Math.random();
//  alert(trg);
//  window.location.href='http://'+location.host+'/rucyrious/'+trg;
  window.location.href=trg;
}

// showThis - AJAX get data
function showThis(str,trg) { 
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
    alert ("Your browser does not support AJAX!");
    return;
    } 
  targElement=trg;
  var url=str;
//  url=url+"&sid="+Math.random();
//  alert(url+" :: "+trg);
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

// stateChanged - AJAX wait for and load data
function stateChanged() { 
  if (xmlHttp.readyState==4) {
    document.getElementById(targElement).innerHTML=xmlHttp.responseText;
  }
}

// GetXmlHttpObject - open an AJAX session
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;
}


/*
WM_preloadImages()
Loads images into the browser's cache for later use.
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
Author: Nadav Savio
Author Email: nadav@wired.com
Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/
function WM_preloadImages() {
  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

/*
WM_imageSwap()
Changes the source of an image.
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
Author: Shvatz
Author Email: shvatz@wired.com
Usage: WM_imageSwap(originalImage, 'newSourceUrl');
Requires: WM_preloadImages() (optional, but recommended)
Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
with variables in ie3 for the mac. 
*/
function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

