var DATA_SOURCE='/eescripts/CountyData.js/';var IMAGE_PATH='/images/counties/';var CSS_WRAPPER_CLASS='countyWrapper';var CSS_IMAGE_CLASS='countyImage';var CSS_INFO_CLASS='countyInfo';var ROTATION_INTERVAL=8;var _isHovering=false;var _autoSelectedCounty=null;function highlightRandomCounty(){if(!_isHovering){var children=$('#map-holder').children('div');var randomIndex=parseInt(Math.random()*children.length);_autoSelectedCounty=$(children[randomIndex]).children('img')[0];hideAllCounties();showCounty(_autoSelectedCounty)}}function showCounty(countyImage){$(countyImage).stop().animate({opacity:1.0},500);$(countyImage).siblings().animate({opacity:1.0},500)}function hideCounty(countyImage){$(countyImage).stop().animate({opacity:0.0},0);$(countyImage).siblings().animate({opacity:0.0},0)}function hideAllCounties(){var counties=$('#map-holder').children('div');for(var i=0;i<counties.length;i++){hideCounty($(counties[i]).children('img')[0])}}$(document).ready(function(){var preloader=document.createElement('div');$('#map-holder').append(preloader);$(preloader).attr('id','preloader');$.ajax({beforeSend:function(xhrObj){xhrObj.setRequestHeader("Content-Type","application/json")},cache:false,timeout:100000,type:'GET',url:DATA_SOURCE,dataType:'json',success:function(data){$.each(data.countyData,function(i,item){var container=document.createElement('div');$('#map-holder').append(container);$(container).attr('id','div'+item.data_county);$(container).attr('class',CSS_WRAPPER_CLASS);$(container).attr('style','left:'+item.data_x+'px; top:'+item.data_y+'px;');var countyImage=document.createElement('img');$(container).append(countyImage);$(countyImage).attr('id',item.data_county+'Image');$(countyImage).attr('class',CSS_IMAGE_CLASS);$(countyImage).attr('src',IMAGE_PATH+item.data_county_image+'.png');$(countyImage).load(function(){$(this).attr('width',countyImage.width);$(this).attr('height',countyImage.height)});$(countyImage).hover(function(){_isHovering=true;hideCounty(_autoSelectedCounty);showCounty($(this))},function(){_isHovering=false;hideCounty($(this))});$(countyImage).click(function(){window.location.href=item.factsLink});var countyInfo=document.createElement('div');$(container).append(countyInfo);$(countyInfo).attr('id',item.data_county+'Info');$(countyInfo).attr('class',CSS_INFO_CLASS);var countyName=item.data_county.toUpperCase();if(countyName=='SAINTLOUISCITY'){countyName='ST. LOUIS CITY'}else{if(countyName.indexOf("SAINT")>-1){countyName="ST. "+countyName.substr(5)}countyName+=" COUNTY"}if(item.story_link=='no'){$(countyInfo).html('<strong>'+countyName+'</strong><br />'+item.data_total_students+' UM Students<br />'+item.data_total_alumni+' UM Alumni<br />'+'$'+item.economicImpact+' Economic Impact<br /><em>Click County For More...</em>')}else{$(countyInfo).html('<strong>'+countyName+'</strong><br />'+item.data_total_students+' UM Students<br />'+item.data_total_alumni+' UM Alumni<br />'+'$'+item.economicImpact+' Economic Impact<br /><strong>Latest story:</strong><br /><img src="'+item.story_link+'" alt="story" height="75" width="110"><br />'+item.story_title+'<em><br />Click County For More...</em>')}})}});$('#preloader').animate({opacity:0.0},1000);setInterval(highlightRandomCounty,ROTATION_INTERVAL*1000)});
