// JavaScript Document

function OpenNewWindow(page) {
  OpenWin = this.open( page, "NewWindow", "top=50,left=50,toolbar=yes,height=400,width=790,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes");
  }

function OpenNewWindowSize(page,width,height) {
  OpenWin = this.open( page, "NewWindow", "top=50,left=50,toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes");
  }

function openFlash(file,width,height) {
  newFlash = this.open("flash/"+file, "monsoon", "top=50,left=50,toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function openABCVideo(video) {
  path = "http://www.abc15.com/video/misc/player-evt-abc15.asp?pad=y&vid=http://real.scripps.com:8480/ramgen/phoenix/" + video;
  newVideo = this.open(path,'abc15video','top=50,left=50,toolbar=0,status=0,menubar=0,scrollbars=0,SCROLLING=yes,resizable,width=386,height=550');
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function setUpNewWindows(){
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (l=0; l<links.length; l++) {
    var link = links[l];
    if (link.getAttribute("rel") == "newwindow") {
      link.onclick = function () {newWindowAuto(this); return false}
    }
  }
}

function newWindowAuto(element) {
  var size = element.getAttribute("size").split(":");
  if (!size) {
    size.push('600','600');
  }
  thiswin = window.open(element.href, "_new", "top=50,left=50,toolbar=no,height="+size[1]+",width="+size[0]+",location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

addLoadEvent(setUpNewWindows);
