function simple_tooltip(target_items, name, ftype){
 $(target_items).each(function(i){
		var thisid = name+ftype+i;
		$("body").append("<div class='"+name+"' id='"+thisid+"'><p>"+$(this).attr('name')+"</p></div>");
		var my_tooltip = $("#"+name+ftype+i);
		$(my_tooltip).mouseover(function(){
		$(this).hide();
		});

		$(this).removeAttr("title").mouseover(function(){
				my_tooltip.css({opacity:1, display:"none"}).show();
		}).mousemove(function(kmouse){
				my_tooltip.css({left:kmouse.pageX+15, top:kmouse.pageY+15});
		}).mouseout(function(){
				my_tooltip.hide();				  
		});
	});
}

function getMapId(mapid) {
	var listindex = 0;
	while (listindex<=20) {
		currentitem = "#mp_"+listindex;
		if (currentitem == mapid) {
			break;
		}
		listindex++;
	}
	
	return listindex;
}

$.fn.textWidth = function(){
  var html_org = $(this).html();
  var html_calc = '<span>' + html_org + '</span>'
  $(this).html(html_calc);
  var width = $(this).find('span:first').width();
  $(this).html(html_org);
  return width;
};

$(window).load(function() {
	$("#menu ul.dropdown ul").show();
});

$(document).ready(function(){
	$(".widecontent h1").width($(".widecontent h1").textWidth() + 50).ready(function() {
		$(".widecontent h1").css("border-bottom", "1px solid #850100");
	});
	
	if ($.browser.msie) {
		$("#featuredlistings_div").css("margin-left", "0");
	}

    $('.hovercounty').hover(function() {
		var mapid = getMapId("#"+$(this).attr("id"));
		var element = document.getElementsByTagName('area')[mapid-1];
		simulateMouseOver(element);
	}, function() {
		var mapid = getMapId("#"+$(this).attr("id"));
		var element = document.getElementsByTagName('area')[mapid-1];
		unSimulateMouseOver(element);
	});

});

var pagename = $("body").attr("id");

function ie7() {
if ($.browser.msie && $.browser.version=="6.0" && pagename != "map_usa"){
return 1;
} else if ($.browser.msie && $.browser.version=="7.0" && pagename != "map_usa") {
return 1;
} else {
return 0;
}
}
var check = ie7();

if (check != 1) {
	simple_tooltip('#map area', "tooltip", "main");
	simple_tooltip('#rr div', "tooltip", "rr");
}

function rr_show(num) {
	element = document.getElementsByTagName('area')[num]; 
	simulateMouseOver(element); 
	$("#tooltipmain"+num).hide();
}

function rr_hide(num) {
	element = document.getElementsByTagName('area')[num];
	unSimulateMouseOver(element)
}

// RR tooltip
$("#rr_vt").hover(function() {rr_show(45);}, function() {rr_hide(45)});
$("#rr_nh").hover(function() {rr_show(29);}, function() {rr_hide(29)});
$("#rr_ma").hover(function() {rr_show(21);}, function() {rr_hide(21)});
$("#rr_ri").hover(function() {rr_show(39);}, function() {rr_hide(39)});
$("#rr_ct").hover(function() {rr_show(6);}, function() {rr_hide(6)});
$("#rr_nj").hover(function() {rr_show(30);}, function() {rr_hide(30)});
$("#rr_de").hover(function() {rr_show(7);}, function() {rr_hide(7)});
$("#rr_md").hover(function() {rr_show(20)}, function() {rr_hide(20)});
$("#rr_dc").hover(function() {rr_show(8);}, function() {rr_hide(8)});
$("#rr_hi").hover(function() {rr_show(11);}, function() {rr_hide(11)});


(function($){$.fn.hoverFlow=function(c,d,e,f,g){if($.inArray(c,['mouseover','mouseenter','mouseout','mouseleave'])==-1){return this}var h=typeof e==='object'?e:{complete:g||!g&&f||$.isFunction(e)&&e,duration:e,easing:g&&f||f&&!$.isFunction(f)&&f};h.queue=false;var i=h.complete;h.complete=function(){$(this).dequeue();if($.isFunction(i)){i.call(this)}};return this.each(function(){var b=$(this);if(c=='mouseover'||c=='mouseenter'){b.data('jQuery.hoverFlow',true)}else{b.removeData('jQuery.hoverFlow')}b.queue(function(){var a=(c=='mouseover'||c=='mouseenter')?b.data('jQuery.hoverFlow')!==undefined:b.data('jQuery.hoverFlow')===undefined;if(a){b.animate(d,h)}else{b.queue([])}})})}})(jQuery);

