function max_words_exceed(thistext, maxwords) {
	if(count_words(thistext)>maxwords) {
		return true;
	}
	return false;
}
function count_words(tekst) {
	var fullStr=tekst+" ";
	var initial_whitespace_rExp=/^[^A-Za-z0-9]+/gi;
	var left_trimmedStr=fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp=rExp=/[^A-Za-z0-9]+/gi;
	var cleanedStr=left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString=cleanedStr.split(" ");
	var word_count=splitString.length-1;
	if(fullStr.length<2) {
		word_count=0;
	}
	return word_count;
}

function ajax_request(url, data, callback) {
	try {
		xhrobj=new XMLHttpRequest();
	} catch (e) {
		try {
			xhrobj=new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			xhrobj=new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
	xhrobj.open('GET', url);
	xhrobj.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 
  
	xhrobj.onreadystatechange=function() {
		if(xhrobj.readyState==4&&xhrobj.status==200) {
			callback(xhrobj.responseText);
		}
	};
	xhrobj.send(data);
}

function array_selected(element_id) {
	var arraylength=document.getElementById(element_id).length;
	for(var i=0; i<arraylength; i++) {
		if(document.getElementById(element_id).options[i].selected) {
			return true;
		}
	}
	return false;
}
