function getSelectedText(){
       var txt = '';
       if (window.getSelection){
               txt = window.getSelection();
       }else if (document.getSelection){
               txt = document.getSelection();
       }else if (document.selection){
               txt = document.selection.createRange().text;
       }
       return txt;
}

$(document).ready(function(){
    if ($.browser.mozilla)
    {
        var path_to_template = $('.path-to-template').html();
        var keys_down = $('.keys-to-get-text').html();
        var iblock_id = $('.iblock-id').html();
        var url = $('.url').html();        
        
        $(document).bind('keydown', 'ctrl+return', function(){
            $('<a class="iframe" href="'+path_to_template+'/send.php?selectedtext='+getSelectedText()+'&iblock_id='+iblock_id+'&url='+url+'&path_to_template='+path_to_template+'&step=1"></a>').fancybox(
            {
                "frameWidth" : 400,     
                "frameHeight" : 400         
            }
            ).click()
            //alert(getSelectedText());    
        });        
    }

}) 
$(document).keypress(function(e){
    
        var path_to_template = $('.path-to-template').html();
        var keys_down = $('.keys-to-get-text').html();
        var iblock_id = $('.iblock-id').html();
        var url = $('.url').html();        
    
        keynum = e.which;
        keycode = e.keyCode;
        ctrl = e.ctrlKey;
        //alert(ctrl+'  '+keycode);

        if ((ctrl==true)&&(keycode==10))
        {
            $('<a class="iframe" href="'+path_to_template+'/send.php?selectedtext='+getSelectedText()+'&iblock_id='+iblock_id+'&url='+url+'&path_to_template='+path_to_template+'&step=1"></a>').fancybox(
            {
                "frameWidth" : 400,     
                "frameHeight" : 400         
            }
            ).click()
            //alert(getSelectedText());             
        }
        
       /* 
        if (!(( (!keynum || $.browser.opera) && (keycode == 9 || keycode == 116 || keycode == 36 || keycode == 35 || keycode == 39 || keycode == 37 || keycode == 45 || keycode == 46 ) ) || keynum == 8 || (keynum==99 && ctrl) || (keynum==97 && ctrl) || (keynum==118 && ctrl) || (keynum>=48 && keynum <= 57) || (keynum>=96 && keynum <= 105) ))
            return false;
       */
        return true;
         
    });
    /*
    $(document).bind('keydown', keys_down, function(){
        $('<a class="iframe" href="'+path_to_template+'/send.php?selectedtext='+getSelectedText()+'&iblock_id='+iblock_id+'&url='+url+'&path_to_template='+path_to_template+'&step=1"></a>').fancybox(
        {
            "frameWidth" : 400,     
            "frameHeight" : 400         
        }
        ).click()
        //alert(getSelectedText());    
    });
    */
 
