// JavaScript Document


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function roundedCorners() {
 var divs = document.getElementsByTagName('div');
 var rounded_divs = [];
 /* First locate all divs with 'rounded' in their class attribute */
 for (var i = 0; i < divs.length; i++) {
   if (/\brounded\b/.exec(divs[i].className)) {
     rounded_divs[rounded_divs.length] = divs[i];
   }
 }
 /* Now add additional divs to each of the divs we have found */
 for (var i = 0; i < rounded_divs.length; i++) {
   var original = rounded_divs[i];
   /* Make it the inner div of the four */
   original.className = original.className.replace('rounded', '');
   /* Now create the outer-most div */
   var tr = document.createElement('div');
   tr.className = 'rounded2';
   /* Swap out the original (we'll put it back later) */
   original.parentNode.replaceChild(tr, original);
   /* Create the two other inner nodes */
   var tl = document.createElement('div');
   var br = document.createElement('div');
   /* Now glue the nodes back in to the document */
   tr.appendChild(tl);
   tl.appendChild(br);
   br.appendChild(original);
 }
}


function homeLinks() {
	var homeLinks = document.getElementsByClassName('home_link');
	
	for (var i = 0; i < homeLinks.length; i++) {
		homeLinks[i].onmouseover = function () {
			//var info = this.getElementsByTagName('div');
			//info = info[0];
			this.style.background = 'url(images/bg_home_link.gif) repeat-x bottom';
		}
		
		homeLinks[i].onmouseout = function () {
			// var img = this.childNodes[1];
			// var info = this.childNodes[3];
			//var info = this.getElementsByTagName('div');
			//info = info[0];
			this.style.background = 'none';
		}
		
		homeLinks[i].onclick = function () {
			//alert(this.childNodes[1].getAttribute('href'));
			var theLink = this.getElementsByTagName('a');
			window.location = theLink[0].getAttribute('href');

		}

	}
}


/* onLoad Events */
addLoadEvent(roundedCorners);
addLoadEvent(homeLinks);
