function BasicSearch() {
    // Add Basic Search to the Advanced Search page....    
    // Markup to look like this:
    //    <div class="basicSearch">
    //        <input type="text" name="keyword" class="theKeyword">
    //        <input type="hidden" class="theSearchPage" value="/doctors-locations/medicare gold/basic-search-results.aspx" >
    //        <input type="hidden" class="thisInputText" value="Name, Specialty, City, and ZIP Code" >
    //        <input type="button"  class="Button basicSearchButton" value="Search">
    //    </div>

    $('.basicSearch').each(function () {
        var thisInputText = $(this).find('input.thisInputText').val();
        var theInput = $(this).find('input.theKeyword');
        if (thisInputText.length) { theInput.val(thisInputText) };

        $(this).find('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) };
                })
                .bind('keypress', function (e) {
                    $(this).siblings('.error:visible').slideUp();
                    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 protocol = jQuery.url.attr('protocol');
                            var searchPage = $(this).siblings('input.theSearchPage').val();
                            window.location = (protocol + '://' + domainURL + searchPage + '?sort=7&keyword=' + kword);
                        }
                        else {
                            $(this).prepend('<div style="color:red" class="error">Please enter in your search criteria.</div>');
                        }
                    }
                });

        $(this).find('.basicSearchButton').click(function () {
            var thisInputText = $(this).siblings('input.thisInputText').val();
            if (thisInputText.length == 0) { thisInputTest = '' };
            var kword = $(this).siblings('input.theKeyword').val();
            if (kword.length && kword != thisInputText) {
                var domainURL = jQuery.url.attr('host'); // returns 'mysite.com'
                var protocol = jQuery.url.attr('protocol');
                var searchPage = $(this).siblings('input.theSearchPage').val();
                window.location = (protocol + '://' + domainURL + searchPage + '?sort=7&keyword=' + kword);
            }
            else {
                $(this).prepend('<div style="color:red" class="error">Please enter in your search criteria.</div>');
            }
        });

    });
}

$(document).ready(function () {
    BasicSearch();

    // For Mobile Template: if any div.cmspage is empty, let's remove it -- avoids padding on empty pages.			
    $('#Mobile div').each(function (i, el) {
        // Remove white space
        var html = $(el).html().replace(/\s+/, '');
        // Check if element is :empty or length of html is zero
        if ($(el).is(':empty') || html.length == 0)
            $(el).remove();
    });

    $('body#Mobile .ERWTRow span a')
	   .each(function () {
	       this.href = this.href.replace(/mymethodist.net/, document.domain);
	       this.href = this.href.replace(/www./, '');
	       this.href = this.href.replace(/services.urgent-care/, 'mobile/UrgentCare');
	   });

});   //END DOC READY


// Quality Reports Pop-Ups
function qualityPopUps() {
	var contentContainer = document.getElementById('PageContent');
	if (contentContainer) {
		var tableList = contentContainer.getElementsByTagName('table');
		for (var i = 0; i<tableList.length; i++) {
			if (tableList[i].className == 'QualityReports') {
				var anchorList = tableList[i].getElementsByTagName('a');
				for (var j = 0; j<anchorList.length; j++) {
					anchorList[j].onclick=function() {
						return popUp(this.href,350,250);
					}
				}
			}
		}
	}
}
addEvent(window, 'load', qualityPopUps, false);


$(document).ready(function(){
						   

// ----------- TEMPLATE EXTRAS ------------------//

	$('#Col3 .GreenBack').wrap('<div class="GreenBack2"></div>');
	$('#Col3 #FlashVideo').parent().parent().parent().parent().parent('.cmspanel').addClass('FlashPanel');
	$('#Col3 .cmsPanelContent').addClass('ClearFix');
	$('body.mcon div.Right').appendTo('#MainNav');

    //Adding Promotional Designation to MMG Doctors
	$('li.doc3a4ecc3eea93de11b26d001372679326').parent().parent().parent().addClass('Promo');

	//Adding Promotional style to Docs at Methodist Center of Integrative Medicine
	$('.DrList dt:contains("Methodist Center for Integrative Medicine")').parent().parent().parent().parent().addClass('Promo');

	//Hiding Dr Photos if it is the silhoutte on Result Page
	$('.DrList .Picture img[src*="silhouette"]').parent('a').addClass('HidePhoto');

	//adding hover to MCON homepage Feature
	$('#MCONHome #Featured .TabContainer.Vertical .Tabnav a').mouseover(function () {
		var $index = $(this).closest('.Tabnav').find('a').index($(this));
		$(this).parent('li').addClass('Tabactive').siblings().removeClass('Tabactive');
		$(this).closest('.TabContainer').find('.Tab').addClass('Tabhide').eq($index).removeClass('Tabhide');
    }); 
	$('#MCONHome #Featured .TabContainer.Vertical .Tabnav a').click(function () {
		window.location = $(this).attr('href');		
		return false;
	});

// ----------- HACK LIST START ------------------//

	// removing padding from empty table cells from calendar event detail header
    $('.CalendarEventDetailHeader td:empty').addClass('Empty');

    // moving flyout panels to be within the MainNav
    $('#MainNav li:nth-child(2)').addClass('Second');
    $('#MainNav li:nth-child(3)').addClass('Third');
    $('#MainNav li:nth-child(4)').addClass('Fourth');
    $('#MainNav li:nth-child(5)').addClass('Fifth');

    $('#Flyout1').appendTo('#MainNav li.First');
    $('#Flyout2').appendTo('#MainNav li.Second');
    $('#Flyout3').appendTo('#MainNav li.Third');
    $('#Flyout4').appendTo('#MainNav li.Fourth');
    $('#Flyout5').appendTo('#MainNav li.Fifth');

    // remove the main nav drop down if .cmspanel doesn't exist or is empty
    $('.Flyout .FlyoutInner:empty').parent().parent().parent().remove();
    $('.Flyout .FlyoutInner .cmspanel:empty').parent().parent().parent().parent().remove();

    // keeping active class on main nav li when hover on Flyout
    $('#MainNav li.Last a').addClass('Last');
    $('#MainNav li.First a').addClass('First');
    $('#MainNav li').hover(function () {
        $(this).toggleClass('FlyoutActive');
    });

    // Adding auto-scroll to services links
    $("#BrowseTab .AlphabetLinks a").each(function () {
        var _href = $(this).attr("href");
        $(this).attr("href", _href + '#BrowseTab');
    });
	
	// Adding preview image to Dr's video player
	$('#DrDetail a.VideoPlayer').attr('name', '&image=/imgs/logo.gif');


// ----------- HACK LIST END ------------------//

});



