function checkSearchTerm(ref,act){
	var SE=new Array("altavista.|&q=","yahoo.|p=|p1=","google.|&q=|q=",
			"netfind.aol|search=","arch.aol|query=","arch.msn|MT=");
	var ret="",ST="";
	for(i=0;i<SE.length;i++){
		sp=SE[i].split("|");
		if (ref.indexOf(sp[0])>-1){
			if ((j=ref.indexOf(sp[1]))>5) ST=ref.substring(j+sp[1].length);
			else if (sp.length==3 && (j=ref.indexOf(sp[2]))>5) ST=ref.substring(j+sp[2].length);
			break;
		}
	}
	if (ST){
		if ((j=ST.indexOf('&'))>3) ST=ST.substring(0,j);
		if ((j=ST.indexOf(';'))>3) ST=ST.substring(0,j);
		if ((j=ST.indexOf('/'))>3) ST=ST.substring(0,j);
		if (ST.length>24) ST=ST.substrinf(0,24);
		act+=".S:"+ST;
  		// analyze ref for keywords in order to set the banner to show; 
  		// if require, overide the default site id (sin)
		ret=act+"|more|";
	}
	return(ret);
}


function ost54(act,ban,sin){
  var ref=document.referrer;
  var c,visit=1,mode='U',sec,i,a,l='A',look4,D,O,Img=new Image; 
  if((i=act.indexOf(':'))>1) { a=act.substring(0,i); l=act.charAt(i+1); } else a=act;
  actPlus=a;
  if (ref.indexOf('=')>5) if (cst=checkSearchTerm(ref,a)){
	  sp=cst.split("|");
	  actPlus=sp[0];
  }

  sp=ban.split("|");
  url="http://in.ff5.com/cgi-bin/igc.cgi/"+sp[2+1*sin]+"/"+actPlus+"/"+l+"?b"+sp[0];
  if (sp[1].charAt(0)=='.') u="image"+sp[1].substring(1); else u=sp[1];
  document.write("<a href='"+url+"'><img src='http://"+u+"' border=0 "+
	"alt='Too hard to show it all... click to see more'></a>");
  look4=a+"_"+l+"VISIT=";
  D=new Date(); O=new Date(2002,10,6);
  sec=parseInt((D.getTime()-O.getTime())/1000)
  if (document.cookie){
    if ((i=document.cookie.indexOf(look4))>-1){
      c=document.cookie.substring(i+look4.length);
      if ((i=c.indexOf(':'))>-1) {
        last=c.substring(0,i); visit=parseInt(c.substring(i+1))+1;
      } else last=parseInt(c);
      if (sec-last>60) mode='T'; else if(sec-last>30) mode='L'; else mode='F';
    }
  } 
  if (typeof screen=='object') msg=''+screen.width+'x'+screen.height+'&'+screen.colorDepth; 
  else msg='--&0';
  msg+="&"+mode+visit+"&b"+sp[0];
  Img.src="http://cashcount.com/cgi-bin/hits/log.cgi/empty?"+a+"&"+l+"&"+ref+"]"+msg;
  O=new Date(D.getTime()+86400100);
  document.cookie=look4+sec+":"+visit+"; path=/; expires="+O.toGMTString();
}

function findMe(a,val){
  for(i=0;i<a.length;i++) if (a[i].indexOf(val)==0) return(a[i]);
  return (false);
}
function o54(act,sin,type,ban){
var BUT=new Array("2565|..crotchphotos.com/banners/free/buttons/120x60_01a.gif|3262|3263",
	"2566|..crotchphotos.com/banners/free/buttons/120x60_02a.gif|3262|3263",
	"2567|..crotchphotos.com/banners/free/buttons/120x60_03a.gif|3262|3263");
var HRZ=new Array("2538|..crotchphotos.com/banners/free/horizontal/468x60_01a.gif|3262|3263",
	"2539|..crotchphotos.com/banners/free/horizontal/468x60_02a.gif|3262|3263",
	"2540|..crotchphotos.com/banners/free/horizontal/468x60_03a.gif|3262|3263",
	"2541|..crotchphotos.com/banners/free/horizontal/468x80_01a.jpg|3262|3263",
	"2542|..crotchphotos.com/banners/free/horizontal/468x80_02a.jpg|3262|3263",
	"2543|..crotchphotos.com/banners/free/horizontal/468x80_03a.jpg|3262|3263",
	"2547|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_1_bl.gif|3262|3263",
	"2548|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_2_gn.gif|3262|3263",
	"2549|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_3_y.gif|3262|3263",
	"2550|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_4_bk.gif|3262|3263",
	"2551|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_5_gy.gif|3262|3263",
	"2552|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_6_bk.gif|3262|3263",
	"2553|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_7_p.gif|3262|3263",
	"2554|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_8_w.gif|3262|3263",
	"2555|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_9_r.gif|3262|3263",
	"2556|..crotchphotos.com/banners/free/horizontal_text/crotchphotos_10_w.gif|3262|3263");
var VER=new Array();
var OTH=new Array("823|11zz.com/i/vmi/cphoto/cphoto_fpa1.jpg|3262|3263",
	"824|11zz.com/i/vmi/cphoto/cphoto_fpa2.jpg|3262|3263",
	"2557|..crotchphotos.com/banners/free/odd/100x100_01a.gif|3262|3263",
	"2558|..crotchphotos.com/banners/free/odd/100x100_02a.gif|3262|3263",
	"2559|..crotchphotos.com/banners/free/odd/100x100_03a.gif|3262|3263",
	"2563|..crotchphotos.com/banners/free/odd/150x150_01a.gif|3262|3263",
	"2564|..crotchphotos.com/banners/free/odd/150x150_02a.jpg|3262|3263",
	"824|11zz.com/i/vmi/cphoto/cphoto_fpa2.jpg|3262|3263");
  b=b1=false;
  if (ban){
    b1=""+ban+"|";
    if ((b=findMe(BUT,b1))==false) if ((b=findMe(HRZ,b1))==false)
    if ((b=findMe(VER,b1))==false) b=findMe(OTH,b1);
  } 
  D=new Date; j=Math.floor(D.getTime()/100);
  if (b && j%10<6) b1=b; // 60% of the time override with request banner
  else {
    b1=false;
    if (type==1) { i=j%BUT.length; b1=BUT[i]; }
    else if (type==2) { i=j%HRZ.length; b1=HRZ[i]; }
    else if (type==3) { i=j%VER.length; b1=VER[i]; }
    if (!b1) { i=j%OTH.length; b1=OTH[i]; }
  }
  ost54(act,b1,sin);
}
