function Initialize()
{
  document.getElementById("chkIAgree").checked = false;
  if (HasRuntimeVersion(runtimeVersion))
  {
    InstallButton.href = directLink;
    BootstrapperSection.style.display = "none";
  }
}

function HasRuntimeVersion(v)
{
  var va = GetVersion(v);
  var i;
  var a = navigator.userAgent.match(/\.NET CLR [0-9.]+/g);
  if (a != null)
    for (i = 0; i < a.length; ++i)
      if (CompareVersions(va, GetVersion(a[i])) <= 0)
		return true;
  return false;
}

function GetVersion(v)
{
  var a = v.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
    return a.slice(1);
}

function CompareVersions(v1, v2)
{
  for (i = 0; i < v1.length; ++i)
  {
    var n1 = new Number(v1[i]);
    var n2 = new Number(v2[i]);
    if (n1 < n2)
      return -1;
    if (n1 > n2)
      return 1;
  }
  return 0;
}

function eval1() { 
	document.forms[0].brand.disabled = false
	document.forms[0].txtLogin.disabled = false
	document.forms[0].txtLogin2.disabled = false
	document.forms[0].txtLogin2.style.background='#FFFFFF'
	document.forms[0].txtPass.disabled = false
	document.forms[0].txtPass2.disabled = false
	document.forms[0].txtPass2.style.background='#FFFFFF'
}

function eval2()
{		
	document.forms[0].brand.disabled = true
	document.forms[0].txtLogin.disabled = true
	document.forms[0].txtLogin2.disabled = true
	document.forms[0].txtLogin2.style.background='#CCCCCC'
	document.forms[0].txtPass.disabled = true
	document.forms[0].txtPass2.disabled = true
	document.forms[0].txtPass2.style.background='#CCCCCC'
}

function checkemail(email){
			var testresults;			
			var str=email;
			var filter=/^(['_a-z0-9-+]+)(\.['_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/i
			if (filter.test(str))
				testresults=true
			else				
				testresults=false				
			return (testresults)			
			}

function CopyValues()
{	
	
	if ((document.forms[0].type[0].checked == false) && (document.forms[0].type[1].checked == false))
	{
		alert("请选择账户类型");				
		document.forms[0].type.focus;
		return false;
	}	
	
	if ((document.forms[0].platform[0].checked == false) && (document.forms[0].platform[1].checked == false) && (document.forms[0].platform[2].checked == false))
	{
		alert("请选择交易平台");				
		document.forms[0].platform.focus;
		return false;
	}
	
	if ((document.forms[0].platform[1].checked) && (document.forms[0].txtLogin2 == null))
	{
		evalweb();
  }
			
	if ((document.forms[0].platform[1].checked) && (document.forms[0].type[1].checked))
	{	
		if (document.forms[0].txtLogin2.value.length == 0)  {  
    alert ("请输入用户名");
    document.forms[0].txtLogin2.focus();    
    return false;
    }
    else
    if (checkemail(document.forms[0].txtLogin2.value) == false) {
    alert ("模拟账户的用户名必须为一个完整的电子邮件地址，也就是您注册模拟账户时填写的电子邮件地址。 如果您不记得用户名和密码，您可以联系我们的客服人员。 谢谢！");
    document.forms[0].txtLogin2.focus(); 
    return false;
    }
    else		
    if (document.forms[0].txtPass2.value.length == 0)  {  
    alert ("请重新输入用户名和密码");
    document.forms[0].txtPass2.focus();    
    return false;
    }
    else	
	  document.Form1.txtPass.value = document.Form1.txtPass2.value;
	  document.Form1.txtLogin.value = document.Form1.txtLogin2.value;
	  document.Form1.txtLogin2.value = "";
	  document.Form1.txtPass2.value = "";			
		document.forms[0].action = 'http://demo.efxnow.com/webclient/intl_applet/Login.aspx'
		document.forms[0].method = 'POST'
	}
	else
	if ((document.forms[0].platform[1].checked) && (document.forms[0].type[0].checked))
	{	
		if (document.forms[0].txtLogin2.value.length == 0)  {  
    alert ("请输入用户名");
    document.forms[0].txtLogin2.focus();    
    return false;
    }
    else    
    if (document.forms[0].txtPass2.value.length == 0)  {  
    alert ("请重新输入用户名和密码");
    document.forms[0].txtPass2.focus();    
    return false;
    }
	  document.Form1.txtPass.value = document.Form1.txtPass2.value;
	  document.Form1.txtLogin.value = document.Form1.txtLogin2.value;
	  document.Form1.txtLogin2.value = "";
	  document.Form1.txtPass2.value = "";		
		document.forms[0].action = 'https://ssl.efxnow.com/webclient/intl_live/Login.aspx'
		document.forms[0].method = 'POST'
	}
	else
	if ((document.forms[0].platform[0].checked) && (document.forms[0].type[1].checked))
	{
		document.forms[0].action = 'http://demo.efxnow.com/frxc_demo/fxgui_s.html'
		document.forms[0].method = 'GET'
	}
	else
	if ((document.forms[0].platform[0].checked) && (document.forms[0].type[0].checked))
	{		
		document.forms[0].action = 'http://applet.efxnow.com/frxc_sys/fxgui_s.html'
		document.forms[0].method = 'GET'
	}
	else
		if (document.forms[0].platform[2].checked)
		{
			if (HasRuntimeVersion(runtimeVersion))
      {
        document.forms[0].action = 'http://cndownload.efxnow.com/forextrader/forextrader.application';
        document.forms[0].method = 'GET'
        document.forms[0].target = '_top';
      }
      else
      {
      	document.forms[0].action = 'http://www.forex.com/cns/land-windows.html';
      	document.forms[0].method = 'GET'
      	document.forms[0].target = '_top';
      }
    }
}


function CopyValues2()
{
	document.forms[1].txtPass.value = document.forms[1].txtPass2.value;
	document.forms[1].txtLogin.value = document.forms[1].txtLogin2.value;
	document.forms[1].txtLogin2.value = "";
	document.forms[1].txtPass2.value = "";		
	
	if ((document.forms[1].type[0].checked == false) && (document.forms[1].type[1].checked == false))
	{
		alert("请选择账户类型")				
		return false;
	}	
	
	if (document.forms[1].txtLogin.value.length == 0)  {  
  alert ("请输入用户名");
  document.forms[1].txtLogin2.focus();    
  return false;
  }
  
  if (document.forms[1].txtPass.value.length == 0)  {  
  alert ("请重新输入用户名和密码");
  document.forms[1].txtLogin2.focus();    
  return false;
  }
	
	if (document.forms[1].type[0].checked)
	{		
		document.forms[1].action = 'http://demo.efxnow.com/webclient/intl_applet/Login.aspx'				
	}
	else
	if (document.forms[1].type[1].checked)
	{
		document.forms[1].action = 'https://ssl.efxnow.com/webclient/intl_live/Login.aspx'				
	}
	
	return true;
}

function CopyValues3()
{
	document.forms[0].txtPass.value = document.forms[0].txtPass2.value;
	document.forms[0].txtLogin.value = document.forms[0].txtLogin2.value;
	document.forms[0].txtLogin2.value = "";
	document.forms[0].txtPass2.value = "";		
	
	if ((document.forms[0].type[0].checked == false) && (document.forms[0].type[1].checked == false))
	{
		alert("请选择账户类型")				
		return false;
	}	
	
	if (document.forms[0].txtLogin.value.length == 0)  {  
  alert ("请输入用户名");
  document.forms[0].txtLogin2.focus();    
  return false;
  }
  
  if (document.forms[0].txtPass.value.length == 0)  {  
  alert ("请重新输入用户名和密码");
  document.forms[0].txtLogin2.focus();    
  return false;
  }
	
	if (document.forms[0].type[1].checked)
	{		
		document.forms[0].action = 'http://demo.efxnow.com/webclient/intl_applet/Login.aspx'				
	}
	else
	if (document.forms[0].type[0].checked)
	{
		document.forms[0].action = 'https://ssl.efxnow.com/webclient/intl_live/Login.aspx'				
	}
	
	return true;
}

function RedirectURL()
{	
	
	if ((document.forms[0].type[0].checked == false) && (document.forms[0].type[1].checked == false))
	{
		alert("请选择账户类型")		
	}
	
	if (document.forms[0].type[0].checked)	
	{	
		window.open('http://demo.efxnow.com/frxc_demo/fxgui_s.html')						
	}			
	if (document.forms[0].type[1].checked)	
	{		
		window.open('http://applet.efxnow.com/frxc_sys/fxgui_s.html')
	}	
		
}	

function IsPopupBlocker2() {
	var oWin = window.open("/white.html","testpopupblocker","toolbar=0,location=0,directories=0,status=0,menuBar=0, resizable=0, width=10, height=10, left=10, top=10");
	if (oWin==null || typeof(oWin)=="undefined") {
		return true;
	} else {
		oWin.close();
		return false;
	}
}

function evaltrader()
{
	var tbl=document.getElementById("typetext");
	tbl.innerHTML='<br>FOREX Java 平台只需下载一次，简洁方便。<br><br><a href="faq_tech.html#7">点击此处下载FOREX Java 平台</a>.<br><br>'
	
	var tbl3=document.getElementById("headerid");	
	tbl3.innerHTML=''
	tbl3.style.visibility = "visible";
	
	var tbl2=document.getElementById("webid");
	tbl2.innerHTML='<p align="center">点击"登陆"，并在Java平台的登陆界面上输入用户名及密码.</p>'
}

function evalweb()
{
	var tbl=document.getElementById("typetext");
	tbl.innerHTML='<br>弹出广告拦截程序将使得您无法进入html平台。 <a href="login-troubleshooting.html#2">点击此处了解如何关闭此程序以进入平台</a>。<br><br>不清楚您是否有拦截窗口拦截程序？ <a href="login-popup.html">点击此处</a>.<br><br>'
	
	var tbl3=document.getElementById("headerid");	
	tbl3.innerHTML=''
	tbl3.style.visibility = "visible";
	
	var tbl2=document.getElementById("webid");
	tbl2.innerHTML = '<p align="center"><input type="hidden" name="brand" value="FRXC"><input type="hidden" name="txtLogin" value=""><input type="hidden" name="txtPass" value=""><input type="hidden" name="txtlang" value="CHS"><table border="0" cellspacing="2" cellpadding="0" class="TextRegular"><tr><td align="left">用户名：</td><td><input type="text" name="txtLogin2" size="20" class="FormHeader"></td></tr><tr><td>密码：</td><td><input type="password" name="txtPass2" size="20" class="FormHeader"></td></tr></table>';
}

function evalwindows()
{
	var tbl=document.getElementById("typetext");
	tbl.innerHTML='<br>功能强大，界面友好的下载型平台；适合投资量较大、交易频繁的交易者，对电脑配置的要求也相应较高。<br><br>'
	
	var tbl3=document.getElementById("headerid");	
	tbl3.innerHTML=''
	tbl3.style.visibility = "visible";
	
	var tbl2=document.getElementById("webid");
	tbl2.innerHTML='<p align="center">点击“登录”，并在弹出的Windows平台登录框中输入用户名及密码。</p>'
}

function rewritefirst()
{
	var tbl=document.getElementById("typetext");
	tbl.innerHTML='<table><tr><td align="center"><img src="/images/login_firsttime2_cns.gif"  border="0" alt="首次登陆用户"><br></td></tr><tr class="TextRegular"><td align="left"><li>我们建议您使用运行稳定、功能齐全的FOREX Java 平台。</li><br><li>首次登录FOREX Java前，您需要简单下载Java程序。<a href="http://video.forex.com/cns/java_download.html">点击观看下载指导</a>。</li><br><li>我们建议将HTML平台作为外出时候的备用平台。登陆HTML平台，<a href="login-troubleshooting.html#2">您需要取消窗口拦截程序</a>。</li><br><img src="/images/arrow_small5.gif" width="9" height="6" alt=">>"> <a href="forex_platform_comparison.html">平台功能对比</a>&nbsp;&nbsp;<img src="/images/arrow_small5.gif" width="9" height="6" alt=">>"><a href="forex_support.html">平台系统配置要求对比</a></td></tr></table>'
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

function passThrough()
{
	var qs = new Querystring();
  
	var account = qs.get("accounttype");
	
	if (account != null)
	{
		var platform = qs.get("platformtype");
		
		if (account == "live")
		{
			document.forms[0].type[0].checked = true;
		}
		else
	  {
	  	document.forms[0].type[1].checked = true;
	  }
	  
		document.forms[0].platform[1].checked = true;
		
		evalweb();
	}	
}