// JavaScript Document

// PNG Fix
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
function fixPNG(myImage) 
{
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   	var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   	var imgStyle = "display:inline-block;" + myImage.style.cssText
	   	var strNewHTML = "<span " + imgID + imgClass + imgTitle
        	+ " style=\"" + "width:" + myImage.width 
            + "px; height:" + myImage.height 
            + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	  		myImage.outerHTML = strNewHTML	  
    }
}

// bar details by county
function getCounty(county)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	
	switch(sPage){
		case 'search.php':
			$("#bar_stat").fadeOut(500, function () {
				$("#bar_stat").load("map/county.php?id="+county ,{},function () {
					$("#bar_stat").fadeIn(500);
				});
			});
			$("#topResults").fadeOut(500, function () {
				$("#topResults").load("map/county.php?val="+county ,{},function () {
					$("#topResults").fadeIn(500);
				});
			});
			$("#header_text").fadeOut(500, function () {
				$("#header_text").load("map/county.php?county="+county ,{},function () {
					$("#header_text").fadeIn(500);
				});
			});
			
		break;
		case 'bar_directory.php':
			$("#bar_stat").fadeOut(500, function () {
				$("#bar_stat").load("map/barstats.php?id="+county ,{},function () {
					$("#bar_stat").fadeIn(500);
				});
			});
			$("#topResults").fadeOut(500, function () {
				$("#topResults").load("map/barstats.php?val="+county ,{},function () {
					$("#topResults").fadeIn(500);
				});
			});
			$("#header_text").fadeOut(500, function () {
				$("#header_text").load("map/barstats.php?county="+county ,{},function () {
					$("#header_text").fadeIn(500);
				});
			});
			
		break;
		case 'hotel_directory.php':
			$("#bar_stat").fadeOut(500, function () {
				$("#bar_stat").load("map/hotelstats.php?id="+county ,{},function () {
					$("#bar_stat").fadeIn(500);
				});
			});
			$("#topResults").fadeOut(500, function () {
				$("#topResults").load("map/hotelstats.php?val="+county ,{},function () {
					$("#topResults").fadeIn(500);
				});
			});
			$("#header_text").fadeOut(500, function () {
				$("#header_text").load("map/hotelstats.php?county="+county ,{},function () {
					$("#header_text").fadeIn(500);
				});
			});
			
		break;
	};
};
function addNewBar(county){
	var town = document.getElementById("barTown").value;
	var bar = document.getElementById("barName").value;
	if(town > 0 && bar > ''){
		$("#bar_stat").fadeOut(500, function () {
			$("#bar_stat").load("map/barstats.php?newBar="+county+"&town="+town+"&bar="+bar ,{},function () {
				$("#bar_stat").fadeIn(500);
			});
		});
	}
}

function getTowns(val){
	$("#townsList").load("map/barstats.php?getTown="+val);
}
function getBars(val){
	$("#barsList").load("map/barstats.php?getBar="+val);
}
function getTownsH(val){
	$("#townsList").load("map/hotelstats.php?getTown="+val);
}
function getBarsH(val){
	$("#hotelsList").load("map/hotelstats.php?getBar="+val);
}

function jumpTo(val){
	window.location.href = val;
}