//this function includes all necessary js files for the application

function include(file)

{



  var script  = document.createElement('script');

  script.src  = file;

  script.type = 'text/javascript';

  script.defer = false;



  document.getElementsByTagName('head').item(0).appendChild(script);

}



// This include doesn't work in Chrome ans Safari

include("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js");



function get_hostname_from_url(url) {

    return url.match(/:\/\/(.[^/]+)/)[1];

}



function external_link() {

  // See the jQuery UI Tabs documentation for

  //  more information about how this works.

  $("a").click(function(event){

     var title = $(this).html().replace('\n', ' ');

     title = title.replace(/[ \t]+/g, ' ');

     

     // If the URL domain name is not the same, then use frames

     if(document.domain != get_hostname_from_url(this.href))

     {

         this.href = "/extlinks/external_page.php?url=" + this.href + "&title=" + title + "&refing_url=" + window.location.href;

         this.target = "_blank";

     }

  });

}
