function showGeoDetails() {	
	var obj = document.getElementById("geoDetail");
	var objImage = document.getElementById("geoMessageDetailsImage");
	var lastSlash = objImage.src.lastIndexOf('/');
	var imageName = objImage.src.substring(lastSlash + 1);	
	
	obj.style.visibility = "visible";
	logInteraction('ShowDetail', imageName);	
}

function hideGeoDetails() {
	var obj = document.getElementById("geoDetail");
	obj.style.visibility = "hidden";	
}

function geoWrongState() {
	var obj = document.getElementById("geoLocation");
	var objLowerBottom = document.getElementById("lowerBlock");
	var objImage = document.getElementById("geoMessageImage");	
	var lastSlash = objImage.src.lastIndexOf('/');
	var imageName = objImage.src.substring(lastSlash + 1);	
	obj.style.display = "none";
	objLowerBottom.style.top = 510 + "px";		
	logInteraction('WrongState', imageName);		
}

function showGeo() {		
	if(document.getElementById("geoMessageImage") != null){	
		var objLowerBottom = document.getElementById("lowerBlock");
		objLowerBottom.style.top = 554 + "px";
		document.getElementById("geoLocation").style.display = "block";
	}	
}

var http = getHTTPObject(); 

function getHTTPObject() {
	var xmlhttp;	
	/*@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;			
		}
	}
	@else
		xmlhttp = false;
	@end @*/	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {	
		try {		
			xmlhttp = new XMLHttpRequest();			
		} 
		catch (e) {		
			xmlhttp = false;			
		}
	}
	if (!xmlhttp && window.createRequest) {	
		try {		
			xmlhttp = window.createRequest();			
		} 
		catch (e) {		
			xmlhttp=false;			
		}
	}
	return xmlhttp;
}
	
function handleHttpResponse() {	
 /* if (http.readyState == 4) {
	if (http.status == 200) alert("URL Exists!")
		else if (http.status == 404) alert("URL doesn't exist!")
				else alert("Status is " + http.status)
  }	*/
}

function logInteraction(action, asset) {
	if(http) {	
		var beginDomain = document.URL.indexOf('://') + 3;
		var domain = document.URL.substring(beginDomain, document.URL.indexOf('/',beginDomain));
		var protocal = document.URL.substring(0, beginDomain - 3);
		var page;
		var url;		
		switch(action) {
			case 'WrongState':
				page = 'GeoWrongState.aspx?asset=';
				break;
			case 'ShowDetail':
				page = 'GeoShowDetail.htm?asset=';				
		}		
		if(domain.indexOf("localhost") > -1) {
			url = page + asset;
		}
		else {
			url = protocal + '://' + domain + '/'+ page + asset;
		}			
		http.open("GET", url, true);	
		http.onreadystatechange = handleHttpResponse;	
		http.send(null);		
	}
}
