﻿/*::::::::::::::::::::::::::::::::::::::::::::
	Parrish Medical Center
	Designed by Angie Thompson
	HTML/CSS/JS by Brandon Kidd
	Internal JS
	Copyright © 2010 McMurry
::::::::::::::::::::::::::::::::::::::::::::*/

(function ($) {
	$(function () {
		// jQuery

		// Pager
		$(".pager a[disabled=disabled]").addClass("disabled");
		$(".pager .pager-command:last").addClass("pager-next");
		//show/hide job details
		$(".showlink").click(function (e) { $(this).parents(".listrow").children(".showhidepanel").slideToggle("fast"); });
		// Open Print Window
		$('#printForm').attr("target", "_blank");

		// Tree View
		$('body.services #sidemenu ul[id$=ServiceListMenu1], body.about #sidemenu ul').treeview({
			animated: "fast",
			collapsed: true,
			persist: "location",
			unique: true
		});

		// Main Content Height
		// var mainSidebarHeight = $('#main_sidebar').outerHeight(true);
		// var mainContentHeight = $('#main_content').outerHeight(true);
		// if (mainSidebarHeight > mainContentHeight) {
		//	$('#main_content').height($('#main_content').height() + (mainSidebarHeight - mainContentHeight));
		// }

		// Accolades Scrollable Widget
		$('#awards-recognition').prepend('<a href="javascript:void(0);" class="tab-prev" title="Previous Accolade">Previous</a><a href="javascript:void(0);" class="tab-next" title="Next Accolade">Next</a>');
		$('#awards-recognition .awards-wrap').scrollable({ clickable: false, items: '.awards', keyboard: false, prev: '.tab-prev', next: '.tab-next', size: 3, speed: 500 }).mousewheel().autoscroll({ autopause: true, steps: 3 });

		// Open Print Window
		$('#printForm').attr("target", "_blank");

		// OMM
		if ($('#main_content #_medialibrary').length > 0) {
			$('#main_content h1, #main_content div.menu').remove();
		}

		// Superscript Replacement
		if ($('#_medialibrary').length == 0) {
			$('#main_content').html($('#main_content').html().replace(/&reg;/gi, '<sup>&reg;</sup>').replace(/®/gi, '<sup>&reg;</sup>'));
			$('#main_content').html($('#main_content').html().replace(/&trade;/gi, '<sup>&trade;</sup>').replace(/™/gi, '<sup>&trade;</sup>'));
		}

		// Right Panel
		var wrapX = $('#wrap').width();
		$(window).resize(function () {
			wrapX = $('#wrap').width();
			isWidescreen(wrapX);
		});
		isWidescreen(wrapX);

		// Healthbridge & Spirit of Women
		if ($('body[class*="healthbridge-registration"]').length > 0 || $('body[class*="spirit-of-women-registration"]').length > 0) {
			if ($('#main_content input[id$="txtReferralSource"]').val().length > 0) {
				$('#main_content select[id$="ddlReferralSource"] option').removeAttr('selected');
				if ($('#main_content select[id$="ddlReferralSource"] option[value="' + $('#main_content input[id$="txtReferralSource"]').val() + '"]').length > 0) {
					$('#main_content select[id$="ddlReferralSource"] option[value="' + $('#main_content input[id$="txtReferralSource"]').val() + '"]').attr('selected', 'selected');
				} else {
					$('#main_content select[id$="ddlReferralSource"] option[value="Other"]').attr('selected', 'selected');
					$('#main_content .referral_other').removeClass('hidden');
				}
			}
			$('#main_content select[id$="ddlReferralSource"]').change(function () {
				if ($(this).val() == 'Other') {
					$('#main_content .referral_other').removeClass('hidden');
					$('#main_content input[id$="txtReferralSource"]').val('');
				} else {
					$('#main_content .referral_other').addClass('hidden');
					$('#main_content input[id$="txtReferralSource"]').val($(this).val());
				}
			});
		}
	});
})(jQuery);

function isWidescreen(a) {
	if (a >= 1215) {
		$('body').addClass('widescreen');
	} else {
		$('body').removeClass('widescreen');
	}
}

// Rounded Corners
//DD_roundies.addRule('#main_content, #main_sidebar #sidemenu, #content .health-bridge, #main_sidebar #quicklinks, #main_sidebar #map', '10px');
//DD_roundies.addRule('#main_content .button, #sidemenu ul li a', '5px');

// Font Resizer
function fontResize(size) { var litContent = document.getElementById("litContent"); switch (size) { case "normal": litContent.style.fontSize = "1em"; break; case "medium": litContent.style.fontSize = "1.2em"; break; case "large": litContent.style.fontSize = "1.4em"; break; } }
// Print
function printpage() { document.getElementById("hdn_Title").value = document.title; document.getElementById("hdn_Content").value = document.getElementById("main_content").innerHTML; document.forms[1].submit(); }
// Bookmark
function bookmarkpage(bookmarkUrl) { var bookmarkTitle = document.title; if (window.sidebar) { window.sidebar.addPanel(bookmarkTitle, bookmarkUrl, ""); } else if (window.external) { window.external.AddFavorite(bookmarkUrl, bookmarkTitle); } else if (window.opera && window.print) { var elem = document.getElementById('menu_bookmark'); elem.setAttribute('href', bookmarkUrl); elem.setAttribute('title', bookmarkTitle); elem.setAttribute('rel', 'sidebar'); elem.click(); } }
// Textbox Char count
function CheckFieldLength(fn, rn, mc) { var len = fn.value.length; if (len > mc) { fn.value = fn.value.substring(0, mc); len = mc; } document.getElementById(rn).innerHTML = mc - len; }
