function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

function displayItem(key){
if(queryString(key)=='false') 
{
document.write("you didn't enter a ?name=value querystring item.");
}else{
document.write(queryString(key));
}
}

function writeCompany()
{
	if (queryString('source') != 'false')
  {
  	if (queryString('source') == 'ib')
  	{
  		document.write('<tr class="cellpad3"><td width="170" align="right">Company:</td><td width="333"><input type="text" name="company" size="28" maxlength="49" class="bodyblack"><input type="hidden" name="inst" value="1"></td></tr>');
    }
    else
    {
      document.write('<input type="hidden" name="company" value="N/A"><input type="hidden" name="inst" value="0">');      
    }
  }
  else
  {
    document.write('<input type="hidden" name="company" value="N/A"><input type="hidden" name="inst" value="0">');      
  }
}


function writeProfile()
{
	if (queryString('source') != 'false')
  {
  	if (queryString('source') == 'ib')
  	{
  		document.write('<tr class="cellpad3"><td width="170" align="right" valign="top">Please select a trading profile:</td><td width="333"><span class="bodyblack"><INPUT TYPE="radio" NAME="trading_profile" VALUE="FXT"  tabindex="12">I am a FX trader and will manage my own account <a href="javascript:void(0);" onmouseover="return overlib(\'Choose this profile if you are an individual who makes your own trading decisions.\', CAPTION, \'FX Trader\', RIGHT);" onmouseout="nd();"><img src="../images/icon-info.gif" border="0"></a><br><input type="radio" name="trading_profile" value="PRO">I am a professional trader / money manager <a href="javascript:void(0);" onmouseover="return overlib(\'Choose this profile if you manage other people`s risk capital and have specific back office requirements.\', CAPTION, \'Professional Trader\', RIGHT);" onmouseout="nd();"><img src="../images/icon-info.gif" border="0"></a><br><input type="radio" name="trading_profile" value="IB">I am an Introducing Broker <a href="javascript:void(0);" onmouseover="return overlib(\'Choose this profile if you have FX trading clients you would like to introduce to GAIN Capital.\', CAPTION, \'Introducing Broker\', RIGHT);" onmouseout="nd();"><img src="../images/icon-info.gif" border="0"></a><br><input type="radio" name="trading_profile" value="WHI">I want to white label GAIN\'s trading technology <a href="javascript:void(0);" onmouseover="return overlib(\'Choose this profile if you are a financial services firm looking to offer online FX trading capabilities to your client base.\', CAPTION, \'White Label\', RIGHT);" onmouseout="nd();"><img src="../images/icon-info.gif" border="0"></a></span></td></tr>');
    }
    else if (queryString('source') == 'ltf')
    {
    	document.write('<INPUT TYPE="hidden" NAME="trading_profile" VALUE="LTTFIIEmail0208">');
    }
    else
    {
      document.write('<INPUT TYPE="hidden" NAME="trading_profile" VALUE="FXT">');      
    }
  }
  else
  {
    document.write('<INPUT TYPE="hidden" NAME="trading_profile" VALUE="FXT">');      
  }	
}

function writeLanguage()
{
	if (queryString('source') != 'false')
  {
  	if (queryString('source') == 'ib')
  	{
  		document.write('<INPUT TYPE="hidden" NAME="language_pref" VALUE="English">'); 
    }
    else
    {
      document.write('<INPUT TYPE="hidden" NAME="language_pref" VALUE="English">');     
    }
  }
  else
  {
    document.write('<INPUT TYPE="hidden" NAME="language_pref" VALUE="English">');      
  }	
}