jQuery(document).ready(function() { function fixWebkitHeightBug(){ var svgW = 959; var svgH = 593; var curSVGW = jQuery('#map_container').width(); var newSVGH = heightInRatio(svgH,svgW,curSVGW); jQuery('#map_container').height(newSVGH); function heightInRatio(oH,oW,nW){ return (oH / oW * nW); } } // lets do some stuff if (jQuery("#map_container").length > 0) { // For all map functions var width = jQuery('#map_container').width(); var height = jQuery('#map_container').height() * 0.99; var svgWidth = 959; var svgHeight = 593; //function for ie resizing function resizePaper() { var container_width = jQuery('#map_container').width(); var scale = container_width / 959; //alert(container_width); //alert(scale); return scale.toFixed(2); } if(!jQuery.browser){ jQuery.browser = {}; (function () { jQuery.browser.msie = false; jQuery.browser.version = 0; if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) { jQuery.browser.msie = true; jQuery.browser.version = RegExp.$1; } })(); } if (jQuery.browser.msie && jQuery.browser.version < 9) { var newScale = resizePaper(); var R = new ScaleRaphael('map_container', 959, 593); R.scaleAll(newScale); jQuery(window).resize(function(){ var container_width = jQuery('#map_container').width(); var scale = container_width / 959; //alert(container_width); //alert(scale); return scale.toFixed(2); R.scaleAll(resizePaper()); }); } else{ var R = Raphael('map_container', '100%', '100%'); R.setViewBox(0, 0, svgWidth, svgHeight, true); } var attr = { "fill" : "#dfe0e1", "stroke" : "#fff", "stroke-opacity" : "1", "stroke-linejoin" : "round", "stroke-miterlimit" : "4", "stroke-width" : "1.75", "stroke-dasharray" : "none" } var usRaphael = {}; //Draw Map and store Raphael paths for (var state in usMap) { usRaphael[state] = R.path(usMap[state]).attr(attr); } //change color of active states var active_states = new Array(); active_states.push('al'); active_states.push('ak'); active_states.push('az'); active_states.push('ar'); active_states.push('ca'); active_states.push('co'); active_states.push('ct'); active_states.push('de'); active_states.push('dc'); active_states.push('fl'); active_states.push('ga'); active_states.push('id'); active_states.push('il'); active_states.push('in'); active_states.push('ia'); active_states.push('ks'); active_states.push('ky'); active_states.push('la'); active_states.push('me'); active_states.push('md'); active_states.push('ma'); active_states.push('mi'); active_states.push('mn'); active_states.push('ms'); active_states.push('mo'); active_states.push('mt'); active_states.push('ne'); active_states.push('nv'); active_states.push('nh'); active_states.push('nj'); active_states.push('nm'); active_states.push('ny'); active_states.push('nc'); active_states.push('nd'); active_states.push('oh'); active_states.push('ok'); active_states.push('or'); active_states.push('pa'); active_states.push('ri'); active_states.push('sc'); active_states.push('sd'); active_states.push('tn'); active_states.push('tx'); active_states.push('ut'); active_states.push('va'); active_states.push('wa'); active_states.push('wv'); active_states.push('wi'); active_states.push('wy'); for (var i = 0; i < active_states.length; i++) { usRaphael[active_states[i]].attr({fill: "#1e83c5"}); usRaphael[active_states[i]].attr({href: "javascript:mapclick('"+active_states[i]+"')"}); if (window.location.pathname != "/") { usRaphael[active_states[i]].hover(function () { this.attr({ "fill-opacity": "0.5" }); }, function () { this.attr({ "fill-opacity": "1.0" }); }).click(function(){ jQuery('#map_container svg a path').each(function(i, el){ jQuery(el).attr({ "fill": "#1e83c5" }); }); this.attr({ "fill": "#124f76" }); }); } } //fix Webkit rendering fixWebkitHeightBug(); //Do Work on Map var scrolloffset = 0; jQuery('#state-select').change(function() { jQuery('#map-results').show(); jQuery("#map-results").scrollTop(0+scrolloffset); scrolloffset++; }); } // alert('AL 146'); // alert('AK 5'); // alert('AZ 60'); // alert('AR 56'); // alert('CA 66'); // alert('CO 35'); // alert('CT 9'); // alert('DE 1'); // alert('DC 1'); // alert('FL 229'); // alert('GA 150'); // alert('ID 9'); // alert('IL 160'); // alert('IN 148'); // alert('IA 27'); // alert('KS 38'); // alert('KY 55'); // alert('LA 38'); // alert('ME 12'); // alert('MD 51'); // alert('MA 23'); // alert('MI 66'); // alert('MN 27'); // alert('MS 53'); // alert('MO 86'); // alert('MT 26'); // alert('NE 6'); // alert('NV 13'); // alert('NH 9'); // alert('NJ 20'); // alert('NM 29'); // alert('NY 38'); // alert('NC 155'); // alert('ND 4'); // alert('OH 197'); // alert('OK 84'); // alert('OR 6'); // alert('PA 87'); // alert('PR 1'); // alert('RI 5'); // alert('SC 68'); // alert('SD 2'); // alert('TN 139'); // alert('TX 503'); // alert('UT 13'); // alert('VA 114'); // alert('WA 28'); // alert('WV 22'); // alert('WI 47'); // alert('WY 6'); }); function mapclick(state) { jQuery.get('/wp-content/themes/nnnr/getpropertybystate.php?json=true&lease=0&state=' + state, function(data) { if(jQuery('body').hasClass('our-portfolio') || jQuery('body').hasClass('buy-a-property')){ populate_map_header(data); } if (document.documentElement.clientWidth > 640) { jQuery('.results-list .listing-link').fancybox({ maxWidth : 800, maxHeight : 600, fitToView : false, width : '70%', height : '70%', autoSize : false, closeClick : false, openEffect : 'none', closeEffect : 'none' }); } }); } function popresults() { var state = jQuery('#state-select').val(); mapclick(state.toLowerCase()); } function roundToTwoDecimals(num){ return num.toFixed(2); } function populate_map_header(data){ var map_header = jQuery('.map-header'); var data = JSON.parse(data); map_header.addClass('map-header--fade-out'); var _left = jQuery('
').addClass('map-header__left'); var _right = jQuery('
').addClass('map-header__right'); var left_content = jQuery('

').html(data.stateName + ": " + data.numProp + " Properties"); var right_content = jQuery('

').html(roundToTwoDecimals(data.tcabr * 100) + "% of Portfolio Base Rent"); _left.html(left_content); _right.html(right_content); setTimeout(function(){ map_header.html(_left).append(_right); map_header.removeClass('map-header--fade-out'); }, 220); }