		
	/*-------------------------------------------------------------------*/
	/* JAVASCRIPT														 */ 
	/*-------------------------------------------------------------------*/
	// 
	// http://scriptasylum.com/tutorials/encdec/encode-decode.html	
	//  code key - 1
	
	var spellcheck = function (data) 
	{
		var found = false;
		var url="";
		var text = data [0];
	
		if (text != document.getElementById ("input_epedia_text").value)
			return;
		
		url= "javascript: submitSearchEpediaBt()";
		for (i=0; i<data [1].length; i++) 
		{
			if (text.toLowerCase () == data [1] [i].toLowerCase ()) 
			{
				found = true;
				
				document.getElementById ("spellcheckresult").innerHTML = "<font color=\"green\" face=\"arial\">Ok - <a href=\"" + url + "\">clique aqui</a>.</font>";
			}
		}
	
		if (! found)
			document.getElementById ("spellcheckresult").innerHTML = "<font  color=\"red\" face=\"arial\"  >Palavra n&atilde;o encontrada.</font>";
		
			
		keyword_option  = "";
		document.getElementById("select1").length = 0;			
		
		for (i=0; i<data [1].length; i++) 
		{
			keyword = data [1] [i];
			value = keyword;
			keyword_option = "1";	
				
			if (i == 0)
			{
				option = new Option ("-- Palavras relacionadas --","",true, true);
				document.getElementById("select1").options[i] = option;
			}
		
			option = new Option (keyword,value, false, false);
		
			
			document.getElementById("select1").options[i+1] = option;
		}
		
		if (keyword_option != "")
		{
			var block_wiki_keywords_div = document.getElementById("wiki_keywords_div");
			block_wiki_keywords_div.style.display = "block";
			
		}
		else
		{
			var block_wiki_keywords_div = document.getElementById("wiki_keywords_div");
			block_wiki_keywords_div.style.display = "none";
		}
		
	}
	
	var getjs = function (value) {
		if (! value)
		{
			document.getElementById ("spellcheckresult").innerHTML = "";
			var block_wiki_keywords_div = document.getElementById("wiki_keywords_div");
			block_wiki_keywords_div.style.display = "none";
			return;
		}
		
		value = leftTrim(value);
		document.getElementById ("input_epedia_text").value = value;
	
		url = "http://pt.wikipedia.org/w/api.php?action=opensearch&search="+value+"&format=json&callback=spellcheck";
	
		document.getElementById ("spellcheckresult").innerHTML = "Checando ...";
		var elem = document.createElement ("script");
		elem.setAttribute ("src", url);
		elem.setAttribute ("type","text/javascript");
		document.getElementsByTagName ("head") [0].appendChild (elem);
	}
	
	function surfto(form) 
	{
		var myindex=form.select1.selectedIndex;
		
		if (form.select1.options[myindex].value != 0) 
		{
			picked_value=form.select1.options[myindex].value;
			document.getElementById("input_epedia_text").value = picked_value;
			getjs (picked_value);
		}
	}
	
	function clean_instruction (field_value)
	{
		if (field_value == "Digite a palavra:")
		{
			document.getElementById("input_epedia_text").value = "";
		}
	}
	
	function leftTrim(sString)
	{
		while (sString.substring(0,1) == " ")
		{
			sString = sString.substring(1, sString.length);
		}
		return sString;
	}

