
var pathToImg=new Array()
for (i=0;i<bgimages.length;i++){
pathToImg[i]=new Image()
pathToImg[i].src=bgimages[i]
}

var inc=-1

function bgSlide(){
if (inc<bgimages.length-1)
inc++
else
inc=0
document.getElementById("banners").style.background = "url("+pathToImg[inc].src+")";
}

if (document.all||document.getElementById)
window.onload=new Function('setInterval("bgSlide()",12000)')


//clear field
function clearField(field){
	document.getElementById(field).value = "";
}

//map image change
function changeMap(map){
	document.getElementById("geomap").src = '/site09/shared/images/pods/'+map;
}


//calculate general cost for payment
function gencostcalc(){
	entered = document.getElementById("amountb").value;
	calcthis = Math.round(entered*100)/100;
	
	var setvalsq = eval(calcthis);
	var calsurq = eval(eval(setvalsq / 100) * 1.2);
	var addsurq = eval(setvalsq + calsurq);
	var addsurqround = Math.round(addsurq*100)/100;
	var finx = eval(addsurqround  * 100);
	document.getElementById("vpc_Amount").value = Math.round(finx);
	
}

//set the date
function setsDate(){
	var months = document.getElementById("month").value;
	if (document.getElementById("month").value.length == "1"){
	var newmonth = "0"+months;
	} else {
	var newmonth = months;
	}
	var years = document.getElementById("year").value;
	if (document.getElementById("year").value.length == "1"){
	var newyear = "0"+years;
	} else {
	var newyear = years;
	}
	document.getElementById("vpc_CardExp").value = newyear+newmonth;
}

//fade to black
function clicker(){
	
	//only do this if image not locked
	//if ((lockimage != 1) && (lockfins != 1)){
	
	var thediv=document.getElementById('displaybox');
	if(thediv.style.display == "none"){
		thediv.style.display = "inline";
		//thediv.innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='middle' width='100%' height='100%'>test<br><br><a href='#' onclick='return clicker();'>CLOSE WINDOW</a></td></tr></table>";
	}else{
		thediv.style.display = "none";
		//thediv.innerHTML = '';
	}
	return false;
	
	//}
}

var prevsub = 'x';
//show sub menu
function showSub(subs){
	
	//if (prevsub != 'x'){
	//document.getElementById(prevsub).style.display = "none";
	//}
	document.getElementById(subs).style.display = "inline";
	prevsub = subs;
}

function hideSub(submen){
	
	if ((prevsub != 'x') && (prevsub != submen)){
	document.getElementById(prevsub).style.display = "none";
	}
	
}


//show drop menu
var menulock;
function showMenu(men){
	
	var count = 1;
	var menus;
	
	//hide menus
	do {
	menus = "drop"+count;
	document.getElementById(menus).style.display = "none";	
	count ++;

	
	} while(count < 5);

	//show menu if required
	if (men != 'x'){
	document.getElementById(men).style.display = "inline";
	}
	
	
}

//this locates the xpd via the drop menus
function locateXPD(){
	window.location = "http://www.noroads.com.au/default/expeditions/"+document.getElementById("expedition").value+"#cont";
}

//this locates the xpd via the drop menus
function locateAct(){
	window.location = "http://www.noroads.com.au/default/adventure-travel-specialists/activities/search/"+document.getElementById("activitymen").value+"#cont";
}

//this locates the xpd via search field
function xpdSearch(){
	window.location = "http://www.noroads.com.au/default/adventure-travel-specialists/findexpedition/search/"+document.getElementById("searchxpd").value+"#cont";
}


var xmlHttp
function getCountry(region)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


var url="/site09/includes/ajax_utilities.php"
url=url+"?region="+region
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=showCountry
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showCountry() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 	//eval(xmlHttp.responseText);
		
		document.getElementById("wrapcount").innerHTML = xmlHttp.responseText;
		
}
}

function getExped(country)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


var url="/site09/includes/ajax_utilities.php"
url=url+"?country="+country
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=showExped
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showExped() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 	//eval(xmlHttp.responseText);
		
		document.getElementById("wrapexped").innerHTML = xmlHttp.responseText;
		
}
}

///get trip from a trip code
function tripCode()
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


var url="/site09/includes/ajax_utilities.php"
url=url+"?code="+document.getElementById("tripcode").value
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=launchTrip
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


var codetrip;
function launchTrip() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 	eval(xmlHttp.responseText);
		
		if (codetrip != "x"){
		clicker();
		getForm(codetrip);
		} else {
		alert("We do not have a trip listed for the code entered.");
		}
		
}
}

function getFormx(trip){
	alert('The online booking system is currently off-line for maintenance. Please download our pdf booking form found under the Expedition Information options in the main menu.')
}
//get booking form
function getForm(trip)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


var url="/site09/includes/ajax_utilities.php"
url=url+"?trip="+trip
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=showForm
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showForm() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 	//eval(xmlHttp.responseText);
		
		document.getElementById("formdiv").innerHTML = xmlHttp.responseText;
		
}
}



 function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}