// request description of the linked element
function more(element, id) {
	
	myTip(); // unhide last Tip.
	
	var gotout = false;
	
	this.onmouseout = function() { gotout = true };
	
	setTimeout( function() {
			
			if( gotout==false ) {	
			
				var url='AjaxXmlGenerator';
				url+='?id='+id;
			    url+='&actionCode='+18;
			    
				xmlreqPOST(url);
			}	
		}, 200 );
					
}

function markAsDepricated( elementId, actionCode ) {
	
	showLoading(elementId);
	
	var url='AjaxXmlGenerator';
	url+='?id='+document.getElementsByName("elementuri")[0].value;
    url+='&actionCode='+actionCode;
    
	xmlreqPOST(url);
}
function markAsNonDepricated( elementId, actionCode ) {
	
	showLoading(elementId);
	
	var url='AjaxXmlGenerator';
	url+='?id='+document.getElementsByName("elementuri")[0].value;
    url+='&actionCode='+actionCode;
    
	xmlreqPOST(url);
}


function addFreezepoint( id, description, elementId ) {
	
	showLoading(elementId);
	
	var url='AddFreezepoint';
	url+='?id='+id;		    
	url+='&description='+description;
    
	xmlreqPOST(url);
}

function removeAllOptions(selectbox)
{
	selectbox.options.length=0;
	/*var i;
	for(i=selectbox.options.length-1;i>=0;i--) {
		selectbox.remove(i);
	}*/
}
function checkRadioDatatypes(idInstancesPanel,nameFormElement) {
	
	selectbox = document.getElementsByName(nameFormElement + '_sel')[0];
	
	// removeAllOptions( document.getElementsByName(nameFormElement + '_list')[0] ); 
	
	document.getElementsByName(nameFormElement)[0].value=selectbox.options[selectbox.selectedIndex].value; 
	selectbox.disabled=false; 
	selectbox.style.visibility = "visible";
	document.getElementById(idInstancesPanel).style.visibility = "hidden";
	document.getElementsByName(nameFormElement + '_adder')[0].disabled=true
	document.getElementsByName(nameFormElement + '_adder')[0].style.visibility = "hidden";
}

function checkRadioObjectTypes(idInstancesPanel, nameFormElement) {
		
	selectboxHidden = document.getElementsByName(nameFormElement)[0];
	selectboxList = document.getElementById(nameFormElement + '_act').getElementsByTagName("span");
	
	selectboxHidden.value="";
	
	for(i=0; i<selectboxList.length; i++) {
		
		selectboxHidden.value += selectboxList[i].id + ",";
	}
	
	document.getElementById(idInstancesPanel).style.visibility = "visible";
	document.getElementsByName(nameFormElement + '_adder')[0].disabled=false; 
	document.getElementsByName(nameFormElement + '_adder')[0].style.visibility = "visible";
	document.getElementsByName(nameFormElement + '_sel')[0].disabled=true
	document.getElementsByName(nameFormElement + '_sel')[0].style.visibility = "hidden";
}
/*

function checkRadioObjectTypes(nameFormElement) {
		
	selectboxHidden = document.getElementsByName(nameFormElement)[0];
	selectboxList = document.getElementsByName(nameFormElement + '_list')[0];
	
	selectboxHidden.value="";
	
	for(i=0; i<selectboxList.options.length; i++) {
		
		selectboxHidden.value += selectboxList.options[i].value + ",";
	}
	
	document.getElementsByName(nameFormElement + '_list')[0].disabled=false; 
	document.getElementsByName(nameFormElement + '_adder')[0].disabled=false; 
	document.getElementsByName(nameFormElement + '_sel')[0].disabled=true
}
 */

/*
function buttonAddToListClick( nameFormElement, receiverId, adderId, typenameNew ) {

	if(document.getElementById(receiverId).value=="") { 
		alert( "To add a new " + typenameNew + " select one of the offered elements or first create one!");
	} else { 
		setFormValueFromBrowseWin(nameFormElement, document.getElementById(receiverId).value, document.getElementById(adderId).value );
		
		document.getElementById(adderId).value = "";
		document.getElementById(receiverId).value = "";
	}
	document.getElementById(adderId).focus();			
}
*/


function switchComment( longentry, shortentry, linktolshort, linktolong ) {
	
	var longentry=longentry;
	var shortentry=shortentry;

	var commentContainer = document.getElementById("commentContainerSwitchable");
	var commSwitch = document.getElementById("commentSwitch");
	
	if( commSwitch.innerHTML.indexOf('short')==-1 ) {
		
		commentContainer.innerHTML=longentry;
		commSwitch.innerHTML=linktolshort;
	}
	else {
		
		commentContainer.innerHTML=shortentry;
		commSwitch.innerHTML=linktolong;
	}
}

function hideDeleteButtonIfNothingSelected( containerId, deleteButtonId ) {

	// 1. find which elements are highlighted:
	var spans = document.getElementById(containerId).getElementsByTagName("span");

	var found = false;
	j=0;
	for( i=0;found==false && i<spans.length;i++ ) {
		if(!spans[i].style.backgroundColor==""){
			found = true;
			break;
		}
	}	
	if( found==false ) {
		// hide the delete button:
		//document.getElementById( deleteButtonId ).style.visibility = "hidden";
		document.getElementById( deleteButtonId ).src = "skins/default/images/delete_unactive.png";
	}
	else {
		document.getElementById( deleteButtonId ).style.visibility = "visible";
		document.getElementById( deleteButtonId ).src = "skins/default/images/delete.png";
	}
}

/**
 * 
 * @param {Object} nameFormElement
 * @param {Object} receiverId	the hidden field which containes the ID of the element to add
 * @param {Object} adderId	the id of the input field which contains the name of the element to add
 * @param {Object} typenameNew
 * @param {Object} receiverContainerId	the id of the container which contains already selected elements 
 */
function buttonAddToSelectedClick( nameFormElement, receiverId, adderId, typenameNew, receiverContainerId, deletebuttonId ) {

	if( document.getElementById(receiverId).value!="" || receiverId=="instanceesHavingClassInDomainEntry_receivedId") { 
 
		// setFormValueFromBrowseWin(nameFormElement, document.getElementById(receiverId).value, document.getElementById(adderId).value );
		
		var id = document.getElementById(receiverId).value;

		var label = document.getElementById(adderId).value;
		if (id=="") {
			id = label;
		}
		
		// TODO: description is not requested...
		addToSelectedElements( receiverContainerId, nameFormElement, id, label, deletebuttonId );
			
		// if( document.getElementsByName(nameFormElement)[0].value.indexOf( id + "," )==-1 ) { // if not added yet...
			
			/*
			var newSpan = document.createElement("span");
			newSpan.setAttribute("id", document.getElementById(receiverId).value );
			// IE
			newSpan.className = "selectedElement";
			// Firefox
			newSpan.setAttribute("class", "selectedElement");	
			newSpan.setAttribute("onclick", "toggleBackground(this);return false;" );	
			newSpan.innerHTML = label;
			
			document.getElementById( receiverContainerId ).appendChild(newSpan);
			*/
			
		//}
		
		document.getElementById(adderId).value = "";
		document.getElementById(receiverId).value = "";
		
		document.getElementById(adderId).blur();
		setTimeout( function() { document.getElementById(adderId).focus(); }, 1 ); // give time so that blur can reset the focus (is a threat)
	}/*
	else {	
		alert( "To add a new " + typenameNew + " select one of the offered elements or first create one!");	
	}*/	
	// document.getElementById(adderId).focus();
}

function addToSelectedElements( receiverContainerId, nameFormElement, id, label, deletebuttonId ) {

	if( document.getElementsByName(nameFormElement)[0].value.indexOf( id + "," )==-1 ) { // if not added yet...
		document.getElementById( receiverContainerId ).innerHTML += " " + generateSelectedElement( id, label, receiverContainerId, deletebuttonId );
		document.getElementsByName(nameFormElement)[0].value+=id+",";
	}
}

function generateSelectedElement( id, label, containerId, deletebuttonId ) {

	return "<span id=\"" + id + "\" class=\"selectedElement\" onmouseover=\"more(this,'"+id+"')\" onclick=\"toggleBackground(this); hideDeleteButtonIfNothingSelected('"+containerId+"','"+deletebuttonId+"'); return false;\">" + label + "</span>"; // WITHOUT "\n" !!!
}

function getFullURI( endOfUri ) {
	
	var uri = endOfUri;
		
	if( uri.substr(0,4)!="http" ) {
		base = document.getElementsByTagName("base")[0].getAttribute("href");		
		uri = base + uri;	
	}	
		
	return uri;
}

function searchboxGo( val ) {
	
	if(val!="") {
				
		//window.location=getFullURI( val );
		changeLoc( val );
	}
	return false;	
}
 

function searchboxOnSelectExistingElement(fieldId, buttonId) {
		
	if( document.getElementById(fieldId).value!="" ) {
		/*
		document.getElementById(buttonId).disabled=false;
		*/
		
		// window.location = getFullURI( document.getElementById(fieldId).value );
		changeLoc( document.getElementById(fieldId).value );
	}
	/*
	else {
		document.getElementById(buttonId).disabled=true;
	}
	*/
}
function disableButtonOnValueNull(fieldId, buttonId) {
		
	if( document.getElementById(fieldId).value!="" ) {
		document.getElementById(buttonId).disabled=false;
	}
	else {
		document.getElementById(buttonId).disabled=true;
	}
}
function searchboxOnBlur( searchBoxId, receiverId, def ) {
	
	box = document.getElementById(searchBoxId);
	
	if( !box.value || box.value.trim()=='' ){ 
		box.value=def;
		document.getElementById(receiverId).value = '';
	}
	/*
	if( document.getElementById(receiverId).value=='') {
		box.style.color='#CCCCCC';
	}
	*/
}
/*
function searchboxOnFocus( input_id, params, receiverId, def ) {
	return searchboxOnFocus( input_id, params, receiverId, def, false, '' );
}
*/
function searchboxOnFocus( input_id, params, receiverId, def, showCreateLinks, createNewAdditionalParams ) {

	var box = document.getElementById( input_id );
	
	if( box.value && box.value.indexOf( def )!=-1 ){
		box.value=''; 
		document.getElementById(receiverId).value = '';
	}
	/*
	box.style.color='#000000';
	*/
	activateAutocompleter(input_id,receiverId,'AjaxXmlGenerator',params,showCreateLinks,createNewAdditionalParams );
}

/**
 * 
 * @param {Object} input_id	ID of the input field with will receive the name of the element
 * @param {Object} receiver_id	ID of the hidden field with will receive the ID of the element
 * @param {Object} requestpath	the path of the XML-file (with AJAX requested)
 * @param {Object} additionalparameters	parameters to send to the Server when requesting with AJAX
 */
var globalAjax4Suggest = new Array();
function activateAutocompleter( input_id, receiver_id, requestpath, additionalparameters, showCreateLinks, createNewAdditionalParams ) {

	if( !document.getElementById(receiver_id).onclick ) {
		
		while( additionalparameters.indexOf("#")!=-1) {
			additionalparameters = additionalparameters.replace(/#/, escape("#")); // for parameters containing "#"
		}
		
		document.getElementById(receiver_id).onclick = new Ajax4Suggest(input_id, receiver_id, requestpath, additionalparameters, 'input', 'POST', showCreateLinks, createNewAdditionalParams );
	}
}
function getSelectionId(text, li) {
	
	//alert( text.id );
	
	//document.getElementById('subClassOfEntry_autocomplete_id').value = li.id;
	//document.getElementById('subClassOfEntry_autocomplete_val').value = text.value;
}

function sendupdaterequest( cssidcontent, nameformalement, oldtimestamp ) {
	sendupdaterequest( cssidcontent, nameformalement, oldtimestamp, showNavigation, true );
}
function sendupdaterequest( cssidcontent, nameformalement, oldtimestamp, showNavigation ) {
	var botton = document.getElementById(nameformalement+'_savebutton');
	botton.src='skins/default/images/loading.gif';
	botton.style.cursor='wait';
	
	
	
	var entry = document.getElementsByName( nameformalement )[0].value;
	
	if( cssidcontent=="divlabel" ) {
		
		var conf = "This operation will not change the label but do the following:\n";
		conf += "1. create a copy of the current element (with the actual STORED contents like description, ...),\n";
		conf += "2. the new element will be labeled '"+entry+"'\n";
		conf += "3. include the new created element everywhere, where the original is used.\n\n";
		conf += "Click OK to create this copy now.";
		
		if( !confirm( conf ) ) {
			// turn the image back to "save.png":
			botton.src = this.base+"skins/default/images/accept.png";
			botton.style.cursor='pointer'
			return;
		}
	}
	
	var url='Update';
	url+='?id='+document.getElementsByName("elementuri")[0].value;
	url+='&oldtimestamp='+oldtimestamp.trim();			    
	url+='&cssidcontent='+cssidcontent.trim();
	url+='&entry='+entry.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    

    
	xmlreqPOST(url);
	
}


function showforminviewmode( cssidcontent ) {
	showforminviewmode( cssidconten, false );
}
function showforminviewmode( cssidcontent, showNavigation ) {
	
	var url='GetFormInViewMode';
	url+='?id='+document.getElementsByName("elementuri")[0].value;	   
	url+='&cssidcontent='+cssidcontent.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    
	xmlreqPOST(url);
}



function showcontentineditmode( cssidcontent, oldtimestamp ) {
	showcontentineditmode( cssidcontent, oldtimestamp, showNavigation, false );
}
function showcontentineditmode( cssidcontent, showNavigation ) {
	
	var url='GetContentInEditMode';
	url+='?id='+document.getElementsByName("elementuri")[0].value;
	url+='&cssid='+cssidcontent.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    
	xmlreqPOST(url);
}

function showformineditmode( cssidcontent, oldtimestamp ) {
	showformineditmode( cssidcontent, oldtimestamp, showNavigation, false, "" );
}
function showformineditmode( cssidcontent, oldtimestamp, showNavigation ) {
	showformineditmode( cssidcontent, oldtimestamp, showNavigation, "" );
}
function showformineditmode( cssidcontent, oldtimestamp, showNavigation, viewtype ) {
	
	var url='GetFormInEditMode';
	
		url+='?id='+document.getElementsByName("elementuri")[0].value;	

	url+='&oldtimestamp='+oldtimestamp.trim();		    
	url+='&cssidcontent='+cssidcontent.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    	    
	url+='&viewtype='+viewtype.trim();
	xmlreqPOST(url);
}

function showpropertyineditmode( cssidcontent,propKey ) {
	
	var url='editMode.do';	    
	url+='?cssidcontent='+cssidcontent.trim();
    url+='&propKey='+propKey;	    
	xmlreqPOST(url);
}

function showpropertyinviewmode( cssidcontent, showNavigation,propKey ) {
	
	var url='viewMode.do';   
	url+='?cssidcontent='+cssidcontent.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    url+='&propKey='+propKey;	
	xmlreqPOST(url);
}

function sendpropertyupdaterequest( cssidcontent, nameformalement, oldtimestamp ,propKey ) {
	showNavigation=true;
	var botton = document.getElementById(nameformalement+'_savebutton');
	botton.src='skins/default/images/loading.gif';
	botton.style.cursor='wait';
	

	
	var entry = document.getElementsByName( nameformalement )[0].value;
	
	if( cssidcontent=="divlabel" ) {
		
		var conf = "This operation will not change the label but do the following:\n";
		conf += "1. create a copy of the current element (with the actual STORED contents like description, ...),\n";
		conf += "2. the new element will be labeled '"+entry+"'\n";
		conf += "3. include the new created element everywhere, where the original is used.\n\n";
		conf += "Click OK to create this copy now.";
		
		if( !confirm( conf ) ) {
			// turn the image back to "save.png":
			botton.src = this.base+"skins/default/images/accept.png";
			botton.style.cursor='pointer'
			return;
		}
	}
	
	var url='update.do';
	url+='?oldtimestamp='+oldtimestamp.trim();			    
	url+='&cssidcontent='+cssidcontent.trim();
	url+='&entry='+entry.trim();
	if( showNavigation )
		url+='&shownavigation=true';
    url+='&propKey='+propKey;	
	xmlreqPOST(url);
	
}
// returns a Query if the user really wants to delete the element
function getDeleteMessage( formName ) { 
	var ans; 
	ans=window.confirm('Do you really want to delete this element?');
	//alert (ans); 
	if (ans==true) { 
		formName.submit();
	} else {
	}
}


function getStateChangeMessage( formName ) { 
	var ans; 
	ans=window.confirm('Do you really want to change the state?');
	//alert (ans); 
	if (ans==true) { 
		formName.submit();
	}
}



// Warning, that the URI does not exist; this is checked by the server.
function checkIfURIIsReachable(elementId,uri,actionCode) {
    var url='AjaxXmlGenerator';
    url+='?actionCode='+actionCode;
	url+='&uri='+uri;
	url+='&elementid='+elementId;
	
	xmlreqPOST(url);
}

function showInSavedSuccessfullyStyle() {
	
	showSmall();
	setTimeout( "self.close()", 1800 );
}

function showSmall() {
	
	var h = 200;
	var w = 400;
	
	h = h - 20; 
	var x=0, y=0, parameter="";
	if (w < screen.availWidth || h < screen.availHeight) {
		x = (screen.availWidth - w - 12) / 2;
		y = (screen.availHeight - h - 104) / 2;
		if (window.opera) 
			y = 0; // Opera positioniert unter den Symbolleisten
		if (x<0 || y<0) { 
			x=0; y=0; 
		}
	}
	
	window.resizeTo( w, h );
	// center:
	window.moveTo( x, y );
}
var numberOfOpenedFields = 0;
function changeLoc( uri ) {
	
	if( uri.indexOf("http://")==-1)
		uri = getFullURI(uri);		
		
	if( numberOfOpenedFields>0 ) {
		var message = "There are opened fields. Do you really want to follow the link without saving your work?";
		
		if( confirm( message )==true )
			window.location = uri;
	}
	else
		window.location = uri;
	
	return false;
}

function openCreateNew( uri ) {

	var h = 700;
	var w = 950;
	
	h = h - 20; 
	var x=0, y=0, parameter="";
	if (w < screen.availWidth || h < screen.availHeight) {
		x = (screen.availWidth - w - 12) / 2;
		y = (screen.availHeight - h - 104) / 2;
		if (window.opera) 
			y = 0; // Opera positioniert unter den Symbolleisten
		if (x<0 || y<0) { 
			x=0; y=0; 
		}
		else 
			parameter = "width=" + w + ",height=" + h + ",";
	}
	
	var _winName = ""; // name it if other popups to the same winName should open in same window (else a new window will be opened).
	var _info  = "toolbar=no";      // yes|no 
	_info += ",location=no";    // yes|no 
	_info += ",directories=no"; // yes|no 
	_info += ",status=no";     // yes|no 
	_info += ",menubar=no";     // yes|no 
	_info += ",scrollbars=yes"; // yes|no 
	_info += ",resizable=yes";  // yes|no 
	_info += ",dependent";      // close the parent, close the popup, omit if you want otherwise 
	_info += ",height=" + h;
	_info += ",width=" + w;
	_info += ",left=" + x;
	_info += ",top=" + y;
	
	if( !window.open( uri, _winName, _info ) ) {
		alert("This editor requires popups. Configure your popup-blocker to allow popups for this site to use all the functionality!");
	}
}

var KEYLEFT = 37;
var KEYUP = 38;
var KEYRIGHT = 39;
var KEYDOWN = 40;
var KEYENTER = 13;
var KEYTAB = 9;
var KEYESC = 27;
var KEYEND = 35;
var KEYHOME = 36;
function getCharacterCode( evt ) {
				
	// evt = (evt) ? evt : event;
	evt = (evt) ? evt : window.event;
	
	ret = (!evt) ? -1 : (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	
	return ret;					
}
function isCharacterInput( evt ) {
	
    var charCode = getCharacterCode( evt );
	
	if( charCode==KEYUP || charCode==KEYDOWN || charCode==KEYLEFT || charCode==KEYRIGHT || charCode==KEYEND || charCode==KEYHOME || charCode==KEYENTER || charCode==KEYTAB || charCode==KEYESC )
		return false;
	else
		return true;	
}


var flagGiveSimilarMatches = false;
function giveSimilarMatches(t,inputfield,actionCode) {

	if( flagGiveSimilarMatches==false && inputfield ) {
		flagGiveSimilarMatches = true;
				
		setTimeout( function() { giveSimilarMatchesNow(t,inputfield,actionCode); flagGiveSimilarMatches=false; }, 300 );
	}
}
// t: array of types of the elements, where is looked for, if they match
// i: input (user input)
function giveSimilarMatchesNow(t,inputfield,actionCode) {
		
	input = inputfield.value;
	if( input && input.trim().length > 0 && validateLabel(inputfield) ) {
	    var url='AjaxXmlGenerator';
	    url+='?actionCode='+actionCode;
	    
		/*
		var typeparams = "";		
	    for(j=0;j<t.length;j++)
	        typeparams+='&type='+t[j]; 
			
	    url+=typeparams;  
	    */
	    url+='&viewtype='+t; 
		
	    url+='&input='+input.trim();
	    
		xmlreqPOST(url);
	}
}
var flagCheckForExistingSynonyms = false;
function checkForExistingSynonyms(inputfield, actionCode) {
	
	if( flagCheckForExistingSynonyms==false ) {
		flagCheckForExistingSynonyms = true;
		
		setTimeout( function() { checkForExistingSynonymsNow(inputfield,actionCode);flagCheckForExistingSynonyms=false;}, 300);
	}
}
function checkForExistingSynonymsNow(inputfield, actionCode) {
	
	input = inputfield.value;
	if( input && input.trim().length > 0 ) {
	
		var url= 'AjaxXmlGenerator';
	
		url += '?actionCode=' + actionCode;
		url += '&input=' + input.trim();
		
		xmlreqPOST(url);
	}
	else {
		document.getElementById('slidebox1').innerHTML = "";
	}		
}

function getWordNetEntry(input, actionCode, resultDivId) {
	
	if( input.length > 0 ) {
	
		showLoading( resultDivId );
		var url= 'AjaxXmlGenerator';
		
		url += '?actionCode=' + actionCode;
		url += '&input=' + input.trim();
			
		xmlreqPOST(url);
	}
	else {
		document.getElementById( resultDivId ).innerHTML = "First input a value!";
	}		
}
function getWikipediaEntry( input, actionCode, resultDivId ) {
	
	if( input.length > 0 ) {
	
		showLoading( resultDivId );
		
		var url= 'AjaxXmlGenerator';
		
		url += '?actionCode=' + actionCode;
		url += '&input=' + input.trim();
		url += '&resultDivId=' + resultDivId.trim();
			
		xmlreqPOST(url);
	}
	else {
		document.getElementById( resultDivId ).innerHTML = "First input a value!";
	}
}

function getRemoteContent( command,input, actionCode, resultDivId ) {
	
	if( input.length > 0 ) {
	
		showLoading( resultDivId );
		
		var url= '/../'+command+'.do';
		
		url += '?param1=' + actionCode;
		url += '&input=' + input.trim();
		url += '&resultDivId=' + resultDivId.trim();
			
		xmlreqPOST(url);
	}
	else {
		document.getElementById( resultDivId ).innerHTML = "First input a value!";
	}
}

function showLoading(elementId) {
	document.getElementById(elementId).innerHTML='<img src="skins/default/images/loading.gif">';
}


// i: input (user input)
function searchYouTubeVideos(elementId,input,actionCode,page,per_page) {
	
	showLoading(elementId);
	
	if( input.length > 0 ) { // if more than 2 characters:
	
		if (page == null){
			page = 1; // 1 is the first page (and not 0!)
		}
		if (per_page == null){
			per_page = 5;
		} 
 
	    var url= "AjaxXmlGenerator";
	    url+='?actionCode='+actionCode;
	    url+='&input='+input.trim();
	    url+='&per_page='+per_page;
	    url+='&page='+page;
		
		xmlreqPOST(url);
	}
}


// t: array of types of the elements, where is looked for, if they match
// i: input (user input)
function searchFlickrImages(elementId,input,actionCode,page,perpage) {
	
	showLoading(elementId);
	
	if( input.length > 0 ) { // if more than 2 characters:
	
		if (page == null){
			page = 1; // 1 is the first page (and not 0!)
		}
		if (perpage == null){
			perpage = 5;
		} 
 
	    var url='AjaxXmlGenerator';
	    url+='?actionCode='+actionCode;	    
	    url+='&input='+input.trim();
	    url+='&page='+page;
	    url+='&perpage='+perpage;
	    
		xmlreqPOST(url);
	}
}


function removeSelectedSpans(inputfieldName, divContainerId){
	var divact = document.getElementById(divContainerId);
	var	inputfield = document.getElementsByName(inputfieldName)[0]; // the element containing the ID of the image (hidden field)
	
	
	// 1. find which elements are highlighted:
	var spans = divact.getElementsByTagName("span");

	var divs2delete = new Array();
	j=0;
	for( i=0;i<spans.length;i++ ) {
		if(!spans[i].style.backgroundColor==""){
			divs2delete[j++]=spans[i];
		}
	}
	
	// necessary to split because otherwise a child would be removed and so the spans-array would change and would get hard to read
	if( divs2delete.length>0 ) {
		for( j=0;j<divs2delete.length;j++ ) {
			inputfield.value=inputfield.value.replace(divs2delete[j].id+",","");
			divact.removeChild(divs2delete[j]);
		}
	}
	else {
		alert( "To remove an element first select one (just click on it)!" );
	}
}


function getImageHTML(id,imgSrc,onclickevent,onmouseoverevent){
	
	return '<span id="' + id + '" class="selectedElement selectedImage"><img src="' + imgSrc + '" class="spanImageThumb" onmouseover="' + onmouseoverevent + '" onclick="' + onclickevent + ';"/></span>';
}

// add an HTML-code to the element with the id elementName_act and adds to the element with id elementName the id.
function insertImage(src,id,preview,elementName){

	var	divact = document.getElementById(elementName+"_act");
	var	inputfield = document.getElementsByName(elementName)[0]; // the element containing the ID of the image (hidden field)
	
	if( inputfield.value.match(id)==null) { 
		// if not found:
		divact.innerHTML+=getImageHTML(
			id,
			src,
			"toggleBackground(document.getElementById('" + id + "'));toggleBackground(this);hideDeleteButtonIfNothingSelected('"+elementName + "_act','"+elementName + "_deletebuttonid');return false;",
			"myFlickrTip('<div class=\\'flickrpreview\\'><img src=\\'"+preview+"\\'/></div>')");
		
		inputfield.value+=id+",";
	}
}

// add an HTML-code to the element with the id elementName_act and adds to the element with id elementName the id.
function insertVideo(src,id,onmouseoverevent,elementName){

	var	divact = document.getElementById(elementName+"_act");
	var	inputfield = document.getElementsByName(elementName)[0]; // the element containing the ID of the image (hidden field)
	
	if( inputfield.value.match(id)==null) { 
		// if not found:
		divact.innerHTML+=getImageHTML(
			id,
			src,
			"toggleBackground(document.getElementById('" + id + "'));toggleBackground(this);hideDeleteButtonIfNothingSelected('"+elementName + "_act','"+elementName + "_deletebuttonid');return false;",
			onmouseoverevent);
			
		inputfield.value+=id+",";
	}
}


function extractPhotoId(elementId,str,actionCode){
	//TODO
	// formats:
	// http://www.flickr.com/photos/summa/1062485760/
	// http://www.flickr.com/photos/30831346@N00/1062485208/
	// http://www.flickr.com/photos/erinleighirish/464066554/in/set-72157600027607690/
	// http://www.flickr.com/photo_zoom.gne?id=1062485208&size=o
	// http://www.flickr.com/photo_zoom.gne?id=1062485208&size=s
	// http://farm2.static.flickr.com/1389/1062485208_bc07ccad34_m_d.jpg
	
	// format see: http://www.flickr.com/services/api/misc.urls.html
	var id = "";
	str = str.trim();
	
	if( str.search(/^http:\/\/(www\.)?flickr.com\/photos\/.*\/.*$/)==0 ) {
		
		str = str.replace(/^http:\/\/(www\.)?flickr.com\/photos\/([^\/]*)\//,"");
		str = str.replace(/\/.*$/,"");
		
		id=str;
	} else if(str.search(/^http:\/\/farm(.*)\.static.flickr.com\/.*\/.*_.*\..*$/)==0 ){
				
		str = str.replace(/^http:\/\/farm(.*)\.static.flickr.com\/.*\//,"");
		str = str.replace(/_.*\..*$/,"");
		
		id=str;
	} else if(str.search(/^http:\/\/(www\.)?flickr.com\/.*id=.*$/)==0 ) {
				
		str = str.replace(/^http:\/\/(www\.)?flickr.com\/.*id=/,"");
		str = str.replace(/&.*$/,"");
		
		id=str;
	} 
	
	if(id==""){
		alert( "The given URI ("+str+") does not fit a Flickr URI pattern!");
	}
	else {
		showLoading(elementId);
	
	
	    var url='AjaxXmlGenerator';
	    url+='?actionCode='+actionCode;	    
	    url+='&input='+id;
	    
		xmlreqPOST(url);
	}
}


function extractVideoId(elementId,str,actionCode){
	//TODO
	// formats:
	// http://www.youtube.com/watch?v=WofFb_eOxxA
	
	var id = "";
	str = str.trim();
	
	if( str.search(/^http:\/\/(www\.)?youtube.com\/watch\?v=.*$/)==0 ) {
		
		str = str.replace(/http:\/\/(www\.)?youtube.com\/watch\?v=/,"");
		str = str.replace(/&.*$/,"");
		
		id=str;
	}
	
	if(id==""){
		alert( "The given URI ("+str+") does not fit a YouTube URI pattern!");
	}
	else {
		showLoading(elementId);
	
	
		var url='AjaxXmlGenerator';
		url+='?actionCode='+actionCode;	    
		url+='&input='+id;
	    
		xmlreqPOST(url);
	}
}


function toggleBackground(element) {
	
	if(element.style.backgroundColor==""){
		element.style.backgroundColor="#CCCCCC";
	}
	else{
		element.style.backgroundColor="";
	}
}



		



// ----------------------






function GetSelectedRadioValue(radiobuttongroup) {
	for(i=0;i<radiobuttongroup.length;i++) {
		if (radiobuttongroup[i].checked) {
			return radiobuttongroup[i].value;
		}
	}
}


function myTip(text) {
	Tip(text, WIDTH, 300, FADEIN, 50, FADEOUT, 200, FOLLOWMOUSE, false, STICKY, true, CLICKCLOSE, true);
}

function myFlickrTip(text) {
	Tip(text, WIDTH, 240, FADEIN, 50, FADEOUT, 200, FOLLOWMOUSE, false, STICKY, true, CLOSEBTN, true);
}

function youTubeTip(text) {
	Tip(text, WIDTH, 240, FADEIN, 50, FADEOUT, 200, FOLLOWMOUSE, false, STICKY, true, CLOSEBTN, true);
}


function processCloud( id, max ) {
	var cloud = getElement(id);
	if(!cloud) return;
	
	var tags = cloud.getElementsByTagName("a");
	
	for(var i=0;i<tags.length;i++) {
		var tag = tags[i];
		var title = tag.getAttribute("title");
		var f = title.substring(title.indexOf(":")+1);
		var fontSize = (150.0*(1.0+(1.5*f-max/2)/max))+"%";
		tag.style.fontSize = fontSize;
	}
}


function getMultiLanguageLabelField() {
	var ret = "<p>\n";
	ret += "<input tabindex=\"\" name =\"multiLanguageLabelEntry[]\" value=\"\" type=\"text\">\n";	
	ret += "<select size=\"1\" name=\"language_list[]\" value=\"\">\n";
	ret += "<option value=\"en\">english</option>\n";
	ret += "<option value=\"de\">german</option>\n";
	ret += "<option value=\"sp\">spanish</option>\n";
	ret += "<option value=\"ch\">chinese</option>\n";
	ret += "</p>\n";
	
	return ret;
}

function multiLangugageLabelProcessor() {

	tmp = document.getElementById("mll").cloneNode(true);
	document.getElementById("mll").appendChild(tmp)

	//document.getElementById('mll').appendChild(t.parentElement.cloneNode(true)) 	
}

function addSeeAlso( nameformelement, def_value ) {
	
	var inputfield = document.getElementById(nameformelement+'_sel');
	var label = inputfield.value;
	var id = label;
	
	if( validateSeeAlsoURI( inputfield, document.getElementById(nameformelement+'_errors') ) ) {
		
		addToSelectedElements(nameformelement +'_act',nameformelement,label.trim(),'',label.trim(),nameformelement + '_deletebuttonid' );
		inputfield.value = def_value;
	}
	
	inputfield.focus();
}


function validateSeeAlsoURI( inputfield, errorfield ) {
	
	var value = inputfield.value;
	value = value.replace(/^\s+|\s+$/g,""); // trim	
	value = value.toLowerCase();
	
	// if value contains blanks:
	if( value.search( " " ) != -1 ) {
		
		errorfield.innerHTML = "<div class=\"error\">Blank symbols are not allowed in an URI!</div>";
		return false;
	}
	
	var message = "<div class=\"error\">URIs must start with the protocol, e.g. \"http://\", \"ftp://\", or \"https://\"!</div>";
	
	var filter = /^(http|https|ftp):\/\/[^\.]+\.[^\.]+.*/;
			
	if( value==""){
		
		return false;
	}
	else if( validateValue( inputfield, errorfield )==false ) {
		
		return false;
	}
	else if( validateURIstartingWithProtocol( value, errorfield )==false ) {

			return false;
	}
	else if( validateURI( value, errorfield )==false ) {

			return false;
	}
	else {
		
		errorfield.innerHTML = "";
		
		return true;
	}
	
	return false;
}

function validateURIstartingWithProtocol( value, errorfield ) {
	
	var message = "<div class=\"error\">URIs must start with the protocol, e.g. \"http://\", \"ftp://\", or \"https://\"!</div>";
	
	var filter = /^(http|https|ftp):\/\//;
	
	if( !filter.test( value ) ) {
		errorfield.innerHTML = message;
		return false;
	}
	else {
			
		// delete the message if shown:
		if( errorfield.innerHTML.indexOf( message )!=-1 ) {
			errorfield.innerHTML = errorfield.innerHTML.replace( message, "" );
		}
		
		return true;
	}
}
function validateURI( value, errorfield ) {
	
	var message = "<div class=\"error\">URIs must start with the protocol followed by domain (e.g. http://domain.com)!</div>";
	
	var filter = /^(http|https|ftp):\/\/[^\.]+\.[^\.]+.*/;
	
	if( !filter.test( value ) ) {
		errorfield.innerHTML = message;
		return false;
	}
	else {
			
		// delete the message if shown:
		if( errorfield.innerHTML.indexOf( message )!=-1 ) {
			errorfield.innerHTML = errorfield.innerHTML.replace( message, "" );
		}
		
		return true;
	}
}

function validateEmail( field ) {
	// var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var strValue = field.value;
	
  	if (!filter.test(strValue) ) {
 		alert ("Not a valid e-mail adress!");
		// setTimeout( function() { field.focus() }, 50 );
    	return false;
	}
    return true;
}


function validateInput( field ) {
	
	var strValue = field.value;
	
	var filter = /\W/;
    if (filter.test(strValue)) {
    	alert ("input not valid: only letters and numbers are allowed");
		// setTimeout( function() { field.focus() }, 50 );
    	return false;
    }
    return true;
}
/*

function validateInput2 (strValue) {
	var illegalChars = /[^a-zA-Z0-9_ ]/;
    if (illegalChars.test(strValue)) {
    	alert ("The input has the wrong format! Only letters and numbers are allowed!");
    }  
}
*/

function validateTranslation( inputfield, errorfield ) {

	return validateValue( inputfield, errorfield );
}
function validateValue( inputfield, errorfield ) {
	
	// var filter = /[^a-zA-Z0-9_ ]/;
	var filter  = /["'�`\/\\'�`]/;
    if( inputfield.value!="" && filter.test(inputfield.value.trim())) {
    	errorfield.innerHTML="<div class=\"error\">The input has the wrong format! Colons and Slashes are not allowed!</div>";
		return false;
    }
	else {
		if( inputfield.value!="") {
    		errorfield.innerHTML="";
			return true;
		}
		else
			return false;
    }
	 
}


function validateLabel( inputfield ) {
		
	//var filter = /[^a-zA-Z0-9_ ]/;
	var filter  = /["'�`\/\\�]/;
    if( inputfield.value!="" && filter.test(inputfield.value)) {
		return false;
    }
	else {
		return true;
    }	 
}
function validateLabelSetField( inputfield, errorfield ) {
	
    if ( validateLabel(inputfield) == false ) {
    	errorfield.innerHTML="<div class=\"error\">The input has the wrong format! Colons and Slashes are not allowed!</div>";
		return false;
    }
	else {
		if( inputfield.value!="") {
    		errorfield.innerHTML="";
			return true;
		}
		else
			return false;
    }
	 
}




function formatWordNetContent(elementId) {
	
	var cont = document.getElementById(elementId).innerHTML;
	//title = title.toLowerCase();;
	var title_regexp = /(\w+)\s(\w+)\s(\w+)\s(\w+)/;
	title_regexp.exec(cont);
	title = RegExp.$4;
	
	function replacer3(str, p1, p2, offset, s) {
		p2 = p2.trim();
		var p3 = p2.replace(/\s/g, "");
		if (p2 == title)
			return str;
		else {				
			return p1 + "<a href=\"javascript:void(0)\" onclick=\"javascript:if( document.getElementsByName('synonymsEntry')[0].value.indexOf('"+p3+"')==-1 ) {document.getElementsByName('synonymsEntry')[0].value+='"+p3+" ';} \">"+p2+"</a>";
		}
	}

	function replacer1(str, p1, offset, s) {
		
		p1 = p1.replace(/(\d+\.\s(?:\(\d+\))*\s)([a-zA-z\s]+)(?=[\s|,])/g, replacer3);
		p1 = p1.replace(/(,\s)([a-zA-z\s]+)(?=[\s|,])/g, replacer3);
		
		return p1;
	}

	
	
	//find all starting numbers \d+\.\s(?:\(\d+\))*
	
	cont = cont.replace(/(\d+\.\s(?:\(\d+\))*\s([a-zA-z\s,])*)(?=--)/g, replacer1);

	document.getElementById(elementId).innerHTML = cont;
}

function addnodesintreerequest( node, currnodesstring, isinclass ){
	var url='AddNodesInTree';
	url+='?parent='+node.trim();
	url+="&module="+domainForGlobalTree.trim();
	url+="&currnodes="+currnodesstring.toString().trim();
	url+="&isinclass="+isinclass.trim();
	xmlreqGET(url);
}
function setOMForGlobalTree( ontologymodule ){
	domainForGlobalTree = ontologymodule;
	var url='OMForGlobalTree';
	url+='?module='+ontologymodule.trim();
	url+='&concept=""';
	
	xmlreqGET(url);
}
function setConceptForGlobalTree( concept, ontologymodule ){
	domainForGlobalTree = ontologymodule;
	var url='OMForGlobalTree';
	url+='?module='+ontologymodule.trim();
	url+='&concept='+concept.trim();

	xmlreqGET(url);
}
function updateHierarchyByDND(objectId, newParentId, oldParentId){
	var url='UpdateHierarchyByDND';
	url+='?concept='+objectId.trim();
	url+='&nP='+newParentId.trim();
	url+='&oP='+oldParentId.trim();
	
	xmlreqGET(url);
}
function printSuperClassesAboveTree(parents, style){
	var ret="<span class=\""+style+"\">";
	for (var i=0; i<parents.length; i++){
		if (i>0)
		  ret+="<br>";
		var parent_components = parents[i].split("|");
      	//var start_idx = parents[i].indexOf("Class/"); 
      	//var href = parents[i].substring(start_idx, parents[i].length);
		var href = parent_components[0];
		var label = parent_components[1]; 		  
		ret+= "<li><a href=\""+href+"\" target=\"_self\">"+label+"</a>";
	}
	ret += "</span>";
	return ret;
}
function getTreeNodesByObjectId(objectId, currnode){
	if (currnode == null)
		return;
	var currnode_siblings = currnode.getSiblings();
	var result_nodes = new Array();
	if (currnode_siblings == null)
		return;
		
	for (var i=0; i<currnode_siblings.length; i++){
		var node = currnode_siblings[i];
		dojo.debug('processing ... '+node.objectId);
		if (node.objectId == objectId){
			result_nodes[result_nodes.length]=node;
		}else{
			if (node.children != null && node.children.length > 0){
				var newones = new Array();
				newones = getTreeNodesByObjectId(objectId, node.children[0]);
				if (newones != null && newones.length > 0)
					result_nodes.extend(newones);
			}
		}
	}	
	return result_nodes;
}
function doDND(treeNode, oldparentNode, sourceTreeNode){
    	var newParentId = treeNode.objectId;
		var oldParentId = oldparentNode.objectId;
		if (newParentId == oldParentId)//should not be possible - just for safety
		  return;                      //would mean different nodes in the tree with same objectId
		  
//      		if (DNDDat.widget == null || DNDDat.oldwidget == null || DNDDat.newwidget == null ||
//      	    	DNDDat.widget.objectId != sourceTreeNode.objectId ||  //this check is to ensure that update
//      	    	DNDDat.oldwidget.objectId != oldParentId || //routine is only called once for a
//      	    	DNDDat.newwidget.objectId != newParentId){  //combination
      	    	DNDDat.widget = sourceTreeNode;
      	    	DNDDat.oldwidget = oldparentNode;
      	    	DNDDat.newwidget = treeNode;
      			updateHierarchyByDND(sourceTreeNode.objectId, newParentId, oldParentId);
//      		}

      		 /*var nParent = treeNode;
      		   if ( nParent.children.length > 0 )  //if children are already in the parent -> other nodes were loaded previously
      		     nParent.serverLoaded = true;	
      		   if (nParent.serverLoaded == null){
      		 		var priorstate = nParent.state;
			 		nParent.state = nParent.loadStates.UNCHECKED;
			 		nParent.serverLoaded = true;
			 		myRpcController.expand(nParent, null, null, null);
			 		nParent.state = priorstate;     
				}*/
}
function addnodesfromajaxresponse(firstnode){
		var newNode;
		if (firstnode == null)
		  return;
		else
		  newnode = firstnode.childNodes[0]; 
		
		for(var i=0; i<firstnode.childNodes.length;i++){
			var newNode = firstnode.childNodes[i];
			var objId = newNode.childNodes[2].firstChild.nodeValue;
			var title = "";
			//title += "<a class=treeElement href=Class/"+newNode.childNodes[0].firstChild.nodeValue+" target=_self>";
			if ( newNode.childNodes[0].attributes.getNamedItem("href") != null){
				title +="<a class=treeElement href="+newNode.childNodes[0].attributes.getNamedItem("href").nodeValue+" target=_self>";
			}
			if ( newNode.childNodes[0].attributes.getNamedItem("strong") != null ){
			  if (newNode.childNodes[0].attributes.getNamedItem("strong").nodeValue == "true")
			  	title += "<span class=treeItemHighlight>"
			}
			if (newNode.childNodes[0].attributes.getNamedItem("grey_italic") != null ){
				if (newNode.childNodes[0].attributes.getNamedItem("grey_italic").nodeValue == "true")
					title += "<span class=treeItemNotInDomain>";
			}
			
		    title += htmlEntities(newNode.childNodes[0].firstChild.nodeValue);
			
	    	if (newNode.childNodes[0].attributes.getNamedItem("grey_italic") != null ){	
				if (newNode.childNodes[0].attributes.getNamedItem("grey_italic").nodeValue == "true")
					title += "</span>";
			}
			if ( newNode.childNodes[0].attributes.getNamedItem("strong") != null ){
				if (newNode.childNodes[0].attributes.getNamedItem("strong").nodeValue == "true")
					title += "</span>";
			}
			if ( newNode.childNodes[0].attributes.getNamedItem("href") != null){
			  title += "</a>";
			}
			var isFol;
			// now check whether node is displayed already
			var exists = false;
			checkexistencefor: for(var j=0; j<parentNodeGlobal.children.length;j++){
				var checkNode = parentNodeGlobal.children[j];
				if (checkNode.objectId == objId){
					exists = true;
					break checkexistencefor;
				}
			}
			if (exists == true)
				continue;
			
			// if we get here, we have to add a new node in our tree
			if (newNode.childNodes[1].firstChild.nodeValue == "false")
				isFol = false;
			else
				isFol = true;
				
			var disable_move = new Array("");
      		if (objId == moreConceptsSignation){
        		disable_move = new Array("move","addChild");		
			}
			var node = dojo.widget.createWidget("TreeNode",{
			title:title,
			isFolder:isFol,
			objectId:objId,
			actionsDisabled:disable_move,
			widgetId:parentNodeGlobal.widgetId+"__ADD__"+i});
			parentNodeGlobal.addChild(node);
			if (firstnode.attributes.length > 0 &&
			    firstnode.attributes.getNamedItem('sublevel') != null &&
			    firstnode.attributes.getNamedItem('sublevel').nodeValue){
				var rpccontr = dojo.widget.getWidgetById("treeController");
				//rpccontr.expand(node, null, null, null)
				rpccontr.expand(node);
			}		
		}		
}
function setTreeDimension(intree){
  
  var newWidth = normWidth;  // is basis
  var newHeight = document.getElementById('myOMSelectionForTree').scrollHeight + document.getElementById('myTreeWidgetContainer').scrollHeight + 80;
  var superclass_area = document.getElementById('myTreeSuperClassesContainer');
  if (superclass_area != null){
  	newHeight+=superclass_area.scrollWidth; 
  }
  if (intree){
     newWidth = dojo.widget.byId('myTreeWidget').containerNode.scrollWidth + 29;
     if (newWidth < 250)  //minimum width when in tree
       newWidth = 250;
  }
  if (newHeight < 300)  //minimum heigth
    newHeight = 300;
  
  dojo.widget.byId('FloatingPane').resizeTo(newWidth, newHeight);
  
  //dojo.widget.byId('FloatingPane').bringToTop();

}

function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

 function htmlEntities(texte) {

texte = texte.replace(/"/g,'&quot;'); // 34 22
texte = texte.replace(/&/g,'&amp;'); // 38 26
texte = texte.replace(/\'/g,'&#39;'); // 39 27
texte = texte.replace(/</g,'&lt;'); // 60 3C
texte = texte.replace(/>/g,'&gt;'); // 62 3E
texte = texte.replace(/\^/g,'&circ;'); // 94 5E
texte = texte.replace(/‘/g,'&lsquo;'); // 145 91
texte = texte.replace(/’/g,'&rsquo;'); // 146 92
texte = texte.replace(/“/g,'&ldquo;'); // 147 93
texte = texte.replace(/”/g,'&rdquo;'); // 148 94
texte = texte.replace(/•/g,'&bull;'); // 149 95
texte = texte.replace(/–/g,'&ndash;'); // 150 96
texte = texte.replace(/—/g,'&mdash;'); // 151 97
texte = texte.replace(/˜/g,'&tilde;'); // 152 98
texte = texte.replace(/™/g,'&trade;'); // 153 99
texte = texte.replace(/š/g,'&scaron;'); // 154 9A
texte = texte.replace(/›/g,'&rsaquo;'); // 155 9B
texte = texte.replace(/œ/g,'&oelig;'); // 156 9C
texte = texte.replace(//g,'&#357;'); // 157 9D
texte = texte.replace(/ž/g,'&#382;'); // 158 9E
texte = texte.replace(/Ÿ/g,'&Yuml;'); // 159 9F
// texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
texte = texte.replace(/¡/g,'&iexcl;'); // 161 A1
texte = texte.replace(/¢/g,'&cent;'); // 162 A2
texte = texte.replace(/£/g,'&pound;'); // 163 A3
//texte = texte.replace(/ /g,'&curren;'); // 164 A4
texte = texte.replace(/¥/g,'&yen;'); // 165 A5
texte = texte.replace(/¦/g,'&brvbar;'); // 166 A6
texte = texte.replace(/§/g,'&sect;'); // 167 A7
texte = texte.replace(/¨/g,'&uml;'); // 168 A8
texte = texte.replace(/©/g,'&copy;'); // 169 A9
texte = texte.replace(/ª/g,'&ordf;'); // 170 AA
texte = texte.replace(/«/g,'&laquo;'); // 171 AB
texte = texte.replace(/¬/g,'&not;'); // 172 AC
//texte = texte.replace(/­/g,'&shy;'); // 173 AD
texte = texte.replace(/®/g,'&reg;'); // 174 AE
texte = texte.replace(/¯/g,'&macr;'); // 175 AF
texte = texte.replace(/°/g,'&deg;'); // 176 B0
texte = texte.replace(/±/g,'&plusmn;'); // 177 B1
texte = texte.replace(/²/g,'&sup2;'); // 178 B2
texte = texte.replace(/³/g,'&sup3;'); // 179 B3
texte = texte.replace(/´/g,'&acute;'); // 180 B4
texte = texte.replace(/µ/g,'&micro;'); // 181 B5
texte = texte.replace(/¶/g,'&para'); // 182 B6
texte = texte.replace(/·/g,'&middot;'); // 183 B7
texte = texte.replace(/¸/g,'&cedil;'); // 184 B8
texte = texte.replace(/¹/g,'&sup1;'); // 185 B9
texte = texte.replace(/º/g,'&ordm;'); // 186 BA
texte = texte.replace(/»/g,'&raquo;'); // 187 BB
texte = texte.replace(/¼/g,'&frac14;'); // 188 BC
texte = texte.replace(/½/g,'&frac12;'); // 189 BD
texte = texte.replace(/¾/g,'&frac34;'); // 190 BE
texte = texte.replace(/¿/g,'&iquest;'); // 191 BF
texte = texte.replace(/À/g,'&Agrave;'); // 192 C0
texte = texte.replace(/Á/g,'&Aacute;'); // 193 C1
texte = texte.replace(/Â/g,'&Acirc;'); // 194 C2
texte = texte.replace(/Ã/g,'&Atilde;'); // 195 C3
texte = texte.replace(/Ä/g,'&Auml;'); // 196 C4
texte = texte.replace(/Å/g,'&Aring;'); // 197 C5
texte = texte.replace(/Æ/g,'&AElig;'); // 198 C6
texte = texte.replace(/Ç/g,'&Ccedil;'); // 199 C7
texte = texte.replace(/È/g,'&Egrave;'); // 200 C8
texte = texte.replace(/É/g,'&Eacute;'); // 201 C9
texte = texte.replace(/Ê/g,'&Ecirc;'); // 202 CA
texte = texte.replace(/Ë/g,'&Euml;'); // 203 CB
texte = texte.replace(/Ì/g,'&Igrave;'); // 204 CC
texte = texte.replace(/Í/g,'&Iacute;'); // 205 CD
texte = texte.replace(/Î/g,'&Icirc;'); // 206 CE
texte = texte.replace(/Ï/g,'&Iuml;'); // 207 CF
texte = texte.replace(/Ð/g,'&ETH;'); // 208 D0
texte = texte.replace(/Ñ/g,'&Ntilde;'); // 209 D1
texte = texte.replace(/Ò/g,'&Ograve;'); // 210 D2
texte = texte.replace(/Ó/g,'&Oacute;'); // 211 D3
texte = texte.replace(/Ô/g,'&Ocirc;'); // 212 D4
texte = texte.replace(/Õ/g,'&Otilde;'); // 213 D5
texte = texte.replace(/Ö/g,'&Ouml;'); // 214 D6
texte = texte.replace(/×/g,'&times;'); // 215 D7
texte = texte.replace(/Ø/g,'&Oslash;'); // 216 D8
texte = texte.replace(/Ù/g,'&Ugrave;'); // 217 D9
texte = texte.replace(/Ú/g,'&Uacute;'); // 218 DA
texte = texte.replace(/Û/g,'&Ucirc;'); // 219 DB
texte = texte.replace(/Ü/g,'&Uuml;'); // 220 DC
texte = texte.replace(/Ý/g,'&Yacute;'); // 221 DD
texte = texte.replace(/Þ/g,'&THORN;'); // 222 DE
texte = texte.replace(/ß/g,'&szlig;'); // 223 DF
texte = texte.replace(/à/g,'&aacute;'); // 224 E0
texte = texte.replace(/á/g,'&aacute;'); // 225 E1
texte = texte.replace(/â/g,'&acirc;'); // 226 E2
texte = texte.replace(/ã/g,'&atilde;'); // 227 E3
texte = texte.replace(/ä/g,'&auml;'); // 228 E4
texte = texte.replace(/å/g,'&aring;'); // 229 E5
texte = texte.replace(/æ/g,'&aelig;'); // 230 E6
texte = texte.replace(/ç/g,'&ccedil;'); // 231 E7
texte = texte.replace(/è/g,'&egrave;'); // 232 E8
texte = texte.replace(/é/g,'&eacute;'); // 233 E9
texte = texte.replace(/ê/g,'&ecirc;'); // 234 EA
texte = texte.replace(/ë/g,'&euml;'); // 235 EB
texte = texte.replace(/ì/g,'&igrave;'); // 236 EC
texte = texte.replace(/í/g,'&iacute;'); // 237 ED
texte = texte.replace(/î/g,'&icirc;'); // 238 EE
texte = texte.replace(/ï/g,'&iuml;'); // 239 EF
texte = texte.replace(/ð/g,'&eth;'); // 240 F0
texte = texte.replace(/ñ/g,'&ntilde;'); // 241 F1
texte = texte.replace(/ò/g,'&ograve;'); // 242 F2
texte = texte.replace(/ó/g,'&oacute;'); // 243 F3
texte = texte.replace(/ô/g,'&ocirc;'); // 244 F4
texte = texte.replace(/õ/g,'&otilde;'); // 245 F5
texte = texte.replace(/ö/g,'&ouml;'); // 246 F6
texte = texte.replace(/÷/g,'&divide;'); // 247 F7
texte = texte.replace(/ø/g,'&oslash;'); // 248 F8
texte = texte.replace(/ù/g,'&ugrave;'); // 249 F9
texte = texte.replace(/ú/g,'&uacute;'); // 250 FA
texte = texte.replace(/û/g,'&ucirc;'); // 251 FB
texte = texte.replace(/ü/g,'&uuml;'); // 252 FC
texte = texte.replace(/ý/g,'&yacute;'); // 253 FD
texte = texte.replace(/þ/g,'&thorn;'); // 254 FE
texte = texte.replace(/ÿ/g,'&yuml;'); // 255 FF
return texte;
}
