function Enum() { 
  for (var i = 0; i < arguments.length; i++) 
    if (typeof(window[arguments[i].toString()]) == "undefined") 
      window[arguments[i].toString()] = i; 
    else 
      alert("Enum error: " + arguments[i] + " is already defined."); 
}

function emptyValue(obj) {
   if (obj.empty == undefined) {
      obj.defaultValue = obj.value;
      obj.empty = false;
   }
   else {
      obj.empty = obj.value == '';
   }

   if (obj.empty) {
      obj.value = obj.defaultValue;
   }
   else if (obj.value == obj.defaultValue) {
      obj.value = '';
   }
}

function rollOver(obj) {
   obj.onmouseover = function() { alert('test'); }
}

function getObject(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

function hide(name) {
   mask(name);
   getObject(name).style.position = 'absolute';
}

function mask(name) {
   getObject(name).style.visibility = 'hidden';
   getObject(name).disabled = true;
}

function unmask(name) {
   getObject(name).disabled = false;
   getObject(name).style.visibility = 'visible';
}

function show(name) {
   unmask(name);
   getObject(name).style.position = 'relative';
}

/**
   Deactivate a product row if the deletion box is checked
   @param obj the checkbox object that was just clicked
*/
function deactivate(obj) {

   name = obj.name;
   match = name.match(/\[(.*?)\]$/, name);
   id = parseInt(match[1]);

   if (id > 0) {

      newValue = (obj.checked) ? true : false;
      colorValue = (newValue) ? "#848484" : "#000000";
      if (getObject("name["+id+"]")) getObject("name["+id+"]").disabled = newValue;
      getObject("summary["+id+"]").disabled = newValue;
      getObject("url["+id+"]").disabled = newValue;
      if (getObject("defaultID["+id+"]")) getObject("defaultID["+id+"]").disabled = newValue;
      getObject("stats["+id+"]").style.color = colorValue;
      getObject("image["+id+"]").disabled = newValue;
   }
}

var knowledgeBase = {
   ratio : "This is the ratio of affiliate hoplinks to owner hoplinks.\n\n50% splits the owner and affiliate links evenly.\n75% shows 3 affiliate hoplinks for 1 owner hoplink.\n100% shows only affiliate hoplinks.\n\nSetting this to Automatic will give 50% of the ads over to the affiliate, and reward that person with a higher percentage -- all the way up to 100% -- as they get more people to sign up under them.",

   signupURL : {
      summary : "The URL to sign up for this affiliate program.",
      owner   : "Be sure to put {id} in place of your affiliate ID so affiliates can sign up under you."
   },

   groupStatus : "If this group's status is set to \"Paused\", it will not show up in any of the ads.\n\nIf Active, ads will show up normally.",

   imageSource : "The filename of the image associated with this product.\n(The file should be placed in this script's \"images\" folder).\n\nIt is recommended you keep the image about 70 pixels wide, and 80 pixels high.",

   defaultGroup : "Choose the default group of ads to show if someone places ads on their site but their ID is not registered.\n\n(For example, a ClickSensor Version 1 affiliate wanting to only promote Clickbank products.)",

   cacheLength : "The amount of time to store search results in the database.\n\nA longer cache means the ads will show up faster, but will not change as frequently.  They will also take up more space.\n\nA shorter cache will put a high load on your server if you get a lot of traffic to your site.\n(But is useful when you are first setting up and testing ads.)",

   adminName : "The name that goes out on all mailings.  This should be your real name or a name your customers recognize is coming from you.",

   adminMail : "Your e-mail address.  Be sure this is accurate so you can receive notifications when new users sign up.",

   brandedName : "The name your ClickSensor installation will be branded as.\n\nExample: If you set this value to 'Your Site,' confirmation mailings will be sent out as 'Your Store Confirmation.'\n\n(To completely customize your script be sure to edit the link in the HTML templates and change the logo on the login page.)",

   autoresponderSeed : "If you have a mailing list or autoresponder series you want new sign-ups to automatically be subscribed to, enter it here.\n\nWhen you have a new sign-up, an e-mail will be sent to the seed autoresponder e-mail address with the prospect's return address.\n\nExample: newsletter@example.com",

   autoSubject : "This will be the text in the subject line of the e-mail ClickSensor sends to seed your autoresponder when a new affiliate signs up.\n\nMany autoresponder scripts and services require you to place a special \"word\" in the subject line to keep the autoresponder from being flooded by spammmers.",

   alternateURL : "If you have other ads you want to show on your site (like Google AdSense) you can paste your AdSense code into an HTML file, put it on your web server, then put the URL to that HTML file here.",

   alternateEnable : "If the conversion rate for ClickSensor ads on a given page drops below this level, ads for this page will switch to an alternate URL... like a page with AdSense code.",

   adminPassword : "This is the administrator password you sign-in with.  Please keep this password written down so you do not forget it.\n\nIf you lose this password, just download the latest copy of ClickSensor and run the install file on your server.  The administrator password will show up for you.",

   paymentMail : "Your PayPal e-mail address so you can receive payments.\n\nIf this is left blank, users will not be charged when their ads are clicked on.",
   
   maxUserAds : "The maximum allowed number of advertisements users are allowed to have.",

   costPerClick : "How much money is taken out of a user's account when an ad of theirs is clicked on?\n\nYou can use fractional cents, for example 0.005 would be half a cent.\n\nSet this to 0.00 if you want all ads to be free.",

   EzineRocket : {
      signUpBalance : "This is the minimum opening balance, in other words the sign-up fee for the coop.\n\nYou are not allowed to charge more than $50 for the entrance fee.",
      costPerLead : "How much it costs an ezine owner for every subscriber you supply to them.\n\nYou may use fractional cents (example: 0.005 means 1/2 of 1 cent).\n\nYou are not allowed to charge more than 10 cents per lead."
   }
}

/**
   Display a help pop-up for a given area.
   @param area the section to get help on
*/
function help(area, user) {

   var msg;

   if (knowledgeBase == undefined) return false;

   obj = eval("knowledgeBase."+area);
   if (obj) msg = (obj.summary) ? obj.summary : obj;

   if (user != undefined && user == 0 && obj.owner) msg += '\n\n' + obj.owner;
   if (msg) alert(msg);
   return false;
}

function indent(obj) {
   obj.style.top = '2px';
   obj.style.left = '2px';
}

function outdent(obj) {
   obj.style.top = '0px';
   obj.style.left = '0px';
}

function copy() {
   var obj = getObject("code");
   //var tempval=eval("document."+obj)
   obj.focus();
   obj.select();

   if (document.all) {
      therange=obj.createTextRange();
      therange.execCommand("Copy");
   }
}