// IMAGE ROLLOVER FUNCTIONS

    var imageroot = "/images/";

    function turnon(pic){
      pic.src = imageroot + pic.id + "_over.gif";
      return true;
    }

    function turnoff(pic){
      pic.src = imageroot + pic.id + ".gif";
      return true;
    }
	
// Function to write today's date

function write_todays_date(){

  var today = new Date();
  document.write("&nbsp;&nbsp;" + today.toLocaleString());
  
}

// Popup a standard 500x500 window
function popup(URL) {
var w = window.open(URL, 'form', 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=500');
}

// Function to Open Window
// Popup a customizable size window
function openwin(the_url,w,h)
{
   newwin=window.open(the_url,"newwin","height=" + h + ",width=" + w + ",left=30,top=30,scrollbars=yes")
}

function validateregistration(f){

  var errorlog = "Please correct the following problems:\n\n";
  var errors = 0;
  
  if(f.fname.value == ""){
    errorlog += "Please fill in your first name.\n";
	errors++;
  }
  
  if(f.lname.value == ""){
    errorlog += "Please fill in your last name.\n";
	errors++;
  }
  
  if( checkEmail( f.email.value ) == false){ 
    return false;
  }
  
  if(errors){
    alert(errorlog);
	return false;
  }
  else { return true; }
  
}

function validateregistration2(f) {

	var errorlog = "Please correct the following problems:\n\n";
	var errors = 0;
  	var valid = true;

	if(f.fname.value.length < 1){
		document.getElementById("err_fname").innerText = "Sorry! You have not filled out a required field - first name.";
//		errorlog += "Sorry! You have not filled out a required field - first name.\n\n";
		errors++;
	}
	else
		document.getElementById("err_fname").innerText = "";

  
	if(f.lname.value.length < 1){
		document.getElementById("err_lname").innerText = "Sorry! You have not filled out a required field - last name.";
//		errorlog += "Sorry! You have not filled out a required field - last name.\n\n";
		errors++;
	}
	else
		document.getElementById("err_lname").innerText = "";
  
	if(f.company.value.length < 1){
		document.getElementById("err_company").innerText = "Sorry! You have not filled out a required field - company.";
//		errorlog += "Sorry! You have not filled out a required field - company.\n\n";
		errors++;
	}
	else
		document.getElementById("err_company").innerText = "";
  
	if(f.title.value.length < 1){
		document.getElementById("err_title").innerText = "Sorry! You have not filled out a required field - title.";
//		errorlog += "Sorry! You have not filled out a required field - title.\n\n";
		errors++;
	}
	else
		document.getElementById("err_title").innerText = "";
  
	if(f.phone.value.length < 1){
		document.getElementById("err_phone").innerText = "Sorry! You have not filled out a required field - phone number.";
//		errorlog += "Sorry! You have not filled out a required field - phone number.\n\n";
		errors++;
	}
	else
		document.getElementById("err_phone").innerText = "";
  
	if((f.currsubscriber[0].checked == false) && (f.currsubscriber[1].checked == false)){
		document.getElementById("err_currsubscriber").innerText = "Are you currently a subscriber?";
//		errorlog += "Are you currently a subscriber?\n\n";
		errors++;
	}
	else
		document.getElementById("err_currsubscriber").innerText = "";
  
	if((f.currsubscriber[1].checked == true) && ((f.wish2subscribe[0].checked == false) && (f.wish2subscribe[1].checked == false))){
		document.getElementById("err_wish2subscribe").innerText = "Would you like to subscribe to our Newsletter?";
//		errorlog += "Would you like to subscribe to our Newsletter?\n\n";
		errors++;
	}
	else
		document.getElementById("err_wish2subscribe").innerText = "";
  
	if((f.participatesurvey[0].checked == false) && (f.participatesurvey[1].checked == false)){
		document.getElementById("err_participatesurvey").innerText = "Would you like to receive an invite to future research surveys?";
//		errorlog += "Would you like to receive an invite to future research surveys?\n\n";
		errors++;
	}
	else
		document.getElementById("err_participatesurvey").innerText = "";
  
	if(errors > 0){
//		alert(errorlog);
		valid = false;
	}

	if( checkEmail( f.email.value ) == false){ 
		valid = false;
	}

	return valid;
}

// VALIDATE Newsletter Subscription FORM
function validatenewslettersubscription(f){

  var errorlog = "Please correct the following problems:\n\n";
  var errors = 0;
  
  if(f.fname.value == ""){
    errorlog += "Please fill in your first name.\n";
	errors++;
  }
  
  if(f.lname.value == ""){
    errorlog += "Please fill in your last name.\n";
	errors++;
  }
  
  if(f.company.value == ""){
    errorlog += "Please fill in the name of your company.\n";
	errors++;
  }
  
  if( checkEmail( f.email.value ) == false){ 
    return false;
  }
  
  if(errors){
    alert(errorlog);
	return false;
  }
  else { return true; }
  
}


// The question is no longer used - it was replaced by a form within the publications script.

//function popup_questionnaire(URL) {

  // If the cookie hasn't been set yet then show them the questionniare, otherwise do nothing
  
  //var the_cookie = document.cookie;
  
  //if(!document.cookie || document.cookie.indexOf("seen_questionnaire") == -1){
  
    // Popup the questionnaire
    //var w = window.open(URL, 'form', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=350');
  
    // Set a cookie showing that the person has seen the questionnaire
    //var the_date = new Date("December 31, 2023");
    //var the_cookie_date = the_date.toGMTString();

    //the_cookie = "seen_questionnaire=true";
    //the_cookie = the_cookie + ";expires=" + the_cookie_date;
    //document.cookie = the_cookie;
  //}
  
//}

