var commentCount = 0;
var currentComment = 0;
var commentTicker;
var commentTime = 10;
var whatTheySay = new commentsArray();

function commentsArray() {
	this[commentCount] = 'Discus has given my company a real edge in identifying suitable candidates for vacancies in our organisation. I wouldn\'t hesitate to recommend it.'; commentCount++;
	this[commentCount] = '...customer service support and flexibility is second to none. I wouldn\'t hesitate to recommend Discus Online.'; commentCount++;
	this[commentCount] = 'As Sales Director recruiting candidates who fit in with our culture and sales process is key to increasing our revenue. The Job Profiling software within discus allows us to quickly find key sales staff and increase retention.'; commentCount++;
	this[commentCount] = 'Having used the tool many times on successful candidates, unsuccessful candidates & existing staff, I am constantly surprised by its consistent accuracy.'; commentCount++;
	this[commentCount] = 'I have been using Discus for many years, its millions of report combinations puts it way ahead of other solutions on the market that only output a limited combination of profiles. Giving us much greater detail.'; commentCount++;
	this[commentCount] = 'The benefits have been immediate: our retention rate has improved and the candidates are more sales focused.'; commentCount++;
	this[commentCount] = 'Generally the reports provide a good overview of applicants, and provide us with some great pointers for areas to explore in subsequent interview.'; commentCount++;
	this[commentCount] = 'This was very interesting and enlightening. Thank you for giving me this opportunity to find out about myself.'; commentCount++;
	//this[commentCount] = 'This report was very interesting to me ... I feel the report is mostly accurate and as such illuminating ... Excellent food for thought.'; commentCount++;
	this[commentCount] = 'I\'ve just done a test myself and I\'m going through the report now.  This is fantastic!  It\'s made the hairs on the back of my neck stand on end.'; commentCount++;
}

function deactivateComment(comment) {
	document.getElementById('navigationLink_'+comment).innerHTML = '<a href="" onclick="chooseComment('+comment+');return false;"><img src="_images/marker.png" width="6" height="6" alt="Choose this quote" style="margin-bottom:1px" /></a>';
}

function animateComment() {
	chooseComment(currentComment + 1);
	commentTicker = setTimeout('animateComment()',commentTime*1000)
}

function chooseComment(comment) {
	if (comment < 0) { comment = commentCount - 1; }
	if (comment >= commentCount) { comment = 0; }
	deactivateComment(currentComment);
	document.getElementById('navigationLink_'+comment).innerHTML = '<img src="_images/marker_selected.png" width="6" height="6" alt="This is the current quote" style="margin-bottom:1px" />';
	document.getElementById('commentHolder').innerHTML = whatTheySay[comment];
	currentComment = comment;
}

function clickComment(comment) {
	clearTimeout(commentTicker);
	chooseComment(comment);
	clearTimeout(commentTicker);
}

function initComments() {
	var i;
	html = '';
	html += '<table align="center" class="commentTable">';
	html += '<tr>';
	html += '<td><a href="" onclick="clickComment(currentComment-1);return false;"><img src="_images/pointer_back.png" width="8" height="9" alt="Previous quote" /></a></td>';
	for (i = 0; i < commentCount; i++) {
		html += '<td id="navigationLink_'+i+'"><a href="" onclick="clickComment('+i+');return false;"><img src="_images/marker.png" width="6" height="6" alt="Choose this quote" style="margin-bottom:1px" /></a></td>';
	}
	html += '<td><a href="" onclick="clickComment(currentComment+1);return false;"><img src="_images/pointer.png" width="8" height="9" alt="Next quote" /></a></td>';
	html += '</tr>';
	html += '</table>';
	document.getElementById('commentsNavigator').innerHTML = html;
	chooseComment(currentComment);
	commentTicker = setTimeout('animateComment()',commentTime*1000)
}

function toggleShareBox(){
	var shareBox = document.getElementById('shareBox');
	if (shareBox.style.display == 'block') {
		shareBox.style.display = 'none';
		document.getElementById('shareButton').src = root_path+'_images/button_share_up_highlight.png';
	} else {
		shareBox.style.display = 'block';
		document.getElementById('shareButton').src = root_path+'_images/button_share_down_highlight.png';
	}
}

function highlightShareImage(){
	var shareBox = document.getElementById('shareBox');
	if (shareBox.style.display == 'block') {
		return root_path+'_images/button_share_down_highlight.png';
	} else {
		return root_path+'_images/button_share_up_highlight.png';
	}
}

function inactiveShareImage(){
	var shareBox = document.getElementById('shareBox');
	if (shareBox.style.display == 'block') {
		return root_path+'_images/button_share_down.png';
	} else {
		return root_path+'_images/button_share_up.png';
	}
}

function openWindow(src,width,height){
	  var windowID = window.open(root_path+src,'defaultWin','scrollbars,resizable,WIDTH='+width+',HEIGHT='+height);
	  windowID.focus();
}

var currentPopup = '';
function closePopup(popup){
	if (popup != '') {
		document.getElementById(popup).style.display = 'none';
		currentPopup = '';
	}
}
function openPopup(popup){
	closePopup(currentPopup);
	document.getElementById(popup).style.display = 'block';
	currentPopup = popup;
}


function validEmail(address){
  var atCount = 0;
  var dotCount = 0;
  var v = true;
  var i;
  if (address == '') { v = false };
  if (v) {
    for (i = 0; i <= address.length; i++){
      if (address.charAt(i) == '@') { atCount++ };
      if (address.charAt(i) == '.') { dotCount++ };
    }
    if (atCount != 1) { v = false };
    if (dotCount == 0) { v = false };
    if (address.indexOf(' ') > -1) { v = false };
    if (address.indexOf('\'') > -1) { v = false };
    if (address.indexOf('"') > -1) { v = false };
    if (address.indexOf(',') > -1) { v = false };
    if (address.indexOf(';') > -1) { v = false };
    if (address.indexOf(String.fromCharCode(13)) > -1) { v = false };
  }
  return v;
}
