//window.onerror = function sysError(){return true;};
if (self.parent.frames.length != 0) self.parent.location=document.location;
function _isTopMenuActive(topMenuId)
{
	var btm = ''+document.body.topmenu;
	if (btm=='' || isNaN(btm)) btm=1;
	return (1*btm == 1*topMenuId);
}
function _hidePanel(panelName){return ((''+document.body.hiddenpanels).toLowerCase().indexOf(panelName.toLowerCase()) >= 0);}
function _rightPannelId() {return ((document.body.rightpannelid && document.body.rightpannelid != null && !isNaN(document.body.rightpannelid) && document.body.rightpannelid*1 == 1) ? 1 : 0);}
function _openCDPage()
{
	event.cancelBubble=true;
	event.returnValue=false;
	window.navigate('Forex.ChangeUserDetails.aspx');
	return false;
}
function _openCPPage()
{
	event.cancelBubble=true;
	event.returnValue=false;
	window.navigate('Forex.ChangePassword.aspx');
	return false;
}
function _showLangsMenu()
{
	var pos = document.all._tblLangsHead.getBoundingClientRect();
	document.all._tblLangsBody.style.left = pos.left + document.body.scrollLeft - 18;
	document.all._tblLangsBody.style.top = pos.bottom + document.body.scrollTop - 2;
	document.all._tblLangsBody.style.width = (pos.right - pos.left);
	document.all._tblLangsBody.onblur = document.all._tblLangsHead.onclick = _hideLangsMenu;
	document.all._tblLangsBody.style.display = '';
	document.all._tblLangsBody.focus();
	return false;
}
function _hideLangsMenu()
{
	if (document.all._tblLangsBody) document.all._tblLangsBody.style.display = 'none';
	if (document.all._tblLangsHead) document.all._tblLangsHead.onclick = _showLangsMenu;
	return false;
}
function _manageSubMenu(smParentObj, openOnly)
{
	var tableNode = (smParentObj.nextSibling.tagName ? smParentObj.nextSibling : smParentObj.nextSibling.nextSibling);
	
	if(1*smParentObj.isopen==0)
	{
		smParentObj.firstChild.src='Images/Forex.arrow_blue_down.gif';
		tableNode.style.display='';
		smParentObj.isopen=1;
	}
	else
	{
		if (!openOnly) {
		smParentObj.firstChild.src='Images/Forex.arrow_blue_right.gif';
		tableNode.style.display='none';
		smParentObj.isopen=0;}
	}
	return false;
}
function _getEventContent(oEvent, addCode)
{
	var evCont='';
	if (oEvent && oEvent != null && (''+oEvent) != '') evCont=(''+oEvent).split('{')[1].split('}')[0];
	return evCont + ';' + addCode;
}
function _showM2div(offsetObj)
{
	if (document.all._divM2)
	{
		document.all._divM2.style.position='absolute';
		document.all._divM2.style.top=offsetObj.getBoundingClientRect().top + document.body.scrollTop - 4;
		document.all._divM2.style.left=offsetObj.getBoundingClientRect().left + document.body.scrollLeft - 18;
		document.all._divM2.style.width=147;
		document.all._divM2.style.display='';
		var tr=document.all._divM2.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild;
		tr.onclick=new Function('', 'document.all._divM2.style.display="none"; return false;');
		tr.style.cursor='hand';
		tr.unselectable='on';
	}
}
var _wsScript=null;
function _waitForWS()
{
	if (document.all._frameWS.ws)
	{
		clearInterval(_wsScript);
		_wsScript=null;
		_authenticateLogin(__usName,__pass,true);
	}
}
var __usName=null, __pass=null;
function _authenticateLogin(UserName, Password, noDialog)
{
	if (document.all._btnAct1) document.all._btnAct1.disabled=true;
	if (document.all._btnAct2) document.all._btnAct2.disabled=true;
	if (!noDialog) window.showModalDialog('Forex.RegisterPopup.aspx',null,'dialogHeight: 282px; dialogWidth: 242px; edge: raised; center: Yes; help: No; resizable: No; status: No; scroll: No;');
	
		var frm = document.createElement('FORM');
		frm.action = "Forex.NLogin.aspx"
		frm.method = "post";
		frm.id="_loginForm";
		frm.name="_loginForm";
		document.body.appendChild(frm);
		
		var hdn = document.createElement("INPUT");
		hdn.type = "hidden";
		hdn.id = "_hdnUN";
		hdn.name = "_hdnUN";
		hdn.value = UserName;
		frm.appendChild(hdn);
		
		hdn = document.createElement("INPUT");
		hdn.type = "hidden";
		hdn.id = "_hdnUP";
		hdn.name = "_hdnUP";
		hdn.value = Password;
		frm.appendChild(hdn);
		
		hdn = document.createElement("INPUT");
		hdn.type = "hidden";
		hdn.id = "_hdnURL";
		hdn.name = "_hdnURL";
		hdn.value = unescape(location.href);
		frm.appendChild(hdn);

		frm.submit();
		
}
var _onLoginResult = null;
function _throwOnLoginResult(result)
{
	if (_onLoginResult != null) _onLoginResult(result);
}
function _loginResult()
{
	if (event.result.error || !event.result.value || event.result.value == null) _loginAgain();
	else
	{
		var loginRes = '' + event.result.value[0];
		if (event.result.value[1]!='' && event.result.value[1]!=null) alert(event.result.value[1]);
		if (event.result.value[2]!='' && event.result.value[2]!=null) {window.execScript(event.result.value[2]);}
		if (loginRes == '') _loginAgain();
		else if (event.result.value[3] == 'true')
		{
			if(!CancelTerms)
				_openCPPage();
		}	
		else {_throwOnLoginResult(true); window.navigate(window.location.href);}
	}	
}
var CancelTerms = false;
function _raiseTerms()
{
	var res = new Object(); res.value = false;
	window.showModalDialog('Forex.Terms.Popup.aspx',res,'dialogHeight: 490px; dialogWidth: 480px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll: No;');
	if (res.value) 
	{
		CancelTerms = false;
		
		var frm = document.createElement('FORM');
		frm.action = "Forex.MarkTerms.aspx"
		frm.method = "post";
		frm.id="_loginForm";
		frm.name="_loginForm";
		document.body.appendChild(frm);
		
		var	hdn = document.createElement("INPUT");
		hdn.type = "hidden";
		hdn.id = "_hdnURL";
		hdn.name = "_hdnURL";
		hdn.value = unescape(location.href);
		frm.appendChild(hdn);
		
		frm.submit();

	}
	else
	{
		CancelTerms = true;
		_Logout();
	}
}
function _Register(){window.navigate('Forex.Register.aspx');}
function _refreshQBox()
{
	if (document.all._qBox) {document.all._qBox.src=""; document.all._qBox.src="Forex.QuotesBox.aspx";}
}
var _qbScript=null, _qbMode, _qbCurr1, _qbCurr2, _qbMidRate, _qbHalfSpread;
function _setQBoxMode(qbMode, qbCurr1, qbCurr2, qbMidRate, qbHalfSpread)
{
	_qbMode=qbMode; _qbCurr1=qbCurr1; _qbCurr2=qbCurr2; _qbMidRate=qbMidRate; _qbHalfSpread=qbHalfSpread;
	if (_qbScript==null)
	{
		if (!document.all._qBox) {_qbScript=setInterval(_waitForQBox,333); return;}
		if (!document.all._qBox.contentWindow) {_qbScript=setInterval(_waitForQBox,333); return;}
		if (!document.all._qBox.contentWindow.loaded) {_qbScript=setInterval(_waitForQBox,333); return;}
	}
	else return;
	document.all._qBox.contentWindow.setMode(qbMode, qbCurr1, qbCurr2, qbMidRate, qbHalfSpread);
}
function _waitForQBox()
{
	if (document.all._qBox)
		if (document.all._qBox.contentWindow)
			if (document.all._qBox.contentWindow.loaded)
			{
				clearInterval(_qbScript);
				_qbScript=null;
				document.all._qBox.contentWindow.setMode(_qbMode, _qbCurr1, _qbCurr2, _qbMidRate, _qbHalfSpread);
			}
}
function _getMSIEVer() {if (this._msieVersion) return this._msieVersion(); else return 4;}
function _openFullQB()
{
	if(1*_getMSIEVer()>=5.5)
	{
		if (document.all._qBox && document.all._qBox.contentWindow && document.all._qBox.contentWindow.openFullQB)
			document.all._qBox.contentWindow.openFullQB();
	}
	else openPage("Forex.Rates.aspx");
}
function _setOnResize()
{
	document.body.onresize = new Function("", _getEventContent(document.body.onresize, ";_hideLangsMenu();if(document.all._divM2)document.all._divM2.style.display='none';"));
}
function _setDocUnload()
{
	document.body.onunload = new Function("", _getEventContent(document.body.onunload, ";if (_wsScript!=null) {clearInterval(_wsScript); _wsScript=null;}"));
}

function winOpener(wn,w,h){
    window.open(wn,null,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no");
}