
function update_p3stats(cat,site,lid,company){
document.images['stats'].src = '/p3stats.asp?cat=' + cat + '&site=' + site + '&lid=' + lid + '&company=' + encodeURIComponent(company)
}

function update_sponstats(cat,site,cattype,lid){
document.images['stats'].src = '/sponstats.asp?cat=' + cat + '&site=' + site + '&cattype=' + cattype + '&lid=' + lid
}

function submitsearch() {

document.searchform.locsearch.value = document.searchform.locsearch.value.replace(/^\s*|\s*$/g,'')

if (document.searchform.locsearch.value != '' && document.searchform.locsearch_old.value != document.searchform.locsearch.value)
 {
 document.searchform.action = '../locationdirect.asp' 
 document.searchform.submit() 
 }
else
 {
 if (document.searchform.catsearch.value == '' && document.searchform.linksearch.value != '')
  {
  document.searchform.action = 'sitesearch.asp'
  document.searchform.submit()
  }
 }
if (document.searchform.catsearch.value != document.searchform.catsearch_old.value || document.searchform.catsearch.value == '')
 {
 document.searchform.submit()
 }

}

function srchOnEnter(event){ 
 var code = 0;
 code = event.keyCode;
 if (code==13)
  submitsearch()
}

function initcat(){
 if (document.searchform.linksearch.value != ""){
  document.searchform.catsearch.value = ""
 }
}

function initlink(){
 if (document.searchform.catsearch.value != ""){
  document.searchform.linksearch.value = ""
 }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function startScrollingDetector(){
var pos = findPos("movingimage")
starttop = pos[0]
startleft = pos[1]
var footer_pos = findPos("footerline")
footertop = footer_pos[0]
footerleft = footer_pos[1]
setInterval("scrollingDetector(starttop,startleft,footertop)", 500);
}

function findPos(el) {
obj = document.getElementById(el)
var curtop = 0
var curleft = 0
if(obj.offsetParent){
do{
curtop += obj.offsetTop
curleft += obj.offsetLeft
}while (obj=obj.offsetParent)
return[curtop, curleft]
}
}
	
function scrollingDetector(starttop, startleft, footertop){
var pos = findPos("movingimage")
currentpos = pos[0]
windowheight = GetHeight()

if(document.documentElement&&document.documentElement.scrollTop){
scrollval = document.documentElement.scrollTop
}else if(document.body&&document.body.scrollTop){
scrollval = document.body.scrollTop
}else if (window.scrollY){
scrollval = window.scrollY
}else{
scrollval = 0
}

if(scrollval>currentpos){
maxpos = footertop-640

if(maxpos>starttop){
newtop = scrollval + 5

if(newtop>maxpos){
newtop = maxpos
}

moveit_down(currentpos, newtop, startleft)
}
}else if(scrollval>starttop){
moveit_up(currentpos, (scrollval + 5), startleft)
}else if(currentpos>starttop){
moveit_up(currentpos, starttop, startleft)
}

}

function GetHeight(){
var y = 0;
if (self.innerHeight){
y = self.innerHeight;
}else if (document.documentElement && document.documentElement.clientHeight){
y = document.documentElement.clientHeight;
}else if(document.body){
y = document.body.clientHeight;
}
return y
}

function moveit_up(a,b,c){

var picture=document.getElementById("movingimage").style;
picture.position = 'absolute'
//var pos = findPos("movingimage")
//c = pos[1]
//picture.left = c + 'px'
if(a>b){
picture.top = a + 'px';
a = a - 10
setTimeout('moveit_up('+a+','+b+','+c+')',1);
}else{
picture.top = b + 'px'
}      

}

function moveit_down(a,b,c){

var picture=document.getElementById("movingimage").style;
picture.position = 'absolute'
//var pos = findPos("movingimage")
//c = pos[1]
//picture.left = c + 'px'
if(a<b){
picture.top = a + 'px';
a+=10;
setTimeout('moveit_down('+a+','+b+','+c+')',1);
}else{
picture.top = b + 'px'
}

}

function azfilterOnEnter(event){ 
 var code = 0;
 code = event.keyCode;
 if (code==13)
  submitazfilter()
}
function submitazfilter(){
document.atozform.submit()
}

