
 function go2(url) { document.location.href=url; }

 function findPos(obj) {
  var curleft=0;
  var curtop =0;
  if(obj.offsetParent) {
   curleft=obj.offsetLeft;
   curtop =obj.offsetTop;
   while(obj=obj.offsetParent) {
    curleft+=obj.offsetLeft;
    curtop +=obj.offsetTop;
   }
  }
  return [curleft,curtop];
 } 

 
 function commentFormSubmit() {
  var cf = document.getElementById('commentform'), de = 0;
  if((de==0)&&(cf.name.value.length<4))   { de=1; alert('Please Enter your Full Name?'); cf.name.focus(); }
  if((de==0)&&(!isMail(cf.email.value)))  { de=2; alert('Please Enter a Valid Email Address'); cf.email.focus(); }
  if((de==0)&&(cf.words.value.length<10)) { de=3; alert('Please enter a longer message.'); cf.words.focus(); }
  if(de==0) { cf.submit(); }
 }

 function commentResponse(r) {
  var cf = document.getElementById('commentform');
  var res = new Array(
   '<h2>Sorry...</h2>Something was wrong with your comment. Perhaps it included links, or you missed something.<br/>Please reload the page and try again.'
  ,'<h2>Thanks!</h2>Comment posted - if it\'s not spam it should be live soon.<br/>.'
  );
  cf.innerHTML = '<div style="width:600px; height:118px; border:1px solid #aaaaaa; padding:8px;">'+res[r]+'</div>';
 }


 function debug(txt) { if(document.getElementById('debugform')) { document.getElementById('debugform').output.value=txt; } }
 
 function adRotate(ad) {
  var adLoop = document.getElementById('adLoop');
  adLoop.innerHTML = '<a href="'+adsList[ad][1]+'" title="click for more details"><img src="/_img/ads/'+adsList[ad][0]+'.jpg" width="775" height="220" alt="click for more details"/></a>';
  if(ad<(adsList.length-1)) { ad++; } else { ad=0;}
  setTimeout('adRotate('+ad+')', 5000);
 }
 
 function stopEvent(e) {
  if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
 }

 function mailFormSubmit() {
  var mf = document.getElementById('mailform');
  var de = 0;
  if((de==0)&&(mf.name.value.length<4))     { de=1; alert('Please enter your full name.'); mf.name.focus(); }
  if((de==0)&&(!isMail(mf.email.value)))    { de=2; alert('Please enter a valid email address.'); mf.email.focus(); }
  if((de==0)&&(mf.email.value!=mf.email2.value)) { de=2; alert('Email addresses do not match!'); mf.email2.focus(); }
  if((de==0)&&(mf.message.value.length<10)) { de=3; alert('Please enter a longer message.'); mf.message.focus();  }
  if(de==0) { mf.submit(); }
 }
 
 /* Email Address Validation */
 function isMail(email) {
  return email.search(/^[\.\w_'-]+@[\w_'-]+\.[\w_-]+(\.[\w_-]+)*$/)==-1 ? false : true;
 }

 function subMenu(cat, mode) {
  var cats = document.getElementById('menu').getElementsByTagName('li');
  var cid  = 0, sub = '';
  for(i=0; i<cats.length; i++) {
   if(cats[i].id.substr(0, 3)=='cat') {
    cid = parseInt(cats[i].id.substr(3, 2));
    if(mode==1) {
	 cats[i].className = (cid==cat) ? "menu1" : "menu0" ;	 
	 sub = document.getElementById('sub'+cid);
	 if(sub) {
	  pos = findPos(cats[i]);
	  sub.style.left = (pos[0]+175)+'px';
	  sub.style.top  = (pos[1]-5  )+'px';
	  sub.style.display = (cid==cat) ? 'block' : 'none' ;
	 }
	}
	if(mode==0) {
	 cats[i].className = 'menu0';
	 sub = document.getElementById('sub'+cid);
	 if(sub) {
	  sub.style.display = 'none';
	 }
	}
   }
  }
 }
