var req=null;
var idbroker=0;

function BrokerChanged(id)
{
	idbroker=id;
 	req = getXMLHTTPRequest();
        if(req)
        {
                req.onreadystatechange=onReadyCh;
                req.open("GET", "getaccounts.php?id=" + id, true);
                req.send(null);
        }
}

function getXMLHTTPRequest()
{
        var xreq=null;
        if(window.XMLHttpRequest)
        {
                xreq = new XMLHttpRequest();
        }
        else if(window.ActiveXObject)
        {
        
                xreq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xreq;
}


function onReadyCh()
{
        if(req.readyState==4)
        {
        	//alert(req.responseText);

//         	document.getElementById('mySelect2').innerHTML=req.responseText;
        
 		eval(req.responseText);


        }
}


function AccountChanged(account)
{
 	req = getXMLHTTPRequest();
        if(req)
        {
                req.onreadystatechange=onAccount;
                req.open("GET", "getsymbols.php?id=" + idbroker + "&account=" + account, true);
                req.send(null);
        }
}

function onAccount()
{
	if(req.readyState==4)
		eval(req.responseText);
// 		document.getElementById('mySelect3').innerHTML=req.responseText;
}

function CheckPrepare()
{
// 	alert("check");
	req = getXMLHTTPRequest();
        if(req)
        {
                req.onreadystatechange=onPrepare;
                req.open("GET", "getstate.php", true);
                req.send(null);
        }
        
}

function onPrepare()
{
	if(req.readyState==4)
	{
 		
		if(req.responseText=="Ready")
		{
			document.location="/confirm.php";
		}

	}
}


function ReloadCaptcha()
{
	var time = new Date();
	document.getElementById('mcaptcha').src='http://contest.tim.ua/CaptchaSecurityImages.php?time=' + time.getTime();
}



  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-23315782-6']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
 
