
hId = "search_help";
timeVisible = 5;
tmpVisible = timeVisible;

intTmpTimer = 0;
statusY = 0;
statusX = 0;

arrstr = new Array();

for (i = 0; i < 30; i ++)
{
   arrstr[i] = "";
}

if (window.XMLHttpRequest)
{
   window.captureEvents(Event.MOUSEMOVE);
   window.onmousemove= displayCoords;
}   


function displayCoords(e) {
    statusX = e.pageX;
    statusY = e.pageY;
}

function set_id(id_name,str_name) {
   document.getElementById(id_name).innerHTML = str_name;}

function get_tagData(my_name){
   return my_name.firstChild.data;}

function writeURL(val)
{
   document.write("<a href=\"" + wwwUrl + "\" target=\"_blank\">see more...</a>");
}

function displayHelp(dstatus)
{
   gId = "display-help";
   sId = "textbox-submit";
   help = "For searching for in categories:<br /><i>{text} + {name categories}</i>.<br />For searching for with use the operations 'OR':<br /><i>{text} or {text} ..</i>";
   if (dstatus == 1)
   {
      if (!window.XMLHttpRequest)
      {
         statusY = event.clientY;
         statusX = event.clientX;
      }
      document.getElementById(gId).style.display = "block";
     document.getElementById(gId).style.top = statusY + 15;
      document.getElementById(gId).style.left = statusX + 15;
      set_id(gId,help);
   }
   else
   {
      document.getElementById(gId).style.display = "none";
   }      
}

function checkForm()
{
   if(document.search_form.str.value.length == 0)
   {
      alert('Error!\nWill enter word for searching!');
      return false;
   }
   else
   {
      return true;
   }
}

function createUrls(uId)
{
   urllink = new Array();
   namelink = new Array();
   word = document.getElementById(uId).firstChild.nodeValue;
   strresult = "";
   namelink[0] = "Encarta World Dictionary";
   urllink[0] = "http://encarta.msn.com/dictionary_/" + word + ".html";
   namelink[1] = "OneLook Dictionaries";
   urllink[1] = "http://www.onelook.com/?w=" + word;
   namelink[2] = "Merriam-Webster";
   urllink[2] = "http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=" + word + "&x=0&y=0";
   namelink[3] = "Google Search";
   urllink[3] = "http://www.google.com/search?q=" + word;
   for (i = 0; i < urllink.length; i ++)
   {
      strresult += "<a href=\"" + urllink[i] + "\" target=\"_blank\">" + namelink[i] + "</a>";
      if (i < urllink.length - 1) strresult += ", ";
   }
   set_id(uId,strresult);
}

function LoadEvent()
{
   if (document.search_form) document.search_form.str.focus();
   if (document.getElementById("url-link")) createUrls("url-link");
   addHelpForSearch();
}

function addHelpForSearch()
{
  var languages = {
     'ru':'<div>Используйте знаки вопроса пропавших без букв (одна "?" - Одно письмо):\n <code>кап?ал или кап???л</code>\n  Используйте звездочку на ЛЮБОЙ несколько неизвестных писем:\n  <code>навигат* или *злы или кро*ворд</code>\n  Исключить слова, содержащие буквы, которые следуют за дефис (тире):\n <code>п??лы -зн</code>\n</div>',
     'de':'<div>Fragezeichen für fehlende Buchstaben benutzen (einer "?" - ein Buchstabe):\n <code>kap?tal oder kap???l</code>\n  Ein Sternchen für JEDE MÖGLICHE Zahl der unbekannten Buchstaben benutzen:\n  <code>nav* oder *ma oder b*g</code>\n  Die Wörter ausschließen, welche die Buchstaben enthalten, die einem Bindestrich (Schlag) folgen:\n <code>p??zle -whk</code>\n</div>',
     'fr':'<div>Utilisez des points d\'interrogation pour les lettres manquantes (un "?" - Une lettre):\n <code>cap?tal ou cap??a?</code>\n  Utilisez un astérisque pour UNE nombre inconnu de lettres:\n  <code>navigat* ou *zzle ou cro*s</code>\n  Exclure des mots contenant les lettres qui suivent un trait d\'union (tiret):\n <code>p???le -wdxu</code>\n</div>',
     'es':'<div>El uso de signos de letras que faltan (un "?" - Una letra):\n <code>cap?tal o cap??a?</code>\n  Utilice un asterisco para cualquier número de cartas desconocidas:\n  <code>pret* o *robo o de*so</code>\n  Excluir palabras que contienen las letras que siguen un guión (guión):\n <code>de???tor -sml</code>\n</div>'
  }
  if (document.getElementById("search_help"))
  {
    if (location.href.split('/')[3] && languages[ location.href.split('/')[3] ])
    {
       document.getElementById("search_help").innerHTML = languages[ location.href.split('/')[3] ];
    }
    else
    {
       document.getElementById("search_help").innerHTML = '<div>Use question marks for missing letters (one "?" - one letter):\n               <code>cap?tal or cap??a?</code>\n               Use an asterisk for ANY number of unknown letters:\n               <code>navigat* or *zzle or cr*word</code>\n               Exclude words containing the letters that follow a hyphen:\n               <code>p??zle -wdxu</code>\n      </div>';
    }
  }
}

function StartTimeout() 
{   
   tmpVisible--;
   if (tmpVisible > 0)
   {
      intTmpTimer = setTimeout("StartTimeout()", 1000);      
   }
   else
   {
      tmpVisible = timeVisible;
      HelpView(0);
   }      
}


function HelpView(type)
{
   if (type == 0) 
   {
      document.getElementById(hId).style.display = "none";
   }
   else
   {   
      document.getElementById(hId).style.display = "block";
      clearTimeout(intTmpTimer);
      StartTimeout();
   }
}

/* CROSSWORD SOLVERPAGE */
function LengthWord(len)
{
   cachearr = new Array();
   allstr = "";
   
   set_id("count-len",len);
   
   for (i = 0; i < 30; i++ )
   {
      if (document.crossform["boxes_" + i]) arrstr[i] = document.crossform["boxes_" + i].value;
   }
   
   for (i = 0; i < len; i++ )
   {
      allstr += "<input name=\"boxes_" + i + "\" type=\"text\" maxlength=\"1\" value=\"" + arrstr[i] + "\" />";
   }   
   
   set_id("inputboxes",allstr);
}
