
function addLetter(value,place) {
	var val = document.getElementById(place);
	if(val.value.length < 64){
		if(document.selection){
			val.focus();
			document.selection.createRange().text = value;
		}
		else if(val.selectionStart || val.selectionStart == '0')	{
			var stb = val.value.substring(0,val.selectionStart);
			var ste = val.value.substring(val.selectionEnd,val.value.length);
			val.value = stb + value + ste;
		}
		else{
			val.value += value;
		}
	}
} 


function openw( w, hash ){
	hash2 = hash ? hash : '';	
	window.open( '/popup/?w=' + w + "&hash=" + hash ,  'slownik', 'scrollbars,resizable, width=800, height=500' );
}

function doRequest() {

		var v 	= $('proposition');
		var typ	= v.typ.value; 
		var cat	= v.cat.value;
		var pol	= v.pol.value;
		var eng	= v.eng.value;

		var opt = {
		    method: 'post',
		    postBody: 'typ='+typ+'&cat='+cat+'&pol='+pol+'&eng='+eng+'&w=3',
		    onSuccess: function(t) {
		        //alert(t.responseText);
		    },
		    // Handle 404
		    on404: function(t) {
		        alert('Error 404: location "' + t.statusText + '" was not found.');
		    },
		    // Handle other errors
		    onFailure: function(t) {
		        alert('Error ' + t.status + ' -- ' + t.statusText);
		    }		
		}
		//new Ajax.Request('/ajax/', opt);
		new Ajax.Updater('infoDiv','/ajax/', opt);
		setTimeout(function () {$('infoDiv').innerHTML = '';} ,2500);
}

function translate(autocompletion, selected) {
	waitMsg();
	document.query_form.submit();
}

function waitMsg(){
	if (document.query_form.query.value == null || document.query_form.query.value =='' || document.query_form.query.value ==' ') {
		alert('The word for translation is not entered!');	
		document.query_form.query.focus();
		return false;
	} else {
		document.all.loadMessage.style.display = "inline"; 
		return true; 
	}
}

function addSearchEngine() {
	window.sidebar.addSearchEngine('http://angielsko-polski.slownik24.pl/angielsko-polski_slownik24_pl.src','http://angielsko-polski.slownik24.pl/i/angielsko-polski_slownik24_pl.png','slownik24.pl','Słowniki');
}