function loadDoc(docname, divname) {

	var xmlhttp=false;
    var fail = 'goto_';

	/*@cc_on @*/

	/*@if (@_jscript_version >= 5)

		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}

	@else

		xmlhttp = false;

	@end @*/

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

		try {
	      xmlhttp = new XMLHttpRequest();
	    } catch (e) {
	      xmlhttp = false;
	    }
	}

	if (xmlhttp) {

	xmlhttp.open("GET", docname,true);
	 xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4&&xmlhttp.responseText!="") {

        var searchlength    = fail.length;

        if (xmlhttp.responseText.substr(0,searchlength)==fail) {
            var resultstr           = xmlhttp.responseText.length - fail.length;
            var targeturl           = xmlhttp.responseText.substr(searchlength,resultstr)
            window.location.href    = "http://hrclub.hu/"+targeturl;
        } else {
            document.getElementById(divname).innerHTML=xmlhttp.responseText;
        }
	  }
	 }
	 xmlhttp.send(null)

	 }

}

function formOperator(op, divname) {
    now = new Date();
    document.getElementById(divname).innerHTML = "<div class=\"regalert\"><p class=\"loading\">Betöltés</p></div>";
    var theForm = document.forms[1];
    var urlText = ""

   for(i=0; i<theForm.elements.length; i++){
    if (theForm.elements[i].type!="button") {
        urlText += theForm.elements[i].name + "="

        if(theForm.elements[i].type == "text" || theForm.elements[i].type == "password" || theForm.elements[i].type == "textarea" || theForm.elements[i].type == "button"){
              urlText += theForm.elements[i].value
        }
        else if(theForm.elements[i].type == "checkbox"){
              urlText += theForm.elements[i].checked
        }
        else if(theForm.elements[i].type == "select-one"){
              urlText += theForm.elements[i].options[theForm.elements[i].selectedIndex].text
        }
        urlText += "&"
    }
   }
   loadDoc('dboperator.php?'+urlText+'op='+op+'&ts='+now, divname);
}

function getOperator(op, divname) {
    now = new Date();
    document.getElementById(divname).innerHTML = "<div class=\"regalert\"><p class=\"loading\">Betöltés</p></div>";
    var urlText = ""

    var query=this.location.search.substring(1);
    if (query.length > 0){
        var params=query.split("&");
        for (var i=0 ; i<params.length ; i++){
            var pos = params[i].indexOf("=");
            var name = params[i].substring(0, pos);
            var value = params[i].substring(pos + 1);
            urlText += name + "=" + value + "&"
        }
    }

   loadDoc('dboperator.php?'+urlText+'op='+op+'&ts='+now, divname);
}
