var flashstatus=0;
var oldflashstatus=0;
var cookieexpiredays=90;


function stopflash(){
 if (flashstatus==1) return;
 flashstatus=1;
 x='<a href=index.asp><img src=gfx/topbara.jpg width=204 height=45 border=0></a><a href=# onClick="startflash(); return false;"><img src=gfx/topbarb.jpg width=562 height=45 border=0></a>';
 changetext('flashdiv',x);
 document.cookie = "noflash=1";
}
function startflash(){
 if (flashstatus==2) return;
 flashstatus=2;
 x='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="766" height="45" id="topflash" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="topflash.swf"><param name="quality" value="high"><param name="bgcolor" value="#ffffff"><embed src="topflash.swf" quality="high" bgcolor="#ffffff" width="766" height="45" name="topflash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
 changetext('flashdiv',x);
 document.cookie = "noflash=0";
}
function setbgimg(obj,img){
 if (document.layers)
  obj.background.src=img.length==0?img:null;
 else if (document.all || document.getElementById)
  obj.style.backgroundImage=img.length>0?'url('+img+')':'none';
}
function togglebgimg(obj,onoff){
 var curimg,newimg='';
 if (document.layers)
  curimg=obj.background.src;
 else if (document.all || document.getElementById)
  curimg=obj.style.backgroundImage;
 if (curimg.substring(curimg.length-1,curimg.length)==')')
  curimg=curimg.substring(4,curimg.length-1);//remove url(...)
 
 switch(curimg){
  case 'vgfxa/rowbg_blue3.gif':
   if (onoff==1) newimg='vgfxa/rowbg_blue2.gif';
   break;
  case 'vgfxa/rowbg_white.gif':
   if (onoff==1) newimg='vgfxa/rowbg_grey.gif';
   break;
  case 'vgfxa/rowbg_red.gif':
   if (onoff==1) newimg='vgfxa/rowbg_red2.gif';
   break;
  case 'vgfxa/rowbg_blue2.gif':
   if (onoff==0) newimg='vgfxa/rowbg_blue3.gif';
   break;
  case 'vgfxa/rowbg_grey.gif':
   if (onoff==0) newimg='vgfxa/rowbg_white.gif';
   break;
  case 'vgfxa/rowbg_red2.gif':
   if (onoff==0) newimg='vgfxa/rowbg_red.gif';
   break;
 }
 if (newimg.length>0)
  setbgimg(obj,newimg);
}
var zdx=10000;
function bringfront(v){
 (v).style.zIndex=++zdx;
}
function changeimg(img,imgfile){
 if (document.images)
  if (document.images[img])
   document.images[img].src = imgfile;
 else
  if (document[img])
   document[img].src = imgfile;
}

function prepjs(x){
 //Handle CR LF \ ' and "
 if (x==null) return;
 return x.replace(/\\/g,'\\\\').replace(/'/g,'\\\'').replace(/"/g,'\\\"').replace(RegExp(String.fromCharCode(10),'g'),'\n').replace(RegExp(String.fromCharCode(13),'g'),'');
}

function prephtml(x){
 if (x==null) return;
 //take non-html string and convert it to html. Handle CR LF <>     //mozilla only does 10 for lf, no cr
 return x.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(RegExp(String.fromCharCode(10),'g'),'<br\>').replace(RegExp(String.fromCharCode(13),'g'),'');
}

function deprephtml(x){
 if (x==null) return;
 return x.replace(RegExp('<br\>','ig'),String.fromCharCode(13)+String.fromCharCode(10)).replace(RegExp('&lt;','ig'),'<').replace(RegExp('&gt;','ig'),'\>').replace(RegExp('&quot;','ig'),'\>').replace(RegExp('&nbsp;','ig'),' ').replace(RegExp('&amp;','ig'),'&');
}

function mydateformat(d){
 if (!isdate(d))
  return '';
 if (!isNaN(Date.parse(d)))
  d=new Date(d);
 else
  d=new Date(d.toUpperCase().replace('PM',' PM').replace('AM',' AM').replace(/[\,\.\-\\]/g,'/'));
 return (d.getMonth()+1) +'-'+ d.getDate() +'-'+ d.getFullYear();
}

function mytimeformat(d){
 if (!isdate(d))
  return '';
 if (!isNaN(Date.parse(d)))
  d=new Date(d);
 else
  d=new Date(d.toUpperCase().replace('PM',' PM').replace('AM',' AM').replace(/[\,\.\-\\]/g,'/'));
 var h=d.getHours();
 var m=(d.getMinutes()<=9)?'0'+d.getMinutes():d.getMinutes();
 var ampm=(h>12)?'PM':'AM';
 h=(h>12)?h-12:h;
 h=(h==0)?12:h;
 return h+':'+m+' '+ampm;
}

function mydatetimeformat(d){
 if (!isdate(d))
  return '';
 return mydateformat(d)+' '+mytimeformat(d);
}

function isdate(d){
 d=(d==null)?'':d;
 if (!isNaN(Date.parse(d)))
  return true;
 d=d.toUpperCase().replace('PM',' PM').replace('AM',' AM').replace(/[\,\.\-\\]/g,'/');
 return (!isNaN(Date.parse(d)));
}

function mytrim(x) { 
 var c9=String.fromCharCode(9);
 var c10=String.fromCharCode(10);
 var c13=String.fromCharCode(13);
 while (x.substring(0,1)==' ' || x.substring(0,1)==c9 || x.substring(0,1)==c10 || x.substring(0,1)==c13) 
  x = x.substring(1, x.length);
 while (x.substring(x.length-1,x.length)==' ' || x.substring(x.length-1,x.length)==c9 || x.substring(x.length-1,x.length)==c10 || x.substring(x.length-1,x.length)==c13)
  x = x.substring(0, x.length-1);
 return x;
} 

function qfix(x){
 if (x==null)
  return 0;
 var n=x.toString().replace(RegExp('[^0-9\-.]','g'),'')*1;
 if (isNaN(n)) n=0;
 return n;
}

var guoc_clickedother=false;
function gourlonclick(url){
 if (guoc_clickedother){
  guoc_clickedother=false;
  return;
 }
 gourl(url);
}

var alreadyclicked=false;
function clickonce(){
 if (!alreadyclicked){
  alreadyclicked=true;
  return true;
 }
 return false;
}

function getcookie(cookiename){
 if (document.cookie.length<=0) return "";
 var pos1=document.cookie.indexOf(cookiename + "=");
 if (pos1!=-1){ 
   pos1=pos1 + cookiename.length+1 
   pos2=document.cookie.indexOf(";",pos1)
   if (pos2==-1) pos2=document.cookie.length
   return unescape(document.cookie.substring(pos1,pos2))
 } 
}

function setcookie(cookiename,value,days){
 days=(days==null)?cookieexpiredays:days;
 var expires=new Date();
 expires.setDate(expires.getDate()+days);
 document.cookie=cookiename+ "=" +escape(value)+";expires="+expires.toGMTString();
}


//are used to monitor speeds of javascript effects
var sd_maxstrikes=3;//if more than this per page then set cookie to never use fx on this computer
var sd_strikes=new Array(0,0);
var sd_dofx=new Array(true,true);
var sd_ccfx=new Array(false,false);
var this_ms=0;
function dofx(fxcategory){
 if (!sd_ccfx[fxcategory]){
  var doit=qfix(getcookie('sd'+fxcategory));//1||mt=do. 2=dont
  sd_dofx[fxcategory]=true;
  if (doit==2)
   sd_dofx[fxcategory]=false;
 }
 return sd_dofx[fxcategory];  
}
function setfx(ison,fxcategory){
 setcookie('sd'+fxcategory,(ison)?1:2,5);//allows another attempt 5 days later
 dofx[fxcategory]=ison;
}
function getspeeddiff(){
 var d=new Date();
 var diff=d.getTime()-this_ms;
 this_ms=d.getTime();
 return diff;
}
function handlespeeddiff(maxmilliseconds,fxcategory){
 var dif=getspeeddiff()-maxmilliseconds;
 if (dif>0){//effect was too slow
  sd_strikes[fxcategory]+=1+dif/maxmilliseconds;
  if (sd_strikes[fxcategory]>sd_maxstrikes)
   setfx(false,fxcategory);
 }
}
getspeeddiff();
