// Finds the query string variable and returns it
// if the variable isn't found it will return the word default
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return ("Default");
}

function displayMessage(dept){
	var code = getQueryVariable('code');
	if (code == 'N') {
		if (dept=="IB"){
		document.write("Internet Banking Help Desk is not available.<br/><br/>The YB Internet Banking Help Desk may be contacted on 08456 000333 between the hours of Monday to Friday 8am - 10pm and Saturday & Sunday 9am - 6pm. <a onclick=\"javascript:window.close();\" href=\"#\">Close Window</a>.");
		}
		else {
			document.write("Mortgages Help Desk is not available.<br/><br/>The YB Mortgages Help Desk may be contacted on 0800 20 21 22 between the hours of Monday to Friday 9am - 7pm. <a onclick=\"javascript:window.close();\" href=\"#\">Close Window</a>.");
		}
	}
	else if (code == 'H') {
		document.write("Sorry, your request cannot be processed as you currently have a call in progress. <a onclick=\"javascript:window.close();\" href=\"#\">Close Window</a>");
	}
	else if (code == 'B') {
		document.write("Sorry, the service is not contactable - please try later. <a onclick=\"javascript:window.close();\" href=\"#\">Close Window</a>");
	}
	else if (code == 'X'){
		document.write("The phone number you have entered is not valid. <a onclick=\"javascript:window.history.back();\" href=\"#\">Please re-submit</a>.");
	}
	else if (code == "Default"){
		document.write("Sorry, there has been an unrecognised error with your request.<br/><br/><a onclick=\"javascript:window.history.back();\" href=\"#\">Please check all details and re-submit</a>.");
	}
	else {
		document.write("Sorry, there has been an unrecognised error with your request.<br/><br/><a onclick=\"javascript:window.history.back();\" href=\"#\">Please check all details and re-submit</a>.");
	}
}

