// Refresh captcha
function reloadImage(xid){
	document.getElementById(xid).innerHTML = "<img border=\"0\" class=\"hand_over\" src=\"etc/component/captcha/captcha.php?r="+Math.random()+"\" onclick=\"reloadImage('captcha');\";/>";
}

// Ajax
function makeRequest(url, parameters, values) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
  	http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
	}}
  if (!http_request) {
  	document.getElementById(xid).innerHTML = "ok";
   }
   http_request.open('GET', url + "?" + parameters + "=" + values, false);
   http_request.send(null);
   document.getElementById(parameters).innerHTML = http_request.responseText;
}

function goURL(thisUrl){
	window.location.href = thisUrl;
}

function doKnowledgeBase(pIndex, mIndex){
	window.location.href='index.php?do=kb&pIndex='+pIndex+'&mIndex='+mIndex;
}

function doTriggerKB(kbIndex){
	document.getElementById(kbIndex).style.display = 'block';	
}

function doTriggerCloseKB(kbIndex){
	document.getElementById(kbIndex).style.display = 'none';	
}

function doClearCookies(){
	document.cookie="PHPSESSID=;path=/";
}

function doMatchPassword(xUrl, pass_field, retype_field, error_field, error_message){
	if ( pass_field != retype_field ){
		document.getElementById(error_field).innerHTML = error_message;
	}else{
		makeRequest(xUrl, error_field, retype_field);
	}
}