    $( document ).ready( function() {

            $( "ul.navleft li.mainmenu" ).click( function() {
                var link = $(this).children( "a" ).attr( 'href' );
                window.location = link;
            });

			$( "div.subnav ul li" ).click( function( event ) {
				if( event.stopPropagation ) {
					event.stopPropagation();
				} else if ( window.event ) {
					window.event.cancelBubble=true;
				}
                var link = $(this).children( "a" ).attr( 'href' );
                window.location = link;
            });

            $( "ul.navleft li.mainmenu, ul.navright li" ).hoverIntent( function() {
                    $(this).addClass( "selected" );
                    $(this).children( ".subnav" ).slideDown( "fast" ).show();
                }, function() {
                    $(this).children( ".subnav" ).slideUp( "fast" );
                    $(this).removeClass( "selected" );
            });

            $( ".subnav li" ).hover( function() {
                    $(this).addClass( "selected" );
                }, function() {
                    $(this).removeClass( "selected" );
            });

			$( ".primary-button" ).hover( function() {
                    $(this).addClass( "primary-button-hover" );
                }, function() {
                    $(this).removeClass( "primary-button-hover" );
                });

            $( ".secondary-button" ).hover( function() {
                    $(this).addClass( "secondary-button-hover" );
                }, function() {
                    $(this).removeClass( "secondary-button-hover" );
                });

			$( ".buttonlink" ).click( function( ) {
				var link = $( this ).attr( 'link' );
				window.location = link;
			});


			$( "div.chart-tab" ).click( function() {
        		var id = $( this ).attr( "id" );
        		var parentclass = $( this ).parent().parent().attr( 'class' ); // Grab the fund class to limit the scope
        		$( this ).parent().children().each( function( index ) {
            		$( this ).removeClass( 'active' );
        		});
        		$( this ).addClass( 'active' );
        		if( id == 'quarter' ) {
            		$( "." + parentclass + " div.month-tab" ).hide();
            		$( "." + parentclass + " div.quarter-tab" ).show();
        		} else {
            		$( "." + parentclass + " div.month-tab" ).show();
            		$( "." + parentclass + " div.quarter-tab" ).hide();
        		}
    		});

			$( "div.fpbutton" ).click( function() {
				$( "div.retaillogin" ).hide();
				$( "div.fplogin" ).show();
			});

			$( "div.retailbutton" ).click( function() {
				$( "div.fplogin" ).hide();
				$( "div.retaillogin" ).show();
			});

			$( "input.username_default" ).focus( function() {
				if( $( this ).val() == 'Username' ) {
					$( this ).val( '' );
					$( this ).removeClass( 'username_default' );
					$( this ).addClass( 'username_focus' );
				}
			});

			$( 'input.username_default' ).blur( function() {
				if( $( this ).val().length == 0 ) {
					$( this ).val( 'Username' );
					$( this ).removeClass( 'username_focus' );
					$( this ).addClass( 'username_default' );
				}
			});

			$( "#fakepass" ).focus( function() {
				$( this ).hide();
				$( "#realpass" ).show().focus();
			});

			$( "#realpass" ).blur( function() {
                if( $( this ).val() == '' ) {
					$( this ).hide();
					$( "#fakepass" ).show();
				}
            });



    });

//Optional parameter includeMargin is used when calculating outer dimensions
(function($) {
$.fn.getHiddenDimensions = function(includeMargin) {
    var $item = this,
        props = { position: 'absolute', visibility: 'hidden', display: 'block' },
        dim = { width:0, height:0, innerWidth: 0, innerHeight: 0, outerWidth: 0, outerHeight: 0 },
        $hiddenParents = $item.parents().andSelf().not(':visible'),
        includeMargin = (includeMargin == null)? false : includeMargin;

    var oldProps = [];
    $hiddenParents.each(function() {
        var old = {};

        for ( var name in props ) {
            old[ name ] = this.style[ name ];
            this.style[ name ] = props[ name ];
        }

        oldProps.push(old);
    });

    dim.width = $item.width();
    dim.outerWidth = $item.outerWidth(includeMargin);
    dim.innerWidth = $item.innerWidth();
    dim.height = $item.height();
    dim.innerHeight = $item.innerHeight();
    dim.outerHeight = $item.outerHeight(includeMargin);

    $hiddenParents.each(function(i) {
        var old = oldProps[i];
        for ( var name in props ) {
            this.style[ name ] = old[ name ];
        }
    });

    return dim;
}
}(jQuery));

