window.onerror = new Function("", "return true;");
function getParameter ( queryString, parameterName )
{	
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		begin = queryString.indexOf ( parameterName );
		if ( begin != -1 ) {
			begin += parameterName.length;
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			return unescape ( queryString.substring ( begin, end ) );
		}
		return "null";
	}
}		


var documentQuery = "?symbol=EURUSD";
var symbol = getParameter(documentQuery,"symbol");


function openBtn()
{
	if(document.all.UserName.value.length != 0 && document.all.Password.value.length != 0)
		document.all.loginBtn.disabled=false;
	else
		document.all.loginBtn.disabled=true;
}

function winResize()
{
	if (!parent.charts && document.all.chAplet)
	{		
		document.all.chAplet.width=document.body.clientWidth;
		document.all.chAplet.height=document.body.clientHeight;
	}	
}

var checkedOpener = 0;
var openerMode;
function errClose()
{
	openerMode=window.setInterval(checkOpener,500);
	return true;
}

function closeChartContent()
{
	window.clearInterval(openerMode);
	doUnload = false;
	window.close();
}

function checkOpener()
{	
	checkedOpener++;
	if (checkedOpener >60 ) closeChartContent();
	else
	{
		window.onerror = errClose;
		if (window.opener.closed)	{closeChartContent();}
		if (window.opener._isSessionTimeout) {closeChartContent();}
		else if (window.opener.document.all._tdLM)
		{	
			 checkedOpener = 0;
			 if (window.opener.setDetachWin) {window.opener.setDetachWin(tabId,window.self);}
		}
		window.onerror = new Function("", "return true;");
	}
}
function authenticateLogin()
{
	document.all.loginBtn.disabled=true;
	parent._onLoginResult = new Function('result', 'if (!result) {document.all.Password.value="";document.all.UserName.select();document.all.loginBtn.disabled=true;document.all.msg.style.display="";}');
	parent._authenticateLogin(document.all.UserName.value, document.all.Password.value);
	return false;
}
function openBtn()
{
	document.all.loginBtn.disabled = (document.all.UserName.value.length == 0 || document.all.Password.value.length == 0);
}

if (!(parent.charts || window.opener.charts)) window.navigate('Forex.charts.aspx');
