$(document).ready(function(){
    $("a").mouseup(DoTrk);
    
    $( ".read-toggle" ).each( function() {
        var text = $( this ).html();
        var startText = text.substring( 0, synonymCharacterLength );
        var toggleText = "<span>" + text.substring( synonymCharacterLength, text.length ) + "</span>";
        $( this ).html( startText + "<em>...</em>" + toggleText );
    } );
    
    $( ".read-toggle:last-child" ).after( '<a href="#" class="read-more">Show more</a>' );
    
    $( "a.read-more" ).unbind("click").click( function() {                
        $( this ).prev().find( "span:first" ).toggle();
        $( this ).prev().find( "em" ).toggle();
        if ( $( this ).html().indexOf( "more" ) > 0 ) {
            $( this ).html( "Show less" );
        }
        else {
            $( this ).html( "Show more" );
        }
    });
    
});

function DoTrk(){
    var loc = this.href.replace(location.protocol+"//"+location.host,"");
    if (loc==this.href || !/(.aspx|^[^.]*$)/gi.test(loc)){
        switch(true) {
            case /^https?:\/\//gi.test(loc):
                TrackURL = loc.replace(/https?:\/\//gi,"/external/");
                break;
            case /^mailto:/gi.test(loc):
                TrackURL = loc.replace(/mailto:/gi,"/email/").replace("@","-at-");
                break;
            default:
                TrackURL = loc;
                break;
        }
        try {pageTracker._trackPageview(TrackURL.toLowerCase());}
        catch(err) { }
    }
}

function ValidateCountryDropdown(source,args) {
    selectList = $(source).nextAll("select")[0];
    args.IsValid = (selectList.selectedIndex > 0);
}
