var browser = getBrowser();
var menuskin = "skin2";
var g_docrange;
var g_menuN;
var obj;
var g_objId = "";
var g_bDblClick = false;
var g_Search = true;
var g_initialselection = "";
var g_b = false;
var g_nFlagSelection = 0;
var g_rangeid;
var g_sBookmark;
var g_x;
var g_y;
var g_rangetext;
var g_dblclickAction = 1;
var g_context = false;
var _activeVoices = "true|true";

function doCopy()
   {if (browser == 1)
       {g_docrange.execCommand("Copy");
       }
    else {}
   }

function doSearch()
   {if (getBrowser() == 1)
       {if (event.button == 2)
           {return;
           }
       }
    else 
       {g_Search = true;
       }
      
    if (g_Search);
       {if (g_docrange.text != "")
           {var C = "";
            var A = "";
            if (browser == 1)
               {if (g_docrange.parentElement().id == "")
                   {return;
                   }
                C = document.getElementById(g_docrange.parentElement().id).getAttribute("direction");
                if (C == null)
                   {return;
                   }
                if (C != "undefined" && C != "" && C != null)
                   {C = (document.all["initialdirection"].value == 101 ? "current_direction": "inverse_direction");
                   }
                else 
                   {C = (document.all["initialdirection"].value == 101 ? "inverse_direction": "current_direction");
                   }
                A = g_docrange.text;
               }
            else 
               {var F = "";
                F = g_objId;
                var E = document.getElementById(F);
                
                if (E != null && E != "undefined" && E.attributes["direction"] != null && E.attributes["direction"] != 
                  "undefined")
                   {C = E.attributes["direction"].value;
                   }
                A = g_docrange;//A=A.replace(" ","");
               var D = document.getElementById("initialdirection");
               var B = D.attributes["value"].value;
                if (C != "undefined" && C != "" && C != null)
                   {C = (B == 101 ? "inverse_direction": "current_direction");
                   }
                else 
                   {C = (B == 101 ? "current_direction": "inverse_direction");
                   }
               }
           //if(A.length>0&&A.indexOf(" ")==-1){
            if (A.toString().length > 0)
               {
               search_word(C, A.toString().replace("'", "\\'"));
               }
           }
       }
   }

function getBrowser()
   {if (navigator.appVersion.indexOf("MSIE") != - 1)
       {return 1;
       }
    if (navigator.appName == "Netscape")
       {if (navigator.userAgent.indexOf("Netscape6") != - 1)
           {return 2;
           }
        else 
           {return 3;
           }
       }
    return 0;
   }

function keydownEvent()
   {if (event.ctrlLeft || event.ctrlKey)
       {return false;
       }
   }

function keydownEventN(A)
   {if (A.which == 67)
       {window.getSelection().removeAllRanges();
        return false;
       }
    return true;
   }

function mouseupEvent()
   {var B = document.selection.createRange();
    var A = B.text;
    if (g_bDblClick)
       {g_bDblClick = false;
        return;
       }
    if (g_dblclickAction != 1)
       {if (A.indexOf(" ") != - 1)
           {B.collapse();
            B.select();
           }
        return;
       }
    if ((g_dblclickAction == 1) && (g_nFlagSelection != - 1 && g_nFlagSelection != 0))
       {g_nFlagSelection = 0;
        if (A.indexOf(" ") == - 1)
           {return;
           }
        DClick();
        if (A.indexOf("  ") != - 1)
           {B.collapse();
            B.select();
           }
        return;
       }
    else 
       {if (g_nFlagSelection <= 0 && ! g_context)
           {doSearch();
           }
        g_nFlagSelection = 0;
       }
   }

function mouseupEventN(E)
   {var C, D;
    var F = "";
    createSelN();
    var B = document.getSelection();
    var A = B.indexOf("  ");
   }

function selectionchangeEvent()
   {CreateSelection();
    var sText = g_docrange.text;
    g_nFlagSelection--;
    if (sText != "")
       {if (sText == document.body.innerText)
           {var r = document.selection.createRange();
            r.collapse();
            r.select();
           }
        if ( ! g_b)g_initialselection = sText;
        else g_b = false;
       }
    else g_b = true;
    hidemenu();
   }

function increaseFlagSelection()
   {g_nFlagSelection++;
   }

function mouseoverEvent()
   {
   document.onselectionchange = function()
       {return false;
       };
   }

function mouseoutEvent()
   {document.onselectionchange = selectionchangeEvent;
   }

function selectionchangeEventN()
   {createSelN();
    var A = g_docrange;
    if (A != "")
       {if (A == document.text)
           {window.getSelection().removeAllRanges();
           }
       }
   }

function contextHandler()
   {g_context = true;
   }

function doLoad()
   {var A = document.getElementById("translate_box");
   }

function preserveRange()
   {var B = g_rangeid;
    if ((typeof (B) != "undefined") && (B != ""))
       {var A = document.body.createTextRange();
        A.moveToBookmark(g_sBookmark);
        A.select();
       }
   }

function manageClick_menu()
   {if (event.button == 0)
       {g_Search = true;
       }
    else 
       {g_Search = false;
       }
    var A = window.event.srcElement.id;
    if ((typeof (A) != "undefined") && (A != "") && (A != "copydiv") && isValidElement(A))
       {g_rangeid = A;
        element = document.getElementById(A);
        showmenuie5();
       }
    return true;
   }

function x()
   {obj.style.backgroundColor = "#ffffff";
   }

function manageClickN(e)
   {
   if (e.target.tagName == "SPAN" && e.target.id != "" && isValidElement(e.target.id)&& e.target.parentNode.className != "menuitems")
       {
       validateSelectionN();
        obj = e.target;
        var id = "";
        for (i = 0;i < obj.attributes.length;i++)
           {if (obj.attributes[i].name == "id")
               {id = obj.attributes[i].value;
                break;
               }
           }
         if (id == "")
           {var pNode = obj.parentNode;
            if (pNode.attributes["id"] != null)id = pNode.attributes["id"].value;
           }
        if (id != "")g_objId = id;
        hidemenuN();
        if (id != "")
           {var range = document.createRange();
			range.selectNode(obj);
            var txtRange = range.toString();
            var mnuItemLabel = document.getElementById(id);
            var disabled = true;
            if (mnuItemLabel != null)
               {var mnuItem = mnuItemLabel.parentNode;
                if (mnuItem != null && mnuItem.className == "menuitems_disabled")disabled = false;
               }
            if (txtRange != "" && disabled) showmenuN(e);
           }
       }
   }

function manageDblCLickN(e)
   {var id = e.target.id;
    if (id == "")
       {if (e.target.parentNode != null && e.target.parentNode != 'undefined' && e.target.parentNode.id != "")id = e.target.parentNode.id;
        else if (e.target.parentNode != null && e.target.parentNode != 'undefined' && e.target.parentNode.parentNode != 
          null && e.target.parentNode.parentNode != 'undefined' && e.target.parentNode.parentNode.id != "")       id = 
          e.target.parentNode.parentNode.id;
        else        if (e.target.parentNode != null && e.target.parentNode != 'undefined' && e.target.parentNode.parentNode != 
          null && e.target.parentNode.parentNode != 'undefined' && e.target.parentNode.parentNode.parentNode != null && e.target.parentNode.parentNode.parentNode != 
          'undefined' && e.target.parentNode.parentNode.parentNode.id != "")id = e.target.parentNode.parentNode.parentNode.id;
       }
    if (g_dblclickAction == 1 && isValidElement(id))
       {CreateSelection();
        doSearch();
        return;
       }
   }

function manageDblCLick()
   {g_Search = true;
    if (g_dblclickAction == 1 && isValidElement(event.srcElement.id))
       {createSel();
        mouseupEvent();
        if (g_docrange.text.indexOf(" ") == - 1)
           {doSearch();
           }
        return;
       }
    g_bDblClick = true;
    if (isValidElement(event.srcElement.id))DClick();
   }

function DClick()
   {var tag = window.event.srcElement.tagName;
    if (tag == "SPAN")
       {var id = window.event.srcElement.id;
        if (id + "" != "")
           {var textRange = document.body.createTextRange();
            eval ("textRange.moveToElementText(" + id +")");
            var rts = textRange.text + "";
            if (rts.lastIndexOf(" ") == rts.length - 1)
               {textRange.moveEnd("character", - 1);
               }
            if (rts.indexOf(" ") == 0)
               {textRange.moveStart("character", 1);
               }
            textRange.select();
           }
       }
   }
//=================================================================
//Modified by   Ciprian Chisalita
//Date          26.06.2007
//Description   This function manage the selection of the words
//                  - removes spaces
//                  - for only some letters, selects the whole word
//=================================================================

function expandSelection()
   {if (event.srcElement.tagName == "SPAN" && event.srcElement.parentElement.className != "menuitems" && isValidElement(event.srcElement.id))
       {var range = document.selection.createRange();// If there is a single word, 
          // and there are just some letters selected
          // the selection is expanded to the whole word:
        if (range.text.indexOf(" ") == - 1)
           {range.expand("word");
            if (range.text == "")
               {//check if the span is a child of another span
                  //in order to expand the selection to the parent		        
               if (event.srcElement.id == "" && event.srcElement.parentElement.tagName == "SPAN" && event.srcElement.parentElement.id != "")
                   {eval ("range.moveToElementText(" + event.srcElement.parentElement.id +")");
                   }
                else eval ("range.moveToElementText(" + event.srcElement.id +")");
               }
           }
       // removes the spaces
        var rts = range.text.toString();
        while (rts.lastIndexOf(" ") == range.text.length - 1)
           {range.moveEnd("character", - 1);
            rts = range.text.toString();
            if (rts.length == 0)break;
           }
        while (rts.indexOf(" ") == 0)
           {range.moveStart("character", 1);
            rts = range.text.toString();
            if (rts.length == 0)break;
           }
       //while(rts.indexOf(" ") != -1)
          //var str = range.text;
          //range.text = 'sub'; str.replace(/\s+/gi,' ');// .re .exec(tempStr);
          //select the range
        range.select();
        g_docrange = range;
       }
   }

function createSel()
   {g_docrange = document.selection.createRange();
   }

function createSelN()
   {g_docrange = window.getSelection();
    rg = g_docrange.getRangeAt(0);
    try 
       {expandRangeToWord(rg);
       }
   catch (A){}
    g_docrange = document.getSelection();
   }
function isChrome()
   {
  	if(navigator.appVersion == null || navigator.appVersion == '')
		return 0;
	return (navigator.appVersion.indexOf("Chrome") == -1 && 
				  navigator.appVersion.indexOf("Safari") == -1) ? 0 : 1;
   }
   
function expandRangeToWord(rang)
   {//alert(rang.toString().indexOf(' ') != -1 || rang.toString().indexOf(String.fromCharCode(160)) != -1 ) 
      //expand to word, if the word contains spaces do not
      //expand to the entire phrase            
   if (rang.toString().indexOf(' ') != - 1 || rang.toString().indexOf(String.fromCharCode(160)) != - 1)
       {
       StripRangeN(rang);
        return;
       }
    var startOfWord = /^[\s(=\'>]\S+$/;
    var endOfWord = /^\S+[\s,!,),\.,\n]$/;
    var whitespace = /^\s+$/;// if offset is inside whitespace
	
	
    if (rang.startOffset > 0)rang.setStart(rang.startContainer, rang.startOffset - 1);
    else rang.setStart(rang.startContainer, 0);
    while (whitespace.test(rang.toString()))
       {rang.setEnd(rang.endContainer, rang.endOffset + 1);
        rang.setStart(rang.startContainer, rang.startOffset + 1);
       }
    while (rang.startOffset > 0 && ! startOfWord.test(rang.toString()))
       {rang.setStart(rang.startContainer, rang.startOffset - 1);
       }
    if (rang.startOffset > 0 || /^[\s,\.]/.test(rang.toString()))rang.setStart(rang.startContainer, rang.startOffset + 1);
    else rang.setStart(rang.startContainer, 0);
    var offSet = 1;
    while ( ! endOfWord.test(rang.toString()))
       {try 
           {rang.setEnd(rang.endContainer, rang.endOffset + 1);
           }
       catch (error)
           {offSet = 0;
            break;
           }
       }
    rang.setEnd(rang.endContainer, rang.endOffset - offSet);
	if(isChrome())
		g_docrange = rang; 

    return rang.toString();
   }

function highlightie5(event)
   {if (event.srcElement)
       {if (event.srcElement.className == "menuitems")
           {event.srcElement.style.backgroundColor = "highlight";
            event.srcElement.style.color = "white";
           }
        else if (event.srcElement.parentElement.className == "menuitems")
           {event.srcElement.parentElement.style.backgroundColor = "highlight";
            event.srcElement.parentElement.style.color = "white";
           }
       }
    else 
       {var oTarget = event.target;
        if (oTarget.className == "menuitems")
           {oTarget.style.backgroundColor = "highlight";
            oTarget.style.color = "white";
           }
        else if (oTarget.parentNode.className == "menuitems")
           {oTarget.parentNode.style.backgroundColor = "highlight";
            oTarget.parentNode.style.color = "white";
           }
       }
   }

function lowlightie5(event)
   {if (event.srcElement)
       {if (event.srcElement.className == "menuitems")
           {event.srcElement.style.backgroundColor = "";
            event.srcElement.style.color = "black";
            status = "";
           }
        else if (event.srcElement.parentElement.className == "menuitems")
           {event.srcElement.parentElement.style.backgroundColor = "";
            event.srcElement.parentElement.style.color = "black";
            status = "";
           }
       }
    else 
       {var oTarget = event.target;
        if (oTarget.className == "menuitems")
           {oTarget.style.backgroundColor = "";
            oTarget.style.color = "black";
           }
        else if (oTarget.parentNode.className == "menuitems")
           {oTarget.parentNode.style.backgroundColor = "";
            oTarget.parentNode.style.color = "black";
           }
       }
   }

function addBookmarkForBrowser()
   {if (window.sidebar)
       {window.sidebar.addPanel("Online Dictionaries, Collins Lexibase, Reverso", "http://" + document.domain, "");
       }
    else 
       {if (document.all)
           {window.external.AddFavorite("http://" + document.domain, "Online Dictionaries, Collins Lexibase, Reverso");
           }
        else 
           {if (window.opera && window.print)
               {return true;
               }
           }
       }
   }

function doChangeLang(A)
   {switch (A)
       {case "en": 
            parent.location.href = "http://dictionary.reverso.net/";
            break;
        case "fr": 
            parent.location.href = "http://dictionnaire.reverso.net/";
            break;
        case "sp": 
            parent.location.href = "http://diccionario.reverso.net/";
            break;
        case "ge": 
            parent.location.href = "http://woerterbuch.reverso.net/";
            break;
        case "it": 
            parent.location.href = "http://dizionario.reverso.net/";
            break;
       }
   }

function doSearchHome(B)
   {if ((window.event && B.keyCode == 13) || (B.which && B.which == 13))
       {var A = document.getElementById("lnkSearch");
        A.focus();
       }
   }

function HandleResultsEvents()
   {var divResults = document.getElementById("DivMainResults");
    searchContext = 0; //set the search context to main
    if (browser == 1 || browser == 6)
       { //IEXPLORER
          //document.body.focus();
       var resultsTable = document.getElementById("TableHTMLResult");
        resultsTable.onkeydown = keydownEvent;
        resultsTable.ondblclick = manageDblCLick;
        resultsTable.onselectstart = startSelection;
        resultsTable.onselect = increaseFlagSelection;
        resultsTable.onmouseup = expandSelection;
        resultsTable.onmousedown = hidemenuie5;
        resultsTable.onselectionchange = selectionchangeEvent;//resultsTable.onclick = manageClick;
          //resultsTable.oncontextmenu = manageRightClick;//showmenuie5;
        divResults.onmousedown = mouseDownEvent;
        divResults.onclick = manageClick_menu;//divResults.oncontextmenu = manageRightClick;//showmenuie5;
        document.onmouseup = validateSelection;
        g_menu.className = menuskin;
        hidemenuie5();
       }
    else 
       {g_menuN = (document.layers ? document.layers["g_menu"]: document.getElementById("g_menu"));
        var resultsTable = document.getElementById("TableHTMLResult");
        resultsTable.onkeydown = keydownEventN;
        resultsTable.ondblclick = manageDblCLickN;
        resultsTable.onmousedown = hidemenuN;
        divResults.onmouseup = manageClickN;//divResults.onclick = manageClickN;	
        divResults.onmousedown = mouseDownEventN;//divResults.oncontextmenu = showmenuN;		 		 	    
        hidemenuN();
       }
   }
//================================================================
//Created by:   Ciprian Chisalita
//Date:         23.07.2007
//Description:  Holds the first object where the selection started
//================================================================

function startSelection()
   {//increase flag selection
   g_nFlagSelection++;
    _selStartObj = null;
    if (event.srcElement.tagName == "SPAN" && event.srcElement.id != "" && event.srcElement.parentElement.className != 
      "menuitems")_selStartObj = event.srcElement;
   }

function hidemenu()
   {if (browser == 1 || browser == 6)hidemenuie5();
    else hidemenuN();
   }

function hidemenuie5()
   {g_menu.style.visibility = "hidden";
   }

function hidemenuN()
   {
   try 
       {g_menuN.style.visibility = "hidden";
       }
   catch (e){}
   }
//==========================================
// Author: Ciprian Chisalita
// Description: Hides the menu in case of 
//              the event provines
//              from the containing divs
//==========================================

function mouseDownEvent()
   {if (event.srcElement.id == "DivMainResults" || event.srcElement.id == "DivFullTextSearchResults")
       {hidemenuie5();//init the selected text  
        g_docrange = "";
       }
   }

function manageRightClick()
   {showmenuie5();//setTimeout("hidemenu()", 2*menutimeout);
    return false;
   }
//==============================================================
// Modified by: Ciprian Chisalita
// Date:        13.07.2007
// Description: Allow to make a selection on mouse up event
//              only when the selection contains a single phrase
//              or words from a phrase
//              (Doesn't contain "\n").
// TODO: remove unnecesary code/preluated from "mouseUP method"
//==============================================================

function validateSelection()
   {var r = document.selection.createRange();
    if (event.srcElement.tagName == "SPAN" && event.srcElement.id != "" && event.srcElement.parentElement.className != 
      "menuitems" && isValidElement(event.srcElement.id))
       {var sText = r.text;
        if (g_bDblClick)
           {g_bDblClick = false;
            return;
           }
        if (g_dblclickAction != 1)
           {if (sText.indexOf(" ") != - 1)
               {r.collapse();
                r.select();
               }
            return;
           }
        if ((g_dblclickAction == 1) && (g_nFlagSelection != - 1 && g_nFlagSelection != 0))
           {g_nFlagSelection = 0;
            if (sText.indexOf(" ") == - 1)return;
            if (sText.indexOf("\n") != - 1)
               {//if the selected text contains more lines
                  //select only the first one (source selection span)
               selectFromStartSelection();
                return;
               }
           //the selection must be valid even there are words 
              //separated by more than one space.
              //the problem is when the words of the same translation are separated by 
              //more than one space
            if (sText.indexOf("  ") != - 1)//if (sText.indexOf(String.fromCharCode(160)) != -1)
               {//r.collapse();
               r.select();
               }
            return;
           }
        else 
           {g_nFlagSelection = 0;
           }
       }
    else 
       {//if the end of the selection is on another control
          //then it is considered that the selection contains the 
          //starting source selection
       if (event.srcElement.tagName == "DIV" || event.srcElement.tagName == "TD")
           {//r.collapse();
              //r.select();	
              // selectFromStartSelection();	        
           }
       }
   }

function showmenuie5()
   {//	create selection
   CreateSelection();//	test for non empty
    if (g_docrange.text == "")
       {return false;
       }
   //mouse coord:	
    var mouseX = 0;
    var mouseY = 0;//container coord:
    var rightedge = 0;
    var bottomedge = 0;
    var DivResults = null;
    if (searchContext == 0) //0 - normal, 1 - full text
       {mouseX = event.x + 10;
        mouseY = event.y + 10;//get the edges of the div	
        DivResults = document.getElementById("DivMainResults");//DivResults = document.getElementById("DivMainResults1"); 
        rightedge = DivResults.clientWidth + DivResults.scrollLeft - mouseX;
        bottomedge = DivResults.clientHeight + DivResults.scrollTop - mouseY;
       }
    else 
       {mouseX = event.x + 10;
        mouseY = event.y + 10;//get the edges of the div	
        DivResults = document.getElementById("DivFullTextSearchResults");
        rightedge = DivResults.clientWidth + DivResults.scrollLeft - mouseX;
        bottomedge = DivResults.clientHeight + DivResults.scrollTop - mouseY + 150;
       }
   /*alert('result width=' + DivResults.clientWidth )
alert('result height=' + DivResults.clientHeight )
alert('scroll left=' + DivResults.scrollLeft )
alert('scroll top=' + DivResults.scrollTop )*/
    DisableMenuItemsIE();//set the position of the contextual menu, acording it's positions
      //to the borders of the div
    if (rightedge < g_menu.offsetWidth)
       {g_menu.style.left = mouseX - g_menu.offsetWidth;
       }
    else 
       {g_menu.style.left = mouseX;
       }
    if (bottomedge < g_menu.offsetHeight)
       {if (DivResults.scrollTop > 0)
           {g_menu.style.top = mouseY - DivResults.scrollTop - g_menu.offsetHeight - 15;
           }
        else 
           {g_menu.style.top = mouseY - g_menu.offsetHeight - 15;
           }
       }
    else 
       {if (DivResults.scrollTop > 0)
           {g_menu.style.top = mouseY - DivResults.scrollTop;
           }
        else 
           {g_menu.style.top = mouseY; // - 150;
           }
       }
    g_menu.style.visibility = "visible";
    return false;
   }
//	create selection
//modified by AD 01/09/2007 

function CreateSelection()
   {
   if (browser == 1 || browser == 6)
       {g_docrange = document.selection.createRange();
       }
    else if(!isChrome())
       {
       //the stranger thing possible 
          //use window.selection first to performs the word selection and then document.getselection        
       g_docrange = window.getSelection();
        if (g_docrange.rangeCount > 0)
           {
           rg = g_docrange.getRangeAt(0);
	        expandRangeToWord(rg);
            
			g_docrange = document.getSelection();
           }
       }
       else
       { 
			g_docrange = window.getSelection();      		
			if (g_docrange.rangeCount > 0)
			   {
				   var selection = new Selection(window);
					g_docrange = selection.getAsRange();				
					expandRangeToWord(g_docrange);		          
					selection.setToRange(g_docrange);
			   }
       }
   }
//================================================================
//Created by:   Ciprian Chisalita
//Date:         23.07.2007
//Description:  Select the span where the selection started
//              This method is called when the selection continues
//              on more than one line
//================================================================

function selectFromStartSelection()
   {if (_selStartObj != null && _selStartObj.tagName == "SPAN")
       {var id = _selStartObj.id;
        if (id + "" != "")
           {var textRange = document.body.createTextRange();
            try //Bradatan Vasile (23.07.2008) - IE error
               {eval ("textRange.moveToElementText(" + id +")");
               }
           catch (err)
               {return;
               }
            var rts = textRange.text + "";
            if (rts.lastIndexOf(" ") == rts.length - 1)textRange.moveEnd("character", - 1);
            if (rts.indexOf(" ") == 0)textRange.moveStart("character", 1);
            textRange.select();
           }
       }
    else 
       {var r = document.selection.createRange();
        r.collapse();
        r.select();
       }
   }
//=====================================================
// Author:      Ciprian Chisalita
// Description: Hide the menu items (IE)
//              according the ActiveContextualOptions
//              hidden control.
//              value ex: "true|false|true"
//              means:
//              Voice enabled|Conjugator|UserDictionary
//=====================================================

function DisableMenuItemsIE()
   {//hide search option when selection is a phrase
      /*  if (g_docrange.text.indexOf(" ") != -1)
    {
        document.getElementById("searchdiv").style.display = 'none';
    }
    else
    {
        document.getElementById("searchdiv").style.display = 'block';
    }    */// verify how many words have been selected 
   var words = new Array();
    words = g_docrange.text.split(" ");// if there are more then 4 words selected hide the 'search' option 
    if (words.length > 2)SetMenuItemStatusIE("searchdiv", false);
    else SetMenuItemStatusIE("searchdiv", true);
    var strActiveContextualOptions = document.getElementById("ActiveContextualOptions").value;
    var option = strActiveContextualOptions.split( '|');//Voice/Speak disabled
    if (option[0] == "false" || ! IsPronunciationAvailable())SetMenuItemStatusIE("speakdiv", false);
    else 
       {if (ParseHtmlString() == '')SetMenuItemStatusIE("speakdiv", false);
        else SetMenuItemStatusIE("speakdiv", true);//SetMenuItemStatusIE("speakdiv", true);
       }
   //Conjugator disabled
    if (option[1] == "false" || ! IsConjugationAvailable() || words.length > 1)SetMenuItemStatusIE("conjugatediv", false);
    else 
       {// if there are more then 2 words selected, hide the 'conjugation' option 
       if (words.length > 2)SetMenuItemStatusIE("conjugatediv", false);
        else SetMenuItemStatusIE("conjugatediv", true);
       }
   //UserDictionary disabled
    if (option[2] == "false" || option[3] == "false")SetMenuItemStatusIE("mydictdiv", false);
    else 
       {// if there are more then 3 words selected hide the 'add to my dict' option 
       if (words.length > 3)SetMenuItemStatusIE("mydictdiv", false);
        else SetMenuItemStatusIE("mydictdiv", true);
       }
   }
//===============================================
//Enable/disable a single menu item in IE
//===============================================

function SetMenuItemStatusIE(menuItemID, enabled)
   {var mi = document.getElementById(menuItemID);
    if (enabled)
       {//check if the item is not active by default
       if (mi.getAttribute('onclick_old') != null)
           {mi.setAttribute('onclick', mi.getAttribute('onclick_old'));
            mi.disabled = false;
           }
       }
    else 
       {//saves the default value of onclick event        
       if (mi.getAttribute('onclick_old') == null)mi.setAttribute('onclick_old', mi.getAttribute('onclick'));
        mi.setAttribute('onclick', 'void(0)');
        mi.disabled = true;
       }
   }
//================================
//Modified by    Ciprian Chisalita
//Description    Added methods
//================================

function doConjugate(langCode)
   {if (g_docrange.text != "" && g_docrange != "")
       {//get the selected word text
       var textForSearch = GetSelectedWordText();//get the direction of the selected word
        var dictDirection = getSelectedWordDirection();//get language id
        var languageControlId;
        var languageControlName;
        if (browser == 1 || browser == 6)
           {source = getSelectedWordSourceIE();
           }
        else 
           {source = getSelectedWordSource();
           }
        if (dictDirection == 201)
           {if (source.indexOf('target') >= 0)var langId = targetLang;
            else var langId = sourceLang;
           }
        else 
           {if (source.indexOf('target') >= 0)var langId = targetLang;
            else var langId = sourceLang;
           }
       //var langId = getControlValue(languageControlId);
          //get language key
        var langPrefix = getConjugatorLanguageKeyByLangID(langId);
        if ("" != langCode)
           {mouseovermenu = false;
            hidemenu();
            if (langCode == "de")
               {if (langPrefix == "eng")urlConj = "englisch";
                if (langPrefix == "ger")urlConj = "deutsch";
                if (langPrefix == "fre")urlConj = "franzosisch";
                if (langPrefix == "spa")urlConj = "spanisch";
                parent.location.href = 'http://konjugator.reverso.net/konjugation-' + urlConj + '-verb-' + 
                  textForSearch +'.html';
               }
            if (langCode == "en")
               {if (langPrefix == "eng")urlConj = "english";
                if (langPrefix == "ger")urlConj = "german";
                if (langPrefix == "fre")urlConj = "french";
                if (langPrefix == "spa")urlConj = "spanish";
                parent.location.href = 'http://conjugator.reverso.net/conjugation-' + urlConj + '-verb-' + textForSearch +
                  '.html';
               }
            if (langCode == "sp")
               {if (langPrefix == "eng")urlConj = "ingles";
                if (langPrefix == "ger")urlConj = "aleman";
                if (langPrefix == "fre")urlConj = "frances";
                if (langPrefix == "spa")urlConj = "espanol";
                parent.location.href = 'http://conjugador.reverso.net/conjugacion-' + urlConj + '-verbo-' + textForSearch +'.html';
               }
            if (langCode == "fr")
               {if (langPrefix == "eng")urlConj = "anglais";
                if (langPrefix == "ger")urlConj = "allemand";
                if (langPrefix == "fre")urlConj = "francais";
                if (langPrefix == "spa")urlConj = "espagnol";
                parent.location.href = 'http://conjugueur.reverso.net/conjugaison-' + urlConj + '-verbe-' + 
                  textForSearch +'.html';
               }
           }
        else 
           {var msgWarning = getControlValue('ctl00_ContentPlaceHolder1_LXMenuToolbar1_hiddenMsgConjSelectWord');
            var langName = getControlValue(languageControlName);
            msgWarning = msgWarning.replace("[LANG]", langName);//hide menu
            hidemenu();
            alert(msgWarning);
           }
       }
   }
//========================================
//Author:       Ciprian Chisalita
//Description:  Get the selected word text
//========================================

function GetSelectedWordText()
   {if (browser == 1 || browser == 6)return g_docrange.text;
    else return g_docrange;
   }
//**********************************************************/
//Gets the current direction for selected word
//
//History: Created, Bogdan, 06.25.07
//History: Added new SPAN conditions, Ciprian, 27.06.2007
//**********************************************************/

function getSelectedWordDirection()
   {var dir = "101";
    if (browser == 1 || browser == 6)
       {var id = GetSelectedSpanID();
        if (id != "")
           {dir = document.getElementById(id).getAttribute("direction");
            if (dir != "undefined" && dir != "" && dir != null)
               {dir = (document.all["initialdirection"].value == 101 ? 201: 101);
               }
            else 
               {dir = (document.all["initialdirection"].value == 101 ? 101: 201);
               }
           }
       }
    else 
       {var id = g_objId;
        var o = null;
        if (id != "")o = document.getElementById(id);
        if (o != null)dir = o.attributes["direction"].value;
        var oInitialdirection = document.getElementById("initialdirection");
        var Initialdirection = oInitialdirection.attributes["value"].value;
        if (dir != "undefined" && dir != "" && dir != null)dir = (Initialdirection == 101 ? 201: 101);
        else dir = (Initialdirection == 101 ? 101: 201);
       }
    return dir;
   }
//================================
// Author:      Ciprian Chisalita
// Date:        27.06.2007
// Comments:    Get the Span id of the current range object.
//================================

function GetSelectedSpanID()
   {//checks if the selected text is a span
      //also checks the posibility when the span is a child of another span
      //(in case of highlight)		
   var id = "";
    if (g_docrange.parentElement().id == "")
       {if (g_docrange.parentElement().parentElement.tagName == "SPAN" && g_docrange.parentElement().parentElement.id != "")id = g_docrange.parentElement().parentElement.id;
       }
    else id = g_docrange.parentElement().id;
    return id;
   }
//**********************************************************/
//Translate the lang id into the language name for conjugator
// (it supports now only English, French, Spanish, German)
//
//History: Created, Bogdan, 06.25.07
//**********************************************************/

function getConjugatorLanguageKeyByLangID(langId)
   {var lang = "";
    switch (langId)
       {case "1031": //german
            lang = "ger";
            break;
        case "1033": //english
            lang = "eng";
            break;
        case "1034": //spanish
            lang = "spa";
            break;
        case "1036": //franch
            lang = "fre";
            break;
        default: 
            lang = "";
       }
    return lang;
   }
//=====================================================
// Author:      Ciprian Chisalita
// Date:        06.07.2007
// Description: Get if the conjugation is available for
//              the selected text
//=====================================================

function IsConjugationAvailable()
   {if (g_docrange.text != "" && g_docrange != "")
       {//get the selected word text
       var textForSearch = GetSelectedWordText();//get the direction of the selected word
        var dictDirection = getSelectedWordDirection();//get language id
        var languageControlId;
        var languageControlName;
        if (dictDirection == 101)
           {//languageControlId = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_sourceLangId";
              //languageControlName = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_sourceLangName";
           var langId = sourceLang;
           }
        else 
           {//languageControlId = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_targetLangId";
              //languageControlName = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_targetLangName";
           var langId = targetLang;
           }
       //var langId = getControlValue(languageControlId);
          //get language key
        var langPrefix = getConjugatorLanguageKeyByLangID(langId);
        if ("" != langPrefix)return true;
       }
    return false;
   }

function doAddToMyDict()
   {/*var my_cookie = getCookie("user_settings");
	if (my_cookie == null)
	{
		parent.location.href='addons.aspx?addon=userdictionary';
		return;
	}*/if (g_docrange.text != "" && g_docrange != "")
       {var textForSearch = GetSelectedWordText();//get the direction of the selected word
        var dictDirection = getSelectedWordDirection();//get language id
        var languageControlId;
        var languageControlName;
        if (dictDirection == 101)
           {// languageControlId = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_sourceLangId";
              //languageControlName = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_sourceLangName";
           var langId = sourceLang;
           }
        else 
           {//languageControlId = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_targetLangId";
              //languageControlName = "ctl00_ContentPlaceHolder1_LXDictionaryFlags1_targetLangName";
           var langId = targetLang;
           }
       // var langId = getControlValue(languageControlId);
          //get language key
        var langPrefix = getConjugatorLanguageKeyByLangID(langId);
        if ("" != langPrefix)
           {mouseovermenu = false;
            hidemenu();//  parent.location.href='http://demo.lexibase.com/liv7/addons.aspx?addon=userdictionary&action=contextual&word=' + textForSearch + '&lang=' + langPrefix;
            if (browser == 1 || browser == 6)parent.location.href ='../CollabDict.aspx?currentcontrol=addentry&word=' + 
              textForSearch;
            else parent.location.href = 'CollabDict.aspx?currentcontrol=addentry&word=' + textForSearch;
           }
       // else
          //	parent.location.href='http://demo.lexibase.com/liv7/addons.aspx?addon=userdictionary&action=contextual&word=' + textForSearch;
          //parent.location.href='../CollabDict.aspx?currentcontrol=addentry&word='+textForSearch
       }
   }
//==========================================================
//Modified by:  Ciprian Chisalita
//Date:         07.07.2007
//Description:  Makes an asynchronous postback 
//              with the selected text and direction.
//              In case there is no selected text or
//              the voice for pronunciation is not available
//              an error message appear
//==========================================================

function doSpeak()
   {if (typeof (g_docrange) == "undefined")CreateSelection();
    if (g_docrange.text != "" && g_docrange != "")
       {var dir;//debugger;
          // if browser is IE perform text stripping (exclude certain words from being pronounced)
        if (browser == 1 || browser == 6)
           {var textForSearch = ParseHtmlString(); //GetSelectedWordText();	
              //remove , if text has this form:   " , text , "  (Bradatan Vasile 27.05.2008)
            textForSearch = textForSearch;
            if (textForSearch.substr(0, 1) ==",")textForSearch = textForSearch.substr(1);
            if (textForSearch.substr(textForSearch.length - 1) ==",")textForSearch = textForSearch.substr(0, textForSearch.length - 1);
            dir = getSelectedWordDirectionIE();
            source = getSelectedWordSourceIE();
           }
       // if browser is Netscape perform no validation (pronounce all the selected text)
        else 
           {var textForSearch = GetSelectedWordText();
            dir = getSelectedWordDirection();
            source = getSelectedWordSource();
           }
        if (textForSearch != "")
           {
            //alert(textForSearch[1]);
            hidemenu();
            if (IsPronunciationAvailable())
               {g_docrange = ""; //clears the previous word from selection
                  //THIS CODE LAUNCH FIRE AJAX UPDATE PANEL VOICE GENERATION   
                  //__doPostBack('SpeakControl1_SpeakPanel','SPEAK~'+ textForSearch + '~' + dir + '~' + source);        
                bannerIFrame = document.getElementById("TOP_BANNER");
                if (bannerIFrame != 'undefined' && bannerIFrame != null)bannerIFrame.src = bannerIFrame.src;
                createMP3(textForSearch, source);
               }
            else 
               {var language = _currentLanguages.split( '|');
                if (dir == 101)language = language[0];
                else language = language[1];// "Pronunciation feature for [LANG] is not available!";
                var msgWarning = getControlValue("VoiceNotAvailableAlertText");
                msgWarning = msgWarning.replace("[LANG]", language);
                alert(msgWarning);
               }
           }
       }
    else 
       {//"Please select first one or several words!";
       var msgWarning = getControlValue("VoiceNoSelectionAlertText");
        alert(msgWarning);
       }
   }
//=================================================================
//Created by    George Pancescu
//Date              10.10.2007
//Description   This function processesfor speak feature
//=================================================================

function ParseHtmlString()
   {var selectedText;
    var selectedHtmlText = "";
    var ok = true;
    var color = "";
    if (g_docrange.text != "" && g_docrange != "")
       {selectedText = GetSelectedWordText();
        selectedHtmlText = g_docrange.htmlText.toUpperCase(); //g_selectEventIE.outerHTML.toUpperCase(); 	
        g_outSpanID = "";// loop through the SPANs in the Html text and verify their style					
        while (selectedHtmlText.indexOf( '</SPAN>') != - 1)
           {var spanEndPos = selectedHtmlText.indexOf( '</SPAN>') + 7;
            var spanStartPos = selectedHtmlText.substr(0, spanEndPos).lastIndexOf( '<SPAN');// get the whole SPAN content(including span tags)
            var htmlContent = selectedHtmlText.substr(spanStartPos, spanEndPos - spanStartPos);//blue: #0000FF   black: #000000
            var colorPos = htmlContent.indexOf('\"COLOR: #');
            var backColorPos = htmlContent.indexOf('\"BACKGROUND-COLOR:');
            var currentSpanText = '';// verify if the color of the text in the current span is blue or black and that the background is white. If so, then mark the text as OK, else
              // remove the text (making sure we do not remove the text surrounded by OK tags)
            if ( ! (colorPos != - 1 && htmlContent.substr(colorPos + 8, 7) != '#0000FF' && htmlContent.substr(colorPos + 8, 7) != '#000000') && backColorPos == - 1 && (color == "" || htmlContent.substr(colorPos + 
              8, 7) == color))
               {if (ok)color = htmlContent.substr(colorPos + 8, 7);
                ok = false;
                var start = htmlContent.indexOf( '>') + 1;
                var end = htmlContent.lastIndexOf( '</SPAN>');
                currentSpanText = '<OK>' + htmlContent.substr(start, end - start).replace( '&NBSP;', ' ') + '</OK>';
                var spanIDpos = htmlContent.indexOf( '<SPAN ID=');
                if (spanIDpos != - 1 && g_outSpanID == "")
                   {var tempText = htmlContent.substring(spanIDpos + 9, htmlContent.length);
                    g_outSpanID = htmlContent.substring(spanIDpos + 9, tempText.indexOf(' ') + spanIDpos + 9);
                   }
               }
            else 
               {var start = htmlContent.indexOf( '<OK>');
                var end = htmlContent.lastIndexOf( '</OK>');
                if (start == - 1 || end == - 1)currentSpanText = ' , ';
                else 
                   {if (start > 0)currentSpanText = ' , ';
                    currentSpanText += htmlContent.substr(start, end - start + 5);
                    if (end < htmlContent.length - 1)currentSpanText += ' , ';
                   }
               }
            selectedHtmlText = selectedHtmlText.substr(0, spanStartPos) + currentSpanText + selectedHtmlText.substr(spanEndPos);
           }
       // remove any Html tags from the text (also remove OK tags)
        var strippedText = selectedHtmlText.replace( /&NBSP;/gi, ' ').replace( /<OK>/gi, '').replace( /<\/OK>/gi, '').replace( /<B>/gi, '').replace( /<\/B>/gi, 
          '').replace( /<I>/gi, '').replace( /<\/I>/gi, '');
        if (strippedText.replace(/,/gi, '').replace(/ /gi, '') == '')
           {return '';
           }
        return selectedHtmlText.replace( /&NBSP;/gi, ' ').replace( /<OK>/gi, '').replace( /<\/OK>/gi, '').replace( /<B>/gi, '').replace( /<\/B>/gi, 
          '').replace( /<I>/gi, '').replace( /<\/I>/gi, '');
       }
    else 
       {return '';
       }
   }
//================================
// Author:       George Pancescu
// Date:          01.11.2007
// Comments: Gets the current direction for selected word
//                    (used only for IE, in corelation with text parsing function)
//================================

function getSelectedWordDirectionIE()
   {   var dir = "101";
    var id = g_outSpanID != "" ? g_outSpanID: GetSelectedSpanID();
    if (id != "")
       {       dir = document.getElementById(id).getAttribute("direction");
        if (dir != "undefined" && dir != "" && dir != null)
           {dir = (document.all["initialdirection"].value == 101 ? 201: 101);
           }
        else 
           {dir = (document.all["initialdirection"].value == 101 ? 101: 201);
           }
       }
    return dir;
   }

function getSelectedWordSourceIE()
   {var dir = "101";
    var id = g_outSpanID != "" ? g_outSpanID: GetSelectedSpanID();
    if (id != "")
       {dir = document.getElementById(id).getAttribute("direction");
       }
    return dir;
   }

function getSelectedWordSource()
   {var dir = "101";
    if (browser == 1 || browser == 6)
       {var id = GetSelectedSpanID();
        if (id != "")
           {dir = document.getElementById(id).getAttribute("direction");
           }
       }
    else 
       {var id = g_objId;
        var o = null;
        if (id != "")o = document.getElementById(id);
        if (o != null)dir = o.attributes["direction"].value;
        var oInitialdirection = document.getElementById("initialdirection");
        var Initialdirection = oInitialdirection.attributes["value"].value;
       }
    return dir;
   }

//=======================================================
// Author:      Ciprian Chisalita
// Date:        06.07.2007
// Description: Get if the pronunciation is available for
//              the selected text
//=======================================================

function IsPronunciationAvailable()
   {if (typeof (g_docrange) == "undefined")g_docrange = document.selection.createRange();
    if (g_docrange.text != "" && g_docrange != "")
       {var dictDirection = getSelectedWordDirection();
        var textForSearch = GetSelectedWordText();
        var option = _activeVoices.split( '|');
        if (dictDirection == 101 && option[0] != "false")return true;
        if (dictDirection == 201 && option[1] != "false")return true;
       }
    return false;
   }
//==================================================================
//Created by:   Ciprian Chisalita
//Description:  Set the active voices string (PRONUNCIATION)
//              This function is called when the selected dictionary
//              is changed.
//              ex: strActiveVoices = "true|false"
//==================================================================

function SetActiveVoices(strActiveVoices)
   {_activeVoices = strActiveVoices;
   }

function showmenuN(e)
   {CreateSelection();
    if (g_docrange == "")return false;//var mouse coord:
    var mouseX = 0;
    var mouseY = 0;//var div container edges:
    var DivResults = null;
    var rightedge = 0;
    var bottomedge = 0;
    if (searchContext == 0) //0: Normal search, 1: FTSearch
       {mouseX = e.layerX + 20;
        mouseY = e.layerY + 10;//DivResults = document.getElementById("DivMainResults");
        DivResults = document.getElementById("DivMainResults");
        rightedge = DivResults.clientWidth + DivResults.scrollLeft - mouseX;
        bottomedge = DivResults.clientHeight + DivResults.scrollTop - mouseY;
       }
    else 
       {mouseX = e.clientX + 10;
        mouseY = e.clientY + 15;
        DivResults = document.getElementById("DivFullTextSearchResults");
        rightedge = DivResults.clientWidth + DivResults.scrollLeft - mouseX;
        bottomedge = DivResults.clientHeight + DivResults.scrollTop - mouseY + 200;
       }
    g_menuN = (document.layers ? document.layers["g_menu"]: document.getElementById("g_menu"));
    var xx = mouseX;
    xx = xx + "px";
    var yy = mouseY;
    yy = yy + "px";
    if (rightedge < g_menuN.offsetWidth)
       {xx = eval (mouseX - g_menuN.offsetWidth);
        xx = xx + "px";
        g_menuN.style.left = xx;
       }
    else 
       {xx = eval (mouseX);
        xx = xx + "px";
        g_menuN.style.left = xx;
       }
    if (bottomedge < g_menuN.offsetHeight)
       {       if (DivResults.scrollTop > 0)       yy = eval (mouseY - DivResults.scrollTop - g_menuN.offsetHeight - 15);
        else yy = eval (mouseY - g_menuN.offsetHeight - 15);
        yy = yy + "px";
        g_menuN.style.top = yy;
       }
    else 
       {if (DivResults.scrollTop > 0)yy = eval (mouseY - DivResults.scrollTop);
        else yy = eval (mouseY);
        yy = yy + "px";
        g_menuN.style.top = yy;
       }
    g_menuN.style.visibility = "visible";
    g_menuN.style.fontSize = "12px";
    DisableMenuItemsFF();
    return false;
   }

function mouseDownEventN(e)
   {
   if (e.target.id == "DivMainResults" || e.target.id == "DivFullTextSearchResults")
       {hidemenuN();//init the selected text     
        g_docrange = "";
       }
   }

function validateSelectionN()
   {var r, obj;
    var id = "";
	var sText = document.getSelection();
	//var newLinePos = sText =='' ? -1 : sText.indexOf("\n");//test for new lines or two spaces
    //if (newLinePos != - 1 || (sText!='' && sText.trim().indexOf("  ") != - 1))window.getSelection().removeAllRanges();
   }
//========================================
// Author:      Ciprian Chisalita
// Description: Strips the range of spaces
//========================================

function StripRangeN(rang)
   {//set the end of the selection
   var index = rang.toString().indexOf(' ');
    if (index == - 1)index = rang.toString().indexOf(String.fromCharCode(160)); //#160 empty char like ' '
    while (index != - 1)
       {//checks if the remained string after the space contains also empty chars  
       if (index < rang.toString().length - 2)if (rang.toString().trim().substring(index).indexOf(String.fromCharCode(160)) != 
          - 1 || rang.toString().trim().substring(index).indexOf(' ') != - 1)return;
        try 
           {rang.setEnd(rang.startContainer, rang.startOffset + index);
            index = rang.toString().indexOf(' ');
            if (index == - 1)index = rang.toString().indexOf(String.fromCharCode(160));
           }
       catch (error)
           {index = - 1;
           }
       }
   }
//=====================================================
// Author:      Ciprian Chisalita
// Description: Hide the menu items (FF)
//              according the ActiveContextualOptions
//              hidden control.
//              value ex: "true|false|true"
//              means:
//              Voice enabled|Conjugator|UserDictionary
//=====================================================

function DisableMenuItemsFF()
   {// hide the copy div
      /*var copyDiv = document.getElementById("copydiv");
	copyDiv.style.height = "0px";	
	copyDiv.style.visibility = "hidden";	
	copyDiv.className = "";	  */// verify how many words have been selected 
   var words = new Array();
    words = g_docrange.split(" ");// if there are more then 4 words selected hide the 'search' option 
    if (words.length > 2)SetMenuItemStatusFF("searchdiv", false);
    else SetMenuItemStatusFF("searchdiv", true);
    var strActiveContextualOptions = document.getElementById("ActiveContextualOptions").value;
    var option = strActiveContextualOptions.split( '|');//Voice disable
    if (option[0] == "false" || ! IsPronunciationAvailable())SetMenuItemStatusFF("speakdiv", false);
    else SetMenuItemStatusFF("speakdiv", true);//Conjugator disable
    if (option[1] == "false" || ! IsConjugationAvailable() || words.length > 1)SetMenuItemStatusFF("conjugatediv", 
      false);
    else 
       {// if there are more then 2 words selected hide the 'conjugation' option 
       if (words.length > 2)SetMenuItemStatusFF("conjugatediv", false);
        else SetMenuItemStatusFF("conjugatediv", true);
       }
   //UserDictionary disable
    if (option[2] == "false" || option[3] == "false")SetMenuItemStatusFF("mydictdiv", false);
    else 
       {// if there are more then 3 words selected hide the 'add to my dict' option 
       if (words.length > 3)SetMenuItemStatusFF("mydictdiv", false);
        else SetMenuItemStatusFF("mydictdiv", true);
       }
   }
//===============================================
//Enable/disable a single menu item FF
//===============================================

function SetMenuItemStatusFF(menuItemID, enabled)
   {var mi = document.getElementById(menuItemID);
    if (enabled)
       {//check if the item is not active by default
       if (mi.getAttribute('onclick_old') != null)
           {mi.setAttribute('onclick', mi.getAttribute('onclick_old'));
            mi.className = "menuitems";
            mi.removeAttribute('disabled');
           }
       }
    else 
       {//saves the default value of onclick event        
       if (mi.getAttribute('onclick_old') == null)       mi.setAttribute('onclick_old', mi.getAttribute('onclick'));
        mi.setAttribute('onclick', 'void(0)');
        mi.setAttribute('disabled', 'disabled');
        mi.className = "menuitems_disabled";
        mi.removeAttribute('style');
       }
   }

function isValidElement(id)
   {if (id.indexOf("lblAlsoFoundIn") == - 1 && id.indexOf("lblGroupInfo") == - 1 && id.indexOf("lblFirstMatchIn") == - 1 && id.indexOf("translationNotFoundInCD") == - 1 && id.indexOf("dicoCopyrigh") == 
      - 1 && id.indexOf("IDS_LABEL_USERDICT") == - 1)
       {return true;
       }
    return false;
   }


function addBookmarkForBrowser()
   {if (window.sidebar)
       {window.sidebar.addPanel("Online Dictionaries, Collins Lexibase, Reverso", document.location.href, "");
       }
    else 
       {if (document.all)
           {window.external.AddFavorite(document.location.href, "Online Dictionaries, Collins Lexibase, Reverso");
           }
        else 
           {if (window.opera && window.print)
               {return true;
               }
           }
       }
   }

function doChangeLang(A)
   {switch (A)
       {case "en": 
            parent.location.href = "http://dictionary.reverso.net/";
            break;
        case "fr": 
            parent.location.href = "http://dictionnaire.reverso.net/";
            break;
        case "sp": 
            parent.location.href = "http://diccionario.reverso.net/";
            break;
        case "ge": 
            parent.location.href = "http://woerterbuch.reverso.net/";
            break;
        case "it": 
            parent.location.href = "http://dizionario.reverso.net/";
            break;
       }
   }

function doSearchHome(B)
   {if ((window.event && B.keyCode == 13) || (B.which && B.which == 13))
       {var A = document.getElementById("lnkSearch");
        A.focus();
       }
   }

var offsetfromcursorX = 12;
var offsetfromcursorY = 10;
var offsetdivfrompointerX = 10;
var offsetdivfrompointerY = 14;
document.write( '<div id="dhtmltooltip"></div>');
document.write( '<img id="dhtmlpointer" src="../images/arrow2.gif" style="display:none">');
var ie = document.all;
var ns6 = document.getElementById && ! document.all;
var enabletip = false;
if (ie || ns6)
   {var tipobj = document.all ? document.all["dhtmltooltip"]: document.getElementById ? document.getElementById("dhtmltooltip"): "";
   }
var pointerobj = document.all ? document.all["dhtmlpointer"]: document.getElementById ? document.getElementById("dhtmlpointer"): "";
document.onmousemove = positiontip;

function ietruebody()
   {return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement: document.body;
   }

function ddrivetip(B, A, C)
   {if (ns6 || ie)
       {if (typeof A != "undefined")
           {tipobj.style.width = A + "px";
           }
        if (typeof C != "undefined" && C != "")
           {tipobj.style.backgroundColor = C;
           }
        tipobj.innerHTML = B;
        enabletip = true;
        return false;
       }
   }

function positiontip(H)
   {if (enabletip)
       {var C = false;
        var D = (ns6) ? H.pageX: event.clientX + ietruebody().scrollLeft;
        var B = (ns6) ? H.pageY: event.clientY + ietruebody().scrollTop;
        var G = ie && ! window.opera ? ietruebody().clientWidth: window.innerWidth - 20;
        var A = ie && ! window.opera ? ietruebody().clientHeight: window.innerHeight - 20;
        var F = ie && ! window.opera ? G - event.clientX - offsetfromcursorX: G - H.clientX - offsetfromcursorX;
        var E = ie && ! window.opera ? A - event.clientY - offsetfromcursorY: A - H.clientY - offsetfromcursorY;
        var I = (offsetfromcursorX < 0) ? offsetfromcursorX * ( - 1): - 1000;
        if (F < tipobj.offsetWidth)
           {tipobj.style.left = D - tipobj.offsetWidth + "px";
            C = true;
           }
        else 
           {if (D < I)
               {tipobj.style.left = "5px";
               }
            else 
               {tipobj.style.left = D + offsetfromcursorX - offsetdivfrompointerX + "px";
                pointerobj.style.left = D + offsetfromcursorX + "px";
               }
           }
        if (E < tipobj.offsetHeight)
           {tipobj.style.top = B - tipobj.offsetHeight - offsetfromcursorY + "px";
            C = true;
           }
        else 
           {tipobj.style.top = B + offsetfromcursorY + offsetdivfrompointerY + "px";
            pointerobj.style.top = B + offsetfromcursorY + "px";
           }
        tipobj.style.visibility = "visible";
        if ( ! C)
           {pointerobj.style.visibility = "visible";
           }
        else 
           {pointerobj.style.visibility = "hidden";
           }
       }
   }

function hideddrivetip()
   {   if (ns6 || ie)
       {       enabletip = false;
        tipobj.style.visibility = "hidden";
        pointerobj.style.visibility = "hidden";
        tipobj.style.left = "-1000px";
        tipobj.style.backgroundColor = "";
        tipobj.style.width = "";
       }
   }

function showtooltip(obj)
   {
   if (ns6 || ie)
       {
       var tooltip = obj.getAttribute( 'tooltip');
       if(tooltip == null || tooltip == 'undefined')
       {
			if (ns6)
				tooltip = obj.textContent;
			else 
				tooltip = obj.innerText;
       }
       tipobj.innerHTML = tooltip;
        enabletip = true;
        return false;
       }
   }
	
function goHomePage(hrefobj, txtSearchTextValue) 
	{
		var val=''; if(txtSearchTextValue != "")
		val="?word="+txtSearchTextValue;
		var url="."+val; hrefobj.href = url; return false;
	}

function groupAnchor(text)
	{
		var url = window.location.href;
		var index = url.indexOf('#translate_box');
		if(index == -1)
			index = url.indexOf('#cd');
		if(index != -1)
			url = url.substring(0, index);
		window.location.href = url.concat(text);
}

function trim (str) 
	{
		var	str = str.replace(/^\s\s*/, ''),
			ws = /\s/,
			i = str.length;
		while (ws.test(str.charAt(--i)));
		return str.slice(0, i + 1);
}






function Selection(window) 
{
this.parentWindow = window;
}

(function() 
{
	if ("getSelection" in window) 
	{
		if ("removeAllRanges" in window.getSelection()) 
		{
			Selection.prototype.setToRange = function(range) 
											{
												with (this.parentWindow.getSelection()) 
												{
													removeAllRanges();
													addRange(range);
												}
											};
			Selection.prototype.getAsRange = function() 
			{
				return this.parentWindow.getSelection().getRangeAt(0).cloneRange();
			};
		}
		else if ("setBaseAndExtent" in window.getSelection()) 
		{
			Selection.prototype.setToRange = function(range) 
			{
				this.parentWindow.setBaseAndExtent(this.startContainer, this.startOffset, this.endContainer, this.endOffset);
			};
	
			Selection.prototype.getAsRange = function() 
											{
												var s = this.parentWindow.getSelection();
												var left = s.baseOffset;
												var right = s.extentOffset;
												
												var range = this.parentWindow.document.createRange();
												
												range.setEnd(s.extentNode, s.extentOffset);
												range.setStart(s.baseNode, s.baseOffset);
												
												if (s != "" && range.toString() != s) 
												{
													// Enter Safari fun
													// Safari Double Click fix
													if (s.type == "Range" && s.baseNode == s.extentNode && s.baseOffset == s.extentOffset) 
													{
														var str = s + "";
														var mode = 0;
														var oldRange;
														var text;
		
														do 
														{
															if (str.indexOf(range.toString()) == -1) 
															{
																range.setStart(oldRange.startContainer, oldRange.startOffset);
																range.setEnd(oldRange.endContainer, oldRange.endOffset);
																if (mode == 0)
																	mode = 1;
																else
																	break;
															}
		
															oldRange = range.cloneRange();
			
															if (mode == 0) 
															{
																if (range.startOffset == 0) 
																{
																	text = prevText(range.startContainer);
																	if (text)
																		range.setStart(text, text.data.length);
																	else 
																	{
																		mode = 1;
																		break;
																	}
																}
			
																range.setStart(range.startContainer, range.startOffset-1);
															}
															else 
															{
																if (range.endOffset == range.endContainer.data.length) 
																{
																	text = nextText(range.endContainer);
																	if (text)
																		range.setEnd(text, 0);
																	else
																		break;
																}
			
																range.setEnd(range.endContainer, range.endOffset + 1);
															}
														} while (true);
													}
													// Backwards selection
													else 
													{
														range.setEnd(s.baseNode, s.baseOffset);
														range.setStart(s.extentNode, s.extentOffset);
													}
												}

												return range;
											};
		}
		else if ("selection" in document) 
		{
			Selection.prototype.setToRange = function(range) 
			{
				range.select();
			};
			Selection.prototype.getAsRange = function() 
			{
				return this.parentWindow.document.selection.createRange().duplicate();
			};
		}
	}

	function prevText(node) 
	{
		do 
		{
			node = prevNode(node);
		} while (node != null && node.nodeType != 3);
	
		return node;
	}
	
	function prevNode(node) 
	{
		while (node.previousSibling == null) 
		{
			if (node.parentNode == node.ownerDocument)
				return null;
			else
				node = node.parentNode;
		}
	
		if (node.previousSibling.hasChildNodes())
			return node.previousSibling.lastChild;
		else
			return node.previousSibling;
	}
	
	function nextText(node) 
	{
		do 
		{
			node = nextNode(node);
		} while (node != null && node.nodeType != 3);
	
		return node;
	}
	
	function nextNode(node) 
	{
		while (node.nextSibling == null) 
		{
			if (node.parentNode == node.ownerDocument)
				return null;
			else
				node = node.parentNode;
		}
	
		node = node.nextSibling;
		while (node.hasChildNodes())
		node = node.firstChild;
		return node;
	}
})();


function openLexicon()
{
	window.open("Lexicon.aspx", "Lexicon", "width=350, height=480, location=0, status=0, fullscreen=0, resizable=0, scrollbars=1, toolbar=0");
}

function openViewEntry(obj)
{
	var w = 820;
	var h = 450;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var url = obj.attributes["link"].value
	var newwindow = window.open(url, "", "width=" + w + ", height=" + h + ", top=" + top + ", left=" + left + ", location=0, status=0, fullscreen=0, resizable=0, scrollbars=1, toolbar=0");
	if (window.focus) {newwindow.focus()}
}

function createMP3(textForSearch,source)
{
	var uri ="SpeakManager.aspx"
	var params="source=" + source +"&textForSearch=" + textForSearch
	GetOriginalVoiceSource(uri,params);
}

function GetOriginalVoiceSource(wsUrl, wsParams)
{
	xmlhttp=null;
	if (window.XMLHttpRequest)
	{// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{// code for IE5 and IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null)
	{
		xmlhttp.open("post",wsUrl + "?" + wsParams,true);
		if(browser == 1)
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form; charset=windows-1252");
		else
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form; charset=UTF-8");
		xmlhttp.setRequestHeader("Content-length", wsParams.length);
		xmlhttp.onreadystatechange=OnComplete_GetOriginalHTMLSource;
		xmlhttp.send(wsParams);
	}
	else
	{
	alert("Your browser does not support XMLHTTP.");
	}
}

function OnComplete_GetOriginalHTMLSource()
{
	if (xmlhttp.readyState==4)
	{// 4 = "loaded"   
		if (xmlhttp.status==200)
		{// 200 = OK
			var arg = xmlhttp.responseText
			voicePlayer=document.getElementById("speak");
			voicePlayer.innerHTML = arg;
		}
	}
}