var demosrc_100k = "https://secure2.fxcorporate.com/fxtr/demo/?ib=fxcmuk_es&DB=U100D3";
var demosrc_mini = demosrc_100k;
 
function iframeLoad_100k() {	 
	iframeLoad( demosrc_100k );
}
function iframeLoad_mini() {	 
	iframeLoad( demosrc_mini );
}

function iframeLoad( name ) {   
		var demosrc = name;		  
		var theCookie = "";
		var theCookie2 = "";
		var theCookie3 = "";
		var theDate = "";		 	 
		
		if ( window.document.cookie != null ) {
			theCookie = getMyCookie( "JSESSIONID" ); 
			if (CampaignString = getMyCookie("s_cpm"))
			{
			  eval("var CampaignArray = " + CampaignString);
			  var CurrentCampaign = CampaignArray[CampaignArray.length - 1][0];
			}
			theCookie2 = CurrentCampaign;
			theCookie3 = getMyCookie( "keyword" );
			theDate = getMyCookie( "tid" );			 	    
		} 
		if ( theCookie  == null ){
			theCookie = getCookie2( "jsessionid" );
		}
		if (theCookie2 == null)
    {
      theCookie2 = getURLParameter('CMP');
    }
		if ( theDate == null ) {
			theDate = getDate();
			if ( theCookie == null ) {
				theDate = theDate + "_" + Math.random()*100000000000000000;
			} else {
				theDate = theDate + "_" + theCookie;
			}		 
			createMyCookie( "tid", theDate, 365 );
		}		 
		demosrc = demosrc + "&tid=" + theDate;
			 		 			 	 
		if ( theCookie2 != null ) {		
			demosrc = demosrc + "&cmp=" + theCookie2;
		}
		if ( refdomain != null ) {
			demosrc = demosrc + "&refdomain=" + refdomain;
		}
		if ( acctNum != null ) {
			demosrc = demosrc + "&acctNum=" + acctNum;
		}
		if ( theCookie3 != null ) {
			demosrc = demosrc + "&keyword=" + theCookie3;
		}
		//alert( demosrc );		 
		document.getElementById( "demo_reg" ).src = demosrc;		 
}


function getURLParameter (ParameterName)
{
  if (document.location.href.indexOf('?') > -1)
  {
    var URLParameters = document.location.href.substr(document.location.href.indexOf('?')+1);
    URLParameters = URLParameters.split('&');
    for (URLParameterIndex in URLParameters)
    {
      if (escape(unescape(URLParameters[URLParameterIndex].split('=')[0].toUpperCase())) == ParameterName.toUpperCase())
      {
        return URLParameters[URLParameterIndex].split("=")[1];
      }
    }
  }
  return null;
}


function cutSFS( cookie ){
	var ret = cookie;	 
	if ( cookie.indexOf( "SFS-" ) > -1 ) {
		ret = ret.substring( 4 );	
	}	 	
	return ret;
}