
	function hide(id){
		document.getElementById(id).style.display = 'none';
	}
	
	function show(id){
		document.getElementById(id).style.display = 'block';
	}
	
	function clearInput(type){
		if(type == 'departingCountry'){
			document.getElementById("departingTown").value = '';
			document.getElementById("departingPostcode").value = '';
			tx_twwcscheduler_pi1clearTown('departingList');
		} else {
			document.getElementById("deliveryTown").value = '';
			document.getElementById("deliveryPostcode").value = '';
			tx_twwcscheduler_pi1clearTown('deliveryList');
		}
	}
	
	function clearInputMini(type,city,zip){
		if(type == 'departingCountry'){
			document.getElementById("departingTown").value = city;
			document.getElementById("departingPostcode").value = zip;
			tx_twwcscheduler_pi1clearTown('departingList');
		} else {
			document.getElementById("deliveryTown").value = city;
			document.getElementById("deliveryPostcode").value = zip;
			tx_twwcscheduler_pi1clearTown('deliveryList');
		}
	}
	
// --------------- Departing Town --------------------------//
	function lookupDeparting(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			hide('departing');
			tx_twwcscheduler_pi1clearTown('departingList');
		} else if(inputString.length > 2) {
			getContentDeparting();
			show('departing');
		
		}
	} // lookup
	
	function fillDeparting(thisValue) {
		document.getElementById("departingTown").value = thisValue
		setTimeout("hide('departing');", 200);
	}
	
	
	function getContentDeparting() {         
		try{ clearTimeout(su); }catch(e) {}        
		su=setTimeout("tx_twwcscheduler_pi1getDepartingTown(xajax.getFormValues('transport_form'))",200);           
	}

// --------------- Departing Area --------------------------//
	function lookupDepartingPostcode(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			hide('departingArea');
			tx_twwcscheduler_pi1clearTown('departingPostcodeList');
		} else if(inputString.length > 0) {
			getContentDepartingArea();
			show('departingArea');
		
		}
	} // lookup
	
	function fillDepartingArea(thisValue) {
		document.getElementById("departingPostcode").value = thisValue
		setTimeout("hide('departingArea');", 200);
	}
	
	
	function getContentDepartingArea() {         
		try{ clearTimeout(su); }catch(e) {}        
		su=setTimeout("tx_twwcscheduler_pi1getArea(xajax.getFormValues('transport_form'),'departing')",200);           
	}
	
// ----------------- Delivery Town--------------------------//
	function lookupDelivery(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			hide('delivery');
			// delete old data
			tx_twwcscheduler_pi1clearTown('deliveryList');
		} else if(inputString.length > 2) {
			getContentDelivery();
			show('delivery');
		
		}
	} // lookup
	
	function fillDelivery(thisValue) {
		document.getElementById("deliveryTown").value = thisValue
		setTimeout("hide('delivery');", 200);
	}
	
	function getContentDelivery() {         
		try{ clearTimeout(su); }catch(e) {}        
		su=setTimeout("tx_twwcscheduler_pi1getDeliveryTown(xajax.getFormValues('transport_form'))",200);         
	}
	
// ------------------- Pallet weight --------------------------//
	
	function addInput(cellId, weightId,prefixId)
	{
		
		document.getElementById(cellId).innerHTML = "";
		var num = document.getElementById(weightId).value;
		var y = document.getElementById(cellId);
		
		if ( parseInt(num)!=num - 0 || num.isAlpha  || num < 0 ){ 
			alert('Pallets can only be entered as a whole number (integer)'); 
			document.getElementById(weightId).value = 0;
		}
		else {
			if (  num < 8 ){
	
				for (var x = 1; x <= num; x++) {	
					var name = prefixId+"[weight"+weightId+x+"]";
					y.innerHTML += "<div class=\"weightRow\"><input class=\"inputSmall\" name="+name+" type=\"text\" id=\"weight" + weightId.substr(0,1) + x + "\" /></div>";
				}									
			}
			else { y.innerHTML += "<input type=\"text\" class=\"inputSmall\" style=\"margin-bottom: 2px; width: 40px;\" id=\"grossweight" + x + "\"\" \/><p>Total gross weight<\/p>"; }		
		}
	}
