//###########################################   START   #######################################################



var pfbasehref="http://www.bankofireland.ie/html/gws/";  //This should be changed when ftp'd to the live site

var pfva="";
var pffeature=false;
pffeatureUrl="";
pffeatureTitle="";
pffeatureText="";



//#####################################################################################################


//Write the start of the form, and start writing the Select Box to the page

function pfStartSelectBox() {  

	pfaddToHtml("  <select id=\"tools_search\" class=\"tools_search\" name=pfswitchPage>  ");
	pfaddToHtml("  <option value=\""+pfbasehref+"\">Please Select");
	for (var i=0; i<3; i++) {
	pfaddToHtml("&nbsp;");
	}
	pfaddToHtml("<\/option>  ");

}


//#####################################################################################################

function pfaddToHtml(v) {
pfva+=v;
}

//Start writing each individual option requested to the page
function SearchAndReplace(Content, SearchFor, ReplaceWith) {
   var tmpContent = Content;
   var tmpBefore = new String();   
   var tmpAfter = new String();
   var tmpOutput = new String();
   var intBefore = 0;
   var intAfter = 0;
   if (SearchFor.length == 0)
      return;
   while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
      intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
      tmpBefore = tmpContent.substring(0, intBefore);
      tmpOutput = tmpOutput + tmpBefore;
      tmpOutput = tmpOutput + ReplaceWith;
      intAfter = tmpContent.length - SearchFor.length + 1;
      tmpContent = tmpContent.substring(intBefore + SearchFor.length);
   }
   return tmpOutput + tmpContent;
}

function pfAddItem(url, text) {  
text2 = text;
	var pffinalurl;
	
		if ( ( url.indexOf("http:") == -1 ) && ( url !="" )) {
	
		//If you want to link outside the regular base href(IE: Using an Absolute URL), 
		//like to http://www.bankofireland.ie/papp/
		//Then this makes sure NOT to place the base href onto the url.

		pffinalurl = pfbasehref + url;

		}

		else {

		//If you want to link within the regular base href(IE: Using a Relative URL), 
		//like to personal/index.html
		//Then this makes sure TO place the base href onto the url.

		pffinalurl = url;
	
		}
	text2 = SearchAndReplace(text2,"personal ","")
	if (text2.length >=22) {
	text2 = text2.substring(0,16);
	}
	pfaddToHtml("  <option value=\"" +pffinalurl + "\">" + text2 + "<\/option>  ");

}



//#####################################################################################################


//Write the end part of the Select Box, close off the form tag and write the image to the page

function pfEndSelectBox() {  

	if (pffeature) {
	pfaddToHtml("  <option value=\"void\">____________________<\/option>  ");
	pfaddToHtml("  <option value=\"void\">"+pffeatureTitle+"<\/option>  ");
	pfaddToHtml("  <option value=\"" +pffeatureUrl + "\">&nbsp;&nbsp; - &nbsp;" + pffeatureText + "<\/option>  ");

	}

	pfaddToHtml("  <\/select>  ");





}


//#####################################################################################################

//This is the function that changes the location of the page to the value of the option selectd in the Select Box

function pfRefreshLocation() {  

	var pfpagetoGo = document.pfgoform.pfswitchPage.options[document.pfgoform.pfswitchPage.selectedIndex].value;
	
		if ((pfpagetoGo!="void") && (pfpagetoGo!="")) {

		document.location=pfpagetoGo

		}
	


}

//#####################################################################################################



function pfFeature(url, text, title) {
pffeature=true;
pffeatureText=text;
pffeatureTitle=title;
pffeatureUrl=url;
}


//#####################################################  END  ################################################




pfStartSelectBox(); 
 
	pfAddItem("/capital_markets/contact/index.html","Contact Treasury");

	pfAddItem("capital_markets/corporate_banking/contact_us/index.html","Contact Corporate");	

	pfAddItem("capital_markets/new_business/index.html","New Business");

	pfAddItem("capital_markets/treasury/economic_research/index.html","Economic Research");



pfEndSelectBox();








