var map; var loc;

function handle(delta) {
        if (delta < 0)
		map.zoomOut();
        else
		map.zoomIn();
}

/** Event handler for mouse wheel event. */
function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

function createLocation(location){
	var text = "";
	switch(location){
		case "northarlington" :
		loc = new GLatLng(32.748800, -97.117100);
		text = "Arlington Memorial Hospital<br/>1001 Waldrop Drive<br/>Suite 708<br/>Arlington, Texas 76012<br/>817.465.0373";
		break;
		
		case "usmd" :
		loc = new GLatLng(32.679600, -97.118200);
		text = "USMD Hospital<br/>811 West Interstate 20<br/>Suite 114<br/>Arlington, Texas 76017<br/>817.465.0373";
		break;
		
		case "trinity" :
		loc = new GLatLng(33.027681, -96.884887);
		text = "Trinity Medical Center<br/>4325 N. Josey Lane<br/>Plaza III, Suite 306<br/>Carrollton, TX 75010<br/>972.401.4940";
		break;
		
		case "cleburne" :
		loc = new GLatLng(32.343339, -97.426909);
		text = "Cleburne Clinic<br/>829 N. Nolan River<br/>Cleburne, Texas 76033<br/>817.465.0373";
		break;
		
		case "denton" :
		loc = new GLatLng(33.175707, -97.088177);
		text = "Denton Clinic<br/>2817 Mayhill Rd Ste. 220<br/>Denton, Texas 76210<br/>940.383.8268";
		break;
		
		case "desoto" :
		loc = new GLatLng(32.645681, -96.879308);
		text = "Methodist Charlton Hospital<br/>935 York Drive<br/>DeSoto, TX 75115<br/>972.709.1876";
		break;
		
		case "medicalcity" :
		loc = new GLatLng(32.909730, -96.772921);
		text = "Medical City<br/>7777 Forest Lane<br/>Suite C-618<br/>Dallas, TX 75230<br/>972.566.7771";
		break;
		
		case "terrell" :
		loc = new GLatLng(32.735800, -97.339900);
		text = "Downtown Medical District<br/>1325 Pennsylvania Ave.<br/>Suite 450<br/>Fort Worth, TX 76104<br/>817.465.0373";
		break;
		
		case "pedi" :
		loc = new GLatLng(32.738000, -97.339900);
		text = "Pediatric - Downtown Medical District<br/>1325 Pennsylvania Avenue<br/>Suite 550<br/>Fort Worth, Texas 76104<br/>817.465.0373";
		break;
		
		case "huguley" :
		loc = new GLatLng(32.585700, -97.317300);
		text = "Huguley Hospital<br/>11803 South Freeway<br/>Suite 206<br/>Fort Worth, Texas 76134<br/>817.465.0373";
		break;
		
		case "hsw" :
		loc = new GLatLng(32.658500, -97.421300);
		text = "Harris Methodist Southwest<br/>6100 Harris Parkway<br/>Suite 265<br/>Fort Worth, Texas 76132<br/>817.465.0373";
		break;
		
		case "grapevine" :
		loc = new GLatLng(32.935739, -97.091997);
		text = "Baylor Regional Medical Center<br/>1600 W. College<br/>Suite 190<br/>Grapevine, TX 76051<br/>817.465.0373";
		break;
		
		case "grandprairie" :
		loc = new GLatLng(32.835174, -97.04052);
		text = "Medical Center at Riverside<br/>2210 N. Highway 360<br/>Grand Prairie, TX 75050<br/>817.465.0373";
		break;
		
		case "heb" :
		loc = new GLatLng(32.834100, -97.123800);
		text = "Harris Methodist HEB<br/>1604 Hospital Parkway<br/>Suite 201 & Suite 202<br/>Bedford, Texas 76022<br/>817.465.0373";
		break;
		
		case "lascolinas" :
		loc = new GLatLng(32.904146, -96.958101);
		text = "Las Colinas Medical Center<br/>7200 State Hwy 161<br/>Suite 200<br/>Irving, TX 75039<br/>972.401.4940";
		break;
		
		case "mansfield" :
		loc = new GLatLng(32.570000, -97.110000);
		text = "Mansfield Clinic<br/>309 Regency Pkwy<br/>Mansfield, TX 76063-5165<br/>817.465.0373";
		break;
		
		case "nrh" :
		loc = new GLatLng(32.828500, -97.213200);
		text = "North Hills Hospital<br/>4375 Booth Calloway Rd.<br/>Suite 510<br/>North Richland Hills, TX 76180<br/>817.465.0373";
		break;
		
		case "plano" :
		loc = new GLatLng(33.014296, -96.791332);
		text = "Baylor Regional Medical Center<br/>4708 Alliance Blvd<br/>Pavillion I, Suite 685<br/>Plano, TX 75093-5340<br/>972.401.4940";
		break;
		
		case "saginaw" :
		loc = new GLatLng(32.870631, -97.374980);
		text = "Saginaw Clinic<br/>833 Towne Court<br/>Saginaw, Texas 76179<br/>817.465.0373";
		break;
		
		case "waxahachie" :
		loc = new GLatLng(32.399807, -96.865130);
		text = "Waxahachie Clinic<br/>1626 W Highway 287 Business Ste. 103<br/>Waxahachie, Texas 75165-4712<br/>817.465.0373";
		break;
		
		case "weatherford" :
		loc = new GLatLng(32.748600, -97.781500);
		text = "Weatherford Clinic<br/>925 Santa Fe<br/>Suite 114<br/>Weatherford, Texas 76086<br/>817.784.0818";
		break;
		
	}//end switch
		map.setCenter( loc, 14 );
		var location = new GMarker( loc );
		map.addOverlay( location );
		GEvent.addListener(location, "click", function(){ location.openInfoWindowHtml(text);} );
}

function updateMap(){
	map.checkResize();
	map.setCenter( loc, 14 );
}

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		var locations = document.getElementById('map').className.split(" ");
		for(var i=0; i < locations.length; i++){
			createLocation(locations[i]);
		}
		if( locations.length > 1 ){
			map.setCenter( new GLatLng(32.710000,-97.160000) , 9 );
		}
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
	}
	//Mouse control
	if (document.getElementById('map').addEventListener){
		/** DOMMouseScroll is for mozilla. */
		document.getElementById('map').addEventListener('DOMMouseScroll', wheel, false);
	}
	else{
		/** IE/Opera. */
		document.getElementById('map').onmousewheel = document.onmousewheel = wheel;
	}
}
