<!-- // Hide script from old browsers
/* General form validation */

function isInCharacterLimit(string, limit) {
	if (string.length<=limit) 
	return true; 
	else return false;
}
function isFilledIn(string) {
	if (string.length>0) return true;
	else return false;
}
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)  return true;
	else return false; 	
}
function isValueSelected(selectBox) {
	if (selectBox.options[selectBox.selectedIndex].value!="") return true;
	else return false;
}
function isValueThis(selectBox, value) {
	if (selectBox.options[selectBox.selectedIndex].value==value) return true; 
	else return false; 
}

// this is a temporary fix
function valueSelected(selectBox) {
	if (selectBox.options[selectBox.selectedIndex].value!="") return true;
	else return false;
}
function isRadioSelected(radioGroup) {
  radioPass = false
  for(var i = 0; i < radioGroup.length; i++) {
    if (radioGroup[i].checked == true) {
	  radioPass = true
	}
  }
  if (radioPass==true) return true;
    else return false;
} 
function isDate(string) {
	datecomps=string.split("/");
	isDate=((datecomps.length==3)&&(datecomps[2].length==2)&&(parseInt(datecomps[1])<=12)&&parseInt(datecomps[0])<=31);	
	return isDate;
}
function isSame(string1,string2) {
	if (string1 == string2) return true;
	else return false;
}
function isNumber(string) {
	num=parseFloat(string);
	if (isNaN(num)) return false;
	else return true;
}
function isNumeric(string) {
	if (string.match(/[^0-9\.\,\,\=\+\-\*\|\[\]\{\}\<\>\(\)\%\$\£\#\&]/))  return false;
	else return true;	
}

/* Functions that validate the field value on the run */
function checkDate(object) {
	if (object.value != '') {
	  string=(object.value)
	  if (!string.match(/^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/(\d{2})$/)) {
	    alert("Date field is not in the correct format (DD/MM/YY)");
	    object.focus();
	  }
	}
}
function checkNumber(object) {
	if (object.value != '') {
	  num = object.value
	  if (isNaN(num)) {
	    alert("Number field is not in the correct format");
	    object.focus();
	  }
	}
}
function checkNumeric(object) {
	if (object.value != '') {
	  string = object.value
	  if (string.match(/[^0-9\.\,\,\=\+\-\*\|\[\]\{\}\<\>\(\)\%\$\£\#\&]/) != null) {
	    alert("Numeric field is not in the correct format");
	    object.focus();
	  }
	}	
}
function checkEmail(object) {
	if (object.value != '') {
	  string = object.value
	  if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
	    alert("Email field is not in the correct format");
	    object.focus();
	  }
	}
}
function checkMandatory(form) {
var pass=true;
for (i=0;i<form.length;i++) {
   var tempobj=form.elements[i];
   if (tempobj.name.substring(0,3)=="pm_") {
     if (((tempobj.type=="text" || tempobj.type=="textarea" || 
tempobj.type=="password") && tempobj.value=='') || 
(tempobj.type.toString().charAt(0)=="s" && 
tempobj.options[tempobj.selectedIndex].value=='')) {
     pass=false;
     break;
     }
   }
}

if (!pass) { 
  alert("Please ensure that all the required fields are properly completed.");
  tempobj.focus();
  return false;
}
  else return true;
}

function no_enter() {
  return !(window.event && window.event.keyCode == 13); }
  
var done = 0;
function confirmButton (msg) {
   if ( done == 1 ) {
     alert ("This form is busy processing, please wait");
     return false;
   }

   if (confirm (msg)) {
     done = 1;
     return true;
   }
   else {
     return false;
   }
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function countOccurances(str, chr){
   var count = 0;
   for (i = 0;  i < str.length;  i++)
   {
      if (chr == str.charAt(i)) count++;
   }
   return count;
}

function isEmailAddressValid(str)
{
  var c, count, domain;
  validEmailChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_@.-`";
     s = stripCharsInBag(str,validEmailChars);

     if (s != "") {
     alert ("Your email address can only include numbers, letters, or _, @, ., ` and -");
     return (false); //email can only include numbers, letters, or _, @, .,` and  -.
     }

     if (str.length < 5) {
     alert ("Your email address needs to be at least 5 characters long");
     return (false); //email has to be at least 5 characters long
     }

     if (countOccurances(str, "@") == 0 || countOccurances(str, "@") > 1) {
     alert ("Your email address can have 1 and only 1 @");
     return (false); //email can have 1 and only 1 @.
     }

     if (countOccurances(str, ".") == 0) {
     alert ("Your email address needs to have at least one dot");
     return (false); //email has to have at least one dot.
     }

     if (((str.length - str.lastIndexOf(".")) > 7) || ((str.length - str.lastIndexOf(".")) < 3)) {
     alert ("Your email address has an incorrect number of characters after the last dot");
     return (false); //After the last dot, there cannot be more than 6 or less than 2 characters
     }

     if (str.charAt(str.indexOf("@") + 1) == "_") {
     alert ("Your email address cannot have an underscore right after the @");
     return (false); //Cannot have an underscore right after the @.
     }

     if (str.charAt(str.indexOf("@") + 1) == ".") {
     alert ("Your email address cannot have a dot right after the @");
     return (false); //Cannot have a dot right after the @.
     }

     return (true);
}
 
/* checking that the keyword is filled in on the searches */
function checkmand(which) {
	if (document.searchForm.phrase_search.value == "")
		{
			alert("You must enter a subject keyword.");
			document.searchForm.phrase_search.focus();
			return (false);
		}
	else if (document.searchForm.phrase_search.value == "Enter subject keyword")
		{
			alert("You must enter a subject keyword.");
			document.searchForm.phrase_search.focus();
			return (false);
		}
	else
	return true;
}


function eea06(){
window.open("/html/bc_alpha/eeacountries06.html", "pop_up", "resizable=0,scrollbars=1,toolbar=0,location=0,menubar=0,status=0,width=400,height=400,left=400,top=400");}


function dynamic_links()
{
 var h=document.getElementsByTagName("h3");
 for(i=0;i<h.length;i++)
    {
     var newli=document.createElement("li");
  var a=document.createElement("a");
  var anchor1=h[i].firstChild; //to access <a> tag inside h2 tag
  if ( anchor1 != null )
  {
   if(document.all)
         {
    var text=anchor1.innerText; // to access article title enclosed inside "a" tag.
   }
   else
   {
    var text=anchor1.innerHTML;
   }
   
   //var anchor=h[i].previousSibling;
   var val=anchor1.getAttribute("name");
   var newtext=document.createTextNode(text);
   
   if ( newtext.innerHTML == null)
   {
    newtext=document.createTextNode(val);
   }
   
   a.setAttribute("href","#"+val);
   a.appendChild(newtext);
   newli.appendChild(a);
   var u=document.getElementById("list");
         u.appendChild(newli);
  }
     }
}
if (window.addEventListener)
window.addEventListener("load", dynamic_links, false)
else if (window.attachEvent)
window.attachEvent("onload", dynamic_links)
else if (document.getElementById)
window.onload=dynamic_links

// End hiding script from old browsers -->