var ok, topact=0, topimgs=new Array();
function getObject(s){
 return document.getElementById?document.getElementById(s):document.all(s);
}
function keepAlive(){
 (new Image()).src = "alive.php?id="+Math.random();
 setTimeout("keepAlive()",600000);
}
function topFade(){
 if(topact<1) topact++; else topact=0;
 o = getObject('idmf');
 if(document.all) o.filters.blendTrans.apply();
 o.src=topimgs[topact].src;
 if(document.all) o.filters.blendTrans.play();
 setTimeout("topFade()", 15000);
}
function rowOver(){
 this.bgColor='#85C4FF';
}
function rowOut(){
 this.bgColor='';
}
function rowClick(){
 location.href = document.getElementById(this.id+'a').href;
}
function addEffect(tableId){
 var rows;
 var oTable = document.getElementById(tableId);
 var oTBody = oTable.getElementsByTagName('TBODY');
 if(oTBody) rows = oTBody[0].getElementsByTagName('TR');
 else rows = oTable.getElementsByTagName('TR');
 for(var i=0; i<rows.length; i++) if(rows[i].id){
  rows[i].onmouseover = rowOver;
  rows[i].onmouseout = rowOut;
  rows[i].onclick = rowClick;
 }
}
function pageInit(){
 addEffect('menu1');
 topimgs[0]=new Image; 
 topimgs[0].src="img/topw.jpg";
 topimgs[1]=new Image; 
 topimgs[1].src="img/tops.jpg";
 setTimeout("topFade()", 15000);
 setTimeout("keepAlive()", 600000);
}
function isnum(o){
 var nc = " .", vc = "0123456789", ok = true, s = "";
 for(i=0;i<o.value.length;i++){
  if(o.value.charAt(i)==",") i=o.value.length;
  else if(nc.indexOf(o.value.charAt(i))==-1) s=s+o.value.charAt(i);
 }
 o.value = s;
 for(i=0;i<s.length && ok == true;i++) if(vc.indexOf(s.charAt(i)) == -1) ok = false;
 return ok;
}
function trm(s) {
 var t = s.replace(/^\s+/,"");
 return(t.replace(/\s+$/,""));
}
function msg(o,t) {
 if(ok){
  ok = false;
  alert(t);
  if(o.select) o.select();
  o.focus();
 }
}
function chk(o,l,t) {
 if(!o.type){
  if(o[0].type == 'radio'){
   for(i=n=0;i<o.length;i++) if(o[i].checked) n++;
   if(n < l) msg(o[0],t);
  }
 } else if(o.type == "select-one"){
   if(o[0].selected) msg(o,t);
 } else {
  o.value = trm(o.value);
  if(o.value.length < l) msg(o,t);
  else if(l<=0 && !isnum(o)) msg(o,t);
  else if(l<0 && o.value < -l) msg(o,t);
  else if(o.name == "mail"){
   i1 = o.value.indexOf("@",0);
   i2 = o.value.indexOf(".",i1+3);
   if(i1 == -1 || i2 == -1) msg(o,t);
  }
 }
}
function chkbx(o,l,t) {
 for(f=i=n=0;i<d.length;i++) if(d[i].name.substring(0,2)==o){
  if(f==0) f=d[i];
  if(d[i].checked) n++;
 }
 if(n<l) msg(f,t);
}
function chkwww(o,t) {
 var s = o.value.toLowerCase();
 if(s.indexOf(".com ")>0) msg(o,t);
 s = s.replace(/ /gi,'') ;
 if(s.indexOf("www")>0) msg(o,t);
 if(s.indexOf(".co.uk")>0) msg(o,t);
}
