var map=null;var layerid=1;var internshipsAdded=false;var mapCentered=false;function DisposeMap(){if(map!=null){map.Dispose();internshipsAdded=false;mapCentered=false;}}
function GetMap(){map=new VEMap('myMap');map.LoadTraffic(true);map.SetDashboardSize(VEDashboardSize.Small);map.LoadMap(new VELatLong(41.99070090282912,-91.65687519156944),12,"r");map.AttachEvent("onendpan",PopulateMap);}
function FindNearby(search){try{map.Find(search,null);}
catch(e){}}
function AddMyLayer(type,value){var l=new VEShapeLayer();var veLayerSpec=new VEShapeSourceSpecification(type,value,l);map.ImportShapeLayerData(veLayerSpec,onFeedLoad);}
function AddInternshipListings(){if(internshipsAdded!=true){var l=new VEShapeLayer();var veLayerSpec=new VEShapeSourceSpecification(VEDataType.GeoRSS,"/wp-content/plugins/portal/internship-georss.php",l);map.ImportShapeLayerData(veLayerSpec,onInternshipFeedLoad);internshipsAdded=true;}}
function onInternshipFeedLoad(layer){var shapeCount=layer.GetShapeCount();for(var i=0;i<shapeCount;i++){var shape=layer.GetShapeByIndex(i);var icon="<img src=\'/map-pushpin.png\'/>";shape.SetCustomIcon(icon);}}
function onFeedLoad(layer){}
function PopulateMap(search){AddInternshipListings();if(search!=''&&typeof search=='string'){savedSearch=search;FindNearby(search);}
if(typeof savedSearch=='string')
FindNearby(savedSearch);}
function CenterMap(pinTitle){if(typeof pinTitle=='string'&&pinTitle!=''&&mapCentered!=true){layer=map.GetShapeLayerByIndex(1);pinCount=layer.GetShapeCount();for(id=0;id<pinCount;id++){shape=layer.GetShapeByIndex(id);title=shape.GetTitle();description=shape.GetDescription();if(title==pinTitle||description.indexOf(pinTitle)!=-1){map.SetCenter(shape.GetPoints()[0]);}}
mapCentered=true;}}
function initializeMap(search,pinTitle){DisposeMap();setTimeout('GetMap();',1000);jQuery('#myMap').css('opacity','0.4');setTimeout('jQuery("#myMap").css("opacity","0.4");',1000);setTimeout('jQuery("#myMap").css({"opacity":"1","filter":""});',4000);setTimeout('PopulateMap("'+search+'");',4000);if(!jQuery.browser.msie)
setTimeout('CenterMap("'+pinTitle+'");',6000);};
