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



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

var va="";
var feature=false;
featureUrl="";
featureTitle="";
featureText="";



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


//Write the start of the form, and start writing the Select Box to the page
function StartSelectBox() {  

	addToHtml("  <select name=switchPage class=\"GlobalSelect\">  ");
addToHtml("  <option value=\"\">Please Select</option>");
	addToHtml("  <option value=\""+basehref+"\">Home");
	for (var i=0; i<60; i++) {
	addToHtml("&nbsp;");
	}
	addToHtml("<\/option>  ");

}


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

function addToHtml(v) {
va+=v;
}

//Start writing each individual option requested to the page

//Start writing each individual option requested to the page

function AddItem(url, text, bold) {  

	var finalurl;
	
		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.

		finalurl = basehref + 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.

		finalurl = url;
	
		}
	if(AddItem.arguments.length>2){
		addToHtml("<option value=\"" +finalurl + "\" class=\"GlobalDropDown\">" + text + "<\/option>");
	}else{
		addToHtml("<option value=\"" +finalurl + "\">" + text + "<\/option>  ");
	}
}


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


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

function EndSelectBox() {  

	if (feature) {
	addToHtml("  <option value=\"void\">______________________________________<\/option>  ");
	addToHtml("  <option value=\"void\">"+featureTitle+"<\/option>  ");
	addToHtml("  <option value=\"" +featureUrl + "\">&nbsp;&nbsp; - &nbsp;" + featureText + "<\/option>  ");

	}

	addToHtml("  <\/select>  ");

	addToHtml("  <a href=\"javascript:RefreshLocation()\">");

	addToHtml("<img border=0 src="+basehref+"includes/general/graphics/go_button.gif>");

	addToHtml("<\/a>");



}


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

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

function RefreshLocation() {  

	var pagetoGo = document.goform.switchPage.options[document.goform.switchPage.selectedIndex].value;
	
		if ((pagetoGo!="void") && (pagetoGo!="")) {

		document.location=pagetoGo

		}
	


}

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



function Feature(url, text, title) {
feature=true;
featureText=text;
featureTitle=title;
featureUrl=url;
}


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



function replace(str) {
var ret="";
	for (var i=0; i<str.length; i++) {
		if (str.charAt(i)!="_") {
			ret+=str.charAt(i);	
		}
		else {
			ret+=" ";
		}
	}
return ret;
}
function checkForm(form) {
var count=1;
alertText="Please fill in the following fields:\n--------------------------------------------------------------------------------\n";
	for (var i=0; i<form.elements.length; i++) {
	  	if ((form.elements[i].value=="") &&(form.elements[i].type!="select") && (form.elements[i].name!="Address 3") && (form.elements[i].name!="Address 4")&& (form.elements[i].name!="Email_Address")&& (form.elements[i].name!="My telephone number")) {
		alertText+=replace(count+": "+form.elements[i].name+":\n");
		count++;
		}
	}
	if (alertText=="Please fill in the following fields:\n--------------------------------------------------------------------------------\n") {
		return true;
	}
	else {
		alert(alertText+"\n--------------------------------------------------------------------------------\n");
		return false;
	}
}



function popprod(wname) {
	prodwin=window.open(wname,"Item","Toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=0,width=660,height=500")
	setTimeout('prodwin.focus()',500);
}

//##################################     POPUP WINDOW                 ################################
