function getMaxOrder(obj, url, divId){
	new Ajax.Updater(divId, 
					 url+'/category_id/'+obj.options[obj.selectedIndex].value, 
					 {asynchronous:true, evalScripts:false});
}


function getMaxOrderItem(obj, url, divId){
	new Ajax.Updater(divId, 
					 url+'/glossary_id/'+obj.options[obj.selectedIndex].value, 
					 {asynchronous:true, evalScripts:false});
}



function SetGlossPage(val){
	$('page_in').value = val;
	$('GlossaryFilter').submit();
}



function getGlossarySelect(obj, url, divId){
	new Ajax.Updater(divId, 
					 url+'/category_id/'+obj.options[obj.selectedIndex].value, 
					 {asynchronous:true, evalScripts:false});
}


function SetGlossFilter(form_id){
	$(form_id).submit();
}


function CheckItemName(nameFieldId, url, divId){
	new Ajax.Updater(divId, 
				 	 url+'/name/'+$(nameFieldId).value, 
				 	 {asynchronous:true, evalScripts:true});
}


function DescriptionField(wordId, url, divId){
	new Ajax.Updater(divId, 
				 	 url+'/word_id/'+wordId, 
				 	 {asynchronous:true, evalScripts:true});	
}


function ClearDescriptionField(url, divId){
	new Ajax.Updater(divId, 
			 	 	 url, 
			 	 	 {asynchronous:true, evalScripts:true});	
}


function CheckItemNameForEditing(nameFieldId, url, divId){
	new Ajax.Updater(divId, 
			 	 	 url+'/name/'+$(nameFieldId).value, 
			 	 	 {asynchronous:true, evalScripts:true});		
}


function UpdateDescriptionField(data){
	for (var i=0; i<data.length; i++){
		ifr = $("desc_"+data[i]['lan']+"_ifr");
		doc = getDocumentForIframe(ifr);
		body = doc.getElementById('tinymce');
//		alert(body.innerHTML);
		body.innerHTML = data[i]['value'];
	}
}


function getDocumentForIframe(target) {
	if (target == undefined)
		return document;
	else if (target.contentDocument)
		return target.contentDocument;
	else if (target.contentWindow)
		return target.contentWindow.document;
	else if (target.document)
		return target.document;
	else
		throw 'unable to get document object';
}
