/* All content copyright © 2003 Tatler Software. */

var win = window;
var agt = navigator.userAgent;
var Mac = (agt.indexOf("Mac") != -1);
var Opera = (agt.indexOf("Opera") != -1);
var Opera7 = (parseFloat(agt.substring(agt.indexOf("Opera")+6)) >= 7);
var MSIE = (navigator.appName == "Microsoft Internet Explorer" && !Opera);
var DOM = ((document.getElementById && !Opera) || Opera7);
var IE4up = (document.all && MSIE);
var NN4 = (document.layers);
var NN6 = (DOM && !document.all);
var NN4up = (NN4 || NN6);
var DHTML = (IE4up || NN4 || DOM);
var PR = (win.print);
var fullRelSize = .9;
var popRelWidth = .75;
var popRelHeight = .75;
var cascadeBy = 28;
var difW,difH,winW,winH,winX,winY,popW,winObj,winFeat,winList,resized,subbed;

if (document.images) {
  var arr = ["help_s1","help_s2"];
  for(var i=0;i<arr.length;i++) {
    window[arr[i]]=new Image();
    window[arr[i]].src="../html/images/"+arr[i]+".gif";
  }
}

function rollIt(img,num) {
  if (document.images) document.images[img].src = eval("help_s"+num).src;
  if (num == 2) window.status = "Get more information about this field.";
  else window.status = "";
  return true;
}

function winStat(txt) {
  if (txt) window.status = txt;
  else window.status = "";
  return true;
}

function sameWin(dir,tgt,url) {
  if (tgt && url) {
    var pop = win[tgt];
    if (pop && !pop.closed && pop.open) pop.location = dir+"popup.html?"+escape(url);
    else win[tgt] = win.open(dir+"popup.html?"+escape(url),tgt);
    return false;
  }
  return true;
}

function ieOffset(pctW,pctH,pctF){
  if (!difW || !difH) {
    popW=null;
    var tstW=winW;
    var tstH=300;
    var offW,offH,offX,offY;
    test=win.open("","chromeTest");test.document.open("text/html","replace");
    test.document.write("<html><head><\/head><body bgcolor='#FFFFFF'>&nbsp;<\/body><\/html>");
    test.document.close();
    offW=test.document.body.clientWidth;
    offH=test.document.body.clientHeight;
    test.resizeTo(tstW,tstH);
    difW=(tstW-(test.document.body.clientWidth-offW))-offW;
    difH=(tstH-(test.document.body.clientHeight-offH))-offH;
    test.close();
  }
  offX=(winX&&winX>0)?winX+cascadeBy-(difW-20)/2:cascadeBy;
  offY=(winY&&winY>0)?winY-difH+cascadeBy+28:cascadeBy;
  popW=new Array(difW,difH,0,0,offX,offY);
  calcSize(difW,difH,pctW,pctH,pctF);
}

function calcSize(difW,difH,pctW,pctH,pctF) {
  popW[6] = (winW*pctF)+difW;
  popW[7] = (winH*pctF)+difH;
  popW[8] = (winW+(difW+4)/2)*pctW;
  popW[9] = (winH*pctH);
}

function checkWin(pctW,pctH,pctF) {
  if (!DHTML) return;
  winW = (win.innerWidth || (document.body && document.body.clientWidth));
  winH = (win.innerHeight || (document.body && document.body.clientHeight));
  var movX = (win.screenX || win.screenLeft);
  var movY = (win.screenY || win.screenTop);
  var moved = (movX != winX || movY != winY);
  if (!popW || moved) {
    winX = (win.screenX || win.screenLeft);
    winY = (win.screenY || win.screenTop);
    if (IE4up) ieOffset(pctW,pctH,pctF);
    else {
      var difW,difH,offX,offY;
      difW = win.outerWidth-winW;
      difH = win.outerHeight-winH;
      sBarW = (NN6 && difW > 18) ? difW-8 : 10;
      offX = (winX && winX > 0) ? (NN6) ? winX+cascadeBy+sBarW-10 : winX+cascadeBy : cascadeBy;
      offY = (winY && winY > 0) ? winY+cascadeBy : cascadeBy;
      popW = new Array(0,0,difW,difH,offX,offY);
    }
  }
  if (IE4up) calcSize(popW[0],popW[1],pctW,pctH,pctF);
  else {
    popW[6] = winW*pctF;
    popW[7] = winH*pctF;
    popW[8] = winW*pctW;
    popW[9] = winH*pctH;
  }
  winX = movX;
  winY = movY;
  resized = 0;
}

function updList(id) {
  if (!winList) {
    winList = new Array();
    winList[0] = id;
  }
  else {
    var len = winList.length;
    for (var i=0; i<len; i++) if (winList[i] == id) return;
    winList[len] = id;
  }
}

function dBarWin(pop,nam,des,url) {
  var doc = pop.document;
  var srv = (des == "User Survey");
  var hdr = (srv) ? 32 :36;
  var dBarHdr = (srv) ? "srvhdr" : "pophdr";
  var dBarCls = "popcls.html";
  var popPath = (win.lnkPath) ? lnkPath+"popups/" : "./popups/";
  var hdrDesc = (des) ? '<scr'+'ipt language="javascr'+'ipt" type="text/javascr'+'ipt">\nvar desc = "'+des+'";\n<\/scr'+'ipt><\/head>' : '';
  var dBarWin =  '<html><head><title>'+nam+'<\/title>';
      dBarWin += (hdrDesc) ? hdrDesc : '<\/HEAD>';       
      dBarWin += '<frameset rows="'+hdr+',*,28" border="0" frameborder="0" framespacing="0">';
      dBarWin += '<frame src="'+popPath+dBarHdr+'.html" name="header" scrolling="no">';
      dBarWin += '<frame src="'+url+'" name="content" scrolling="auto">';
      dBarWin += '<frame src="'+popPath+'popcls.html" name="closebtn" scrolling="no">';
      dBarWin += '<\/frameset><\/html>';
  doc.open("text/html","replace");
  doc.write(dBarWin);
  doc.close();
}

function openWin(id,nam,des,url,w,h,fix,ctr,scr,menu,tool,addr,stat,pctW,pctH,pos0) {
  if (win.focus && frames[0]) frames[0].focus();
  var x = (pos0 || Opera) ? 0 : "";
  var y = (pos0 || Opera) ? 0 : "";
  var args = openWin.arguments;
  var dBar = (id.indexOf('dBar_') != -1);
  id = (dBar) ? id.substring(id.indexOf('dBar_')+5,id.length) : id;
  var full = (id.toLowerCase().indexOf('ful') > -1);
  var newW = (pctW) ? pctW/100 : popRelWidth;
  var newH = (pctH) ? pctH/100 : popRelHeight;
  var newF = (pctW && full) ? pctW/100 : fullRelSize;
  checkWin(newW,newH,newF);
  updList(id);
  var wPos = ((winX || (winX && winX == 0)) && (winY || (winY && winY == 0)) && winW && winH);
  var scrl = (scr || args.length < 9) ? "yes" : "no";
  winFeat = new Array();
  winFeat[0] = (!menu || args.length < 10) ? "no" : "yes";
  winFeat[1] = (!tool || args.length < 11) ? "no" : "yes";
  winFeat[2] = (!addr || args.length < 12) ? "no" : "yes";
  winFeat[3] = (!stat || args.length < 13) ? "no" : "yes";
  if (full) {
    if (popW && wPos) {
      w = (fix && w && w != 0) ? (popW && popW[0]) ? (w*1)+popW[0] : w : popW[6];
      h = (fix && h && h != 0) ? (popW && popW[1]) ? (h*1)+popW[1] : h : popW[7];
      x = (pos0 || Opera) ? 0 : (ctr) ? (IE4up) ? ((winW-w+popW[0])/2)+winX-4 : (NN6) ? ((winW-w)/2)+winX+popW[2]-8 : ((winW-w)/2)+winX : popW[4];
      y = (pos0 || Opera) ? 0 : (ctr) ? (IE4up) ? ((winH-h-popW[1])/2)+winY+28 : ((winH-h)/2)+winY : popW[5];
    }
    win[id] = win.open(url,id,"width="+w+",height="+h+",menubar=yes,toolbar=yes,directories=yes,location=yes,status=yes,resizable=yes,scrollbars="+scrl+",screenX="+x+",screenY="+y+",left="+x+",top="+y);
  }
  else {
    if (popW && wPos) {
      var adjY = 0;
      for (i=0; i<winFeat.length; i++) if (winFeat[i] == "yes") adjY += 25;
      w = (fix && w && w != 0) ? w : (popW && popW[8]) ? popW[8] : w;
      h = (fix && h && h != 0) ? h : (popW && popW[9]) ? popW[9] : h;
      x = (pos0 || Opera) ? 0 : (ctr) ? (IE4up) ? ((winW-w)/2)+winX+4 : (NN6) ? ((winW-w)/2)+winX+popW[2]-8 : ((winW-w)/2)+winX : popW[4];
      y = (pos0 || Opera) ? 0 : (ctr) ? (IE4up) ? ((winH-h-popW[1]-adjY+31)/2)+winY : (NN6) ? ((winH-h+popW[3]-adjY-28)/2)+winY : ((winH-h+popW[3]-adjY-31)/2)+winY : popW[5];
      h =  (IE4up && adjY > 0) ? h-18 : h;
    }
    win[id] = win.open("",id,"width="+w+",height="+h+",menubar="+winFeat[0]+",toolbar="+winFeat[1]+",directories=no,location="+winFeat[2]+",status="+winFeat[3]+",resizable=yes,scrollbars="+scrl+",screenX="+x+",screenY="+y+",left="+x+",top="+y+",true");
  }
  winObj = eval(id);
  if (winObj) {
    if (dBar) {
      if (win.focus) setTimeout("winObj.focus()",100);
      setTimeout("dBarWin(winObj,'"+nam+"','"+des+"','"+url+"')",200);
    }
    else if (url) setTimeout("winObj.location.href = url",100);
  }
}

function closeWin(id) {
  var len = (id) ? 1 : (winList) ? winList.length : 0;
  for (var i=0; i<len; i++) {
    var pop = (id) ? win[id] : win[winList[i]];
    if (pop && !pop.closed && pop.open) pop.close();
  }
}

function printPage(frame,arg) {
  if (frame == win) printThis();
  else {
    link = arg;
    printFrame(frame);
  }
}

function printThis() {
  if (PR) win.print();
  else if (IE4up && !Mac) vbPrintPage();
  else alert("Sorry, your browser doesn't support this feature.");
}

function printFrame(frame) {
  var msg = "Sorry, your browser doesn't support this feature.";
  if (PR && IE4up) {
    frame.focus();
    win.print();
    link.focus();
  }
  else if (PR) frame.print();
  else if (IE4up && !Mac) {
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  }
  else alert("Sorry, your browser doesn't support this feature.");
}

if (IE4up && !PR && !Mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH=0 HEIGHT=0 CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}