function DisplayPopunder(State,Adname) {
  var aAd = Adname.split("|");
  var aWin = new Array(aAd.length);
  var iNumAd = 1; // aAd.length;
  for( i=0; i<iNumAd; i++ ) {
      WritePopunderCookieAndOpenWin(aAd[i],aWin[i], State, i);
  }
}

function WritePopunderCookieAndOpenWin(sAd,dWindow,State,adnumber) {
  var Height=600,Width=425;TopLeft=20 + (360 * adnumber); // GS-9468
  //var Height=300,Width=720;TopLeft=20 + (360 * adnumber);
  var URL="/cgi-bin/ad_popup";
  var Debug=0;
  var hours=12;
  var numexpDate=new Date();
  numexpDate.setTime(numexpDate.getTime()+(hours * 60 * 60 * 1000));
  var expDate=new Date();
  expDate.setTime(expDate.getTime()+(hours * 60 * 60 * 1000));
  if (document.referrer.indexOf('realestate.yahoo.com') > -1 || document.referrer.indexOf('education.yahoo.com') > -1) {
    document.cookie='NumAd='+adnumber+';expires='+numexpDate.toGMTString()+';path=/';
  }
  if(!HasPopunderCookie('NumAd')) {
    var displayed = 0;
    document.cookie='NumAd=-1;expires='+expDate.toGMTString()+';path=/';
    if(HasPopunderCookie('NumAd=-1')) {
        dWindow=window.open(URL+"?state="+State+"&ad="+sAd,sAd,'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,top='+TopLeft+',left=150,width='+Width+',height='+Height);
        if (dWindow) {
            dWindow.blur();
            window.focus();
            displayed = 1;
        } 
        if (displayed == 1) {
            document.cookie='NumAd='+adnumber+';expires='+numexpDate.toGMTString()+';path=/';
        }
    }
  }
}

function HasPopunderCookie(Junk) {
  var idx=parseInt(document.cookie.indexOf(Junk));
  return(idx>-1);
}
