//TEXT SIZER
function addTextSizer() {
	$('#PageToolsWrapper').append('<div id="TextSizer" class="ClearFix"><ul>' +
				'<li><a class="NormalFont" href="javascript:;" title="Small Font Size"></a></li>' +
				'<li><a class="LargeFont" href="javascript:;" title="Medium Font Size"></a></li>' +
				'<li><a class="X-LargeFont" href="javascript:;" title="Large Font Size"></a></li>' +
			'</ul></div>');
	$('a.NormalFont').click(function() {$('#Content').removeClass('textLarge').removeClass('textXLarge');$.cookie('text_sizer', null, { path: '/' });});
	$('a.LargeFont').click(function() {$('#Content').addClass('textLarge').removeClass('textXLarge');$.cookie('text_sizer', 'large', { path: '/' });});
	$('a.X-LargeFont').click(function() {$('#Content').removeClass('textLarge').addClass('textXLarge');$.cookie('text_sizer', 'xlarge', { path: '/' });});
	$('#TextSizer a').click(function() {$('#TextSizer a').removeClass('active');$(this).addClass('active');});
}

function text_size_checker() {
	var text_sizer_cookie = $.cookie('text_sizer');
	if (text_sizer_cookie==null){$('a.NormalFont').addClass('active')};
	if (text_sizer_cookie=='large'){ $('#Content').addClass('textLarge');$("a.LargeFont").addClass('active') };
	if (text_sizer_cookie=='xlarge'){ $('#Content').addClass('textXLarge');$("a.X-LargeFont").addClass('active') };
}

// Add Page Tools
function addPageTools() {
    var urlToUse = (('https:' == document.location.protocol) ? 'https://s7.addthis.com/js/250/addthis_widget.js?pub=deanhealth' : 'http://s7.addthis.com/js/250/addthis_widget.js?pub=deanhealth');
    var imgPath = '/imgs/icons/';
    $('#PageToolsWrapper').append('<div id="PageTools">' +
		'<ul>' +
		    '<li class="Print"><a href="#">Print</a></li>' +
			'<li class="Email"><a href="#">Email</a></li>' +
			'<li class="AddThis">' +
			    '<!-- AddThis Button BEGIN -->' +
                    '<a href="http://www.addthis.com/bookmark.php?v=250&amp;pub=deanhealth" rel="nofollow" class="addthis_button_expanded"><img src="/imgs/icons/addthis.gif" alt="Bookmark and Share" style="border:0"/></a>' +
                    '<script type="text/javascript" src="' + urlToUse + '"></script>' +
				'<!-- AddThis Button END -->' +
			'</li>' +
		'</ul>' +
	'</div>');
    var clientDomainName = 'deancare.com';
    var clientSiteName = 'Dean';
    var titleEl = document.getElementsByTagName('title')[0];
    var currentPageTitle = '';
    if (titleEl.text) { currentPageTitle = titleEl.text; } else { currentPageTitle = title.data; }
    currentPageTitle = escape(currentPageTitle);
    var currentPageUrl = document.location;
    var emailSubject = clientDomainName + ': ' + currentPageTitle;
    var emailHref = 'mailto:?subject=' + emailSubject + '&body=I thought you would be interested in a page on the ' + clientSiteName + ' Web site: ' + currentPageTitle + ' - ' + currentPageUrl;
    $('li.Email a').attr({ href: emailHref });
    $('li.Print a').click(function() { print(); return false; });
}

// Add Accordion
function initAccordion() {
    $('ul.Accordion li a:not("ul.Accordion ul li a")').wrapInner('<span></span>');
    $('ul.Accordion ul').hide();
    $.each($('ul.Accordion'), function() {
        $('#' + this.id + '.expandfirst ul:first').show().parent().addClass('Open');
    });
    $('ul.Accordion li a').click(
		function() {
		    var checkElement = $(this).next();
		    var parent = this.parentNode.parentNode.id;

		    if ($('#' + parent).hasClass('noaccordion')) {
		        $(this).next().slideToggle('fast').parent().toggleClass('Open');
		        return false;
		    }
		    if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
		        if ($('#' + parent).hasClass('collapsible')) {
		            $('#' + parent + ' ul:visible').slideUp('fast').parent().removeClass('Open');
		        }
		        return false;
		    }
		    if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		        $('#' + parent + ' ul:visible').slideUp('fast').parent().removeClass('Open');
		        checkElement.slideDown('fast').parent().addClass('Open');
		        return false;
		    }
		});
}

function dynamicVideoPlayer(){
// markup to use: <a class="VideoLink" href="video/widescreen.mp4" title="height=288;width=512;aspect=16x9;hideControls=true;imageFilename=video/widescreen.jpg;">Video</a>
	String.prototype.startsWith = function(str) {return (this.match("^"+str)==str);}; // this creates a function that can be used to check if a string starts with a value
	// for each a.VideoLink, put a player in place
	$('a.VideoLink').each(function(n){
		var divID = 'videoID'+n;
			$(this).wrap('<div class="DynamicVideoPlayer" id="' + divID + '"></div>');
		var filename = $(this).attr('href');
		var vars = $(this).attr('title').replace(/\s+/g,'');
		var varArray = vars.split(";");
		var height, width, aspect, hideControls, imageFilename, theImage;
		height = width = aspect = hideControls = imageFilename = theImage = '';
		
		var cnt = 0;
		while (cnt < varArray.length) {
			if (varArray[cnt].toLowerCase().startsWith('height=')) { height = varArray[cnt].toLowerCase().replace(/height=/g,''); }
			if (varArray[cnt].toLowerCase().startsWith('width=')) { width = varArray[cnt].toLowerCase().replace(/width=/g,''); }
			if (varArray[cnt].toLowerCase().startsWith('aspect=')) { aspect = '_' + varArray[cnt].toLowerCase().replace(/aspect=/g,''); }
			if (varArray[cnt].toLowerCase().startsWith('hidecontrols=')) { hideControls = varArray[cnt].toLowerCase().replace(/hidecontrols=/g,''); }
			if (varArray[cnt].toLowerCase().startsWith('imagefilename=')) { imageFilename = varArray[cnt].toLowerCase().replace(/imagefilename=/g,''); }
			cnt+=1;
		}
		if (height < 0 || height > 600) { height = "240"; }
		if (width < 0 || width > 800) { width = "360"; }
		if ( aspect.length && !(aspect == '_4x3' || aspect == '_16x9' || aspect == '_1x1') ) { aspect = "_4x3"; }
		if (hideControls !== 'true' && hideControls !== 'false') { hideControls = 'false'; }
		if (imageFilename.length > 0 ) { theImage = 'imageFilename=' + imageFilename + '&'; }
			
		var so = new SWFObject('/video/videoPlayer' + aspect + '.swf?videoURL=' + filename, 'swf', width, height, '7' );
		so.addParam('wmode', 'transparent');
		so.addParam('FlashVars', theImage + 'hideControls=' + hideControls);
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');	
		so.write(divID);
	});
}


$(document).ready(function() {

	addTextSizer();
	text_size_checker();
	addPageTools();
	initAccordion();
	dynamicVideoPlayer();


// Function: CREATE AN ARRAY FROM SELECTED ELEMENTS' ATTRIBUTES - used in POPUP IMAGE (below)
$.fn.attrs = function(key, val){
        if (val != undefined)
                return this.attr(key, val);
        return $.map(this, function(a){
                return $(a).attr(key);
        });
}

//POPUP IMAGE FOR PLASTIC SURGERY PAGES
	$('.compareImgs img').each(function(){
	   $(this).click(function(){
			var index = $(this).parents('div.compareImgs').find('img').index($(this));
			var imgGrp = $(this).parents('div.compareImgs').find('img').size()-1;
			var img = '<img width="664" width="500" class="' + index + '" src="' + $(this).attr('name') + '"/>'
			var closeIt = '<div id="ImgClose"></div>'
			var nav = ''
			if (imgGrp>0){
				 if(index==0)
					{nav = '<div id="Nav" class="next"></div>'}
					else
					{nav = '<div id="Nav" class="prev"></div>'}
			}
			var popup = '<div class="popUpCompare"><div id="theNav">' + closeIt + nav + '</div><div id="ImgHolder" class="loading"><div class="theImage" id="' + imgGrp + '"><span class="' + index + '">' + img + '</span></div></div><div class="theTitle">' + $(this).attr('alt') + '</div></div>'
			$('div.popUpCompare').fadeOut('fast', function() { $(this).remove(); });
			$(this).parents('div.compareImgs').prepend(popup);
			$('#ImgHolder img').load(function(){
				$(this).parent('#ImgHolder').removeClass('loading');
				$(this).fadeIn();
			});
		}); 
	});
	// NEXT/PREVIOUS IMAGE BUTTON CONTROL	
	$('#theNav #Nav').live('click',function(){
		var NXT = 0
		if ($(this).hasClass('next')){NXT=1;$(this).removeClass().addClass('prev')}else{NXT=-1;$(this).removeClass().addClass('next')}
		var arr =  $(this).parents('.compareImgs').find('ul img[name]').attrs('name')
		var TitleArray =  $(this).parents('.compareImgs').find('ul img[alt]').attrs('alt')
		var theId = $('.popUpCompare .theImage').attr('id')
		var theImg = $('.popUpCompare .theImage span').attr('class')
		var nextImg = parseInt(theImg)+NXT
		nextImg+=''
		$('#ImgHolder div.theImage img').hide().attr('src', arr[nextImg]).load(function(){$(this).fadeIn();});
		$('div.popUpCompare div.theTitle').html(TitleArray[nextImg]);
		$('div.popUpCompare div.theImage span').removeClass().addClass(nextImg);
	});
	// CLOSE THE WINDOW
	$('#theNav #ImgClose').live('click',function(){
		$(this).parents('div.popUpCompare').fadeOut('fast', function() { $(this).remove(); });
	});
	$(document).keydown(function(e) {
		// ESCAPE key pressed
		if (e.keyCode == 27) {
			$('div.popUpCompare').fadeOut('fast', function() { $(this).remove(); });
		}
	});


// A jumpmenu that will either 
//     1: show a hidden div with the class of 'Hidden' plus a # (<div class="Hidden1">) 
//     2: load the url listed in the option value in the current window.
//     3: load the url listed in the option value in a NEW window.

	$('.JumpMenu')
		.attr('selectedIndex', 0)
		.change(function() {
        var val = $(this).val();
        if (val != '') {
			if (val.indexOf('Hidden')>=0){ // Option 1: Hide all divs with class*=Hidden and show the one selected
				$('*[class*="Hidden"]').hide();
				$('.'+val).fadeIn('slow');
			}
			else {
				if ($(this).children('option:selected').attr('class').toLowerCase()=='new') {
					window.open(val);  // Option 3: if <option class="new"> then open url in a NEW window
				}
				else {
					location.href=val; // Option 2: go to url 
				} // end if: class=new
			} // end if: Option 1
        } // end if: val not empty
    });
	$('*[class*="Hidden"]').hide(); // HIDE ALL DIVS WITH THE CLASS NAME OF *Hidden*

	
// Add Basic Search to the Advanced Search page....	
// Markup to look like this:
//	<div id="basicSearch">
//		<input type="text" name="keyword" id="theKeyword">
//		<input type="hidden" value="/doctors-locations/medicare gold/basic-search-results.aspx" id="theSearchPage">
//		<input type="hidden" value="Name, Specialty, City, and ZIP Code" id="thisInputText">
//		<input type="button" value="Search" id="basicSearchButton" class="Button">
//	</div>
  
	$('#basicSearch').each(function(){
		var thisInputText = $(this).children('input#thisInputText').val()
		var theInput = $('#basicSearch input#theKeyword')
		if (thisInputText.length){theInput.val(thisInputText)}
	});
	
	$('#basicSearch input#theKeyword')
		.bind('focus', function() {
			var thisInputText = $(this).siblings('input#thisInputText').val()
			if ($(this).val()==thisInputText){ $(this).val('') }
		})
		.bind('blur', function() {
			var thisInputText = $(this).siblings('input#thisInputText').val()
			if ($(this).val()==''){ $(this).val(thisInputText) }
		});
	
	$('#basicSearch #basicSearchButton').click(function(){
		var thisInputText = $(this).siblings('input#thisInputText').val()
			if (thisInputText.length==0) {thisInputTest = ''}
		var kword = $(this).siblings('#basicSearch input#theKeyword').val();
		if (kword.length && kword != thisInputText){
			var domainURL = jQuery.url.attr('host') // returns 'mysite.com'
			var searchPage = $(this).siblings('#basicSearch input#theSearchPage').val();
			window.location = ('http://' + domainURL + searchPage + '?sort=7&keyword=' + kword);
		}
		else{
			$('#basicSearch').prepend('<div style="color:red" class="error">Please enter in your search criteria.</div>');
		}
	});
		
	$('#basicSearch input#theKeyword').bind('keypress', function(e) {
		if (e.keyCode == 13) {
			e.preventDefault();
			var thisInputText = $(this).siblings('input#thisInputText').val()
				if (thisInputText.length==0) {thisInputTest = ''}
			var kword = $(this).val();
			if (kword.length && kword != thisInputText){
				var domainURL = jQuery.url.attr('host') // returns 'mysite.com'
				var searchPage = $('#basicSearch input#theSearchPage').val();
				window.location = ('http://' + domainURL + searchPage + '?sort=7&keyword=' + kword);
			}
			else{ 
				$('#basicSearch').prepend('<div style="color:red" class="error">Please enter in your search criteria.</div>');
			}
		}
	});
	$('#basicSearch input#theKeyword').bind('keypress', function(e) {
		$(this).siblings($('.error:visible').slideUp());																	 
	});
	
	
// Provider Services Dropdown widget	
	$('.dropdown dt a').click(function() {$('.dropdown dd ul').toggle(); });
	$('.dropdown dd ul li a').click(function() {
		var text = $(this).html();
		$('.dropdown dt a span').html(text);
		$('.dropdown dd ul').hide();
		$('#result').html('' + getSelectedValue('sample'));
	});
	function getSelectedValue(id) {return $('#' + id).find('dt a span.value').html(); }
	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass('dropdown')){ $('.dropdown dd ul').hide();}
	});
			

	// FIX DROP DOWNS IN IE
		$('select').each(function(){ 
			$(this).IELongDropDown(); 
		 });

}); // <-- END DOCUMENT READY



// FIX DROP DOWN BOXES IN IE SO THEY ACT LIKE FIREFOX DROP DOWNS (<SELECT>)
(function($) {
    $.fn.IELongDropDown = function(cln) {
        if ($.browser.msie) { //only IE has problems with long select boxes
            var el = this;
            var previousWidth = el.width();
			if(previousWidth>0){
				var divWrapper = '<div style="padding:0;margin:0;overflow:hidden;width:'+ previousWidth +'px"></div>';
				el.wrap(divWrapper);
				var newWidth = el.width('auto').width();
				el.width(previousWidth);
				if(newWidth > previousWidth && $.browser.version!='6.0') {
					el.bind('mousedown', function(){ return el.width('auto').focus(); }); 
					el.bind('blur', function(){ return el.width(previousWidth); });
					el.bind('change', function(){ return el.width(previousWidth); });
				}
				else if(newWidth > previousWidth && $.browser.version=='6.0') {  
					el.bind('focusin',function(){el.width('auto').focus();});
					el.blur(function(){el.width(previousWidth);});
//					el.bind('mousedown', function(){ return el.width('auto').focus(); }); 
//					el.bind('blur', function(){ return el.width(previousWidth); });
//					el.bind('change', function(){ return el.width(previousWidth); });
				}
			} 
        } 
        return this;
    };
})(jQuery);

$(document).ready(function() {
    // Proximity Nav (interior pages)
    // Removing ul from Proximity Nav if on site search page. Needs to be above other Prox Nav js.
    if ($('#SiteSearchContainer').length > 0) {
        $('#ProximityNav ul').remove();
    }
    // Removing Proximity Nav if on page not in subsection. Needs to be above other Prox Nav js.
    if ($('#Breadcrumbs p a[href]').length < 2) {
        $('#ProximityNav').addClass('Remove');
    }
    // Adding Proximity Nav back if on En Espanol page. Needs to be above other Prox Nav js.
    $('#Breadcrumbs strong')
        .andSelf()
        .contents()
        .filter(function() {
            return this.nodeType === 3;
        })
        .filter(function() {
            // Only match when contains 'simple string' anywhere in the text
            return this.nodeValue.indexOf('En') != -1;
        })
        .each(function() {
            // Do something with this.nodeValue
            $('#ProximityNav').removeClass('Remove');
        });

    //Proximity Nav adding anchor button for dropdown and extra div for styling
    $('#ProximityNav ul:first').before('<a id="ProxNavButton" class="Toggle"><span>In This Section</span></a>');
    $('#ProximityNav').wrapInner('<div class="ClearFix"></div>');
});
// Proximity Nav (interior pages)
function proxNav() {
    $('#ProximityNav div').hover(
		function() {
		    $('#ProximityNav ul').slideDown('fast');
		    $('#ProximityNav a.Toggle').addClass('over');
		},
		function() {
		    $('#ProximityNav ul').slideUp('fast');
		    $('#ProximityNav a.Toggle').removeClass('over');
		}
	);
}

// Slide Tabs (landing page)
function slideTabs() {
    var _holder = $('#carousel');
    if (_holder.length) {
        var _btn = _holder.find('.nav > li');
        var _list = _holder.find('.carousel > li');
        var _a = _btn.index(_btn.filter('.active:eq(0)'));
        if (_a == -1) _a = _list.length - 1;
        _list.removeClass('active').hide().eq(_a).addClass('active').show();
        var _step = _list.parent().width();
        _btn.each(function(_i) {
            var _el = $(this);
            var _i = _i;
            var _t;
            _el.mouseenter(function() {
                if (_t) clearTimeout(_t);
                _t = setTimeout(function() {
                    if (_i != _a) {
                        _btn.removeClass('active');
                        _el.addClass('active');
                        if (_i > _a || _a == _list.length - 1) {
                            _list.eq(_a).stop().animate({ left: -_step }, 400, function() {
                                $(this).css({ display: 'none', left: '0' });
                            });
                            _list.eq(_i).stop().css({ display: 'block', left: _step }).animate({ left: 0 }, 400);
                        }
                        else {
                            _list.eq(_a).stop().animate({ left: _step }, 400, function() {
                                $(this).css({ display: 'none', left: '0' });
                            });
                            _list.eq(_i).stop().css({ display: 'block', left: -_step }).animate({ left: 0 }, 400);
                        }
                        _a = _i;
                    }
                }, 400);
            }).mouseleave(function() {
                if (_t) clearTimeout(_t);
            });

        });
    }
}

// homeTabs
var homeTabs = { height: 85, interval: null, tabHeight: 0 };
function homeTabs_init() {
    $('#homeTabs').removeClass();
    $('#homeTabSlider .homeTabs a').click(function() {
        var tab = this.parentNode.className;
        var homeTabsElem = document.getElementById('homeTabs');
        if (homeTabs.height == 85 || homeTabsElem.className != tab) {
            homeTabsElem.className = tab;
            homeTabs.tabHeight = $('#homeTabSlider .homeTabContent .' + tab).height() + 100;
            if (homeTabs.tabHeight > 450) {
                homeTabs.tabHeight = 450;
            }
            document.getElementById('homeTabSlider').style.zIndex = '700';
            clearInterval(homeTabs.interval);
            homeTabs.interval = setInterval('homeTabs_grow()', 25);
        }
        else {
            clearInterval(homeTabs.interval);
            homeTabs.interval = setInterval('homeTabs_shrink()', 25);
        }
        return false;
    });
    $('#homeTabSlider .close a').click(function() {
        clearInterval(homeTabs.interval);
        homeTabs.interval = setInterval('homeTabs_shrink()', 25);
        return false;
    });
}
function homeTabs_grow() {
    var slider = document.getElementById('homeTabSlider');
    if (homeTabs.height < homeTabs.tabHeight) {
        homeTabs.height = homeTabs.height + ((homeTabs.tabHeight - homeTabs.height) / 10) + 1;
        if (homeTabs.height >= homeTabs.tabHeight) {
            homeTabs.height = homeTabs.tabHeight;
            slider.style.height = homeTabs.height + 'px';
            clearInterval(homeTabs.interval);
        }
        else {
            slider.style.height = homeTabs.height + 'px';
        }
    }
    else {
        homeTabs.height = homeTabs.height - ((homeTabs.height - homeTabs.tabHeight) / 10) - 1;
        if (homeTabs.height <= homeTabs.tabHeight) {
            homeTabs.height = homeTabs.tabHeight;
            slider.style.height = homeTabs.height + 'px';
            clearInterval(homeTabs.interval);
        }
        else {
            slider.style.height = homeTabs.height + 'px';
        }
    }
}
function homeTabs_shrink() {
    var slider = document.getElementById('homeTabSlider');
    homeTabs.height = homeTabs.height - ((homeTabs.height - 85) / 10) - 1;
    if (homeTabs.height <= 85) {
        homeTabs.height = 85;
        slider.style.height = '85px';
        clearInterval(homeTabs.interval);
        document.getElementById('homeTabSlider').style.zIndex = '0';
        $('#homeTabs').removeClass();
    }
    else {
        slider.style.height = homeTabs.height + 'px';
    }
}



$(document).ready(function() {

    // ----------- TEMPLATE EXTRAS ------------------//

    proxNav();
    slideTabs();

    if (document.getElementById('homeTabs')) {
        homeTabs_init();
    }

    //hiding containers if empty
    $('#BelowLeft:empty').remove();
    $('#BelowRight:empty').remove();
    $('#BottomPanels:empty').remove();
    $('#LandingLeftWide:empty').remove();
    $('#LandingLeft:empty').remove();
    $('#LandingMiddle:empty').remove();
    $('#LandingRight:empty').remove();
    $('#LandingRightWide:empty').remove();
    $('#LandingWide:empty').remove();
    $('body.Landing #CurveRight').insertBefore('.nav');
    $('body.Landing #CurveLeft').insertBefore('.nav');

    // Adding class for first header in col 3 to get purple style
    $('#Col3 .cmspanel').each(function() { $(this).children(':header').eq(0).not('thead :header').addClass('PanelHeader'); });
    $('#Col3 .cmsPanelContent').each(function() { $(this).children(':header').eq(0).not('thead :header').addClass('PanelHeader'); });
    // Adding class to panel with Panel Buttons so that we can remove margins between.
    $('.PanelButton').parent().addClass('NoMargin');
    // Removing empty header elements (this is to fix smartpanels/forms that have empty h2s)
    $('.cmspanel h2:empty').remove();
    // Hide the HeaderIcons if aesthetic-surgery-center shows up in the url
    var thisDir = $.url.attr('directory')
    if (thisDir.indexOf('aesthetic-surgery-center') > 0) {  // if the word 'aesthetic-surgery-center' exists in the url path anywhere, then do this
        $('#HeaderIcons a').remove();
    }
	// If the URL has the anchor #classes, add .Open to the parent li of the anchor and open ul
    if(location.href.indexOf("#classes") != -1) {
      $('a.classes').parent().addClass('Open');
      $('li.Open ul').css({ display: 'block'});
    } else {
      // Fragment doesn't exist
    }


    // ----------- HACK LIST START ------------------//

    // LOCATIONS SAVE KEYWORD IN QUERYSTRING
    $('.LocationsTabs li.Tabactive a').click(function() { return false; }); // ignore the current tab

    var theKeyword = $.url.param('keyword'); // get the keyword from the querystring
    var theKeyword2 = $.url.param('keyword2'); // get the keyword2 from the querystring (exists if Next/Previous button was clicked)
    var theSort = $.url.param('sort'); // get the sort parameter from the querystring
    if (theSort == '' || theSort == null) { theSort = '13' } // set sort to 13 if it's not there
    var thePage = $.url.param('page'); // get the sort parameter from the querystring

    // if keyword exists then append all fake tab links with keyword and sort from querystring
    if (theKeyword != '' && theKeyword != null) {
        $('.LocationsSearchTextBox').val(theKeyword);
        $('.LocationsTabs li,').not('.Tabactive').each(function() { var thisHref = $(this).children('a').attr('href'); $(this).children('a').attr('href', thisHref + '&keyword=' + theKeyword + '&sort=' + theSort); });
        // also, add the keyword variable to the location detail links
        $('.LocationsList li a.Picture, .LocationsList li a.Name').each(function() { var thisHref = $(this).attr('href'); $(this).attr('href', thisHref + '&keyword2=' + theKeyword); });
        // also, add the keyword2 variable to the querystring on the Next/Previous links
        $('.Paging .BackNext a').each(function() { var thisHref = $(this).attr('href'); $(this).attr('href', thisHref + '&keyword2=' + theKeyword); });
    }
    else {
        // if keyword doesnt exist but keyword2 does, then append all fake tab links with keyword and sort from querystring
        if (theKeyword2 != '' && theKeyword2 != null) {
            $('.LocationsSearchTextBox').val(theKeyword2);
            $('.LocationsTabs li').not('.Tabactive').each(function() { var thisHref = $(this).children('a').attr('href'); $(this).children('a').attr('href', thisHref + '&keyword=' + theKeyword2 + '&sort=' + theSort); });
            // also, add the keyword variable to the location detail links
            $('.LocationsList li a.Picture, .LocationsList li a.Name').each(function() { var thisHref = $(this).attr('href'); $(this).attr('href', thisHref + '&keyword2=' + theKeyword2); });
            // also, add the keyword2 variable to the querystring on the Next/Previous links
            $('.Paging .BackNext a').each(function() { var thisHref = $(this).attr('href'); $(this).attr('href', thisHref + '&keyword2=' + theKeyword2); });
            // also, add the keyword2 variable to the querystring on the return to search results links on the detail page
            $('#LocationsDetail p.ReturnToResults a').each(function() { var thisHref = $(this).attr('href'); $(this).attr('href', thisHref + '?keyword2=' + theKeyword2); });
        }
    }

    // Okay, the Dean doesn't want to show the silhouette images... so, let's hide them with transparent gifs
    $('#DrDetail .QuickInfo img').each(function() {
    if ($(this).attr('src') == '../../imgs/doctors/silhouette_malebig.gif' || $(this).attr('src') == '../../imgs/doctors/silhouette_femalebig.gif') {
            $(this).replaceWith('');
            $('#DrDetail .QuickInfo div.Designations').css({ 'margin-left': '0' });
        }
    });

    // Add "Provider's" to Last Name field in Doctor Search
    $('.DrSearch .PhysicianLast label').prepend('Provider\'s ');

    // LOCATIONS: REMOVED PHYSICIANS LINK: Address list in Client Portfolio
    //Removed since html change with June 2010 release//$('.LocationsList .Address').each(function() { $(this).children('a').eq(1).remove(); $(this).children('span').eq(1).remove(); $(this).addClass('ModifiedInClientJS'); });
    $('#LocationsDetail .ContactWrapper .ContactCol2').each(function() { $(this).children('a').eq(0).remove(); $(this).addClass('ModifiedInClientJS'); });

    $('.cmspanel').addClass('ClearFix');

    // Moving Locations tabs within the locations module right below the search box
    $('div.LocationsTabs').insertAfter('#LocationsSearch .SearchBox');
    // Adding ClearFix to tab content so that floated elements don't fall out.
    $('.Tab').addClass('ClearFix');
    //removing padding from empty table cells from calendar event detail header
    $('.CalendarEventDetailHeader td:empty').addClass('Empty');

    // Adding print link for Google API Maps within the Locations and Doctors Details
    $('.MapWrapper').after('<br /><img src="/imgs/icons/print_map.gif" class="print" alt="print" title="print" onclick="window.open(\'/print.html\')" />');
    $('#DrDetail .Locations').after('<br /><img src="/imgs/icons/print_map.gif" class="print" alt="print" title="print" onclick="window.open(\'/print.html\')" />');

    // ----------- HACK LIST END ------------------//


});  // End Document Ready

