/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Padonak, Steve Aurigema | http://www.webdeveloper.com/forum/showthread.php?p=767324#post767324 */
function init(){
  var dlinks = document.getElementById('mainDiv').getElementsByTagName('a');
  var timer;

 	for(var n = 0; n < dlinks.length; n++) {
  		dlinks[n].onmouseover = function() {
   			var txt = null;
   			for( var i in this.childNodes ) {
    				try {
     					if(this.childNodes[i].className == 'bracket' || this.childNodes[i].getAttribute('class') == 'bracket') return; 
  				  } catch(e){ if(this.childNodes[i].className == 'bracket') return; }
  				if(this.childNodes[i].nodeType=='3') txt = this.childNodes[i].cloneNode(false);
  			}
  			while(this.childNodes.length != 0){ this.removeChild(this.childNodes[0]); }
  			var left = document.createElement('span');
  			var right = document.createElement('span');
  			left.setAttribute('id','lbrak'); left.setAttribute('class','bracket'); left.appendChild(document.createTextNode('['));
  			right.setAttribute('id','rbrak'); right.setAttribute('class','bracket'); right.appendChild(document.createTextNode(']'));
  			left.className = 'bracket'; right.className="bracket";
  			this.appendChild(left); this.appendChild(txt); this.appendChild(right);
  			doTarget(15);  // change this number to change the animation of the links
 		}

 		dlinks[n].onmouseout = function(){
  			try {
   				if(timer != ""){clearTimeout(timer);}
   				this.removeChild(document.getElementById("lbrak"));
   				this.removeChild(document.getElementById("rbrak"));
  			} catch(e){ }
 		}

 		dlinks[n].onfocus = function(){this.blur();}
 	}
}

function doTarget(n){
 	var lb = document.getElementById("lbrak");
 	var rb = document.getElementById("rbrak");
 	if(n > 3) {
 		 lb.style.marginRight = n + "px";
 		 rb.style.marginLeft = n + "px";
 		 n--;
 	}
 	else{timer = ""; return;}
 	timer = setTimeout("doTarget(" + n + ")",50);
}

// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  init();
});

