// $Revision: 1.5 $

var mdocsID=-1, mdocsLength=5*1000, mdocs_pos=-1;
var elem_mdocs_promo_img, elem_mdocs_promo_href; 
var mdocsPromotions = [
                        [ 'http://www.webshots.com/r/Premium/sitewide/dlunlimited/anon', 'http://www.webshots.com/r/Premium/sitewide/dlunlimited/signedup', 'Webshots Premium - Download unlimited photos!'],
                        [ 'http://www.webshots.com/r/mdocs/sitewide/hirespromo/anon', 'http://www.webshots.com/r/mdocs/sitewide/hirespromo/signedup', 'FREE Premium Access - Get 4 of our highest-resolution downloads. FREE!'],
                        [ 'http://www.webshots.com/r/Premium/sitewide/entirepages/anon', 'http://www.webshots.com/r/Premium/sitewide/entirepages/signedup', 'Webshots Premium - Download entire pages of photos in one click!'],
                        [ 'http://www.webshots.com/r/Premium/sitewide/noads/anon', 'http://www.webshots.com/r/Premium/sitewide/noads/signedup', 'Upgrade to Premium - Surf Webshots with no distracting ads!'],
                        [ 'http://www.webshots.com/r/Premium/sitewide/photostorage/anon', 'http://www.webshots.com/r/Premium/sitewide/photostorage/signedup', 'Upgrade to Premium - Get 12x more personal photo storage!']
                      ];
                        
function MDocsInit()
{
  if(document.getElementById)
  { 
  	elem_mdocs_promo_img  = document.getElementById("mdocsPromoIMG"); 
  	elem_mdocs_promo_href = document.getElementById("mdocsPromoHREF");
  }
  else if (document.mdocsPromoIMG)
  { 
  	elem_mdocs_promo_img  = document.mdocsPromoIMG; 
  	elem_mdocs_promo_href = document.mdocsPromoHREF;
  }
  else if (document.all && document.all.mdocsPromoIMG)
  {
    	elem_mdocs_promo_img  = document.all.mdocsPromoIMG;
    	elem_mdocs_promo_href = document.all.mdocsPrompHREF;
  }
  SetMDocsTimeout();
}

function SwapMDocsPromotion()
{
  if (elem_mdocs_promo_img && elem_mdocs_promo_href)
  {
	if (mdocs_pos < 0)
	{
      if (Math.random)
		mdocs_pos = Math.round(Math.random() * (mdocsPromotions.length - 1));
    }
    mdocs_pos = (mdocs_pos+1) % mdocsPromotions.length;

  	elem_mdocs_promo_img.innerText   = mdocsPromotions[mdocs_pos][2];
  	if (document.cookie.indexOf("daily=") >= 0)
	  	elem_mdocs_promo_href.href = mdocsPromotions[mdocs_pos][1];
	else
	  	elem_mdocs_promo_href.href = mdocsPromotions[mdocs_pos][0];		
   }
  SetMDocsTimeout();
}

function SetMDocsTimeout()
{
	mdocsID = setTimeout("SwapMDocsPromotion()", mdocsLength);
}

function GetMDocsPromotion()
{
  if (mdocs_pos < 0)
  { 
    if (Math.random)
	 mdocs_pos = Math.round( Math.random() * (mdocsPromotions.length - 1 ));
  }
  // Older browsers will not rotate except on page refresh
  var href;
  if (document.cookie.indexOf("daily=") >= 0)
  	href = mdocsPromotions[mdocs_pos][1];
  else
	href = mdocsPromotions[mdocs_pos][0];		

  var str = "<img src='http://p.webshots.com/img/mdocs/star_bl_9x10.gif' height=10 width=9 hspace=3 align=middle><a class='wl' ";
  str += "id='mdocsPromoHREF' name='mdocsPrompHREF' href='" + href + "'><font face=verdana size=1><b>";
  str += "<span id='mdocsPromoIMG' name='mdocsPrompIMG'>" + mdocsPromotions[mdocs_pos][2]+"</span></b></font></a>";
  return str;
}

if (!Premium)
{
	document.write(GetMDocsPromotion());
	MDocsInit();
}
