/* 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_aboutus').show();
			},function(){
				$(this).find('ul.subnav_aboutus').hide();
			});
			$(this).hover(function(){  
				$(this).find('ul.subnav_new').show();
			},function(){
				$(this).find('ul.subnav_new').hide();
			});
			$(this).hover(function(){  
				$(this).find('ul.subnav_services').show();
			},function(){
				$(this).find('ul.subnav_services').hide();
			});
			$(this).hover(function(){  
				$(this).find('ul.subnav_experience').show();
			},function(){
				$(this).find('ul.subnav_experience').hide();
			});
			
			$(this).hover(function(){  
				$(this).find('ul.subnav').show();
			},function(){
				$(this).find('ul.subnav').hide();
			});
			

			
			
		});
		
		
		document.getElementById('hometabA').style.backgroundPosition = "0 -38px";
		$('#homeNav > li.homeliA').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavA').show();
				document.getElementById('hometabA').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		
		$('ul.homeSubNavB').hide();
		$('#homeNav > li.homeliB').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavB').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				document.getElementById('hometabB').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		
		$('ul.homeSubNavC').hide();
		$('#homeNav > li.homeliC').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavC').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				document.getElementById('hometabC').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		$('ul.homeSubNavD').hide();
		$('#homeNav > li.homeliD').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavD').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				document.getElementById('hometabD').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		$('ul.homeSubNavE').hide();
		$('#homeNav > li.homeliE').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavE').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				document.getElementById('hometabE').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		$('ul.homeSubNavF').hide();
		$('#homeNav > li.homeliF').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavF').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				document.getElementById('hometabF').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		$('ul.homeSubNavG').hide();
		$('#homeNav > li.homeliG').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavG').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				document.getElementById('hometabG').style.backgroundPosition = "0 -38px";
				$('#homeNav > li.homeliH').find('ul.homeSubNavH').hide();
				document.getElementById('hometabH').style.backgroundPosition = "0 0";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		$('ul.homeSubNavH').hide();
		$('#homeNav > li.homeliH').each(function(i){						 
			$(this).hover(function(){  
				$(this).find('ul.homeSubNavH').show();
				$('#homeNav > li.homeliA').find('ul.homeSubNavA').hide();
				document.getElementById('hometabA').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliB').find('ul.homeSubNavB').hide();
				document.getElementById('hometabB').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliC').find('ul.homeSubNavC').hide();
				document.getElementById('hometabC').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliD').find('ul.homeSubNavD').hide();
				document.getElementById('hometabD').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliE').find('ul.homeSubNavE').hide();
				document.getElementById('hometabE').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliF').find('ul.homeSubNavF').hide();
				document.getElementById('hometabF').style.backgroundPosition = "0 0";
				$('#homeNav > li.homeliG').find('ul.homeSubNavG').hide();
				document.getElementById('hometabG').style.backgroundPosition = "0 0";
				document.getElementById('hometabH').style.backgroundPosition = "0 -38px";
			},function(){
				//$(this).find('ul.homeSubNavA').hide();
			});
		});
		
		
		$("a.anchorLink").anchorAnimate()

});



			
/* 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);
};

/* ANIMATE SCROLL ON CLICK */


<!--a href="#anchorTarget" class="anchorLink"></a-->

 
<!--a name="anchorTarget" id="anchorTarget" /-->

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;
		})
	})
}
