<!-- Initialize the XMLHttpRequest Object -->
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
<!-- End XMLHttpRequest Initialization -->

function makeGrey(greyVar, newCity) {
	var obj2 = greyVar;
	var obj3 = "addEventCity" + obj2;
	var obj4 = document.getElementById(obj3);	
	
	cityid = document.addevent.metro.value;
	
	if ( cityid == "" ) {
		
		obj4.style.backgroundColor = "#E5ECF3";
		document.addevent.metro.value = obj2;
		document.addevent.city.value = newCity;
		
	} else {
		
	}
	
}

function makeRegisterGrey(greyVar, newCity) {
	var obj2 = greyVar;
	var obj3 = "addEventCity" + obj2;
	var obj4 = document.getElementById(obj3);	
	
	cityid = document.addevent.cityid.value;
	
	if ( cityid == "" ) {
		
		obj4.style.backgroundColor = "#E5ECF3";
		document.addevent.cityid.value = obj2;
		document.addevent.city.value = newCity;
		
	} else {
		
	}
	
}

function checkField(myField, myVal) {

		searchUrl = "/actions/fieldcheck.php?field=" + myField + "&value=" + myVal;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
				} else {

					document.getElementById("registerFeedback").innerHTML = xmlhttp.responseText;

				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

}

function citySearch() {

	searchText = document.citysearch.city.value;
	searchLength = searchText.length;
	commaSearch = searchText.search(",");
	mycountry = document.countryform.mycountry.value;

	if ( searchLength > 2 ) {
	
		searchUrl = "/citysearch.php?input=" + searchText + "&country=" + mycountry;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
					document.getElementById("results").style["visibility"]= "hidden";
				
				} else {
			
					document.getElementById("results").innerHTML = xmlhttp.responseText;
					
					document.getElementById("results").style["visibility"]= "visible";
				
				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

	}

}

function addEventSearch() {

	searchText = document.addevent.city.value;
	searchLength = searchText.length;
	commaSearch = searchText.search(",");
	mycountry = document.countryform.mycountry.value;
	
	document.addevent.metro.value = "";

	if ( searchLength > 2 ) {
	
		searchUrl = "/addeventsearch.php?input=" + searchText + "&country=" + mycountry;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
					document.getElementById("eventSearchResults").style["visibility"]= "hidden";
					
					document.addevent.metro.value = "";
				
				} else {
					
					document.addevent.metro.value = "";
			
					document.getElementById("eventSearchResults").innerHTML = xmlhttp.responseText;
					
					document.getElementById("eventSearchresults").style["visibility"]= "visible";
				
				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

	}

}

function registerCitySearch() {

	searchText = document.addevent.city.value;
	searchLength = searchText.length;
	mycountry = document.countryform.mycountry.value;

	if ( searchLength > 2 ) {
	
		searchUrl = "/registercitysearch.php?input=" + searchText + "&country=" + mycountry;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
					document.getElementById("eventSearchResults").style["visibility"]= "hidden";
					
					document.addevent.cityid.value = "";
				
				} else {
					
					document.addevent.cityid.value = "";
			
					document.getElementById("eventSearchResults").innerHTML = xmlhttp.responseText;
					
					document.getElementById("eventSearchresults").style["visibility"]= "visible";
				
				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

	}

}

function updateAddress(id) {

	searchUrl = "/address_query.php?id=" + id;

	xmlhttp.open("GET", searchUrl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			resultString = xmlhttp.responseText;
		
			if ( xmlhttp.responseText == null ) {
				
				document.addevent.address.value = "";
			
			} else {
				
				address_array = resultString.split("#####");
		
				document.addevent.address.value = address_array[0];
				document.addevent.location.value = address_array[1];
				
				var obj2 = id;
				var obj3 = "updateAddress" + obj2;
				var obj4 = document.getElementById(obj3);	
					
				obj4.style.backgroundColor = "#E5ECF3";
			
			}
		
		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function locationSearch() {

	searchText = document.addevent.location.value;
	searchCityVal = document.addevent.metro.value;
	searchCityBackupVal = document.addevent.backupcityid.value;
	searchLength = searchText.length;
	
	if ( searchCityVal == "" ) {
		
		searchCityVal = searchCityBackupVal;
		
	}

	if ( searchLength > 3 ) {
	
		searchUrl = "/locationsearch.php?input=" + searchText + "&cityid=" + searchCityVal;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
					document.getElementById("locationSearchResults").style["visibility"]= "hidden";
				
				} else {
			
					document.getElementById("locationSearchResults").innerHTML = xmlhttp.responseText;
					
					document.getElementById("locationSearchresults").style["visibility"]= "visible";
				
				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

	}

}

function rssSearch() {

	searchText = document.addevent.city.value;
	searchLength = searchText.length;
	commaSearch = searchText.search(",");
	mycountry = document.countryform.mycountry.value;
	
	document.addevent.cityid.value = "";

	if ( searchLength > 2 ) {
	
		searchUrl = "/rsssearch.php?input=" + searchText + "&country=" + mycountry;

		xmlhttp.open("GET", searchUrl,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
			
				resultString = xmlhttp.responseText;
			
				if ( xmlhttp.responseText == null ) {
				
					document.getElementById("eventSearchResults").style["visibility"]= "hidden";
					
					document.addevent.cityid.value = "";
				
				} else {
					
					document.addevent.cityid.value = "";
			
					document.getElementById("eventSearchResults").innerHTML = xmlhttp.responseText;
					
					document.getElementById("eventSearchresults").style["visibility"]= "visible";
				
				}
			
			}					   
		    
		}
		}
		xmlhttp.send(null);

	}

}

function getData(cityCode) {

	dataUrl = "/events.php?citycode=" + cityCode;
	
	xmlhttp.open("GET", dataUrl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			resultString = xmlhttp.responseText;
		
			if ( xmlhttp.responseText == null ) {
			
			} else {

				document.getElementById("data").innerHTML = xmlhttp.responseText;
				
				Effect.toggle('resultSlide','slide');

			}
		
		}					   
	    
	}
	}
	xmlhttp.send(null);	

}

function searchThiscity(cityid) {
	
	dataUrl = "/searchthiscity.php?citycode=" + cityid;
	
	xmlhttp.open("GET", dataUrl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			resultString = xmlhttp.responseText;
		
			if ( xmlhttp.responseText == null ) {
			
			} else {

				document.getElementById("city-listings").innerHTML = xmlhttp.responseText;

			}
		
		}					   
	    
	}
	}
	xmlhttp.send(null);	
	
}

function editEvent() {
	
	val = document.editform.editevent.value;
	
	document.location = "/editevent/" + val;
	
}

function delEvent() {
	
	val = document.editform.editevent.value;
	
	document.location = "/delevent/" + val;
	
}