var statedata = new Array(); var hazdata = false; var statecolor = new Array(); var statepalette = new Array("#EACF98","#839417","#F06A27","#788979"); var overbox = false; var oversomething = false; var statetimeout = new Array(); $(document).ready(function (){ $.ajax({ url: 'states.json', dataType: 'json', success: function (data) { for(var it in data){ statedata[data[it].geo.cached_slug] = data[it].geo; if(data[it].geo.coroner_system == "none" && data[it].geo.medical_examiner_system == "state"){ statecolor[data[it].geo.cached_slug] = 0; } if(data[it].geo.coroner_system == "county" && data[it].geo.medical_examiner_system == "none"){ statecolor[data[it].geo.cached_slug] = 1; } if(data[it].geo.coroner_system == "district" && data[it].geo.medical_examiner_system == "none"){ statecolor[data[it].geo.cached_slug] = 1; } if(data[it].geo.coroner_system == "none" && data[it].geo.medical_examiner_system == "county"){ statecolor[data[it].geo.cached_slug] = 2; } if(data[it].geo.coroner_system == "county" && data[it].geo.medical_examiner_system == "state"){ statecolor[data[it].geo.cached_slug] = 3; } if(data[it].geo.coroner_system == "sometimes" && data[it].geo.medical_examiner_system == "sometimes"){ statecolor[data[it].geo.cached_slug] = 3; } if(data[it].geo.coroner_system == "county" && data[it].geo.medical_examiner_system == "county_state"){ statecolor[data[it].geo.cached_slug] = 3; } if(data[it].geo.coroner_system == "sometimes_justices" && data[it].geo.medical_examiner_system == "sometimes"){ statecolor[data[it].geo.cached_slug] = 2; } if(data[it].geo.coroner_system == "none" && data[it].geo.medical_examiner_system == "county_state"){ statecolor[data[it].geo.cached_slug] = 2; } if(data[it].geo.coroner_system == "none" && data[it].geo.medical_examiner_system == "county_state"){ statecolor[data[it].geo.cached_slug] = 2; } if(data[it].geo.coroner_system == "none" && data[it].geo.medical_examiner_system == "district"){ statecolor[data[it].geo.cached_slug] = 2; } } hazdata = true; drawmap('initial'); }, error: function (req, something, whatever) { $("#container").html(something); } }); }); function drawmap (caller) { $("#mapcontainer").html(''); var mywidth = $("#mapcontainer").width(); var myheight = 710; var ratio = 1; if(mywidth != 980){ ratio = mywidth / 980; myheight = Math.floor(mywidth * .8); $("#mapcontainer").css({ 'height': myheight + 'px' }); } var R = Raphael("mapcontainer", mywidth, myheight), attr = { "fill": "#d3d3d3", "stroke": "#fff", "stroke-opacity": ".5", "stroke-linejoin": "round", "stroke-miterlimit": "4", "stroke-width": "0.75", "stroke-dasharray": "none" }, usRaphael = {}; for (var state in usmap) { usRaphael[state] = R.path(usmap[state]).attr(attr); if(ratio != 1){ usRaphael[state].scale(ratio,ratio,0,0); } usRaphael[state].attr({fill: statepalette[statecolor[state]]}); } for (var state in usRaphael) { (function (st, state) { st[0].style.cursor = "pointer"; $(st[0]).mouseover(function (e) { st.animate({fill: '#ED1B24'}, 300); // st.toFront(); boxon(e.pageX,e.pageY,state) R.safari(); oversomething = true; clearTimeout(statetimeout[state]); }); $(st[0]).mouseout(function () { oversomething = false; statetimeout[state] = setTimeout(function () { st.animate({fill: statepalette[statecolor[state]]}, 300); if(!oversomething) { boxoff(); } // st.toFront(); R.safari(); }, 200); }); })(usRaphael[state], state); } } function boxon (x,y,statecode){ var txt = '