//  The billboard ad product only works on a PC on the following browsers: IE 5.5+, Mozilla
//  Firefox, and Netscape 7.1.  This script needs to appear below the body tag.  Failing to do
//  so will result in lots of nasty javascript errors.  
//  sja 12/14/04
var doLocal = false;
var nonRegistered = true;
// see if the user is local
if ( ( startAt = document.cookie.indexOf( 'WPATC' ) ) != -1 )
{
  endAt = document.cookie.indexOf( ';', startAt ) == -1 
        ? document.cookie.length 
        : document.cookie.indexOf( ';', startAt );
  var tempWPATC = document.cookie.substring( startAt + 6, endAt );
  doLocal = ( tempWPATC.indexOf('C=1') != -1 );
  nonRegistered = false;
}


showBillboard = false;

function dateToString(date) {
	var yyyy = date.getYear();
	var mm = date.getMonth() + 1;
	var dd = date.getDate();
	var hour = date.getHours();
	var min = date.getMinutes();

	if (mm < 10) mm = "0"+mm;
	if (dd < 10) dd = "0"+dd;
	if (hour < 10) hour = "0"+hour;
	if (min < 10) min = "0"+min;
	return ''+mm+dd+hour+min;
}

function getDay(today) {return today.getDay()}

var today = new Date();
var now = dateToString(today);

switch (thisNode) {
// Node specific billboard information begins here
// All subsequent conditions should be in the form of an else if statement
// Variable Definitions:
// billboard_kw = Doubleclick key value that is supplied by the Account Mananger.
// billboard_site = Doubleclick site for the advertisement.
// billboard_linktext = Linked text that appears in popup window
// billboard_url = Click through URL that appears in popup window.
// showBillboard = A true condition activates billboard in that node.
//Converted to JS Switch conditional 5/12/2005 - JLH

case 'artsandliving/travel': 
	if (now >= "05170000" && now <= "05222359") {
	billboard_kw = 'asheville_760';
	billboard_url = 'http://exploreasheville.com/ashevilledeals.asp';
	billboard_linktext = 'Asheville CVB';
	billboard_site = 'travel';
	showBillboard = true;	
	}
	 break


case 'business': 
	if (now >= "05160000" && now <= "05162359") {
	billboard_kw = 'gwu_biz';
	billboard_url = 'https://www.gwu.edu/~survey/index.cfm?SURVEY_ID=5464';
	billboard_linktext = 'George Washington University';
	billboard_site = 'business';
	showBillboard = true;	
	}
	 break

case 'metro/traffic': 
	if (now >= "05160000" && now <= "05302359") {
	billboard_kw = 'vdrpt';
	billboard_url = 'http://www.dullesmetro.com';
	billboard_linktext = 'Dulles Corridor Metrorail Project';
	billboard_site = 'metro';
	showBillboard = true;	
	}
	 break
	 
	 
case 'education': 
	if ((now >= "05060000" && now <= "05071000")||(now >= "05090000" && now <= "05092359")) {
	billboard_kw = 'jhu_760';
	billboard_url = 'http://www.jhu.edu/advanced';
	billboard_linktext = 'Johns Hopkins University';
	billboard_site = 'education';
	showBillboard = true;	
	}
	 break

case 'artsandliving': 
	if (now >= "05090000" && now <= "05152359") {
	billboard_kw = 'corcoran_arts';
	billboard_url = 'http://www.corcoran.edu/corcoran/index.asp';
	billboard_linktext = 'Corcoran College of Art & Design';
	billboard_site = 'artsandliving';
	showBillboard = true;
	}
	 break

case 'cars': 
	if (now >= "05010000" && now <= "05072359") {
	billboard_kw = 'scion';
	billboard_url = 'http://www.scion.com/';
	billboard_linktext = 'Toyota Scion';
	billboard_site = 'cars';
	showBillboard = true;
	}
	 break

case 'sports': 
	if (now >= "05130000" && now <= "05132359") {
	billboard_kw = 'sportspassport_760';
	billboard_url = 'http://www.passportbmw.com/';
	billboard_linktext = 'Passport BMW';
	billboard_site = 'sports';
	showBillboard = true;
	}
	 break

default:  
}

// End individual billboard logic
// There is no need to edit past this point
//********************************
if (showBillboard) {
_b = '';
_r = Math.floor(Math.random() * 1000000);
ie = navigator.appName.toLowerCase().indexOf("explorer") != -1;
pc = navigator.userAgent.toLowerCase().indexOf("windows") != -1;



_b += '<div style="width:1024px;" id="_fB"><div style="float:left;padding-left:10px;">';

if (ie && pc) _b += '<a href="javascript:wPostCloseSticky()">';
else if (!ie && pc) _b += '<a href="javascript:wPostCloseStickyMozilla()">';

_b += '<img src="http://media.washingtonpost.com/wp-srv/javascript/common/ads/xbox.gif" border="0"></a><br><a href="javascript:buildPopup()"><img src="http://media.washingtonpost.com/wp-srv/javascript/common/ads/aboutad.gif" border="0"></a></div><div style="width:760px;float:left;"><iframe src="http://ad.doubleclick.net/adi/wpni.'+billboard_site+'/;kw='+billboard_kw+';sz=760x60;ord='+_r+'?" width="760" height="60" frameborder="no" border="0" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no"></iframe></div></div>';


if (ie && pc) {
var _g =new formatObject();

_g.mainAdWidth = "760";//"200";
_g.mainAdHeight ="68";
_g.showHeight="0";

_g.getInnerContent=getContent_2;
_g.wPostInitMedia=wPostInitMedia_2;
_g.wPostInitFormat=wPostInitFormat;
_g.mainReff=4;
_g.mainAdLeft="0";
_g.mainAdTop="0";

_g.origAdTop=_g.mainAdTop;
_g.origAdLeft=_g.mainAdLeft;
_g.origAdWidth=_g.mainAdWidth;
_g.origAdHeight=_g.mainAdHeight;

_g.doOnload=wPostDoNothing;
_g.sendOut=wPostDoNothing;
_g.sendOver=wPostDoNothing;
_g.sendClick=wPostMainClick;
if(typeof(TheWindow)=="undefined")
	  TheWindow=window;
function wPostDoNothing()
{
  return false;
}	  
function wPostMainClick()
{
  window.open(_g.main_creative_link,"_blank");
}
function wPostGetTagObj(tagId)
{
       var tagObj;
	 tagObj=eval("TheWindow.document.all."+tagId);
	  return tagObj;
}
var wPostOldLoadEvent=document.body.onload;
TheWindow.document.body.onload=wPostLoadEvent;
function wPostLoadEvent()
{
	
  	if(wPostOldLoadEvent)
		wPostOldLoadEvent();
   _g.doOnload();		
}
function formatObject()
{
  this.VAR100=100;
  this.VARRESIZE=100;
  this.VARCENTER=2;
  this.CENTER=1;
  this.UPPER_LEFT=2;
  this.UPPER_RIGHT=3;
  this.LOWER_LEFT=4;
  this.LOWER_RIGHT=5;
  
  this.mainAdAddress;
  this.mainAdWidth;
  this.mainAdHeight;
  this.mainAdID;
  this.mainContId;
  this.mainContInner;
  this.mainReff;
  this.mainAdLeft;
  this.mainAdTop;
  this.getContainerObj=getContainerObj;
  this.wPostGenInner=wPostGenInner;
  this.wPostInitRmmCamp=wPostInitRmmCamp;
  this.wPostInitIframeParams=wPostInitIframeParams;
  //this.wPostMainPosition=wPostMainPosition;
  this.writewPostDivs=writewPostDivs;
 
}
function getContainerObj()
{
  return eval("TheWindow.document.all."+this.mainContId);
}

function checkScreenSize()
{
  setTimeout("_g.wPostMainPosition()",20);
}

function wPostGenInner()
{

   this.mainAdLeft=encodeFixToScript(this.mainReff,this.mainAdLeft,this.mainAdWidth,true);

   this.mainAdTop=encodeFixToScript(this.mainReff,this.mainAdTop,this.mainAdHeight,false);
   this.mainAdHeight=encodeSizeToScript(this.mainAdHeight,true);
   this.mainAdWidth=encodeSizeToScript(this.mainAdWidth,false);
   this.mainAdInner=this.getInnerContent( this.mainAdAddress,eval(this.mainAdWidth),eval(this.mainAdHeight),this.mainAdID,"");
   
     this.getContainerObj().innerHTML=this.mainAdInner;
	this.wPostMainPosition();
	 
}
function wPostInitRmmCamp()
{
  this.wPostInitIframeParams();
  TheWindow.onresize = checkScreenSize;
  
  this.wPostInitFormat();
  

}
function wPostWriteAdjacent(visibilityStr,divId)
{
  var divStr = "<div id='"+divId+"' style='text-align: left;z-index:100;visibility:"+visibilityStr+";position:absolute;cursor:auto'> </div>";
  TheWindow.document.body.insertAdjacentHTML("afterBegin" , divStr);  
}
function writewPostDivs(visibilityStr)
{
  this.mainAdID ="wPostAdId_"+_g.adIframe;
  this.mainContId="wPostContId_"+_g.adIframe;
  wPostWriteAdjacent(visibilityStr,this.mainContId) ;
  document.getElementById(this.mainContId).style.backgroundColor = '#003366';
  document.getElementById(this.mainContId).style.paddingTop = 2 + 'px';
  document.getElementById(this.mainContId).style.paddingBottom = 6 + 'px';
}
function wPostInitIframeParams()
{

	this.parentIndex=-1;
	if(TheWindow!=window)
	{
		if(typeof(parent.innerWin)=="undefined")
		{
			parent.innerWin=new Array();
		}
		this.parentIndex=parent.innerWin.length;
		parent.innerWin[this.parentIndex]=window;
	}
	this.adIframe="";
	this.prefix="";
	if(this.parentIndex!=-1)
	{
	  this.adIframe="_"+this.parentIndex;
	  this.prefix="innerWin["+this.parentIndex+"].";
	  
	}  
}

function encodeSizeToScript(size,bIsX)
{
  if(size.indexOf("%") > 0)
  {
   size=size.substring(0,size.length-1);
   if(bIsX)
   {   
      size = " ( TheWindow.document.body.clientWidth * ( " + size + " / _g.VAR100 ) ) " ;
   }
   else
   {
      size = " ( TheWindow.document.body.clientHeight * ( " + size + " / _g.VAR100 ) ) ";
   }
  }
  //prompt("",eval(size));
  return eval(size);
  
}
function encodeFixToScript(fixReferance,size,imageSize,bIsX)
{
  var dest,offset;
  fixReferance=eval(fixReferance);
  
  dest=encodeSizeToScript(size,bIsX);
  
  var imageResize=100;
  if(imageSize.indexOf("%") > 0)
  {
    offset=imageSize.substring(0,imageSize.length-1);
    if(bIsX)
    {
       offset = "( ( TheWindow.document.body.clientWidth * ( " + offset + " / _g.VARRESIZE ) )  * ( " + imageResize + " / _g.VARRESIZE ) )";
    }
    else
    {
       offset = "( ( TheWindow.document.body.clientHeight * ( " + offset + " / _g.VARRESIZE ) ) * ( " + imageResize + " / _g.VARRESIZE ) )"
    }
  }
  else
  {
   offset = "( ( " + imageResize + " / _g.VARRESIZE ) * " + imageSize + " )"
  }

  switch(fixReferance)
  {
   case _g.UPPER_LEFT:
     return dest;
	 
   break;
   case _g.UPPER_RIGHT:
    if(bIsX)
	{
 	 return "TheWindow.document.body.clientWidth - ( " + "( " + "0" + " * _g.UPPER_RIGHT )" + " ) - " + offset + " - 2 - "+dest;
	}
	else
	{
	 return dest;
	}
   break;
   case _g.LOWER_LEFT:
    if(bIsX)
	{
	 return  dest + " - 2";
	}
	else
	{
	 return "TheWindow.document.body.clientHeight - ( " + "( " + "0" + " * _g.LOWER_LEFT )" + " ) - " + offset+" - "+dest;
	}
   break;
   case _g.LOWER_RIGHT:
     if(bIsX)
	{
	 return "TheWindow.document.body.clientWidth - ( " + "( " + "0" + " * _g.LOWER_RIGHT )" + " ) - " + offset + " - 2 - "+dest;
	}
	else
	{
	 return "TheWindow.document.body.clientHeight - ( " + "( " + "0" + " * _g.LOWER_RIGHT )" + " ) - " + offset + " - 2 - "+dest;
	}
   break;
   case _g.CENTER:
     if(bIsX)
	{
	 return "( TheWindow.document.body.clientWidth / _g.VARCENTER ) + ( " + "( " + "0" + " * _g.CENTER )" + " ) - ( ( " + offset + " ) / _g.VARCENTER ) +"+dest;
	}
	else
	{
	 return "( TheWindow.document.body.clientHeight / _g.VARCENTER ) + ( " + "( " + "0" + " * _g.CENTER )" + " ) - ( ( " + offset + " ) / _g.VARCENTER ) +"+dest;
	}
   break;
  }
  
  return size;
}

function wPostInitMedia_2()
{
// removed	
}
function getContent_2()
{    
    var retStr = _b;
	return _b;
}

function doStickiness()
{

  docurl = document.location.href;
  orbit = docurl.indexOf("content") != -1?true:false;
  if (orbit) {
  TheWindow.document.body.style.overflow='hidden';
  TheWindow.document.body.style.padding= document.body.style.padding;
  TheWindow.document.body.style.marginRight= document.body.style.marginRight;
  TheWindow.document.body.style.marginLeft = document.body.style.marginLeft - 1 + "px";
  TheWindow.document.body.style.marginTop = document.body.style.marginTop;
  TheWindow.document.body.style.marginBottom = document.body.style.marginBottom;
  }
  else {
  
  TheWindow.document.body.style.overflow='hidden';
  TheWindow.document.body.style.padding='0px';
  TheWindow.document.body.style.marginRight='0px';
  TheWindow.document.body.style.marginLeft = '2px';
  TheWindow.document.body.style.marginTop = '2px';
  
  if (thisNode != 'homepage') {
  if (thisNode == 'cars/vendor') {
  TheWindow.document.body.style.marginLeft = '2px';
  TheWindow.document.body.style.marginTop  = '2px';
  }
  else {
  TheWindow.document.body.style.marginLeft = '10px';
  TheWindow.document.body.style.marginTop = '0px';
  }
  }
  
  }

  
  var oNewNode = document.createElement("div");
  oNewNode.id="overAllDiv";
  oNewNode.style.width="100%";

  oNewNode.style.position="absolute";
  oNewNode.style.overflow="auto";
  oNewNode.style.overflowY="scroll";


  document.body.applyElement(oNewNode,"inside");
  _g.currentHeight=0;



}
function wPostCloseSticky()
{
 TheWindow.document.all.overAllDiv.style.height="100%";

  wPostGetTagObj(_g.mainContId).innerHTML="";
 wPostGetTagObj(_g.wPostCloseDivId).innerHTML="";
}
function wPostOverAllDivPos()
{
//alert(_g.origAdWidth);
clearTimeout(_g.stickyTimeoutHndl);
 _g.mainAdLeft=encodeFixToScript(_g.LEFT,_g.origAdLeft,_g.origAdWidth,true);
//alert(_g.mainAdLeft); 
if(_g.currentHeight>=_g.mainAdHeight)
  _g.currentHeight=_g.mainAdHeight+1;
document.all.overAllDiv.style.height=TheWindow.document.body.clientHeight-parseInt(_g.currentHeight);
eval("TheWindow.document.all."+_g.mainContId+".style.clip ='rect("+(eval(_g.mainAdHeight)-_g.currentHeight)+" auto auto 0)'");
if(_g.currentHeight<_g.mainAdHeight)
 {
   _g.currentHeight+=4;
   _g.stickyTimeoutHndl=setTimeout("wPostOverAllDivPos()",60);
 } 
 else
 {
   //alert(wPostGetTagObj(_g.mainAdID).getBoundingClientRect().left);
 //alert(wPostGetTagObj(_g.mainContId).getBoundingClientRect().left);
  wPostGetTagObj(_g.wPostCloseDivId).style.pixelTop=eval(_g.mainAdTop);
  wPostGetTagObj (_g.wPostCloseDivId).style.pixelLeft=eval(_g.mainAdLeft)+eval(_g.mainAdWidth);
 }
 
}

function wPostStickyPos()
{
  wPostOverAllDivPos();
  this.getContainerObj().style.pixelTop=eval(this.mainAdTop);
  this.getContainerObj().style.pixelLeft=eval(this.mainAdLeft);
  
  
 
  
}
function wPostStickyLoad()
{
  doStickiness();
  _g.writewPostDivs("visible");
  _g.wPostCloseDivId="wPostCloseDiv";

  
  wPostWriteAdjacent("visible",_g.wPostCloseDivId);
  _g.wPostGenInner();  
  wPostOverAllDivPos();
}
function wPostInitFormat()
{
  _g.wPostInitMedia();
}   
_g.wPostMainPosition=wPostStickyPos;
_g.doOnload=wPostStickyLoad;
_g.wPostInitRmmCamp();
}

else if (pc) {
function wPostCloseStickyMozilla() {
document.body.style.marginBottom = '0px';
_bObj.style.display = 'none';


}

document.write(_b);
_bObj = document.getElementById("_fB");
_bObj.style.backgroundColor = '#003366';
_bObj.style.zIndex = 1000;
_bObj.style.paddingTop = 2 + 'px';
_bObj.style.paddingBottom = 6 + 'px';
_bObj.style.position = 'fixed';
_bObj.style.bottom = 0;
_bObj.style.left = 0;
document.body.style.marginBottom = '68px';
}

else {
null;
}

function buildPopup() {
var pU = window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no,width=500,height=245,left=150,top=200,screenX=150,screenY=200');
pU.document.open('text/html');
pU.document.write('<html> <title>About this Ad</title> <head></head> <body bgcolor="#CCCCCC" topmargin="0" marginheight="0" leftmargin="0" marginwidth="0"> <table width="500" cellpadding="10" cellspacing="0" border="0"><tr><td><font face="verdana" size="-2"><b>About this Ad</b><br> This ad is called a "billboard," and it is intended to present a compelling message from one of our quality advertisers. We have worked hard to make certain that the ad does not disrupt your experience on washingtonpost.com ? in fact, you can close the ad altogether by simply clicking on the "x" in the upper left-hand corner of the ad. <p> washingtonpost.com is able to deliver the highest quality news and information thanks in large part to businesses and organizations that choose to advertise on our site. Innovative advertising vehicles like this billboard are an important part of our ability to bring you the very best in news and information.<p><p><a href="'+billboard_url+'" target="_new">'+billboard_linktext+'</a><p><a href="http://www.washingtonpost.com/wp-srv/admin/help/popup/ask_pop_up.html" target="_blank">Contact Us</a><p><a href="javascript:window.close();">Close window</a></font></td></tr></table>');
pU.document.close();
}

}
