//
// http://jquery.andreaseberhard.de/pngFix/  all png files
//
$(document).ready(function(){ $(document).pngFix(); });


//
//tooltip, http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
//
this.tooltip = function(){
        /* CONFIG */
                xOffset = 10;
                yOffset = 10;
                // these 2 variable determine popup's distance from the cursor
                // you might want to adjust to get the right result
        /* END CONFIG */
        $("a.tooltip").hover(function(e){
                this.t = this.title;
                this.title = "";
                $("body").append("<p id='tooltip'>"+ this.t +"</p>");
                $("#tooltip")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px")
                        .fadeIn("fast");
    },
        function(){
                this.title = this.t;
                $("#tooltip").remove();
    });
        $("a.tooltip").mousemove(function(e){
                $("#tooltip")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px");
        });
};



// starting the script on page load
$(document).ready(function(){
        tooltip();
});



/* START iconize
---------------------------------------------------------------- */
(function($){

        $.fn.iconize = function(options) {
                var extensions = new Array('mailto', 'html','htm','php','hwp', 'doc', 'rtf', 'txt', 'xls', 'rss', 'atom', 'opml', 'phps', 'torrent', 'vcard', 'exe', 'dmg', 'app', 'pps', 'ppt', 'pdf', 'xpi', 'fla', 'swf', 'zip', 'rar','tgz','gz', 'gzip', 'bzip', 'ace', 'ical', 'css', 'ttf', 'jpg', 'gif', 'png', 'bmp', 'jpeg', 'svg', 'eps', 'mov', 'wmv', 'mp4', 'avi', 'mpg', 'mp3', 'wav', 'ogg', 'wma', 'm4a')
                var i;

                this.each(function() {
                          var $this = $(this);
                        var url = this.href;
                        if($this.is('a') && $this.attr('href') != '') {
                                var file_type = url.split('.')[(url.split('.').length)-1];
                                file_type = file_type.split('/')[0];
                                file_type = file_type.split(':')[0];
                                file_type = file_type.split('=')[0];

                                var ext_in_array = find_extension(file_type);
                                if (ext_in_array != -1 && this.className != 'exclude' ){
                                        $this.addClass(file_type);
                                }
                        }
                  });
                  // returns the jQuery object to allow for chainability.
                  return this;

                  function find_extension(elem){
                                  for (i=0; i < extensions.length; i++){
                                          if (extensions[i] == elem){
                                                  return (1);
                                          }
                                  }
                                  return (-1);
          }

        }

})(jQuery);


 $(document).ready(function () {
 //$('a').iconize();    // original to all links
   $("a[class='download']").iconize(); // sunjoo, modified to show icons to download class only
 });




