// JavaScript Document
function grabLatLong(ltlng) {
			
			document.getElementById('location_lat').value = String(ltlng.lat());
			document.getElementById('location_lng').value = String(ltlng.lng());
	
	}
	
	
		function getBreeds(speciesID,intRegType) {
		//alert(speciesID)
		if (speciesID==0) {
		resetSpecies();
		}  else {
		$.post('/includes/ajaxResponse.asp','frmAction=getBreeds&speciesID='+ speciesID+'&regType='+intRegType,function(data) {document.getElementById('breeds').innerHTML = data;}) ;
		resetColour();
		if (speciesID.search("99_")==0) {
				//WARNING hard coded SpeciesID - not robust!
				showHide(1,1,"cont-freezemark")	;
				showHide(0,1,"cont-coll")	//hide the collar drop down
				document.getElementById('collar').options[document.getElementById('collar').options.selectedIndex=2]; //force the value to no for the collar dd
				
				}
				else {
				showHide(0,1,"cont-freezemark")
				showHide(1,1,"cont-coll") ;//show the collar drop down
				showHide(0,1,"cont-freeze");
				document.getElementById('collar').options[document.getElementById('collar').options.selectedIndex=0]; //resetthe value for the collar dd
				document.getElementById('freezemark').options[document.getElementById('freezemark').options.selectedIndex=2]; //force the value to no for freezemark dd
				}	
		
		}
	}
	
	function getColours(breedID) {
		breedID = breedID.toString()
		if (breedID==0) {
				resetColour();		
		}  else {
		if ((breedID.search("144_")==0) || (breedID.search("0_")==0)){
				//WARNING hard coded BreedID - not robust!
				showHide(1,1,"coat")				
				}
				else {
				showHide(0,1,"coat")
				}		
		$.post('/includes/ajaxResponse.asp','frmAction=getColours&breedID='+ breedID,function(data) {document.getElementById('colours').innerHTML = data;}) 
		}
	}
	
	function resetSpecies() {
	
		var html
		html = '<select name="breedSelect" id="breedSelect" class="required"><option value="">Please select species first</option></select>';
		document.getElementById('breeds').innerHTML = html;
	}
	
	function resetColour() {
	
		var html
		html = ' <input name="colour"  type="text" class="required inp_stnrd" id="colour" maxlength="100"/>';
		document.getElementById('colours').innerHTML = html;
	}
	
	function showHide(v,matchVal,e) {
	
		if (v==matchVal) {
			$("#" + e).slideDown("fast");
			
		} else {
			$("#" + e).slideUp("fast");
		}
		
	}