/*
Planet Bods core JavaScript - (planned) to be used throughout the site
Some parts make use of the Yahoo Event library
*/

var a = new Array() ;
var imageCache = new Array(); 
var coreScript = {
  init : function() {

  // Check for image tags with a class of "rollover", assign rollovers 
  // to them and pre-cache the "on" images.
  var rolls = document.getElementsByTagName('img');
  for (i=0;i<rolls.length;i++) {
    if (rolls[i].className=="rollover") {
	YAHOO.util.Event.addListener(rolls[i],'mouseover',this.rollover);
	YAHOO.util.Event.addListener(rolls[i],'mouseout',this.rollover);
	imageCache[i] = new Image() ;
	c = rolls[i].src.substring(rolls[i].src.lastIndexOf('.'),rolls[i].src.length);
	imageCache[i].src = rolls[i].src.replace(c,"_on"+c) ;
    }
  }

	// Check for text inputs and assign form clearing
	var inp = document.getElementsByTagName('input');
	for (i=0;i<inp.length;i++) {
	  if (inp[i].type=="text") {
		a[inp[i].id] = inp[i].value ;
		YAHOO.util.Event.addListener(inp[i],'focus',formClear);
		YAHOO.util.Event.addListener(inp[i],'blur',formPopulate);
	  }
	}

	// Check for textareas and assign form clearing
	var inp = document.getElementsByTagName('textarea');
	for (i=0;i<inp.length;i++) {
	  a[inp[i].id] = inp[i].value ;
	  YAHOO.util.Event.addListener(inp[i],'focus',formClear);
	  YAHOO.util.Event.addListener(inp[i],'blur',formPopulate);
	}
  },
  rollover : function(e) {
	if (this.src.match('_on')) {
	  this.setAttribute('src',this.src.replace(/_on/gi,""));
	} else {
	  c = this.src.substring(this.src.lastIndexOf('.'),this.src.length);
	  this.setAttribute('src',this.src.replace(c,"_on"+c)); 
	}
  }
}


function formClear(e) { if (this.value == a[this.id]) { this.value = "" ; } }
function formPopulate(e) { if (this.value == "" ) { this.value = a[this.id] ; } }

function initScripts() {
	coreScript.init() ;
}
YAHOO.util.Event.addListener(window,'load',initScripts);

// Google Analytics code
_uacct = "UA-1042546-1";
urchinTracker();
