function SetCookie (name, value, expiration) {
 value=escape(value);

 if (name.indexOf(" ") != -1 || name.indexOf("=")!= -1) {
  alert("Invalid cookie name: " + name + ";");
  return null;
  }
 document.cookie = name + "=" + value + "; expires=" + expiration + ";domain=.thefixer.org";

 }

function GetCookie (name) {
 name+="=";
 var allcookies=document.cookie;
 var pos=allcookies.indexOf(name);

 if(pos != -1) {
  var start = pos + name.length;
  var end = allcookies.indexOf(";",start);
  if (end == -1) {
   end=allcookies.length
   };

  var value=allcookies.substring(start,end);
  value=unescape(value);

  return value;
 }
 else return null;
  }

function Pup() {

var windowVals = "width="+popupWidth+",height="+popupHeight +",resizable=no,status=no,scrollbars=no";


if (IsInClient==false) {
 windowVals+=",left="+XPositionValue+",top="+YPositionValue+",screenX="+XPositionValue+",screenY="+YPositionValue;
 }
    var win;

    win=window.open(popupURL,"pup",windowVals);

    if (!win.opener) {
        win.opener=self;
    }
    if (win.focus) {
        win.focus();
    }
}



//qualify 4.0 and up, and Win Mac
// Mac removed 8-1-01 by hr
if (  ((navigator.appName == "Netscape" && navigator.appVersion.charAt(0) < "5") || (navigator.appVersion.indexOf("MSIE") != -1)) &&
      (navigator.appVersion.charAt(0) >= "4") &&
      (navigator.userAgent.indexOf ("AOL 3.0") == -1) && (navigator.userAgent.indexOf("AOL 2.0") == -1) &&
      ((navigator.userAgent.indexOf ("Mac") == -1) || (navigator.userAgent.indexOf("Win") != -1) )
   )
{

// names of popups to switch to and override
PopupOverride='me_x';

var popData = new Array();

//   Enter popup data using this template.
//
//   //---------------------
//
// //Popup <?> data
//  popData[?] = { //Use next sequential #
//  popName:'?', //Popup name
//  startDay:?, //Day 0 (sun) - 6 (sat)
//  startHour:?, //Hour 0-23
//  fallback:'?' //Fallback Popup Name (or null)
// }
//
//
// //--------------------


  //Popup A data
 popData[0] = {
 popName:'index2',
 startDay:1, //Mon
 startHour:10,
 fallback: null
 }


  //Popup B data
 popData[1] = {
 popName:'Help_b',
 startDay:4, //Thu
 startHour:10,
 fallback: null
   }
  /*
  //Popup C data
 popData[2] = {
 popName:'test_c',
 startDay:5, //Fri
 startHour:6,
 fallback:'test_c1'
   }

 */


//true -- this is a client popup. False, this is an out-of-client popup.
IsInClient=false;

// true - use override. False use above
override = false;

// Extension for popup (No '.')
extension = "html";

// Prefix for popup.  Include ending /  (ie http://ads.web.aol.com/subdir/)
prefix = "";


// height and width of the popup in pixels
var popupHeight = 500;
var popupWidth = 500;

var UsedByClient = true;

// X and Y position of a popup
XPositionValue=25;
YPositionValue=200;

// true - cookie expires using numberOfDaysFromNow, false cookie expires on the_date
var useNumberOfDaysFromNow = true;

var numberOfDaysFromNow = 3;

// Use the format below - Month Day, Year (4 digit) HH:MM:SS
var the_date = new Date("November 21, 2000 00:00:00");


// DO NOT CHANGE ANYTHING BELOW THIS LINE

// Set the time in GMT
if (useNumberOfDaysFromNow) {
    var exp = new Date();
    var dateInGMT = exp.getTime() + (numberOfDaysFromNow * 24 * 60 * 60 * 1000);
    exp.setTime (dateInGMT);
    expiresStr = exp.toGMTString();
}
else {
    var expiresStr = the_date.toGMTString();
}

if (override) {
    popupName = PopupOverride;
}
else {
   var popList = new Array();

   for (i=0;i < popData.length; i++) {
   itemtime = popData[i].startDay + ((popData[i].startHour)/100);
   popList[i] = {time:itemtime,popName:popData[i].popName,fallback:popData[i].fallback};
   }

 //sort so start events are in ascending order

 popList.sort(function(a,b) {return a.time - b.time;});

    now = new Date();
    dayNum = now.getDay();
    dayHours = now.getHours();
    dayTime = (dayNum + (dayHours/100));

  //if time now < first item time, use last item time
      if (dayTime < popList[0].time) {
   popupName = popList[(popList.length-1)].popName;
   popupFallback=popList[(popList.length-1)].fallback;
   }
   else {
   //walk list to find current event

   for (i=0; i< (popList.length);i++) {
      if (dayTime >= popList[i].time) {
      popupName = popList[i].popName;
      popupFallback=popList[i].fallback;
      }
      else {
      break;
      }
      }
   }
   }


LastShown=GetCookie("Offer");


 if (LastShown == null) {
  // no cookie - create cookie and show main
  popupURL = prefix + popupName + "." + extension;
  showPopup = true;

  SetCookie("Offer",popupName,expiresStr);
  SetCookie("OfferExp",expiresStr,expiresStr);

  } else {
  // cookie not null
   if (LastShown == popupName) {
   // saw main - show fallback, don't change exp.
    if (popupFallback != null) {
     //Fallback is not null
     popupURL = prefix + popupFallback + "." + extension;
     showPopup = true;
     expiresStr=GetCookie("OfferExp")
     SetCookie("Offer",popupFallback,expiresStr);
     } else {
     //Fallback is null. Do nothing
     showPopup = false;
     }
   } else {
    if (LastShown == popupFallback) {
    // saw fallback - show nothing, don't change exp.
    showPopup = false;
    } else {
    // cookie exists but is old series - show main and re-init cookie.
    popupURL = prefix + popupName + "." + extension
    showPopup = true;

    SetCookie("Offer",popupName,expiresStr);
    SetCookie("OfferExp",expiresStr,expiresStr);
    }
   }
  }

if (showPopup == true) {

  window.pup = Pup;
    if (window.pup != null) {
        pup();
    }
    }

     }
