var questionnaire = new questionnaireType;
var currentQuestion = 0;
function questionnaireType()
{
  this[0] = new question('Adopting a dominant attitude to others','Influencing other people\'s ideas','Remaining steady and calm at all times','Complying with instructions and regulations');
  this[1] = new question('Behaving compassionately towards others','Persuading others to your point of view','Showing modesty in describing your achievements','Producing original ideas');
  this[2] = new question('Receiving attention from other people','Working together with others to achieve an aim','Standing up for your rights','Showing affection in personal relationships');
}
function question(a,b,c,d)
{
  this[0] = a;
  this[1] = b;
  this[2] = c;
  this[3] = d;
};

function changeQuestion(){
  var i;
  var most;
  var least;
  var charCode = 'ABCD';
  var error = '';
  var lastQuestion = 2;
  // Assess 'Most' and 'Least'
  most = '?';
  least = '?';
  for (i = 0; i <= 3; i++) {
    if (qmost[i].checked) { most = charCode.charAt(i) };
    if (qleast[i].checked){ least = charCode.charAt(i)};
  };
  // Validate
  if ((most == '?') || (least == '?'))  {error = 'You must select a \'Most\' and a \'Least\' answer before proceeding.'};
  if ((most == least) && (error == '')) {error = 'The answer you choose for \'most\' and a \'least\' cannot be the same.'};
  if (error != ''){
    window.alert(error);
    return false;
  } else {
    // Store Response
    if (currentQuestion > 0) {
      eval('qmost.value = most');
      eval('qleast.value = least');
    };
    // Clear Existing Radios
    for (i = 0; i <= 3; i++) {
      qmost[i].checked = false;
      qleast[i].checked = false;
    };
    // Update Display
    if (currentQuestion == lastQuestion){ currentQuestion = -1 };
    currentQuestion++;
    qtexta.innerHTML = questionnaire[currentQuestion][0];
    qtextb.innerHTML = questionnaire[currentQuestion][1];
    qtextc.innerHTML = questionnaire[currentQuestion][2];
    qtextd.innerHTML = questionnaire[currentQuestion][3];
    return false;
  };
};

function checkRepeats(index,column){
  if (column == 0) {
    qleast[index].checked = false;
  } else {
    qmost[index].checked = false;
  };
};

function launchDaLG()
{
    window.open('http://www.discusonline.com/Dalg/dalg.html','DOL_DALG_WINDOW','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=640,height=480,top=20,left=20');
}

function launchUDISC()
{
    window.open('http://www.discusonline.com/UDISC/','DOL_UDISC_WINDOW','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=640,height=480,top=30,left=30');
}

function showMessage(){
  window.alert('After completing the actual questionnaire, you should press this \'Questionnaire Completed\' button to submit your answers.');
};

function alertFavourite() {
	if (document.all) {
		msg = "Add this site to your favourites?\n";
    	if (confirm(msg)) {
			window.external.AddFavorite(location.href,document.title);
		}
	}
}

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}

var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        clients_page_over = newImage("../img/clients_page-over.gif");
        candidates_page_over = newImage("../img/candidates_page-over.gif");
        our_vacancies_over = newImage("../img/our_vacancies-over.gif");
        rpc_coaching_over = newImage("../img/rpc_coaching-over.gif");
        rpc_profiling_over = newImage("../img/rpc_profiling-over.gif");
        email_alert_over = newImage("../img/email_alert-over.gif");
        preloadFlag = true;
    }
}

