/**
 * @title: JQuery Navigation
 * @author: Michael Aguiar
 * @description: Animation effect for the navigation when hovered
 */

// When document is ready, define 'toggle' variable.
$(document).ready(function() {
    var toggle = function(direction, display) {
	    return function() {
		    var self = this;
      		var ul = $('ul', this);
      		if( ul.css('display') == display && !self['block' + direction] ) {
    		    self['block' + direction] = true;
        		ul['slide' + direction]('fast', function() {
				    self['block' + direction] = false;
    		    });
      		}
    	};
  	}
  	
  	//  Toggle sub nav effect on hover
	$('li.menu').hover(toggle('Down', 'none'), toggle('Up', 'block'));
	$('li.menu ul').hide();
	
	// CSS Controls - if these are changes, it will change the output of every link.
	var cssHover = {
	    'background-position' : 'bottom',
	   // 'margin' : '0 0 0 -1px',
	   // 'padding' : '0 1px',
	    'background-color' : '#151515'
	}
	
	var cssReset = {
	    'background-position' : 'top',
	    //'margin' : '0 1px 0 0',
	    //'padding' : '0',
	    'background-color' : 'transparent'
	}
	
	// About Link
	$('#aboutUl').hover(function() {
        $('#homeAbout').css(cssHover);
    }, function() {
        $('#homeAbout').css(cssReset);    
    });
    $('#homeAbout').hover(function() {
        $(this).css(cssHover);
    }, function() {
        $(this).css(cssReset);
    });
    
    // IT Link
	$('#itUl').hover(function() {
        $('#homeIT').css(cssHover);
    }, function() {
        $('#homeIT').css(cssReset);    
    });
    $('#homeIT').hover(function() {
        $(this).css(cssHover);
    }, function() {
        $(this).css(cssReset);
    });
    
    // Hosting Link
	$('#hostingUl').hover(function() {
        $('#homeHosting').css(cssHover);
    }, function() {
        $('#homeHosting').css(cssReset);    
    });
    $('#homeHosting').hover(function() {
        $(this).css(cssHover);
    }, function() {
        $(this).css(cssReset);
    });
    
    // Outsource Link
	$('#outsourceUl').hover(function() {
        $('#homeOutsource').css(cssHover);
    }, function() {
        $('#homeOutsource').css(cssReset);    
    });
    $('#homeOutsource').hover(function() {
        $(this).css(cssHover);
    }, function() {
        $(this).css(cssReset);
    });
    
    // Compliance Link
	//$('#complianceUl').hover(function() {
    //    $('#homeCompliance').css(cssHover);
    //}, function() {
    //    $('#homeCompliance').css(cssReset);    
    //});
    //$('#homeCompliance').hover(function() {
    //    $(this).css(cssHover);
    //}, function() {
    //    $(this).css(cssReset);
    //});
});