var url_open = 0; 
var table_open = 0; 
var td_open = 0; 
var tr_open = 0; 

    function doMatchCalendar(month,year) {
	var ajax=new dle_ajax();
	ajax.onShow('');
	var varsString="";
	ajax.setVar("year",year);
	ajax.setVar("month",month);
	ajax.requestFile=dle_root+"engine/ajax/match_calendar.php";
	ajax.method='GET';
	ajax.element='match_calendar-layer';
	ajax.sendAJAX(varsString)
    };

function is_array( mixed_var ) {   
    return ( mixed_var instanceof Array );   
}  

    function getGetArray() {
	var query = window.location.search.substring(1);  
	var vars = query.split("&");
	var arr = new Array(); 
	for (var i=0;i<vars.length;i++) {
	    var pair = vars[i].split("=");
       	    arr[pair[0]] = pair[1];
	}
	return arr;
    }

    var GetArr = getGetArray()

    function GetGetVar(varname) {
	for(i in GetArr){
	    if (i==varname) return GetArr[i];
	}
	return 6;
    }

    var contid = "mess_cont";

    function positionMessage(elem) {
	elem.style.position = 'absolute';

	var scroll = document.documentElement.scrollTop || document.body.scrollTop;
	elem.style.top = scroll + 200 + 'px';

	elem.style.left = Math.floor(document.body.clientWidth/2) - 150 + 'px';
    }

    function loading_progress(text){
	if ( (!text) || (text.length==0) ) text = 'Загрузка данных...';
	var cont = document.getElementById(contid);
	if (!cont){
		cont = document.createElement('div');
		cont.align = 'center';
		cont.padding = '0px';
		cont.margin = '0px';
		cont.id = contid;
	}
	if (!cont){alert('не найден контейнер');}	

        while (cont.firstChild) {
        	cont.removeChild(cont.firstChild);
	}

	body_table = document.createElement('table');
	body_table.style.width = '100%';
        body_table.cellPadding = 0;
        body_table.cellSpacing = 0;

        var topRow = body_table.insertRow(-1);
        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_lt';
	newCell.innerHTML = '&nbsp;';

        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.align = 'center';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_top';
	newCell.innerHTML = '&nbsp;';

        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_rt';
	newCell.innerHTML = '&nbsp;';

        var bodyRow = body_table.insertRow(-1);
        newCell = bodyRow.insertCell(-1);
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.className = 'news_lft';
	newCell.innerHTML = '&nbsp;';

        bodyCell = bodyRow.insertCell(-1);
	bodyCell.align = 'center';
	bodyCell.border = '1px solid blue';
	bodyCell.className = 'news_body';
	bodyCell.innerHTML = text;

        newCell = bodyRow.insertCell(-1);
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.className = 'news_rgt';
	newCell.innerHTML = '&nbsp;';


        var bottomRow = body_table.insertRow(-1);
        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.vAlign = 'top';
	newCell.className = 'news_lb';
	newCell.innerHTML = '&nbsp;';

        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.align = 'center';
	newCell.vAlign = 'top';
	newCell.className = 'news_btm';
	newCell.innerHTML = '&nbsp;';

        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.vAlign = 'top';
	newCell.className = 'news_rb';
	newCell.innerHTML = '&nbsp;';

	cont.appendChild(body_table);
	cont.style.width = '450px';

	positionMessage(cont);

	document.body.appendChild(cont);
    }

    function show_message(messtext) {
	var container = document.getElementById(contid);
	if (!container){
		container = document.createElement('div');
		container.align = 'center';
		container.padding = '0px';
		container.margin = '0px';
		container.id = contid;
	}
	if (!container){alert('не найден контейнер');}	
	
        while (container.firstChild) {
        	container.removeChild(container.firstChild);
	}
	
	mess_body = document.createElement('div');
	mess_body.id = 'mess_body';
	body_table = document.createElement('table');
	body_table.style.width = '100%';
        body_table.cellPadding = 0;
        body_table.cellSpacing = 0;

        var topRow = body_table.insertRow(-1);
        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_lt';
	newCell.innerHTML = '&nbsp;';

        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.align = 'center';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_top';
	newCell.innerHTML = '&nbsp;';

        newCell = topRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.vAlign = 'bottom';
	newCell.className = 'news_rt';
	newCell.innerHTML = '&nbsp;';

        var bodyRow = body_table.insertRow(-1);
        newCell = bodyRow.insertCell(-1);
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.className = 'news_lft';
	newCell.innerHTML = '&nbsp;';

        bodyCell = bodyRow.insertCell(-1);
	bodyCell.align = 'left';
	bodyCell.border = '1px solid blue';
	bodyCell.className = 'news_body';

	body_div = document.createElement('div');
	body_div.innerHTML = messtext;
	bodyCell.appendChild(body_div);

	brEl = document.createElement('br');
	bodyCell.appendChild(brEl);

	btn_div = document.createElement('div');
	btn_div.align = 'center';

	mess_btn = document.createElement('input');
	mess_btn.id = 'mess_btn';
	mess_btn.type = "button";
	mess_btn.value = 'закрыть';
	mess_btn.className = 'bbcodes_poll';
	mess_btn.align = 'center';
	btn_div.appendChild(mess_btn);
	bodyCell.appendChild(btn_div);

        newCell = bodyRow.insertCell(-1);
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.className = 'news_rgt';
	newCell.innerHTML = '&nbsp;';

        var bottomRow = body_table.insertRow(-1);
        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'right';
	newCell.vAlign = 'top';
	newCell.className = 'news_lb';
	newCell.innerHTML = '&nbsp;';

        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.align = 'center';
	newCell.vAlign = 'top';
	newCell.className = 'news_btm';
	newCell.innerHTML = '&nbsp;';

        newCell = bottomRow.insertCell(-1);
	newCell.style.height = '10px';
	newCell.style.width = '10px';
	newCell.align = 'left';
	newCell.vAlign = 'top';
	newCell.className = 'news_rb';
	newCell.innerHTML = '&nbsp;';

	mess_body.appendChild(body_table);
	container.appendChild(mess_body);

	container.style.width = '500px';

	positionMessage(container);

	mess_btn.onclick = function() {
	    container.parentNode.removeChild(container);
	}

	document.body.appendChild(container);
	
	return false;
    }


function file_contents_message(url){
if (window.XMLHttpRequest) req = new XMLHttpRequest();  
else if (window.ActiveXObject) {    
    try {
        req = new ActiveXObject("Msxml2.XMLHTTP");    
    } catch (e){}
    try {     
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
    } catch (e){} 
}  
if (req) {
    var messcont = (document.all) ? document.all.mess_cont : document.getElementById(contid);       

    req.open("GET", url, true); 
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.status == 200){
		if (messcont){
                    while (messcont.firstChild) {
                        messcont.removeChild(messcont.firstChild)
		    }
                }
		var s = req.responseText;		
		var s = s.replace(/[\r\n]/g, ' ');
  		show_message(s);
            }else{
    		messcont = (document.all) ? document.all.mess_cont : document.getElementById(contid);       
	    	if (messcont){messcont.parentNode.removeChild(messcont);}
                alert("Ошибка: "+req.statusText);
            }
        }else{
	    if (messcont){
                while (messcont.firstChild) {
                    messcont.removeChild(messcont.firstChild);
		}
            }
	    loading_progress();
        }
    }
    req.send(null); //отправка запроса без параметров, т.к. они установлены в url
}
else 
    {alert("Браузер не поддерживает AJAX");}
return false;
}    
