var xmlhttp2;

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
    xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp2=false;
  }
 }
@else
 xmlhttp2=false
 @end @*/
if (!xmlhttp2 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp2 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}
if (!xmlhttp2 && window.createRequest) {
	try {
		xmlhttp2 = window.createRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}


function ajax_go(URL,obj){
    var mode = (arguments.length > 2) ? arguments[2] : "rewrite";
	loc = document.getElementById( obj );
	xmlhttp2.open("GET",URL+'&ajax=1',true );
	xmlhttp2.onreadystatechange = function() {
	 if (typeof xmlhttp2=='undefined') return;
		if ( xmlhttp2.readyState == 4 ) {
			cmd = xmlhttp2.responseText;
			if (cmd!='' && loc!=null) {
			  load (loc,cmd,mode);
			}
		}
	}
	xmlhttp2.setRequestHeader( "Accept", "message/x-jl-formresult" );
	xmlhttp2.send(null);
}


function load (obj,html,mode){
if (obj!=null) appendData(html, obj, mode);
return false;
}


function appendData(data_str, obj, mode){
var js_reg = /<script.*?>(.|[\r\n])*?<\/script>/ig;
var js_str = js_reg.exec(data_str);
if (js_str != null) var js_arr = new Array(js_str.shift());      
while(js_str) {
        js_str = js_reg.exec(data_str);
        if (js_str != null) js_arr.push(js_str.shift());
}

if(mode == 'rewrite') {
obj.innerHTML = data_str;
} else if (mode == 'append') {
obj.innerHTML += data_str;
}

var js_content_reg = /<script.*?>((.|[\r\n])*?)<\/script>/ig;
if ( js_arr!=null){
	for (i = 0; i < js_arr.length; i++) {
		js_content_reg.lastIndex = 0;
		var js_content = js_content_reg.exec(js_arr[i]);
		globaleval (js_content[1]);
		//alert(js_content[1]);
	}
}
                       
}

var globaleval =  function(script){
  if(window.execScript){
    return window.execScript(script);
  } else if(navigator.userAgent.indexOf('KHTML') != -1){ //safari, konqueror..
      var s = document.createElement('script');
      s.type = 'text/javascript';
      s.innerHTML = script;
      document.getElementsByTagName('head')[0].appendChild(s);
  } else {
    return window.eval(script);
  }
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Connector() {

	var xmlreq = false;
	if (window.XMLHttpRequest) {
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
			}
		}
	}
	return xmlreq;

}


var http = new Array();

function ajax_get(id, url, obj, mode, params){
	http[id] = Connector();
	if ('undefined' == typeof(http[id])){
		alert('Sorry, but your web browser does not support Ajax\nPlease, update your browser with latest version');
		return;
	}

	http[id].onreadystatechange = function() {
		if (http[id].readyState == 4) {
			if (http[id].status == 200) {
				if (http[id].responseText != ''){
					    cmd = http[id].responseText;
						try {	eval(cmd); }  catch(e) {
							if (obj && mode){
								loc = document.getElementById( obj );
								if (loc)  {load (loc,cmd,mode);}
							}
  						}
 
				}
			}
		}
	}

	if ('undefined' != typeof(params)){
		str = '';	
		for (key in params){
			str += key + '=' + params[key] + '&';
			
		}
		str = str.substr(0,(str.length - 1));
		http[id].open('POST', url, true);
		http[id].setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		http[id].send(str);
	}else{

		http[id].open('GET', url, true);
		http[id].send(null);
	}
	
}