//-*-java-*- (C) All rights reserved: Grant Tegtmeier 6/10/04 Offers Network Inc.
function showInfo(infoIndex) {
  var href = "help.php?index=" + infoIndex;
  var newwin = window.open(href, "", "menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=480,height=320");
  if (newwin.opener == null) {
    newwin.opener = self;
  }
  newwin.focus();
}

function winOffer(clientID, offerID, userID, affiliateID, ptype) {
  var href = "view.php?pr=" + clientID + "." + offerID + "." + userID;
  if (affiliateID > 0) {
    href = href + "&af=" + affiliateID;
  }
  var newwin = '';
//   if (ptype == '1') {
//     newwin = window.open(href, "", "menubar=no,toolbar=no,status,scrollbars,resizable,width=640,height=480");
//   } 
//   else if (ptype == '4') {
    newwin = window.open(href, "", "menubar=yes,toolbar=yes,location=yes,"
			 + "status=yes,scrollbars=yes,resizable=yes,"
			 +"left=" + (window.screenLeft + 32) 
			 + ",top=" + (window.screenTop + 32));
//   } 
//   else {
//     newwin = window.open(href, "", "menubar=no,toolbar=no,status,scrollbars,resizable");
//   }
  newwin.focus();
}

function jwlink(mode) {
  var l = document.frmOffer.adhttp.value;
  if (l.length < 5 || l.indexOf('.') < 2) {
    window.alert('"' + l + '" is not a valid link.');
    return false;
  }
  if (l.substr(0, 7) != 'http://') {
    while (l.substr(0, 2) != '//') {
      l = '/' + l;
    }
    l = 'http:' + l;
  }
  document.frmOffer.adhttp.value = l;
  if (document.frmOffer.txtTitle.value == ''
      || document.frmOffer.txtSubtitle.value == '') {
    window.alert('You MUST enter a Title and a Tag-Line.');
    return false;
  }
  var s = "menubar=no,toolbar=no,status,scrollbars,resizable";
  var w = '', h = '';
  if (document.frmOffer.pwid.value != '') {
    w = parseInt(document.frmOffer.pwid.value);
    document.frmOffer.pwid.value = w;
    if (w > 0) {
      s += ",width=" + w; 
    }
  }
  if (document.frmOffer.phit.value != '') {
    h = parseInt(document.frmOffer.phit.value);
    document.frmOffer.phit.value = h;
    if (h > 0) {
      s += ",height=" + h; 
    }
  }
  if (mode == 0) { // 0 - Test the link
    var newwin = 
      window.open(document.frmOffer.adhttp.value, "", s);
    if (newwin.opener == null) {
      newwin.opener = self;
    }
    newwin.focus();
  } else { // 1 - Save the link
    document.frmOffer.section.value = 
      (document.frmOffer.savelink.value == "Save Link")? 
      'AddPageLink': 'UpdateContent';
    document.frmOffer.pageLink.value = '|' + w + '|' + h + '|' + l;
    document.frmOffer.submit();
  }
}

function frmODirty() {
  var f = document.frmOffer;
  f.btnReset.disabled = false;
  f.btnSave.disabled = false;
  f.btnDone.disabled = true;
  return true;
}

function frmOReset(yes) {
  var f = document.frmOffer;
  f.btnReset.disabled = yes;
  f.btnSave.disabled = yes;
  f.btnDone.disabled = !yes;
  f.reset();
  return true;
}
