
$(document).ready(function(){
      $("#cmeid").live("mouseup", function(e){
      gethightlightText(e);
    });
  });

function gethightlightText(e)
{
    var newtext = getSelText();
    if(newtext != '' && newtext.toString().length < 60)
    {
        if($('#cme').size()==0)$('body').append("<div id='cme'/>");
	$.ajax({
         url: "ub?cmd=qsf&t="+newtext,
		 type: "GET", 
		 async: false,
                 cache: false,
		 success: function(xml){
		     if(xml != "")
		     {
                       
			 $('#cme').html(xml);
			 $('#cluetip').css('top', e.pageY + -20).css('left', e.pageX + 10);
			 $('#cluetip').click(function(){$('#cluetip').remove(); });
                         document.searchform.search.value="";
                     }
		     if(xml.match("Glimpse"))
		     {
		         document.searchform.search.value=newtext;
		     }
		      
		 }
 	});
    }
    return true;
}

function getSelText()
{
    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;
    
}
function toggleimage(name, zoomimage, normalimage)
{
    var x = document.getElementsByName(name);
    var link = x[0].src;
    if(link.indexOf('imagec') != -1)
    {
        x[0].src = normalimage;
    }
    else
    {
        x[0].src = zoomimage;
    }
}

