//
// World of WarCraft - DC Comics
//
// addLoadEvent():      queues functions to window.onLoad
// popUp():             opens a new browser window
// swap_title_text()    changes the titles on rollover for the thumbnails
// catDetailLinkSetup()	formats thumbnail links on the datalog detail page to be popups
//


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != "function") {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function popUp() {
  if (!document.getElementsByTagName) return false;
    var links=document.getElementsByTagName("a");
    for (var i=0; i < links.length; i++) {
      if (links[i].className.match("popup")) {
        links[i].onclick=function() {
        window.open(this.href);
        return false;
      }
    }
  }
}

function swap_title_text(new_text) {
    document.getElementById('main_image_title').firstChild.nodeValue = new_text;
}




function catDetailThumbSetup() {
  if (!document.getElementById) return false;
  if (document.getElementById('catalog_detail')) {
    var thumbList = document.getElementById("thumbs");
    var thumbListLinks = thumbList.getElementsByTagName("a");
    var jVar = 98;
	var dtcbId = String(window.location);
	var digit1 = dtcbId.indexOf('=') + 1;
	var digit2 = digit1 + 3;
	dtcbId = dtcbId.substr(digit1,digit2);
    for (var i=0; i < thumbListLinks.length; i++) {
      var href = thumbListLinks[i].getAttribute('href');
      thumbListLinks[i].setAttribute('href','javascript:void(0)');
      thumbListLinks[i].setAttribute('onClick','images_popup = window.open(\'popup_images.php?i=' + dtcbId + '&j=' + String.fromCharCode(jVar) + '\', \'images_popup\',\'width=500,height=700,screenX=100,screenY=50,left=100,top=40,scrollbars=no,status=no,location=no,resizable=yes,\')');
      if (navigator.appName == "Microsoft Internet Explorer") {
      	thumbListLinks[i]['onClick'] = new function () {
      		alert('this works');
      	}
      }
      thumbListLinks[i].onmouseover = function () {window.status='View Larger!';}
      thumbListLinks[i].onmouseout = function () {window.status='';}
      jVar++;
    }
  }
}

addLoadEvent(popUp);
//addLoadEvent(catDetailThumbSetup);