/* 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();
			});
		});
		
		$("a.anchorLinkA").anchorAnimate()
		$("a.anchorLinkC").anchorAnimate()

});

/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
		

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}


		
/* 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) ? '0px' :'0px';
      labels[j].style.margin = (hide) ? '0 0 0 230px' :'4px 4px';
	  labels[j].style.background = (hide) ? 'black' :'none';
	  labels[j].style.padding = (hide) ? '4px' :'0';
	  labels[j].style.border = (hide) ? '1px solid red' :'0';
	  labels[j].style.color = (hide) ? '#ffffff' :'#858585';
      return true;
    }
  }
}
	
window.onload = function () {
  setTimeout(initOverLabels, 50);
};

