//Auto Scroll
jQuery(document).ready( function( $){
    $('a:not([class^="colorbox"],[class^="swap"])').each( function(){
        var thisNode = $(this),
            thisHref = thisNode.attr('href'),
            ix = thisHref.indexOf('#'),
            link = thisHref.split('#')[0],
            linkId = thisHref.split('#')[1],
            thisUrl = location.href.split('#')[0];
            
        //only inner page link are set with scrollTo.
        if( ix != -1 && ( link == thisUrl || thisUrl.indexOf( link) !== -1)){
            //set scrollTo
            thisNode.click( function(){
                if( linkId == 'contents_header' || linkId == 'HEADER' || linkId == 'CONTENT_TOP' || linkId == 'PAGE_TOP'){
                    $.scrollTo( {top:'0'}, 800);
                    $.fn.colorbox.close();
                }
                else{
                    $.scrollTo( $('#' + linkId), 800);
                    //$.scrollTo( $('#' + linkId), 800, {offset:-35});
                    $.fn.colorbox.close();
                }
                return false;
            });
        }

    });//end each
});

