// Path: src/main/java/com/syndicapp/scraper/FSSUserAgent.java
// public class FSSUserAgent {
//     public static HttpClient httpclient = HttpClientBuilder.create().build();
//     public static Logger log = Logger.getLogger(FSSUserAgent.class);
//     public static BasicHttpContext context = new BasicHttpContext();
// 
//     public FSSUserAgent() {
//     }
// 
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/AccountDropdownItem.java
// public class AccountDropdownItem
// {
// 
//     public AccountDropdownItem(String accountId, String accountName, String accountBalance)
//     {
//         this.accountId = accountId;
//         this.accountName = accountName;
//         this.accountBalance = accountBalance;
//     }
// 
//     public String getAccountName()
//     {
//         return accountName;
//     }
// 
//     public String getAccountId()
//     {
//         return accountId;
//     }
// 
//     public String getAccountBalance()
//     {
//         return accountBalance;
//     }
// 
//     public void setAccountBalance(String accountBalance)
//     {
//         this.accountBalance = accountBalance;
//     }
// 
//     public void setAccountId(String accountId)
//     {
//         this.accountId = accountId;
//     }
// 
//     public void setAccountName(String accountName)
//     {
//         this.accountName = accountName;
//     }
// 
//     private String accountId;
//     private String accountName;
//     private String accountBalance;
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/AccountDropdownList.java
// public class AccountDropdownList {
// 	private Vector<AccountDropdownItem> accountDropdownItems;
// 
// 	public AccountDropdownList() {
// 		accountDropdownItems = new Vector<AccountDropdownItem>();
// 	}
// 
// 	public void addAccountDropdownItem(AccountDropdownItem a) {
// 		accountDropdownItems.add(a);
// 	}
// 
// 	public AccountDropdownItem getAccountByName(String name) {
// 		for (Iterator<AccountDropdownItem> itr = accountDropdownItems.iterator(); itr.hasNext();) {
// 			AccountDropdownItem a = (AccountDropdownItem) itr.next();
// 			if (a.getAccountName().equalsIgnoreCase(name))
// 				return a;
// 		}
// 
// 		return null;
// 	}
// 
// 	public AccountDropdownItem getAccountById(String index) {
// 		if (index == null) {
// 			return accountDropdownItems.get(0);
// 		} else {
// 			int i = Integer.parseInt(index);
// 			return accountDropdownItems.get(i);
// 		}
// 	}
// 
// 	public Vector<AccountDropdownItem> getAccountDropdownItems() {
// 		return accountDropdownItems;
// 	}
// 
// 	public void setAccountDropdownItems(Vector<AccountDropdownItem> accountDropdownItems) {
// 		this.accountDropdownItems = accountDropdownItems;
// 	}
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/exception/UnexpectedPageContentsException.java
// public class UnexpectedPageContentsException extends Exception
// {
// 
//     public UnexpectedPageContentsException(String s)
//     {
//         super(s);
//     }
// 
//     private static final long serialVersionUID = 0xf57ed4fa93f8378aL;
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import com.syndicapp.scraper.FSSUserAgent;
import com.syndicapp.scraper.aib.model.AccountDropdownItem;
import com.syndicapp.scraper.aib.model.AccountDropdownList;
import com.syndicapp.scraper.exception.UnexpectedPageContentsException;


		HttpPost httppost = new HttpPost(
				"https://aibinternetbanking.aib.ie/inet/roi/transfersandpaymentslanding.htm");
		List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
		nvps.add(new BasicNameValuePair("iBankFormSubmission", "true"));
		nvps.add(new BasicNameValuePair("transactionToken", transactionToken));
		nvps.add(new BasicNameValuePair("selectedPaymentType", "1"));
		log.fatal((new StringBuilder())
				.append("Clicking 'Transfers between my own accounts' with ")
				.append(nvps.toString()).toString());
		httppost.setEntity(new UrlEncodedFormEntity(nvps, "ISO-8859-1"));
		HttpResponse response = httpclient.execute(httppost);
		HttpEntity entity = response.getEntity();
		page = EntityUtils.toString(entity);
		
		if (!page.contains("Transfer between my own AIB Accounts")) {
			throw new UnexpectedPageContentsException(
					"Didn't get to the Transfers between my own accounts Page!");
		}
		
		AccountDropdownList addlFrom = new AccountDropdownList();
		p = Pattern
				.compile("selectedFromAccountIndex\" class=\"jsIntroText0 aibInputStyle04\" onchange=\"return setDrNarrative\\(\\)\">\\s*<option value=\"-1\" selected=\"selected\">Please select:</option>\\s*(.*?)\\s*</select>");
		m = p.matcher(page);
		if (m.find()) {
			p = Pattern
					.compile("<option value=\"(\\d+)\">(.*?) \\(([\\s\\d\\.,DCR]*?)\\)</option>");
			m = p.matcher(m.group(1));
			while (m.find()) {
				addlFrom.addAccountDropdownItem(

// Path: src/main/java/com/syndicapp/scraper/FSSUserAgent.java
// public class FSSUserAgent {
//     public static HttpClient httpclient = HttpClientBuilder.create().build();
//     public static Logger log = Logger.getLogger(FSSUserAgent.class);
//     public static BasicHttpContext context = new BasicHttpContext();
// 
//     public FSSUserAgent() {
//     }
// 
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/AccountDropdownItem.java
// public class AccountDropdownItem
// {
// 
//     public AccountDropdownItem(String accountId, String accountName, String accountBalance)
//     {
//         this.accountId = accountId;
//         this.accountName = accountName;
//         this.accountBalance = accountBalance;
//     }
// 
//     public String getAccountName()
//     {
//         return accountName;
//     }
// 
//     public String getAccountId()
//     {
//         return accountId;
//     }
// 
//     public String getAccountBalance()
//     {
//         return accountBalance;
//     }
// 
//     public void setAccountBalance(String accountBalance)
//     {
//         this.accountBalance = accountBalance;
//     }
// 
//     public void setAccountId(String accountId)
//     {
//         this.accountId = accountId;
//     }
// 
//     public void setAccountName(String accountName)
//     {
//         this.accountName = accountName;
//     }
// 
//     private String accountId;
//     private String accountName;
//     private String accountBalance;
// }
// 
// Path: src/main/java/com/syndicapp/scraper/aib/model/AccountDropdownList.java
// public class AccountDropdownList {
// 	private Vector<AccountDropdownItem> accountDropdownItems;
// 
// 	public AccountDropdownList() {
// 		accountDropdownItems = new Vector<AccountDropdownItem>();
// 	}
// 
// 	public void addAccountDropdownItem(AccountDropdownItem a) {
// 		accountDropdownItems.add(a);
// 	}
// 
// 	public AccountDropdownItem getAccountByName(String name) {
// 		for (Iterator<AccountDropdownItem> itr = accountDropdownItems.iterator(); itr.hasNext();) {
// 			AccountDropdownItem a = (AccountDropdownItem) itr.next();
// 			if (a.getAccountName().equalsIgnoreCase(name))
// 				return a;
// 		}
// 
// 		return null;
// 	}
// 
// 	public AccountDropdownItem getAccountById(String index) {
// 		if (index == null) {
// 			return accountDropdownItems.get(0);
// 		} else {
// 			int i = Integer.parseInt(index);
// 			return accountDropdownItems.get(i);
// 		}
// 	}
// 
// 	public Vector<AccountDropdownItem> getAccountDropdownItems() {
// 		return accountDropdownItems;
// 	}
// 
// 	public void setAccountDropdownItems(Vector<AccountDropdownItem> accountDropdownItems) {
// 		this.accountDropdownItems = accountDropdownItems;
// 	}
// 
// }
// 
// Path: src/main/java/com/syndicapp/scraper/exception/UnexpectedPageContentsException.java
// public class UnexpectedPageContentsException extends Exception
// {
// 
//     public UnexpectedPageContentsException(String s)
//     {
//         super(s);
//     }
// 
//     private static final long serialVersionUID = 0xf57ed4fa93f8378aL;
// }


// Path: src/main/java/com/syndicapp/scraper/aib/TransferBetweenMyOwnAccountsPage.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import com.syndicapp.scraper.FSSUserAgent;
import com.syndicapp.scraper.aib.model.AccountDropdownItem;
import com.syndicapp.scraper.aib.model.AccountDropdownList;
import com.syndicapp.scraper.exception.UnexpectedPageContentsException;


		HttpPost httppost = new HttpPost(
				"https://aibinternetbanking.aib.ie/inet/roi/transfersandpaymentslanding.htm");
		List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
		nvps.add(new BasicNameValuePair("iBankFormSubmission", "true"));
		nvps.add(new BasicNameValuePair("transactionToken", transactionToken));
		nvps.add(new BasicNameValuePair("selectedPaymentType", "1"));
		log.fatal((new StringBuilder())
				.append("Clicking 'Transfers between my own accounts' with ")
				.append(nvps.toString()).toString());
		httppost.setEntity(new UrlEncodedFormEntity(nvps, "ISO-8859-1"));
		HttpResponse response = httpclient.execute(httppost);
		HttpEntity entity = response.getEntity();
		page = EntityUtils.toString(entity);
		
		if (!page.contains("Transfer between my own AIB Accounts")) {
			throw new UnexpectedPageContentsException(
					"Didn't get to the Transfers between my own accounts Page!");
		}
		
		AccountDropdownList addlFrom = new AccountDropdownList();
		p = Pattern
				.compile("selectedFromAccountIndex\" class=\"jsIntroText0 aibInputStyle04\" onchange=\"return setDrNarrative\\(\\)\">\\s*<option value=\"-1\" selected=\"selected\">Please select:</option>\\s*(.*?)\\s*</select>");
		m = p.matcher(page);
		if (m.find()) {
			p = Pattern
					.compile("<option value=\"(\\d+)\">(.*?) \\(([\\s\\d\\.,DCR]*?)\\)</option>");
			m = p.matcher(m.group(1));
			while (m.find()) {
				addlFrom.addAccountDropdownItem(

						new AccountDropdownItem(m.group(1), m.group(2), ""));
