﻿$(document).ready(function () {

	// by Location -------------------------------------------------------------------------------------------------------------
	$('#LocImage').css('display', 'none');

	$('#Loclist li').each(function () {
		var link = $(this).children('a');
		var image = $(link).attr('image-name');
		var slide = parseInt($(this).attr('id'));

		// add mouseover, mouse click
		$(link).bind({
			click: function () {
				$('#Info').cycle(slide);

				//            },
				//            mouseenter: function () {
				$('#LocImage').css('display', 'block');
				$('#LocImage').attr('src', image);
				return false;
			}
		});
	});

	// by Specialty ---------------------------------------------------------------------------------------------------------------
	$('#Speclist li').each(function () {
		var link2 = $(this).children('a'); // grab link name
		var slide2 = parseInt($(this).attr('class'));  // set slide # by class #
		var Spec = $(link2).text();  // set specialty name by link name
		var hasPage = $(link2).attr('data-hasPage');

		// add mouseover, mouse click
		$(link2).bind({
			click: function () {
				$('#Info').cycle(slide2);

				// change slide header 
				$('.specPage').html(Spec);


				// activate and change department link if it exists (except Pediatrics)
				if ((hasPage != 'false') && (Spec != 'Women\'s Health') && (Spec != 'Pediatrics') ) {
					$('.specLink').css('display', 'inline');
					$('.specLink').attr('href', Spec + '.aspx');
					return false;
				}
				// special link for Pediatrics/Women's external site
				else if (Spec == 'Pediatrics') {
					$('.specLink').css('display', 'inline');
					$('.specLink').attr('href', 'http://www.cshpkids.net');
					return false;
				}
				else if (Spec == 'Women\'s Health') {
					$('.specLink').css('display', 'inline');
					$('.specLink').attr('href', 'http://www.cshpwomenshealth.net/');
					return false;
				}
				// disable link if it doesn't exist
				else {
					$('.specLink').css('display', 'none');
					return false;
				}
			}
		});
	});

});
