function setup_cookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );

  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" );
}

function set_cookie(EncAdvNo, AdvNo) {
  setup_cookie( 'EncodedAgentNo', EncAdvNo, 30, '/', '', '' );
  setup_cookie( 'AgentNo', AdvNo, 30, '/', '', '' );

  var CurHost = window.parent.document.location + '';
	var CurHost = CurHost.toLowerCase();
	var SunnetHost = "https://";
	
	if(CurHost.indexOf("dev-www.ca.sunlife")>=0)
	  SunnetHost = SunnetHost + "www.sunnet.sunlife.com:445";
	else if(CurHost.indexOf("uat-www.ca.sunlife")>=0)
	  SunnetHost = SunnetHost + "www.sunnet.sunlife.com:444";
	else if(CurHost.indexOf("stage-www.sunlife.ca")>=0)
	  SunnetHost = SunnetHost + "stage.sunnet.sunlife.com";
	else
	  SunnetHost = SunnetHost + "www.sunnet.sunlife.com";
	
	document.write("<img style='width:0; height:0; top:0; left:0; position: absolute' src='" + SunnetHost + "/distpublic/AdvisorPresenceSLF.asp?AID=" + AdvNo + "'/>");
}
