/* This may be moved to global.js */

jQuery(document).ready(function(){

	jQuery(".map-nav-state").click(function(){
		var a = jQuery(this).children(".map-nav-state-subnav").hasClass("map-nav-state-subnav-active");
		if (a) {
			jQuery(".map-nav-state-subnav").removeClass("map-nav-state-subnav-active");
		} else {
			jQuery(".map-nav-state-subnav").removeClass("map-nav-state-subnav-active");
			jQuery(this).children(".map-nav-state-subnav").addClass("map-nav-state-subnav-active");
		}
	});

	jQuery(".map-nav-city").click(function(){
		var a = "."+jQuery(this).attr("rel");
		var b = jQuery(a).hasClass("map-city-active");
		jQuery(".map-city").removeClass("map-city-active");
		jQuery(a).addClass("map-city-active");
		if (!b) {
			return false;
		}
	});
	
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (!agentID) {
		jQuery(".map-nav-city").hover(function(){
			var a = "."+jQuery(this).attr("rel");
			jQuery(".map-city").removeClass("map-city-active");
			jQuery(a).addClass("map-city-active");
		},function(){
			jQuery(".map-city").removeClass("map-city-active");
		});

		jQuery(".map-nav-state").hover(function(){
			jQuery(".map-nav-state-subnav").removeClass("map-nav-state-subnav-active");
			jQuery(this).children(".map-nav-state-subnav").addClass("map-nav-state-subnav-active");
		},function(){
			jQuery(".map-nav-state-subnav").removeClass("map-nav-state-subnav-active");
		});
	}
});

