var W = window;
var D = document;
var DA = document.all;
var PW = parent.window;
var WA = window.dialogArguments;
var DF = document.frames;
var WO = window.opener;
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 go( url, opt, tb, w, h, s, r, wn ){
	if( !url )return false;
	
	l = ( screen.width - w )/2;
	t = ( screen.height - h )/2;
	if( !w )w = 700;
	if( !h )h = 500;
	if( !s )s = 1; else s = 0;
	if( !r )r = 1; else r = 0;
	if( !tb )tb = 1; else tb = 0;
	if( !wn )wn = "_blank";
	
	if( MAIN_HOST ){
		url = MAIN_HOST + url;
	}
	
	if( opt == 1 ){
		return window.open( url, wn, "toolbar="+tb+",scrollbars="+s+",resizable="+r+",left="+l+",top="+t+",width="+w+",height="+h );
	}
	else if( opt == 2 ){
		return window.open( url, wn );
	}
	else{
		window.location.href = url;
	}
}


function igo( url ){
	DA.ifrm.src = url;
}

function select_all( val, form_name ) {
	if ( !form_name ) form_name = 'frm';
	for ( i = 0; i < document.forms[ form_name ].elements.length; i++ ) {
		if ( document.forms[ form_name ].elements[i].type == 'checkbox' ) {
			document.forms[ form_name ].elements[i].checked = val;
		}
	}

}

function wcenter( w, h ){
	
	l = ( screen.width - w ) / 2;
	t = ( screen.height - h ) / 2;
	if( t < 40 )t = 40;
	window.moveTo( l, t - 40 );
	
}

function up( obj ){
	if( !obj ){
		document.body.scrollTop = document.body.scrollHeight + 2500;
		return;
	}
	obj.scrollTop = obj.scrollHeight;
}

function mod( url, w, h, nr, m ){
	
	var d_args = new Array( );
	if( !w ){	w = 400;	res = "Yes";	}
	if( !h ){	h = 400;	res = "Yes";	}
	if( nr ){	res = "No"; }else{	res = "Yes";	}
	
	d_args[0] = window;
	prop = "dialogHeight: "+h+"px; dialogWidth: "+w+"px; edge: Raised; center: Yes; scroll: Yes; help: No; resizable: "+res+"; status: No;";
	if( !m )W.showModelessDialog( url , d_args , prop );
	else W.showModalDialog( url , d_args , prop );
}



function privat_chat( url,  u_id ){
	return go( url, 1, 1, 550, 540, 1, 1, u_id );
}


function ajax_go(URL,obj){
    var mode = (arguments.length > 2) ? arguments[2] : "rewrite";
	loc = document.getElementById( obj );
	xmlhttp2.open("GET",URL,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 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);
	}
	
}