$(document).ready(function(){
	var speed = 200;
	var oTable;
	var asInitVals = new Array();

	oTable = $('#dealers').dataTable({
		"iDefaultSortIndex": 0,
		"sDefaultSortDirection": "asc",
		"iDisplayLength" : 5
	});
	
	$("#dealers .sortinput1 input").keyup( function () {
		oTable.fnFilter( this.value, $("#dealers .sortinput1 input").index(this) );
	} );
	$("#dealers .sortinput2 input").keyup( function () {
		oTable.fnFilter( this.value, $("#dealers .sortinput2 input").index(this) );
	} );
	/*
	 * Support functions to provide a little bit of 'user friendlyness' to the textboxes in 
	 * the footer
	 */
	$("#dealers input").each( function (i) {
		asInitVals[i] = this.value;
	} );
	
	$("#dealers input").focus( function () {
		if ( this.className == "search_init" ){
			this.className = "";
			this.value = "";
		}
	} );
	$("#dealers input").blur( function (i) {
		if ( this.value == "" ){
			this.className = "search_init";
			this.value = asInitVals[$("#dealers input").index(this)];
		}
	} );
	
	$("#dealermap area").mouseover(function(){
					classH = $(this).attr("class");
					$("#"+classH).fadeIn(speed);
					$(".li"+classH+" .block").addClass("hover");
				});
	$("#dealermap area").mouseout(function(){
					classH = $(this).attr("class");
					$("#"+classH).fadeOut(speed);
					$(".li"+classH+" .block").removeClass("hover");
				});
	
	$(".maplinks li").hover(
			function(){
					if (!($(this).find(".block").hasClass("active"))){
						classH = $(this).attr("class");
						if (classH){
							classH = classH.replace(/limaph/gi, "maph");
							$("#"+classH).fadeIn(speed);
						}
						$(this).find(".block").addClass("hover");
					}
				},
			function(){
					if (!($(this).find(".block").hasClass("active"))){
						$("#"+classH).fadeOut(speed);
						$(this).find(".block").removeClass("hover");
					}
				}
	);
	
});