var runtimeVersion = "2.0.0";

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 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 (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 = "";
	  setwsEntityHigh("NA");
        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 = "";
	  setwsEntityHigh("NA");
		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)) {
	    setwsEntityHigh("NA");
		document.forms[0].action = 'http://demo.efxnow.com/frxc_demo/fxgui.html'
		document.forms[0].method = 'GET'
	}
	else
	if ((document.forms[0].platform[0].checked) && (document.forms[0].type[0].checked)) {
	    setwsEntityHigh("NA");
		document.forms[0].action = 'http://applet.efxnow.com/frxc_sys/fxgui.html'
		document.forms[0].method = 'GET'
	}
	else
	if (document.forms[0].platform[2].checked) {
	    setwsEntityHigh("NA");
		document.forms[0].method = 'GET'
		if (HasRuntimeVersion(runtimeVersion))
    {
      document.forms[0].action = 'http://download.efxnow.com/ForexTraderPro/ForexTraderPro.application'
      document.forms[0].target = '_top'
    }
    else
    {
    	document.forms[0].action = 'http://www.forex.com/ar/land-windows.html'
    	document.forms[0].target = '_top'
     }
    }
}

function evaltrader()
{	
	
	var tbl3=document.getElementById("headerid");	
	tbl3.innerHTML=''
	tbl3.style.visibility = "visible";
	
	var tbl2=document.getElementById("webid");
	tbl2.innerHTML='<p align="center">سوف يتم الطلب منك ادخال اسم المستخدم و كلمة السر الخاصّين بك.</p>'
}

function evalweb()
{	
	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="EN"><table border="0" cellspacing="2" cellpadding="0" class="arabic_main_text"><tr><td align="left">اسم المستخدم:</td><td><input type="text" name="txtLogin2" size="18" class="arabic_main_text"></td></tr><tr><td align="left">كلمة السر:</td><td><input type="password" name="txtPass2" size="20" class="FormHeader"></td></tr></table>';
}

function evalwindows()
{	
	
	var tbl3=document.getElementById("headerid");	
	tbl3.innerHTML=''
	tbl3.style.visibility = "visible";
	
	var tbl2=document.getElementById("webid");
	tbl2.innerHTML='<p align="center">سوف يتم الطلب منك ادخال اسم المستخدم و كلمة السر الخاصّين بك.</p>'
}