function mailer( u, d ) {
    self.location.href="mailto:"+u+"@"+d
}

function verify4() {
	var themessage = "You are required to complete the following fields: ";
	if (document.payment.M_Coursedate.value=="") {
	themessage = themessage + " - Course date";
}
	if (document.payment.M_Name.value=="") {
	themessage = themessage + " - Delegate name";
}
	if (document.payment.M_Jobtitle.value=="") {
	themessage = themessage + " -  Delegate job title";
}
	if (document.payment.M_Publication.value=="") {
	themessage = themessage + " -  Publication/web site";
}
	if (document.payment.M_Organisation.value=="") {
	themessage = themessage + " -  Organisation";
}
	if (document.payment.Address.value=="") {
	themessage = themessage + " -  Address";
}
	if (document.payment.M_Telephone.value=="") {
	themessage = themessage + " -  Telephone number";
}
	if (document.payment.Email.value=="") {
	themessage = themessage + " -  Email address";
}
	if (document.payment.M_Terms.checked) {
}
	else {
	themessage = themessage + " -  You must agree the terms first";
}
//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
	document.payment.submit();
}
	else {
	alert(themessage);
	return false;
    }
}

function verify3() {
	var themessage = "You are required to complete the following fields: ";
	if (document.payment.M_Name.value=="") {
	themessage = themessage + " - Delegate name";
}
	if (document.payment.M_Jobtitle.value=="") {
	themessage = themessage + " -  Delegate job title";
}
	if (document.payment.M_Publication.value=="") {
	themessage = themessage + " -  Publication/web site";
}
	if (document.payment.M_Organisation.value=="") {
	themessage = themessage + " -  Organisation";
}
	if (document.payment.M_Telephone.value=="") {
	themessage = themessage + " -  Telephone number";
}
	if (document.payment.M_Email.value=="") {
	themessage = themessage + " -  Email address";
}
	if (document.payment.M_Terms.checked) {
}
	else {
	themessage = themessage + " -  You must agree the terms first";
}
//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
	document.payment.submit();
}
	else {
	alert(themessage);
	return false;
    }
}

function verify2() {
	var themessage = "You are required to complete the following fields: ";
	if (document.payment.M_Name.value=="") {
	themessage = themessage + " - Name or organisation";
}
	if (document.payment.M_Invoice.value=="") {
	themessage = themessage + " -  Invoice number";
}
	if (document.payment.amount.value=="") {
	themessage = themessage + " -  Amount to be paid";
}
	if (document.payment.M_Telephone.value=="") {
	themessage = themessage + " -  Telephone number";
}
	if (document.payment.M_Email.value=="") {
	themessage = themessage + " -  Email address";
}
//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
	document.payment.submit();
}
	else {
	alert(themessage);
	return false;
    }
}

function phpads_deliverActiveX(content)
{
	document.write(content);	
}

function newTempWindow( url ) {
	tmpWin = window.open(url, 'ViewEmail', 'width=1,height=1');
	setTimeout("tmpWin.close()",2250);
}

function changeSelect() {
	var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	var start = parseInt( document.form1.elements['training.startmonth'].value );

	document.form1.elements['training.endmonth'].options.length = 0;
	document.form1.elements['training.endmonth'].options.length = (13 - start);

	var optionName = new Option('', '', '');
	document.form1.elements['training.endmonth'].options[ 0 ] = optionName
	for (var i = 1; i < (13 - start); i++) {
		var monthindex = (i+start-1)	
		var optionName = new Option(months[ monthindex ], monthindex, '');
		document.form1.elements['training.endmonth'].options[ i ] = optionName;
	}
}

function calcHiddenDate(){
	document.form1.elements['training.startdate'].value = document.form1.elements['training.startday'].value + '/' + document.form1.elements['training.startmonth'].value + '/' + document.form1.elements['training.year'].value;
}

function closeRefresh() {  
    self.close();
window.opener.location.href="/cgi-bin/webdata_pro.pl?_cgifunction=search&_layout=Trainingmembers";
}

function updateFreelanceSkills(){
	document.freedbpay.elements['freelance.skills'].value = 
		document.freedbpay.elements['freelance.skills1'].value + ' ' + 
		document.freedbpay.elements['freelance.skills2'].value + ' ' + 
		document.freedbpay.elements['freelance.skills3'].value + ' ' + 
		document.freedbpay.elements['freelance.skills4'].value + ' ' + 
		document.freedbpay.elements['freelance.skills5'].value;
}

function updateFreelanceSpecialism(){
	document.freedbpay.elements['freelance.specialism'].value = 
		document.freedbpay.elements['freelance.specialism1'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism2'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism3'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism4'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism5'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism6'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism7'].value + ' ' + 
		document.freedbpay.elements['freelance.specialism8'].value;
}

function verify() {
	var themessage = "You are required to complete the following fields: ";
	if (document.payment.jname.value=="") {
	themessage = themessage + " - Your name";
}
	if (document.payment.address.value=="") {
	themessage = themessage + " -  Your address";
}
	if (document.payment.postcode.value=="") {
	themessage = themessage + " -  Your post code";
}
	if (document.payment.email.value=="") {
	themessage = themessage + " -  Your email address";
}
	if (document.payment.M_Terms.checked) {
}
	else {
	themessage = themessage + " -  You must agree the terms first";
}
//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
	document.payment.submit();
}
	else {
	alert(themessage);
	return false;
    }
}

function forgot(f) {
  val=f.username.value;
  atsign=val.indexOf('@');
  dot=val.indexOf('.',atsign);
  if ((atsign==-1)||(dot==-1)) {alert('Please enter an e-mail address in the first box');return};
  f._cgifunction.value="Mail Password";
  f.submit();
}

function changer() {
	document.forms['sub'].FormValue_Email.value=
	document.forms['sub'].FormValue_Email2.value;
}
	
  function orderLink(field) {
    f=document.nav;
    f._orderby.value=field;
    f._pageNum.value=1;
    f._cgifunction.value="Search";
    f.submit();
  }

function viewform(keyval,layout) {
    urlstring="http://www.journalism.co.uk/cgi-bin/webdata_pro.pl?_cgifunction=form&_layout="+
	escape(layout)+"&keyval="+keyval;
    if ("") {urlstring+="&_homeZip=&_zipDistance="};
    location=urlstring;
  }

  function goToPage(i) {
    f=document.nav;
    f._cgifunction.value="Next Page";
    f._pageNum.value=i-1;
    f.submit();
  }
  
  function modify(table,key) {
    options='toolbar=0,scrollbars=1,status=1,resizable=1';
    nw=window.open('http://www.journalism.co.uk/cgi-bin/webdata_pro.pl?_cgifunction=Modify+Record&key='+key+'&_tableName='+table+'&isPopup=1','',options);
    nw.focus();
  }
  
  function deleteRecord(table,key) {
    options='toolbar=0,scrollbars=1,status=1,resizable=1,width=200,height=100';
    if (confirm('Are you sure you want to permanently delete this record?')) {
    nw=window.open('','',options); 
    nw.document.write('<BODY BGCOLOR=WHITE><h2>Deleting Record...</h2></BODY>');
    nw.document.close();
    nw.location='http://www.journalism.co.uk/cgi-bin/webdata_pro.pl?_cgifunction=deleteRecord&_tableName='+table+'&_key='+key;  
    nw.focus();
    }
  }

  function bulkmail(field) {
    document.nav.keyval.value=field;
    document.nav._cgifunction.value="bulkmail";
    document.nav.submit();
  }

function newWindow() {
	testimonialWindow = window.open('/testimonial.html', 'testimonialWin', 'width=300,height=650,scrollbars=yes')
} 
function newWindow2() {
	dotjsubWindow = window.open('http://www.journalism.co.uk/listsub.shtml', 'dotjsubWin');
	return false;
}

function newWindow3() {
	dotjsubWindow = window.open('http://www.journalism.co.uk/listsub.shtml', 'dotjsubWin2');
	return false;
}

function insertValue() {
    document['forms']['poppy'].FormValue_Email.value = 
    window.opener.document.forms['sub'].FormValue_Email.value;
}

function fontsizeup() {
  active = getActiveStyleSheet();
  switch (active) {
    case 'A--' : 
      setActiveStyleSheet('A-');
      break;
    case 'A-' : 
      setActiveStyleSheet('A');
      break;
    case 'A' : 
      setActiveStyleSheet('A+');
      break;
    case 'A+' : 
      setActiveStyleSheet('A++');
      break;
    case 'A++' :
      break;
    default :
      setActiveStyleSheet('A');
      break;
  }
}

function fontsizedown() {
  active = getActiveStyleSheet();
  switch (active) {
    case 'A++' : 
      setActiveStyleSheet('A+');
      break;
    case 'A+' : 
      setActiveStyleSheet('A');
      break;
    case 'A' : 
      setActiveStyleSheet('A-');
      break;
    case 'A-' : 
      setActiveStyleSheet('A--');
      break;
    case 'A--' : 
       break;
    default :
      setActiveStyleSheet('A--');
      break;
  }
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  return ('A-');
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
if (title == 'null') {
  title = getPreferredStyleSheet();
}

setActiveStyleSheet(title);

//** Featured Content Slider script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: Oct 28th, 06

////Ajax related settings
var csbustcachevar=0 //bust potential caching of external pages after initial Ajax request? (1=yes, 0=no)
var csloadstatustext="<img src='loading.gif' /> Requesting content..." //HTML to indicate Ajax page is being fetched
var csexternalfiles=[] //External .css or .js files to load to style the external content(s), if any. Separate multiple files with comma ie: ["cat.css", dog.js"]

////NO NEED TO EDIT BELOW////////////////////////
var enablepersist=true
var slidernodes=new Object() //Object array to store references to each content slider's DIV containers (<div class="contentdiv">)
var csloadedobjects="" //Variable to store file names of .js/.css files already loaded (if Ajax is used)

function ContentSlider(sliderid, autorun){
var slider=document.getElementById(sliderid)
slidernodes[sliderid]=[] //Array to store references to this content slider's DIV containers (<div class="contentdiv">)
ContentSlider.loadobjects(csexternalfiles) //Load external .js and .css files, if any
var alldivs=slider.getElementsByTagName("div")
for (var i=0; i<alldivs.length; i++){
if (alldivs[i].className=="contentdiv"){
slidernodes[sliderid].push(alldivs[i]) //add this DIV reference to array
if (typeof alldivs[i].getAttribute("rel")=="string") //If get this DIV's content via Ajax (rel attr contains path to external page)
ContentSlider.ajaxpage(alldivs[i].getAttribute("rel"), alldivs[i])
}
}
ContentSlider.buildpagination(sliderid)
var loadfirstcontent=true
if (enablepersist && getCookie(sliderid)!=""){ //if enablepersist is true and cookie contains corresponding value for slider
var cookieval=getCookie(sliderid).split(":") //process cookie value ([sliderid, int_pagenumber (div content to jump to)]
if (document.getElementById(cookieval[0])!=null && typeof slidernodes[sliderid][cookieval[1]]!="undefined"){ //check cookie value for validity
ContentSlider.turnpage(cookieval[0], parseInt(cookieval[1])) //restore content slider's last shown DIV
loadfirstcontent=false
}
}
if (loadfirstcontent==true) //if enablepersist is false, or cookie value doesn't contain valid value for some reason (ie: user modified the structure of the HTML)
ContentSlider.turnpage(sliderid, 0) //Display first DIV within slider
if (typeof autorun=="number" && autorun>0) //if autorun parameter (int_miliseconds) is defined, fire auto run sequence
window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorun)}, autorun)
}

ContentSlider.buildpagination=function(sliderid){
var paginatediv=document.getElementById("paginate-"+sliderid) //reference corresponding pagination DIV for slider
var pcontent=""
for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link
pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(i+1)+'</a> '
pcontent+='<a href="#" style="font-weight: bold;" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">Next</a>'
paginatediv.innerHTML=pcontent
paginatediv.onclick=function(){ //cancel auto run sequence (if defined) when user clicks on pagination DIV
if (typeof window[sliderid+"timer"]!="undefined")
clearTimeout(window[sliderid+"timer"])
}
}

ContentSlider.turnpage=function(sliderid, thepage){
var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //gather pagination links
for (var i=0; i<slidernodes[sliderid].length; i++){ //For each DIV within slider
paginatelinks[i].className="" //empty corresponding pagination link's class name
slidernodes[sliderid][i].style.display="none" //hide DIV
}
paginatelinks[thepage].className="selected" //for selected DIV, set corresponding pagination link's class name
slidernodes[sliderid][thepage].style.display="block" //show selected DIV
//Set "Next" pagination link's (last link within pagination DIV) "rel" attribute to the next DIV number to show
paginatelinks[paginatelinks.length-1].setAttribute("rel", thenextpage=(thepage<paginatelinks.length-2)? thepage+1 : 0)
if (enablepersist)
setCookie(sliderid, sliderid+":"+thepage)
}

ContentSlider.autoturnpage=function(sliderid, autorunperiod){
var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //Get pagination links
var nextpagenumber=parseInt(paginatelinks[paginatelinks.length-1].getAttribute("rel")) //Get page number of next DIV to show
ContentSlider.turnpage(sliderid, nextpagenumber) //Show that DIV
window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod)}, autorunperiod)
}

function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value
}

////////////////Ajax Related functions //////////////////////////////////

ContentSlider.ajaxpage=function(url, thediv){
var page_request = false
var bustcacheparameter=""
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
thediv.innerHTML=csloadstatustext
page_request.onreadystatechange=function(){
ContentSlider.loadpage(page_request, thediv)
}
if (csbustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

ContentSlider.loadpage=function(page_request, thediv){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
thediv.innerHTML=page_request.responseText
}

ContentSlider.loadobjects=function(externalfiles){ //function to load external .js and .css files. Parameter accepts a list of external files to load (array)
for (var i=0; i<externalfiles.length; i++){
var file=externalfiles[i]
var fileref=""
if (csloadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
csloadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
