// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

function CreateRequest() {

	var Request = false;

	if( window.XMLHttpRequest )
	 {
		Request = new XMLHttpRequest();
	 }
	else
	 {
		if( window.ActiveXObject )
		 {
			try
			 {
				Request = new ActiveXObject( "Microsoft.XMLHTTP" );
			 }
			catch( CatchException )
			 {
				Request = new ActiveXObject( "Msxml2.XMLHTTP" );
			 }
		 }
	 }

	if( !Request )
	 {
		alert( 'Извините, при попытке сделать AJAX запрос произошла ошибка!' );
	 }

	return Request;
}

// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

function SendRequest( r_method, r_path, r_args, r_handler ) {

	var Request = CreateRequest();

	if( !Request ) return;

	Request.onreadystatechange = function()
	 {
		if( Request.readyState == 4 )
		 {
			r_handler(Request);
		 }
	 }

	if( r_method.toLowerCase() == "get" && r_args.length > 0 )
	 {
		r_path += "?" + r_args;
	 }

	Request.open( r_method, r_path, true );

	if( r_method.toLowerCase() == "post" )
	 {
		Request.setRequestHeader( "Content-Type","application/x-www-form-urlencoded; charset=utf-8" );
		Request.send( r_args );
	 }
	else
	 {
		Request.send(null);
	 }
}

// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

function get_content( home, tip, id ) {
	var Handler = function( Request )
	 {
		document.getElementById( 'content' ).innerHTML = Request.responseText;
	 }
	var mont = document.getElementById( 'mont' ).value;
	document.getElementById( 'content' ).innerHTML = '<table width="100%"><tr><td align="center"><img src="' + load.src + '" /></td></tr></table>';
	SendRequest( 'POST', 'http://' + home + '/ajax/get_list.php', 'tip=' + tip + '&mont=' + mont + '&id=' + id, Handler );
}

// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

function get_content_date( home, data, razdel, id ) {
	var Handler = function( Request )
	 {
		document.getElementById( 'content' ).innerHTML = Request.responseText;
	 }
	document.getElementById( 'content' ).innerHTML = '<table width="100%"><tr><td align="center"><img src="' + load.src + '" /></td></tr></table>';
	SendRequest( 'POST', 'http://' + home + '/ajax/get_list.php', 'tip=data&data=' + data + '&r=' + razdel + '&id=' + id, Handler );
}

// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

levo = 0;
function win_visibility( id ) {
	if( levo == 0 )
	 {
		levo = window.event.clientX-200;
	 }
	document.all('win'+id).style.left= levo;
	document.getElementById( 'win' +id ).style.visibility='visible';
}

// -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

function win_hidden( id ) {
	document.getElementById( 'win' +id ).style.visibility = 'hidden';
}
