/* IMAGE ROLLOVER */

function roll(imagename, newimage){
	if (document.images){
   		document[imagename].src = newimage;
	}
}

/* DROP DOWN MENU */

$(document).ready(function(){

		$('#Nav > li').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.subnav').show();
			},function(){
				$(this).find('ul.subnav').hide();
			});
		});

});



			
/* TEXT OVERLAY TEXT BOX */

function initOverLabels () {
  if (!document.getElementById) return;      

  var labels, id, field;

  // Set focus and blur handlers to hide and show 
  // labels with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var j = 0; j < labels.length; j++) {

    if (labels[j].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[j].htmlFor || labels[j].getAttribute('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      } 

      // Change the applied class to hover the label 
      // over the form field.
      labels[j].className = 'overlabel-apply';

      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to label elements (for Safari).
      labels[j].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

    }
  }
};

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var j = 0; j < labels.length; j++) {
    field_for = labels[j].htmlFor || labels[j].getAttribute('for');
    if (field_for == field_id) {
      labels[j].style.textIndent = (hide) ? '-99999em' :'0px';
      labels[j].style.margin = (hide) ? '-1000px' :'2px 4px';
      return true;
    }
  }
}
	
window.onload = function () {
  setTimeout(initOverLabels, 50);
};
