

var qsParm = new Array();


function qs() {

	var query = window.location.search.substring(1);
	var parms = query.split('&');
	
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
			}
		}
}


// test for numeric value

function isNum(passedVal) {
	if (passedVal == "") {
		return false
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}

	return true

}




// validate standard fields on order form

function submitIt(inForm) {


	// make sure they select a river

	inputChoice = inForm.river.selectedIndex
	if (inForm.river.options[inputChoice].value == "") {
			alert ("Please select a river from the drop down list")
			inForm.river.focus()
			inForm.river.select()
			return false
	}			

	// make sure they enter site code

	inputChoice = inForm.sitecode.selectedIndex
	if (inForm.sitecode.options[inputChoice].value == "") {
			alert ("Please select your site code from the drop down list")
			inForm.sitecode.focus()
			inForm.sitecode.select()
			return false
	}			

	// make sure they enter date
	
	inputChoice = inForm.daynum.selectedIndex
	if (inForm.daynum.options[inputChoice].value == "") {
			alert ("Please select a day number from the drop down list")
			inForm.daynum.focus()
			inForm.daynum.select()
			return false
	}	
	
	inputChoice = inForm.mthnum.selectedIndex
	if (inForm.mthnum.options[inputChoice].value == "") {
			alert ("Please select a month from the drop down list")
			inForm.mthnum.focus()
			inForm.mthnum.select()
			return false
	}	
	
	inputChoice = inForm.yrnum.selectedIndex
	if (inForm.yrnum.options[inputChoice].value == "") {
			alert ("Please select a year from the drop down list")
			inForm.yrnum.focus()
			inForm.yrnum.select()
			return false
	}	
		
		
	// make sure they enter time
	
	inputChoice = inForm.hrnum.selectedIndex
	if (inForm.hrnum.options[inputChoice].value == "") {
			alert ("Please select an hour from the drop down list")
			inForm.hrnum.focus()
			inForm.hrnum.select()
			return false
	}	
	
	inputChoice = inForm.minnum.selectedIndex
	if (inForm.minnum.options[inputChoice].value == "") {
			alert ("Please select minutes from the drop down list")
			inForm.minnum.focus()
			inForm.minnum.select()
			return false
	}	
	
	inputChoice = inForm.ampm.selectedIndex
	if (inForm.ampm.options[inputChoice].value == "") {
			alert ("Please select AM or PM from the drop down list")
			inForm.ampm.focus()
			inForm.ampm.select()
			return false
	}		
		
	// make sure they enter who the tester is
	
	inputChoice = inForm.whoby.selectedIndex
	if (inForm.whoby.options[inputChoice].value == "") {
			alert ("Please select the name of the tester from the drop down list")
			inForm.whoby.focus()
			inForm.whoby.select()
			return false
	}	
		
	// make sure a password is entered
	  		
	if (inForm.passfield.value == "") {
			alert ("Please enter your password in the box provided")
			inForm.passfield.focus()
			inForm.passfield.select()
			return false
		}
		
			
		
	// Check there is some sample data
		
	if (inForm.temp.value =="" && inForm.turbidity.value =="" && inForm.cond.value =="" && inForm.ph.value =="")
	
	{
			alert ("There are no water sample test results!")
			inForm.temp.focus()
			inForm.temp.select()
			return false
		}		


}
		


// Update Site description from site code selected
// called on change of site code

function updateDesc(what) {

	var siteDesc=new Array( 
" ",
"Cethana", 
"Short Cut Rd",
"Sheffield Rd",
"Lower Beulah",
"Claude Rd",
" "
		);
		
	var eastDesc=new Array( 
" ",
"431910", 
"",
"441770",
"",
"",
" "
		);

	var northDesc=new Array( 
" ",
"5408184", 
"",
"5420000",
"",
"",
" "
		);
	var chainDesc=new Array( 
" ",
"1950", 
"",
"6400",
"",
"",
" "
		);		
		
	var sel = what.selectedIndex;	

	document.formadd.sitedesc.value = siteDesc[sel]; 
	document.formadd.easting.value = eastDesc[sel]; 
	document.formadd.northing.value = northDesc[sel]; 
	document.formadd.chainage.value = chainDesc[sel]; 
}




