$(document).ready(function() {

$('.login-box input').each(function() {
    if ($(this).attr('type') == 'text') {
        $(this).focus(function() {
            oneClick(this);
        });

        $(this).blur(function() {
            outClick(this);
        });
    }
    if ($(this).attr('type') == 'password') {
	
		$(this).next().css( { "left": "8px"} ).removeClass('hidden');
	
        $(this).focus(function() {
			$(this).next().addClass('hidden');
        });

        $(this).blur(function() {
			if ($(this).val() == '') {
				$(this).next().removeClass('hidden');
			}
        });
    }
});

$('#nav li').each(function() {
    var parts = document.location.href.split('/');
    var match = '/' + parts[parts.length - 1];
    if ($('a', this).attr('href') == match) {
        $(this).addClass('active');
    }
});

//menuSetup();

});

function oneClick(obj) {
    if (obj.value == obj.defaultValue) {
        $(obj).val('');
    }
}

function outClick(obj) {
    if (obj.value == '') {
        $(obj).val(obj.defaultValue);
    }
}

function menuSetup()
{
    $('.standardmenu a').click(function() {
        menuOpen(this);
        return false;
    });
}

function menuOpen(obj)
{
    $('.childmenu').css('display', 'none');
    var subMenuID = $(obj).parent().attr('id') + '_children';
    $('#' + subMenuID).css('display', 'block');
}

/* shawn */
String.prototype.endsWith = function(str) {
	var lastIndex = this.lastIndexOf(str);
	return (lastIndex != -1) && (lastIndex + str.length == this.length);
}

jQuery(document).ready(function() {

	var url = window.location.href.split('#')[0];

	jQuery('#sidebar .navigation ul .childmenu a').each(function() {
	
		if (url.endsWith(jQuery(this).attr('href'))) {
		
			//console.log('Found Current Link');
		
			jQuery(this).parent().addClass("current");
			jQuery(this).parent().parent().parent().css("display", "block");

		
		}
	
	});
	
	jQuery("#faccxtext a[href='#top'], #faccxtext a[href='#TOP']").click(function () { 

		scrollTo(0, 0);

		return false;

	});

});

function loadServicesContent() {

	jQuery(document).ready(function() {

		jQuery(".service-summary a").click(function () {
		
			if (jQuery(this).parent().find('div').is('.ajax-holder')) {
			
				jQuery(this).parent().find('div.ajax-holder').slideToggle("fast");
				
			} else {
		
				var toLoad = $(this).attr('href').replace('#', ' #');
			
				jQuery(this).parent().append('<div class="ajax-holder"></div>').find('div.ajax-holder').load(toLoad);

			
			}
		
			return false;
		
		});
		
	});

}