<!--

var ExternalLinks_InNewWindow = '1';

function initSpoilers(context) {
	var context = context || 'body';
	$('div.spoiler-head', $(context))
		.click(function(){
		    var ctx = $(this).next('div.spoiler-body');
			var code = ctx.children('textarea').text();
			if (code) {
			    ctx.children('textarea').replaceWith(code);
			    initSpoilers(ctx);
			}
			$(this).toggleClass('unfolded');
            $(this).next('div.spoiler-body').slideToggle('fast');
            $(this).next('div.spoiler-body').next().slideToggle('fast');
		});
}

$(document).ready(function(){
	initSpoilers('body');
});

//-->

function getXmlHttp(){
	var xmlhttp
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e1) {
      			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	return xmlhttp;
}

function urlEncodeData(data) {
    var query = [];
    if (data instanceof Object) {
        for (var k in data) {
            query.push(encodeURIComponent(k) + "=" + encodeURIComponent(data[k]));
        }
        return query.join('&');
    } else {
        return encodeURIComponent(data);
    }
}

function check_login(){
            var req = getXmlHttp();
            var dinf= document.getElementById('dinf');
            var linf = [];
            linf.push("chk_login");
            linf.push(document.forms.sform.wantusername.value);
            linf=urlEncodeData(linf);
            if(dinf){
                 dinf.innerHTML="Проверка логина";
            }
	req.open('GET', 'dynamic.php?'+linf, true);
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if(req.status == 200) {
				if(dinf)
                                                 dinf.innerHTML=req.responseText;
			}else{
                                        dinf.innerHTML="Ошибка связи"; 
                                    }
		}
	}
	req.send(null) 
}
