var pageNum = 1;
var mapSections = 1;

function gotoNextPage() {
	if (pageNum < 5) {
		pageNum++;
	} 

	switchSections(pageNum);
}

function gotoLastPage() {
	if (pageNum > 1) {
		pageNum--;
	}

	switchSections(pageNum);
}

function gotoPage(num) {
	pageNum = num;

	switchSections(pageNum);
}
		
function switchSections(page) {
	// reset everything
	for (i=1; i<=5; i++) {
		questionName = "question" + i;
		boxName = "progressBox" + i;
		document.getElementById(questionName).style.display = 'none';
		document.getElementById(boxName).style.backgroundColor = '#e6e6e6';
	}

	// determine which elements need changing
	questionName = "question" + page;
	boxName = "progressBox" + page;

	// change the elements for the currently active page
	document.getElementById(boxName).style.backgroundColor = '#84c162';
	document.getElementById(questionName).style.display = 'block';
	document.getElementById('progressText').innerHTML = page + ' of 5';
}

function initialize() {
	switchSections(1);  // switch to section 1
	document.getElementById('errorText').style.display = 'none';  // turn off error text
}

function form_switch(section) {
	// reset everything
	document.getElementById("tourdafrique_form").style.display = 'none';
	document.getElementById("orientexpress_form").style.display = 'none';
	document.getElementById("silkroute_form").style.display = 'none';
	document.getElementById("southamerica_form").style.display = 'none';

	document.getElementById(section).style.display = 'block';
}

function pay_switch(section) {
	// reset everything
	document.getElementById("pay_paypal").style.display = 'none';
	document.getElementById("pay_other").style.display = 'none';

	document.getElementById(section).style.display = 'block';
}

// constructs email link dynamically to prevent spam
function mail(address) {
	emailLink = '<a href="mailto:' + address + '@tourdafrique.com' + '">' + address + '@tourdafrique.com' + '</a>';
	document.write(emailLink);
}

function submit(type) {
	if (type == "paypal") {
		document.theForm.action = "../forms/pay_paypal.php";
	} else {
		document.theForm.action = "../forms/pay_other.php";
	}

	document.theForm.submit();
}

function rollover(buttonName, turnOn) {
  theImage = document.getElementById(buttonName);  
  if (turnOn) {
    theImage.src = theImage.src.replace(/_off/, '_on');     
  } else {
    theImage.src = theImage.src.replace(/_on/, '_off');
  }
}