﻿//window.onerror = function sysError(){return true;};
if (self.parent.frames.length != 0) self.parent.location=document.location;
function _isTopMenuActive(topMenuId)
{
    if (document.body.attributes["topmenu"] == null)
         return false;
	var btm = "" + document.body.attributes["topmenu"].value;
	if (btm=="" || isNaN(btm)) btm=1;
	return (1*btm == 1*topMenuId);
}
//img preloader
if (document.images)
{
	image1=new Image();
	image1.src="i/tulBxTl.gif";
	image2=new Image();
	image2.src="i/rghB.gif";
	image3=new Image();
	image3.src="i/bspc.gif";
}

function _displayActiveMenu()
{
    if (document.body != null)
    {
        if(document.body.attributes["topmenu"] == null)
            return;
        var no = document.body.attributes["topmenu"].value;
	    //var no = gebi("attr").getAttribute("topmenu");
    	if(isNaN(no))return;
	    var tm = 'tm' + no;
		switch(1*no)
		{
			case 1:break;
			case 2: gebi("tmt").style.cursor='pointer';
					break
			case 3: gebi("tm1").style.display='none';
					gebi("tm3").style.display='block';
					break;
			default: break;
		}
	}
	else
	{
	    setTimeout(_displayActiveMenu,100);
	}
}

function _hidePanel(panelName)
{
    var hiddenpanles = document.body.attributes["hiddenpanels"];
    if (hiddenpanles != null)
    {
        return ((hiddenpanles.value).toLowerCase().indexOf(panelName.toLowerCase()) >= 0)
    }
    return 0;
}

function _openCDPage()
{
	//event.cancelBubble=true;
	//event.returnValue=false;
	window.location='Forex.ChangeUserDetails.aspx';
	return false;
}
function _openCPPage()
{
	//event.cancelBubble=true;
	//event.returnValue=false;
	window.location='Forex.ChangePassword.aspx';
	return false;
}

function _showLangsMenu()
{
	var a = gebi("_tblLangsBody");
	a.onblur = gebi("_tblLangsHead").onclick = _hideLangsMenu;
	a.style.display = 'block';
	a.focus();
	return false;
}

function _hideLangsMenu()
{
	var a = gebi("_tblLangsBody");
	var b = gebi("_tblLangsHead");
	if (a) a.style.display = 'none';
	if (b) b.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='i/Forex.arrow_blue_down.gif';
		tableNode.style.display='';
		smParentObj.isopen=1;
	}
	else
	{
		if (!openOnly) {
		smParentObj.firstChild.src='i/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 _hideM2div(offsetObj,e)
{
    gebi("divM2").style.display='none';
    var tr=gebi("tmt");
		tr.onclick=new Function('', '_showM2div("divM2")');
}

function _showM2div(offsetObj,e)
{
	if (gebi("divM2"))
	{
	    gebi("divM2").style.backgroundColor="white";
		gebi("divM2").style.position='absolute';
		if(navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Safari") != -1)
        {
    		gebi("divM2").style.top= (findPosY(gebi("tmt")) + gebi("tmt").clientHeight + 1) + "px";
    		if (self.scrollMaxY<=0)
    		    gebi("divM2").style.left= (findPosX(gebi("tmt"))-6) + "px";
    		else
		        gebi("divM2").style.left= (findPosX(gebi("tmt"))) + "px";
		}
		else
		{
		    gebi("divM2").style.top= (findPosY(gebi("tmt")) + gebi("tmt").clientHeight + 1) + "px";
		    gebi("divM2").style.left= (findPosX(gebi("tmt")) + 2) + "px";
		}
		gebi("divM2").style.width="145px";
		gebi("divM2").style.display='';
		gebi("divM2").style.zIndex="10000";
		var tr=gebi("tmt");
		tr.onclick=new Function('', '_hideM2div("divM2")');
		tr.unselectable='on';
	}
}
function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
    while(1) 
    {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
    while(1)
    {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
    else if(obj.y)
    curtop += obj.y;
    return curtop;
}
var _wsScript=null;
function _waitForWS()
{
	if (gebi("_frameWS").ws)
	{
		clearInterval(_wsScript);
		_wsScript=null;
		_authenticateLogin(__usName,__pass,true);
	}
}
function _authenticateLogin(UserName, Password, noDialog)
{
    if(navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Safari") != -1)
    {
        _authenticateFFLogin(UserName, Password, noDialog);
    }
    else
    {
        _authenticateIELogin(UserName, Password, noDialog);
    }
}

var __usName=null, __pass=null;var Dialog;
function _authenticateIELogin(UserName, Password, noDialog)
{
	var ba1 = gebi("_btnAct1");
	var ba2 = gebi("_btnAct2");
	if (ba1) ba1.disabled=true;
	if (ba2) ba2.disabled=true;
	if (!noDialog) 
	    window.showModalDialog('Forex.RegisterPopup.aspx',null,'dialogHeight: 282px; dialogWidth: 242px; edge: raised; center: Yes; help: No; resizable: No; status: yes; 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();	
}

function _authenticateFFLogin(UserName, Password, noDialog)
{
	var ba1 = gebi("_btnAct1");
	var ba2 = gebi("_btnAct2");
	if (ba1) ba1.disabled=true;
	if (ba2) ba2.disabled=true;
	if (!Dialog)
	{
	    Dialog = new createPopUpDiv("Dialog");
	}
	
	var w = 480, h = 340;
	
	if(navigator.userAgent.indexOf("IE") != -1)
	{ 
       w = document.body.clientWidth;
       h = document.body.clientHeight;
    }
    else {
       w = window.innerWidth;
       h = window.innerHeight;
    }
    var popW = 235, popH = 230;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	Dialog.Show('Forex.RegisterPopup.aspx','height=230px, width=235px, edge= raised, ,top='+topPos +',left='+ leftPos +', help= No, resizable= No, status= No, scroll= No')
	Dialog.AfterClose=_afterauthenticateLogin;	
}

function _afterauthenticateLogin()
{
	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.value;
		frm.appendChild(hdn);
		
		hdn = document.createElement("INPUT");
		hdn.type = "hidden";
		hdn.id = "_hdnUP";
		hdn.name = "_hdnUP";
		hdn.value = Password.value;
		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);}
	}	
}
function _raiseTerms()
{
	if(navigator.userAgent.indexOf("Firefox") != -1)
	{
	    _raiseFFTerms();
	}
	else
	{
	    _raiseIETerms();
	}
}

function _raiseIETerms()
{
    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) 
	{
		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();
	
		CancelTerms = false;
	}
	else
	{
		CancelTerms = true;
		_Logout();
	}	
}

var CancelTerms = false;
var res = new Object(); res.value = false;
function _raiseFFTerms()
{
    if (!Dialog)
    {
        Dialog = new createPopUpDiv("Dialog");
    }
    Dialog.Show('Forex.Terms.Popup.aspx','height= 455px, width= 480px, edge= Raised, center= Yes, help= No, resizable= No, status= No, scroll= No');
    Dialog.retrunValue = res;
    Dialog.AfterClose=_AfterRaiseTermsFF;
}
function _AfterRaiseTermsFF(Obj)
{
	if (Obj.retrunValue.value) 
	{
		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();
	
		CancelTerms = false;
	}
	else
	{
		CancelTerms = true;
		_Logout();
	}	
}

//function _AfterRaiseTermsIE()
//{
//	if (res.value) 
//	{
//		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();
//	
//		CancelTerms = false;
//	}
//	else
//	{
//		CancelTerms = true;
//		_Logout();
//	}	
//}

function _Register(){window.location.assign('Forex.Register.aspx');}

 var gblQBX = gebi("_qBox");
function _refreshQBox()
{
	if (gblQBX) {gblQBX.src=""; gblQBX.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)
	{
	    gblQBX = gebi("_qBox");
		if (!gblQBX) {_qbScript=setInterval(_waitForQBox,333); return;}
		if (!gblQBX.contentWindow) {_qbScript=setInterval(_waitForQBox,333); return;}
		if (!gblQBX.contentWindow.loaded) {_qbScript=setInterval(_waitForQBox,333); return;}
	}
	else return;
	gblQBX.contentWindow.setMode(qbMode, qbCurr1, qbCurr2, qbMidRate, qbHalfSpread);
}
function _waitForQBox()
{
	if (gblQBX)
		if (gblQBX.contentWindow)
			if (gblQBX.contentWindow.loaded)
			{
				clearInterval(_qbScript);
				_qbScript=null;
				gblQBX.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 (gblQBX && gblQBX.contentWindow && gblQBX.contentWindow.openFullQB)
			gblQBX.contentWindow.openFullQB();
	}
	else openPage("Forex.Rates.aspx");
}
function _setOnResize()
{
	document.body.onresize = new Function("", _getEventContent(document.body.onresize, ";_hideLangsMenu();if(gebi('divM2'))gebi('divM2').style.display='none'"));
}
function _setDocUnload()
{
	document.body.onunload = new Function("", _getEventContent(document.body.onunload, ";if (_wsScript!=null) {clearInterval(_wsScript); _wsScript=null;}"));
}

function CookieVar(name)
{
	var index1 = document.cookie.indexOf(name + "=");
	if(index1 == -1) return "";
	var index2 = document.cookie.indexOf(";", index1);
	if(index2 != -1) return isPOpen = document.cookie.substring(index1 + name.length + 1 , index2);
	return isPOpen = document.cookie.substring(index1 + name.length + 1);
}	
function showHideDiv(toDisplay,img,dPos,cuki){
    var arr = document.getElementById(toDisplay);
    var v = gebi(img);
    if(arr.length==null)
    {
        var o = gebi(toDisplay)
        if(navigator.userAgent.indexOf("Firefox") == -1)
        {
            if(_hidePanel("left"))
            {
                var o = document.all[toDisplay][1];
            }
        }
        if (o.style.display == "block")
        {
            var toHeight;
            if(navigator.userAgent.indexOf("Firefox") == -1)
            {
                 toHeight = o.offsetHeight;
                 gebi("mfc").style.height = gebi("mfc").offsetHeight + "px";
            }
            else
            {
                toHeight = o.clientHeight;
                gebi("mfc").style.height = gebi("mfc").clientHeight + "px";
            }
            o.style.display = "none";
            v.src="i/arwLft.gif";
            document.cookie = cuki+"=0;path=/";
            gebi("mfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2)+ "-" + toHeight)  +"px";
            gebi("Mainmfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2)+ "-" + toHeight)  +"px";
                
        }else{
            o.style.display = "block";
            var toHeight;
            if(navigator.userAgent.indexOf("Firefox") == -1)
            {
                 toHeight = o.offsetHeight;
                 gebi("mfc").style.height = gebi("mfc").offsetHeight + "px";
            }
            else
            {
                toHeight = o.clientHeight;
                gebi("mfc").style.height = gebi("mfc").clientHeight + "px";
            }
            v.src="i/Forex.arrow_blue_down.gif";
            document.cookie = cuki+"=1;path=/";
            gebi("mfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "+" + toHeight )  +"px";
            gebi("Mainmfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "+" + toHeight)  +"px";
        }
        }else{
            var o0 = arr[0].style;
            var o1 = arr[1].style;
            if (o0.display == "block"){
            o0.display = "none";
            o1.display = "none";
            v.src="i/arwLft.gif";
            document.cookie = cuki+"=0"
            gebi("mfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "-231")  +"px";
            gebi("Mainmfc").style.height=eval(gebi("Mainmfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "-231")  +"px";
        }else{
            o0.display = "block";
            o1.display = "block";
            v.src="i/Forex.arrow_blue_down.gif";
            document.cookie = cuki+"=1"
            gebi("mfc").style.height=eval(gebi("mfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "+231")  +"px";
            gebi("Mainmfc").style.height=eval(gebi("Mainmfc").style.height.substr(0,gebi("mfc").style.height.length-2) + "+231")  +"px";
        }
    }
}

function Go2Url(MyUrl) {
	document.location = MyUrl
}

function winOpener(wn,w,h){
    window.open(wn,null,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no");
}

function createPopUpDiv(varname)
{
    var divPopupMask
    //win - var that contain the popup window
    this.win;
    //AfterClose - get poiner to the function after the window closed
    this.AfterClose;
    //retrunValue - paramter that talk with the window
    this.retrunValue;
    this.Show = function (url,propertis)
    {
        divPopupMask = document.createElement("div");
        divPopupMask.id="popupMask";
        divPopupMask.className="popupMask";
        divPopupMask.zIndex="10000";
        divPopupMask.style.height = document.height + "px";
        document.body.appendChild(divPopupMask);
        this.win = window.open(url,"",propertis);
        divPopupMask.setAttribute("onclick",varname + ".win.focus()");
    }
    this.Close = function ()
    {
        document.body.removeChild(divPopupMask);
        this.divPopupMask=null;
        if(this.AfterClose)
            this.AfterClose(this);
    }
    this.Unload = function()
    {
        this.Close();
    }
}

/*
var innerdiv = document.createElement("div");
innerdiv.id="innerDiv";
innerdiv.style.position="absolute";
innerdiv.style.top="200px";
innerdiv.style.left="300px";
innerdiv.style.width="200px";
innerdiv.style.height="245px";
innerdiv.style.textAlign="center";
innerdiv.style.backgroundColor="white";
innerdiv.innerHTML="<iframe id='imodalframe' width='100%' height='100%' src='http://localhost/EZFX_MULTI_LANGUAGE_V12.5FireFox/RTL/Forex.RegisterPopup.aspx' />";
innerdiv.style.zIndex="2001";
document.body.appendChild(innerdiv)
*/
//imodalframe.contentWindow.document.getElementsByTagName("input")
//setTimeout("y()",3000);