var runtimeVersion = "2.0.0";
var directLink = "http://download.efxnow.com/forextraderpro/forextraderpro.application";
var setupLink = "http://download.efxnow.com/forextraderpro/setup.exe";

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 evalWindows()
{
	if (HasRuntimeVersion(runtimeVersion))
  {
    document.windows_form.action = directLink;
    document.windows_form.target = '_top'
  }
  else
  {
  	document.windows_form.action = setupLink;
    document.windows_form.target = '_top'
  }
}

function CopyValues()
{  	
	//make sure that the UserID is not blank.
  if (document.Form2.txtLogin2.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your User ID");
    document.Form2.txtLogin2.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
  
  //make sure that the Password field is not blank.
  if (document.Form2.txtPass2.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your password");
    document.Form2.txtPass2.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
  
  if ((document.Form2.type[0].checked == false) && (document.Form2.type[1].checked == false))
	{
		alert("Please select an account type")				
		document.Form2.type.focus
		return false;
	}
  
	document.Form2.txtPass.value = document.Form2.txtPass2.value;
	document.Form2.txtLogin.value = document.Form2.txtLogin2.value;
	document.Form2.txtLogin2.value = "";
	document.Form2.txtPass2.value = "";		
	
	if (document.Form2.type[0].checked)
	{		
		document.Form2.action = 'http://demo.efxnow.com/webclient/htmlclient/Login.aspx'		
		document.Form2.brand.value = "DEMO"
		
		demourl = 'http://demo.efxnow.com/webclient/htmlclient/Login.aspx?brand=DEMO&txtlang=EN&txtLogin=' + document.Form2.txtLogin.value + '&txtPass=' + document.Form2.txtPass.value;
							
		window.open(demourl,'newWindow2','height=640,width=1014,toolbars=yes,status=yes,scrollbars=no,resizable=no,top=50,left=50');
		return false;
	}
	else
	if (document.Form2.type[1].checked)
	{
		document.Form2.action = 'https://ssl.efxnow.com/webclient/htmlclient/Login.aspx'		
		document.Form2.brand.value = "GAIN"
	}
}

function CopyValuesIB()
{
  //make sure that the UserID is not blank.
  if (document.Form1.txtLogin.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your User ID");
    document.Form1.txtLogin.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
  
  //make sure that the Password field is not blank.
  if (document.Form1.txtPass.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your password");
    document.Form1.txtPass.focus();
    //and return false so the form doesn't get submitted
    return false;
  } 
  if ((document.Form1.mode[0].checked == false) && (document.Form1.mode[1].checked == false))
	{
		alert("Please select an account type")				
		document.Form1.mode.focus
		return false;
	}		                   
	
	if (document.Form1.mode[0].checked)
	{		
		document.Form1.action = 'https://secure.efxnow.com/reports3-demo/Login.aspx'				
	}
	else
	if (document.Form1.mode[1].checked)
	{
		document.Form1.action = 'https://secure.efxnow.com/reports3/Login.aspx'				
	}
}

function checkemac()
{
	//make sure that the UserID is not blank.
  if (document.frmLogin.ExtEmacMTLogin.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your User ID");
    document.frmLogin.ExtEmacMTLogin.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
  
  //make sure that the Password field is not blank.
  if (document.frmLogin.ExtEmacMTPassword.value.length == 0)  {
    //it isn't so show the user an alert and go to that field
    alert ("Please enter your password");
    document.frmLogin.ExtEmacMTPassword.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
}


function RedirectURL()
{		
	if ((document.applet_form.type[0].checked == false) && (document.applet_form.type[1].checked == false))
	{
		alert("Please select an account type")		
	}
	
	if (document.applet_form.type[0].checked)	
	{	
		window.open('http://demo.efxnow.com/demo/fxgui.html')						
	}		
	
	if (document.applet_form.type[1].checked)	
	{
		window.open('http://applet.efxnow.com/production/fxgui.html')			
	}	
}


function RedirectURL2()
{
	
	if ((document.silverlight_form.type[0].checked == false) && (document.silverlight_form.type[1].checked == false))
	{
		alert("Please select an account type")		
	}
	
	if (document.silverlight_form.type[0].checked)	
	{	
		window.open('http://demo.efxnow.com/forextraderproweb/index.aspx')						
	}		
	
	if (document.silverlight_form.type[1].checked)	
	{
		window.open('https://ssl.efxnow.com/ForexTraderProWeb/Index.aspx')			
	}		
}	
