function applyPopups()
{
  a = document.getElementsByTagName("a");

  for(i=0; i<a.length; i++)
  {
	if(a[i].getAttribute("class") && a[i].getAttribute("class") == "popup")
    {
      a[i].onclick = function()
      {
        url = this.getAttribute("href");
        window.open(url,'popup','width=500,height=400, scrollbars=yes');
        return false;
      }
    }
  }
}
 
window.onload = applyPopups;


<!--// toggle visibility of side bar
	// first set the visability
	
	
function setVis(id, display) {
  e = document.getElementById(id);
  e.style.display = display;
}
	
	
function setVisibility(obj){
	target = document.getElementById(obj);
	target.style.display = "none";
}

// then set the visability
function toggleVisibility(targetId){
	if (document.getElementById){
		target = document.getElementById( targetId );
		if (target.style.display == "none"){
			target.style.display = "block";
		} else {
			target.style.display = "none";
		}
	}
} 

function toggleBoxes(subjectCount, boxList, state){
	var theForm = document.forms[0];
	for(i=0; i<subjectCount; i++){
		theForm.elements[boxList+'['+i+']'].checked = state;
	}	
}

function toggleDisplay(whichLayer)
{			
	/*Used to toggle the Taking a Course links on the Online Learning home page*/
	var style2 = document.getElementById(whichLayer).style;				
	style2.display = style2.display? "":"block";
}

function chkInput(inputName)
{
	/*Sets the Join our Mailing list input boxes back to their default, if nothing entered*/
	if (document.getElementById(inputName).value == '') {
		if (inputName == 'firstname') document.getElementById(inputName).value = 'First Name*';
		if (inputName == 'lastname') document.getElementById(inputName).value = 'Last Name*';
		if (inputName == 'postcode') document.getElementById(inputName).value = 'Postcode';
		if (inputName == 'email') document.getElementById(inputName).value = 'Email*';							
	}
}

function checkInput(id) {
  i = document.getElementById(id);
  i.checked = "checked";
}

function setFocus(id) {
  i = document.getElementById(id);
  i.focus();
}

// CPD common code to open a new window
function openwindow(url, width, height)
{
var features;
features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width +",height=" + height
new_window = window.open(url,"thewindow", features);
new_window.focus();
}


//used to remove the submit application button on the enrolment form and replace it with processing text
function submitForm(button) {
    button.disabled = true;
    button.value = "Processing details, please wait...";
    button.form.submit();
}


//Used to add the search text to the url so webtrends can track the parameters
function alterSearchURL() {
    if (document.getElementById('homeSearch') != null && document.getElementById('homeSearch').exactMatch != undefined) {
        if (document.getElementById('homeSearch').exactMatch.checked) {
            document.getElementById('homeSearch').action = document.getElementById('homeSearch').action+'?searchString='+document.getElementById('homeSearch').searchString.value+'&exactMatch=1';
        }
        else {
            document.getElementById('homeSearch').action = document.getElementById('homeSearch').action+'?searchString='+document.getElementById('homeSearch').searchString.value;
        }           
    }
    else {
        if (document.getElementById('searchform').exactMatch.checked) {
            document.getElementById('searchform').action = document.getElementById('searchform').action+'?searchString='+document.getElementById('searchform').searchString.value+'&exactMatch=1';
        }
        else {
            document.getElementById('searchform').action = document.getElementById('searchform').action+'?searchString='+document.getElementById('searchform').searchString.value;
        }
    }
}
