var ajax = new Array();

// show the pricing for a selected duration
function showNewPricing(sel,id) {
	
	var duration = sel.options[sel.selectedIndex].value;
	
	if (duration.length > 0){
		
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/project-price-new.php?duration=' + duration + '&id=' + id;
		ajax[index].onCompletion = function(){ createPricing(index) };
		ajax[index].runAJAX();
		
	}
}

function createPricing(index) {
	
	document.getElementById('price_big_text').innerHTML = "";
	document.getElementById('price_big_deposit').innerHTML = "";
	
	var obj_text = document.getElementById('price_big_text');
	var obj_deposit = document.getElementById('price_big_deposit');
	
	var obj_link_UK = document.getElementById('link_UK');
	var obj_link_US = document.getElementById('link_US');
	var obj_link_AU = document.getElementById('link_AU');
	var obj_link_CA = document.getElementById('link_CA');
	var obj_link_EU = document.getElementById('link_EU');
	var obj_link_SA = document.getElementById('link_SA');
	
	eval(ajax[index].response);
	
}

// gets the dates for a project depending on the duration selected
function getDateListDurationNew(sel,id) {
	
	var duration = sel.options[sel.selectedIndex].value;
	document.getElementById('dates').options.length = 0;	// Empty dates select box
	if(duration.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/project-dates-new.php?duration=' + duration + '&id=' + id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createDatesDuration(index,id) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

// gets the dates for a project depending on the duration selected
function getDateListDuration(sel,id) {
	
	var duration = sel.options[sel.selectedIndex].value;
	document.getElementById('dates').options.length = 0;	// Empty dates select box
	if(duration.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/project-dates.php?duration=' + duration + '&id=' + id;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createDatesDuration(index,id) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createDatesDuration(index,id)
{
	var obj = document.getElementById('dates');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


// gets the dates for a project
function getDateList(sel,what) {
	
	var projectCode = sel.options[sel.selectedIndex].value;
	document.getElementById('project_' + what + '_dates').options.length = 0;	// Empty dates select box
	if(projectCode.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/booking-dates.php?code='+projectCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createDates(index,what) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createDates(index,what)
{
	var obj = document.getElementById('project_' + what + '_dates');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

// get the cape town week option for a project
function getCTWList(sel,what,type) {
	
	var projectCode = sel.options[sel.selectedIndex].value;
	document.getElementById('project_' + what + '_ctw').options.length = 0;	// Empty dates select box
	if(projectCode.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/booking-ctw.php?code='+projectCode+'&type='+type;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCTW(index,what) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createCTW(index,what)
{
	var obj = document.getElementById('project_' + what + '_ctw');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

// get the additional options for a project
function getMoreList(sel,what) {
	
	var projectCode = sel.options[sel.selectedIndex].value;
	document.getElementById('project_' + what + '_more').options.length = 0;	// Empty dates select box
	if(projectCode.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'includes/booking-more.php?code='+projectCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createMore(index,what) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
	}
}

function createMore(index,what)
{
	var obj = document.getElementById('project_' + what + '_more');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
