
var ad1 = "<a href=\"http://click.linksynergy.com/fs-bin/click?"+
        "id=4FNBlqOa4b0&amp;offerid=";

var ad2 = "&amp;type=4&amp;subid=0\" target=\"_blank\">"+
        "<img width=\"120\" height=\"90\" alt=\"Shop at Sephora.com\" "+ "border=\"0\" src=\"";
var ad3 = "\"></a><span id=\"";

var ad4 = "\"></span><br><br>";
/**		
var ad3 = "\"></a><img border=\"0\" width=\"1\" height=\"1\" "+
        "src=\"http://ad.linksynergy.com/fs-bin/show?id=4FNBlqOa4b0&amp;bids=";

var ad4 = "&amp;type=4&amp;subid=0\" alt=\"Sephora affiliate Polished "+
        "Social Image Consultants\"><br><br>";
*/
var amazon = "";
/**
var amazon = "<iframe width=\"120\" height=\"240\" scrolling=\"no\" "+
    "frameborder=\"0\" src=\"http://rcm.amazon.com/e/cm?"+
    "t=polishedsocia-20&p=28&o=1&l=dl1&f=ifr\">" +

    "<map name=\"boxmap-b3\"><area shape=\"rect\" "+
    "coords=\"0, 230, 120, 240\" href=\"http://rcm.amazon.com/e/cm/" +
    "privacy-policy.html?o=1\" >" +

    "<area coords=\"0,0,10000,10000\" href=\"" +
    "http://www.amazon.com/exec/obidos/redirect?"+
    "tag=polishedsocia-20&creative=92497&camp=8117&link_code=dl1&"+
    "path=subst/misc/amazon-cobrand-cc/v3/"+
    "marketing-from-associates-step1.html/ref%3Db1_assoc_28\" ></map>"+
    "<img src=\"http://rcm-images.amazon.com/images/G/01/associates/"+
    "promotions/b1c-120x240.gif\" width=\"120\" height=\"240\" "+
    "border=\"0\" usemap=\"#boxmap-b3\" alt=\"Amazon.com Platinum Visa Card\">"+
    "</iframe>";
*/

function buildAd(arr) {
    return ad1 + arr[0] + ad2 + arr[1] + ad3 + arr[0] + ad4;
}
var arr0 = new Array("32532.10000171", "sephora_img/lipfusion_120x90.jpg");
var arr1 = new Array("32532.10000159", "sephora_img/be_120x90.jpg");
var arr2 = new Array("32532.10000147", "sephora_img/jonathan_120x90.jpg");
var arr3 = new Array("32532.10000119", "sephora_img/specials_120x90.gif");
var arr4 = new Array("32532.10000112", "sephora_img/seasonal_120x90.jpg");
var arr5 = new Array("32532.10000108", "sephora_img/seasonal_120x90.jpg");
//var arr6 = new Array("32532.10000010", "sephora_img/brandscroll_120x90.gif");

var theContent = new Array( arr0, arr1, arr2, arr3, arr4, arr5);

/* Specifies the period of time between updates:
    month - once a month
    date - once per every day of the month (repeats the next month)
    weekday - once per every day of the week (repeats the next week)
    hour - once per hour (repeats the next day)
    request - once per browser request (default)
*/

var updatePeriods = new Array("month","date","weekday","hour","request");

// Invoked to display rotated HTML content in a Web page. The period
// argument should be an element of the updatePeriods array.

function displayTheRotatedContent(period) {
 var updatePeriod = -1;
 for(var i=0;i<theContent.length;++i) {
  if(period.toLowerCase() == updatePeriods[i].toLowerCase()) {
   updatePeriod = i
   break
  }
 }
 return (buildAd(selectTheHTML(updatePeriod))+amazon);
}

function selectTheHTML(updatePeriod) {
 var n = 0;
 var max = theContent.length;
 var d = new Date()
 switch(updatePeriod) {
  case 0: // Month (0 - 11)
   n = d.getMonth()
   break
  case 1: // Date (1 - 31 scaled to 0 - 30)
   n = d.getDate() - 1
   break
  case 2: // Weekday (0 - 6)
   n = d.getDay()
   break
  case 3: // Hour (0 - 23)
   n = d.getHours()
   break
  case 4: // Request (Default)
  default:
   n = selectAnyRandom(max)
 }
 n %= max
 return theContent[n]
}

// Select a random integer that is between 0 (inclusive) and max (exclusive)
function selectAnyRandom(max) {
 var r = Math.random()
 r *= max
 r = parseInt(r)
 if(isNaN(r)) r = 0
 else r %= max
 return r

}

