function getSelectedText(){
    if(window.getSelection){
        return window.getSelection().toString();
    }
    else if(document.getSelection){
        return document.getSelection();
    }
    else if(document.selection){
        return document.selection.createRange().text;
    }
} 

(function($){
    $(function(){
        $("table.hi tr.row")
            .mouseenter(function(){$(this).addClass('hover')})
            .mouseleave(function(){$(this).removeClass('hover')});

        $("img.autosize").each(function(){
            var classes = this.className.split(' ');
            var hh = 50;
            var ww = 50;
            for (i = 0; i < classes.length; i++) {
                var p = classes[i].split('-');
                if(p[0] == 'autosize' && p.length == 3) {
                    ww = p[1];
                    hh = p[2];
                }
            }
            var $img = $(this);
            var h = $img.height();
            var w = $img.width();
            var s = h*w;
            var r = Math.sqrt(ww * hh / s);
            h *= r;
            w *= r;
            $img.width(w);
            $img.height(h);
            $img.show();
        });


        /*
           
        $(".shadow").each(function(){
            var $this = $(this);
            var $div = $("<div></div>");
            $div.css({
                        left: 0,
                        top: 0,
                        width:  $this.css('width'),
                        zIndex:0
            });
            if($this.css("position")!="relative"){
                $this.css("position","absolute");
            }
            $this.before($div);

            var c1 = "#D0D0D0";
            var c2 = "#C0C0C0";

            if($this.hasClass("light")){
                c1 = "#E0E0E0";
                c2 = "#D0D0D0";
            }


            for(var i=0;i<2;i++) {
                var divShadow = $this
                    .clone()
                    .css({
                        left: $this.position().left+1+i,
                        top: $this.position().top+1+i,
                        width: $this.outerWidth,
                        height: $this.outerHeight,
                        marginTop: $this.css("marginTop"),
                        marginBottom: $this.css("marginBottom"),
                        marginLeft: $this.css("marginLeft"),
                        marginRight: $this.css("marginRight"),
                        position:"absolute",
                        color:(i?c1:c2),
                        zIndex:2-i
                    });
                $this.css("zIndex",3);
                $this.after(divShadow);
            }
        });*/         

    });
})(jQuery);
