	var LF = String.fromCharCode(13) + String.fromCharCode(10);
	var DOWN_AREA_SIGN = "!DOWN_AREA_SIGN!";
	var SAPORATOR = "*|*";
	var SAPORATOR2 = "#|#";
	var SAPORATOR3 = "!|!";

	function isIE(){
        if(document.all) return(true);
        else return(false);
    }
	
/////////////////////////////////////////////////////////
	//onError function
	//onerror=handleErr
	function handleErr(msg,url,l){
	  var str="Error!!";
	  //str+="\\nFile: " + url;
	  str+="\n\nLine: " + l;
	  str+="\n\n"+msg;
	  alert(str);
	return(true);
	}

/////////////////////////////////////////////   		
	//for tracing
	
	document.write("<div id=\"traceDiv\" style=\"position:absolute;width:250px;height:300px;top:100;left:700;display:none;overflow:auto;\"></div>");
	
	var traceNum = 0;
	function trace(text){
		//return(false); //remove me
		var div;
		placeX = 1000;
		if(arguments.length>1) placeX = arguments[1]; 
		
		div = document.getElementById("traceDiv");
		if(!div){
			alert(text);
			return(false);
		}	
		traceNum ++;
		div.style.backgroundColor = "#B9DBF0";
		div.style.background = "#B9DBF0";
		div.style.display = "";
		div.style.left = placeX;		
		div.innerHTML = "<br>" + traceNum + ":&nbsp;&nbsp;" + text + div.innerHTML;
	}
	
	function clearTrace(){
		var div;
		div = getElement("traceDiv");
		if(!div) return(false);		
		div.innerHTML = "";
		traceNum = 0;
	}
	
/////////////////////////////////////////////////////////	
	
    function getElement(objectName){
	   var obj = document.getElementById(objectName);
	   if(!obj){
 	      alert(objectName + " error - no object");
		  return(false);
	   }
	   return(obj)
	}

/////////////////////////////////////////////////// 

    function getElements(objectName){
	   var obj = document.getElementsByName(objectName);
	   if(!obj){
 	      alert(objectName + " error - no object");
		  return(false);
	   }
	   return(obj)
	}
	
/////////////////////////////////////////////////// 
	
	function displayElement(elementID,show){
		if(typeof show == "undefined") var show = true;
		var el = getElement(elementID);
		if(!el) return(false);
		
		if(show == true) el.style.display = "";
		else if(show == false) el.style.display = "none";
	}
	
	/////////////////////////////////////////////////// 
	
	function focusElement(elementID){
		var el = getElement(elementID);
		if(!el) return(false);
		el.focus();
	}
	
	/////////////////////////////////////////////////// 
	
	function enableElement(elementID,show){				
		if(typeof show == "undefined") var show = true;
		var el = getElement(elementID);		
		if(!el) return(false);
		el.disabled = (!show);		
	}
	
//////////////////////////////////////////////////////////////////////////////	

    function valueElement(objectName,text){
	   var obj = document.getElementById(objectName);
	   if(!obj){
 	      alert(objectName + "error - no object");
		  return(false);
	   }
	   
	   if(obj.tagName == "TD" || obj.tagName == "DIV") obj.innerHTML = text;
		else obj.value = text;
		
	   return(obj)
	}
	
//////////////////////////////////////////////////////////////////////////////	
	//validate the name field:
	function validateName(textboxID,fieldName){	
		var textbox = getElement(textboxID),displayName;
		if(textbox.value.length==0){
			displayName = "";
			if(fieldName != undefined) displayName = " '" + fieldName + "'";
			alert("The field" + displayName + " should not be empty");
			textbox.focus();
			return(false);
		}
				
		if(textbox.value.indexOf(SAPORATOR,0)>=0){
			alert("the field should not contain those sequences: " + SAPORATOR);
			textbox.focus();
			return(false);			
		}		
		return(true);
	}
	
//////////////////////////////////////////////////////////////////////////////	
	//validate the email field:
	function validateEmail(textboxID,fieldName){
		var emailField = getElement(textboxID),displayName;
		if(emailField.value.length == 0) return(true);
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailField.value)) return(true);
		else{
			displayName = "";
			if(fieldName != undefined) displayName = " '" + fieldName + "'";
			alert("The field" + displayName + " is invalid email");
			emailField.focus();
			return(false);			
		}
	}
	
//////////////////////////////////////////////////////////////////////////////	
	//validate the name field:
	function validateNumber(textboxID){
		var fieldValue;
		var textbox = getElement(textboxID);
		if(textbox.value.length==0 || isNaN(Number(textbox.value))){
			fieldValue = "";
			if(arguments.length==2) fieldValue = ": '" + arguments[1] + "' ";
			alert("The field"+fieldValue+" should be a numeric");
			textbox.focus();
			return(false);
		}
		return(true);
	}


function validateDate(dateFieldID){
	var dat,arrDate,temp,sap,RegExPattern,textbox,fieldText;
	textbox = getElement(dateFieldID);
	RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
	dat = textbox.value;
	sap = "";
	//switch months with days, and validate the date.
	if(dat.length>3){
		if(dat.indexOf(":")>=0) sap = ":";
		else if(dat.indexOf("-")>=0) sap = "-";
		else if(dat.indexOf(".")>=0) sap = ".";
		else if(dat.indexOf("/")>=0) sap = "/";
		if(sap.length>0){
			arrDate = dat.split(sap);
			if(arrDate.length == 3){
				temp = arrDate[1];
				arrDate[1] = arrDate[0];
				arrDate[0] = temp;
				dat = arrDate[0] + sap + arrDate[1] + sap + arrDate[2];
				if(dat.match(RegExPattern)) return(true);
			}
		}
	}	//in case of wrong date:
	
	fieldText = "";
	if(arguments.length == 2) fieldText = " in field: '" + arguments[1] + "' ";
	alert("Date "+fieldText+" is wrong , should be in format dd/mm/yyyy!!! and have the correct day/month/year values.");
	textbox.focus();
	return(false);
}
		
	function replaceAll(str,sign1,sign2){
		str = String(str);
		while(str.indexOf(sign1)!=-1) str = str.replace(sign1,sign2);		
		return(str);		
	}
	
	//------------------------ select fuinctions -----------------------------------------
	
	//////////////////////////////////////////////////////////////////////////////
	// return selected option of select box
	function getSelectedOption(selectID){
		var i,selectedOption,select;
		selectedOption = false;
		select = getElement(selectID);
		for(i=0;i<select.options.length;i++) 
			if(select.options[i].selected){ selectedOption = select.options[i];}			
		return(selectedOption);
	}
	
	
	//////////////////////////////////////////////////////////////////////////////
	// deselect all options from select
	function unselectAllMultiple(selectID){
		var i,select;
		select = getElement(selectID);
		for(i=0;i<select.options.length;i++) select.options[i].selected = false;
	}
	
	//////////////////////////////////////////////////////////////////////////////	
	//finds in array some data. if found - return place, if not - return -1
	function searchInArray(arr,data){
		var i;
		for(i=0;i<arr.length;i++){
			if(arr[i] == data) return(i);
		}
		return(-1);
	}
	
	//////////////////////////////////////////////////////////////////////////////	
	// get all values in array - except the exceptions (saporated by comas) and filter by maskValues (saporated by coma)
	function getStrAllValuesFromSelect(selectMultID,sap,exValues,maskValues){
		var select,i,value,arrEx,j,flag,str,arrMask;
		select = getElement(selectMultID);		
		if(arguments.length<2){
			alert("getStrAllValuesFromSelect error - to few arguments");
			return(false);
		}
		if(arguments.length <= 2) exValues = "";	//empty exValues
		if(arguments.length <= 3) maskValues = "";	//empty maskValues
		
		arrEx = new Array();
		
		if(exValues.length>0) arrEx = exValues.split(",");
		if(maskValues.length>0) arrMask = maskValues.split(",");		
				
		str = "";		
		for(i=0;i<select.options.length;i++){
			value = select.options[i].value;
			flag = true;
						
			//if the item is not in the exceptions list , and the item is in the mask list: add it to string.				
			if(exValues.length>0 && searchInArray(arrEx,value) != -1) flag = false;
			else{
				if(maskValues.length>0 && searchInArray(arrMask,value) == -1) flag = false;
			}
			if(flag == true){
				if(str.length > 0) str += sap;
				str += value;
			}
		}
		return(str);
	}			
	
	//////////////////////////////////////////////////////////////////////////////
	// select multiple items by value
	function selectMultiple(selectID,values,sap){
		var i,select,arrValues,value;
		values = String(values);
		select = getElement(selectID);
		if(values.length == 0) return(false);
		arrValues = values.split(sap);
		if(arrValues.length == 0) return(false);
		for(i=0;i<select.options.length;i++){
			//trace(select.options[i].value);
			//trace(arrValues[0]);			
			for(j=0;j<arrValues.length;j++){
				if(select.options[i].value == arrValues[j]) select.options[i].selected = true;
			}
		}		
	}
	
	//////////////////////////////////////////////////////////////////////////////
	// get the values coma saporated by saporator, or by coma. default - coma. if none - return false
	// if 3-th argument will be "names" - retrieve names.
	function getMultipleSelectValues(selectID,sap){
		var values,i,select,flagNames = false;
		if(arguments.length == 3 && arguments[2] == "names") flagNames = true;
		if(typeof sap != "string") var sap = ",";
		select = getElement(selectID);
		values = "";
		for(i=0;i<select.options.length;i++) 
			if(select.options[i].selected){ 
				if(values.length>0) values += sap;
				if(flagNames) values += select.options[i].text;
				else values += select.options[i].value;
			}
		return(values);
	}
	
/////////////////////////////////////////////   	
	//remove all items from a select
	function clearSelect(selectID){
		var select = getElement(selectID);
		while(select.options.length != 0) select.remove(0);
	}

	/////////////////////////////////////////////   	
	//find select option by value, and update text
	function updateSelectByValue(selectID,value,text){
		var select,selectedOption;
		selectedOption = false;
		select = getElement(selectID);
		for(i=0;i<select.options.length && selectedOption==false;i++) if(select.options[i].value == value) selectedOption = select.options[i];
		if(selectedOption){
			selectedOption.text = text;
		}		
	}
	
	/////////////////////////////////////////////   	
	//find select option by value, and return text. if not found - return -1
	function getSelectTextByValue(selectID,value){
		var select,selectedOption,text,i;
		text = "";
		selectedOption = false;
		select = getElement(selectID);
		for(i=0;i<select.options.length && selectedOption==false;i++) if(select.options[i].value == value) selectedOption = select.options[i];
		if(selectedOption) text = selectedOption.text;
		return(text);
	}
	
	/////////////////////////////////////////////////////////////////////
	//add some element to select.
	function addToSelect(selectID,text,value,dir){		
		var select,option,flagNew,optionOld,indexOld;
		select = document.getElementById(selectID);		
		option = document.createElement('option');
		flagNew = false;
		
		option.text = text;
		option.value = value;
		
		indexOld = -1;
		optionOld = null
		if(!dir) var dir = "up";
		if(dir.toLowerCase() == "down"){
			if(select.selectedIndex >= 0){
			   if(select.selectedIndex == select.length-1) optionOld = null;
			   else{
					indexOld = select.selectedIndex+1;
					optionOld = select.options[indexOld];
			   }	
			}			
		}
		else{
			if (select.selectedIndex >= 0){
				indexOld = select.selectedIndex;
				optionOld = select.options[indexOld];
			}
		}
		
			try {
				select.add(option, optionOld); // standards compliant; doesn't work in IE
			}
			catch(ex) {
				if(indexOld != -1) select.add(option, indexOld); // IE only
				else select.add(option); // IE only
			}
		if(select.multiple == false) option.selected = true;		
	}
	
	//////////////////////////////////////////////////////////////////////////////	
	//remove item from list , by the value
	function removeFromSelectByValue(selectID,value){
		var select,options,i,removeIndex,selectIndex;
		select = getElement(selectID);
		options = select.options;
		removeIndex = -1;
		for(i=0;i<select.options.length && removeIndex == -1;i++)
			if(select.options[i].value == value) removeIndex = i;
			
		if(removeIndex != -1){
			select.remove(removeIndex);
			
			//select next option
			if(removeIndex < select.options.length) selectIndex = removeIndex;
			else selectIndex = select.options.length-1;
			
			if(selectIndex>=0) select.options[selectIndex].selected = true;
		}
	}
	
/////////////////////////////////////////////////////////
	//Find absolute position on the screen of some element
	function findPos(obj){
	  var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}			
		return[curleft,curtop];
	}
	
/////////////////////////////////////////////////////////
	//Get selected radio number. if not - return 0
	function getSelectedRadioNumber(radioID){
		var radios,i;
		radio = getElements(radioID);
		for(i=0;i<radio.length;i++){
			if(radio[i].checked) return(i);
		}
		return(-1);
	}
	
/////////////////////////////////////////////////////////
	// if the number has only one digit, add zero before it.
	function addZero(num){
		var str;
		str = String(num);
		if(Number(num)<10 && Number(num)>0) str = String("0" + num);
		return(str);
	}

/////////////////////////////////////////////////////////	
	// print array by trace name/id -> element	
	function print_r(arr){
		if(typeof arr!="object"){
			trace("print_r error , the given array argument is not object, but: " + typeof arr);
			return(false);
		}
		var i,x;		
		for(x in arr){
			trace(x + " - " + arr[x] + "");
		}
	}

/////////////////////////////////////////////////////////	
	//fix transparent png image.
    function writePngImg(src,width,height){
		if (isIE()){
			document.write("<div style=\"width:"+width+"px;"+height+"px;background:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ src +"' ,sizingMethod=’crop’);\"></div>");
		 } else {
			document.write("<img src='"+ src +"' width=\""+width+"\" height=\""+height+"\" vspace=\"0\" hspace=\"0\" border=\"0\" >");
		}
    }
	
	function getPngImg(src,width,height){
		if (isIE()){
			return("<div style=\"width:"+width+"px;"+height+"px;background:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ src +"' ,sizingMethod=’crop’);\"></div>");
		 } else {
			return("<img src='"+ src +"' width=\""+width+"\" height=\""+height+"\" vspace=\"0\" hspace=\"0\" border=\"0\" >");
		}	
	}
		
/////////////////////////////////////////////////////////	
	//custom function - get elements by class name
	document.getElementsByClassName = function(cl) {
		var retnode = [];
		var myclass = new RegExp('\\b'+cl+'\\b');
		var elem = this.getElementsByTagName('*');
		for (var i = 0; i < elem.length; i++) {
			var classes = elem[i].className;
			if (myclass.test(classes)) retnode.push(elem[i]);
		}
		return retnode;
	};		


/////////////////////////////////////////////////////////	
	
	function trim(str){
		return str.replace(/^\s+|\s+$/g,"");
	}
	
	
/////////////////////////////////////////////////////////	

	 //get view area sizes (set global 
	 function getViewSizes(){
		var viewWidth,viewHeight;
		//firefox
		 if(typeof window.innerWidth != 'undefined'){
		      viewWidth = window.innerWidth;
		      viewHeight = window.innerHeight;
		 }	 
		 //explorer
		 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){		     
		   viewWidth = document.documentElement.clientWidth;
		   viewHeight = document.documentElement.clientHeight;
		 }
		 //older explorer
		 else{
			   var bodies = document.getElementsByTagName('body');
			   if(!bodies){
					alert("getViewSizes (javascriptFunctions.js) error - the body not found");
					return([0,0]);
			   }
			   viewWidth = bodies[0].clientWidth;
			   viewHeight = bodies[0].clientHeight;
		 }
		  return([viewWidth,viewHeight]);
	 }
	 
/////////////////////////////////////////////////////////	

	//deside how the error will be printed	
	function printError(err){
		alert(err);
	}

/////////////////////////////////////////////////////////	
	// load external js code
	function loadJsCode(code){
		if(window.execScript) window.execScript(code)
		else window.eval(code);
	}

/////////////////////////////////////////////////////////
	//string left and string right functions:
	
	function left(str,n){
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}
	
	function right(str, n){
		if (n <= 0)
		   return "";
		else if (n > String(str).length)
		   return str;
		else {
		   var iLen = String(str).length;
		   return String(str).substring(iLen, iLen - n);
		}
	}
	
//--------------------------------------------------------------------------

	function getSrcElementFromEvent(e){
		if(isIE()) return(e.srcElement);
		return(e.target);
	}
	
	//---------------------------------------------------------------------------
	// get array saporated by saporator1 and saporator2
	function getArrData(data){
		var arr1,arrResult;
		arrResult = new Array();
		arr1 = data.split(SAPORATOR);
		for(i=0;i<arr1.length;i++){
			arr2 = arr1[i].split(SAPORATOR2);			
			if(arr2.length != 2) trace("getArrData error - failed retrieving element in arr " + i + " " + arr1[i]);
			arrResult[arr2[0]] = arr2[1];
		}	
		return(arrResult);
	}
	
	
	//------------------------------------------------------------------------------------------------------------------------------------------------------
	// dump functions
	
	function dump_a(obj){
		var ret_val="<blockquote>";
		if(typeof obj == 'object' || typeof obj == 'function')
		{
		//ret_val += '<font color=green>***'+obj.name+'***</font><br />';
		for(var i in obj){
			ret_val += ('<b>' + i + '</b> (' + typeof obj[i] + ') :' + obj[i] + '<hr color=LightSkyBlue  /><br />');
	//			if  (typeof obj[i] == 'object')// && (bool == true))
	//				ret_val += "<hr color=DarkGreen />"+ dump(obj[i]) +"<hr color=DarkGreen /";
			}
		}
		else ret_val = ('(' + typeof obj + ') :' + obj + '<br>');
		ret_val += "</blockquote>";
		return ret_val;
	}


	function dump_all(obj,count){
		//if(obj == null)
		if(typeof obj == 'undefined')
			return "undefined";
		if( obj == 'parent')
			return "Pt4567";
			
	//	var ret_val= "";
		var ct = ( count == null)? 3 : parseInt(count)-1
			
		if  (ct > 0)
		{
			//ret_val += ct+ ('(' + typeof obj + ') :' + obj + '<br>')+dump_all(obj,ct);
			
			/**/
		
			var ret_val = '<blockquote>' + ('<br /><b>' + ct + '</b><hr color=DarkSlateBlue />');
			 
			if(typeof obj == 'object')
			{
				for(var i in obj){
					ret_val += ('<b>' + i + '</b> (' + typeof obj[i] + ') :' + obj[i] + '<hr color=LightSkyBlue  /><br />');
					if (i != 'parent'){
						if  ((typeof obj[i] == 'object') )// && ((count == null)  ))
							ret_val += "<hr color=DarkGreen />"+ dump_all(obj[i],ct) +"<hr color=DarkGreen /";
					}
					else
						ret_val += "<hr color=FireBrick  /><b>XXX parant</b><hr color=FireBrick  /";
					}
			}
			else
					ret_val += ('<b>' + obj + '</b> (' + typeof obj + ') :' + obj + '<hr color=LightSkyBlue  /><br />');
			
			ret_val += '</blockquote>';
			/**/
		}
		if (ret_val == null)
			return "stoped looking";
		else
			return ret_val;
	}

	///////////////////////////////////////////////////////////////


	function print_blank(txt,objName){
		var preText = (objName == null) ? '' : objName;	
	 	if (objName != '')
			preText =  '<font color=green>***'+objName+'***</font><br />';

		var a = window.open("about:blank");
		
		a.document.writeln(preText+txt);
		a.document.close();
		
	}

	///////////////////////////////////////////////////////////////

	function dmp(obj,depth){
		var depth = (depth == null) ? 0 : depth;
		var preText = '';
		if (depth>1){
			print_blank(dump_all(obj,depth),obj.name);
		}
		else{
			print_blank(dump_a(obj),obj.name);
			//preText =  '<font color=green>***'+obj.name+'***</font><br />';
		}
	}

	///////////////////////////////////////////////////////////////
	
		
	function switchItems(id1,id2){
		item1 = getElement(id1);
		item2 = getElement(id2);
		item1.style.display = "none";
		item2.style.display = "";
	}

	//------------------------------------------------------------------------------------------------
	// do some functions when click enter
	function doOnEnter(evt,func){
		if(evt.keyCode == 13){
			eval(func);
		}
	}
	
	//------------------------------------------------------------------------------------------------		
	// set event in general.
	function setEvent(eventFirefox,eventExplorer,strFunc){
		if(window.addEventListener){
			window.addEventListener(eventFirefox, eval(strFunc), false);
		}	
		else if (window.attachEvent){
			window.attachEvent(eventExplorer, eval(strFunc));
		}
		else if (document.getElementById) eval("window."+eventExplorer+"="+strFunc);
	}
	
	//------------------------------------------------------------------------------------------------		
	//sets onload function 
	function setOnloadFunction(strFunc){
		setEvent("load","onload",strFunc)
	}
	
	//------------------------------------------------------------------------------------------------		
	//------------------------------------------------------------------------------------------------		
	//encoding functions

	function dec2hex( textString ) {
	 return (textString+0).toString(16).toUpperCase();
	}
	//--------------------------------------------------------------------------------------------------------

	function  dec2hex2 ( textString ) {
	  var hexequiv = new Array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
	  return hexequiv[(textString >> 4) & 0xF] + hexequiv[textString & 0xF];
	}
	
	function convertCP2UTF8(textString) {
	  var outputString = "";
	  textString = textString.replace(/^\s+/, '');
	  if (textString.length == 0) { return ""; }
	  textString = textString.replace(/\s+/g, ' ');
	  var listArray = textString.split(' ');
	  for ( var i = 0; i < listArray.length; i++ ) {
	    var n = parseInt(listArray[i], 16);
	    if (i > 0) { outputString += ' ';}
	    if (n <= 0x7F) {
	      outputString += dec2hex2(n);
	    } else if (n <= 0x7FF) {
	      outputString += dec2hex2(0xC0 | ((n>>6) & 0x1F)) + ' ' + dec2hex2(0x80 | (n & 0x3F));
	    } else if (n <= 0xFFFF) {
	      outputString += dec2hex2(0xE0 | ((n>>12) & 0x0F)) + ' ' + dec2hex2(0x80 | ((n>>6) & 0x3F)) + ' ' + dec2hex2(0x80 | (n & 0x3F));
	    } else if (n <= 0x10FFFF) {
	      outputString += dec2hex2(0xF0 | ((n>>18) & 0x07)) + ' ' + dec2hex2(0x80 | ((n>>12) & 0x3F)) + ' ' + dec2hex2(0x80 | ((n>>6) & 0x3F)) + ' ' + dec2hex2(0x80 | (n & 0x3F));
	    } else {
	      outputString += '!erreur ' + dec2hex(n) +'!';
	    }
	  }
	  return( outputString );
	}

	//--------------------------------------------------------------------------------------------------------

	function getCPfromChar(textString){
		var codepoint = "";
		var haut = 0;
		var n = 0; 
		for (var i = 0; i < textString.length; i++) {
			var b = textString.charCodeAt(i); 
			if (b < 0 || b > 0xFFFF) {
				codepoint += 'Error: Initial byte out of range in getCPfromChar: '+dec2hex(b);
				}
			if (haut != 0) { // we should be dealing with the second part of a supplementary character
				if (0xDC00 <= b && b <= 0xDFFF) {
					codepoint += dec2hex(0x10000 + ((haut - 0xD800) << 10) + (b - 0xDC00)) + ' ';
					haut = 0;
					continue;
					}
				else {
					codepoint += 'Error: Second byte out of range in getCPfromChar: '+dec2hex(haut);
					haut = 0;
					}
				}
			if (0xD800 <= b && b <= 0xDBFF) { //b is the first part of a supplementary character
				haut = b;
				}
			else { // this is not a supplementary character
				codepoint += b.toString(16).toUpperCase()+' ';
				}
			} 
		return codepoint;
	}

	//----------------------------------------------------------------------------------------------------------------
	// encodes string to pass it to server with ajax to sequence of codes.
	function encodeUtf8(str){
		str = getCPfromChar(str); 
		str = str.substring(0, str.length-1);
		str = convertCP2UTF8(str);
		return(str);
	}
	
