
this.mfb_callback=function(methodName,params,onSuccess){if(typeof(params)=="undefined"){params="{}";}
if(typeof(onSuccess)=="undefined"){onSuccess=function(){};}
$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:"/CMSTemplates/MaryFreeBed/ServiceCallBackHandler.asmx/"+methodName,data:params,dataType:"json",success:function(result){onSuccess(result);},error:handleErr});}
this.handleErr=function(xhr,ajaxOptions,thrownError){alert("Error: "+xhr.responseText);}
this.MainMenu=function(){$("#menuElem li").hover(function(){$(this).addClass("sfhover");},function(){$(this).removeClass("sfhover");});var strOffset=$("#menuElem li").first().offset().left;var $offset=$(".menu").offset().left;$("#menuElem > li").hover
(function()
{var $strElement=$(this).has("li");$strElement.css("background","url('/MaryFreeBed/media/layout/sprite.png') no-repeat center 13px");if($strElement.offset()!=null&&$strElement.offset().left>strOffset)
{var strMargin;$(this).has("ul ul ul ul").addClass("applyOffset");if($(this).hasClass("applyOffset"))
{strMargin=$strElement.offset().left-strOffset;$strElement.children("ul").css("margin-left","-"+strMargin+"px");}
else
{$strElement.children("ul").css("width","369px");}}},function(){$(this).has("li").css("background","none");});var $secondLevel=$("#menuElem li li").has("li")
$secondLevel.css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_grey.jpg') no-repeat 95% 70%");$secondLevel.hover
(function(){$(this).css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_white.jpg') no-repeat 95% 70% #8c978e");},function(){$(this).css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_grey.jpg') no-repeat 95% 70% #bcc6be");});var $thirdLevel=$("#menuElem li li li").has("li")
$thirdLevel.css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_grey_grey.jpg') no-repeat 95% 70%");$thirdLevel.hover
(function(){$(this).css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_dark_white.jpg') no-repeat 95% 70% #677167");},function(){$(this).css("background","url('/MaryFreeBed/media/layout/navigation_arrow_right_grey_grey.jpg') no-repeat 95% 70% #8c978e");});}
this.LoadRotator=function(){if($("#mfb_main_banner").get(0)){mfb_callback("GetBannerImages","{'SiteName':'MaryFreeBed','AliasPath':'/Files/Banners/Live/%'}",function(result){var imgs=[];var atags=[];var banners=result.d;$(banners).each(function(k){var src=this;imgs[imgs.length]="<img src='";imgs[imgs.length]=src.replace("~","");imgs[imgs.length]="' alt='' /> ";atags[atags.length]="<a href='#' rel='";atags[atags.length]=k+1;atags[atags.length]="' /> ";});if($("#mfb_main_banner").get(0)){$("#mfb_main_banner").append(imgs.join(''));}
if($("#mfb_main_banner_items").get(0)){$("#mfb_main_banner_items").append(atags.join(''));}
Rotator();});}}
this.Join=function()
{$(".join").hover(function(){$(".joinContainer").show();},function(){$(".joinContainer").hide();});$(".joinContainer").hover(function(){$(this).show();},function(){$(this).hide();});$(".addthis_button_print").click(function(){window.print();return false;});}
this.Rotator=function(){$(".paging").show();$(".paging a:first").addClass("active");var imageWidth=$(".window").width();var Filesum=$(".imageReel img").size();var imageReelWidth=imageWidth*Filesum;$(".imageReel").css({'width':imageReelWidth});rotate=function(){var triggerID=$active.attr("rel")-1;var image_reelPosition=triggerID*imageWidth;$(".paging a").removeClass('active');$active.addClass('active');$(".imageReel").animate({opacity:0,left:-image_reelPosition},{duration:0,complete:function(){$(".imageReel").animate({opacity:1},1000)}});};rotateSwitch=function(){play=setInterval(function(){$active=$('.paging a.active').next();if($active.length===0){$active=$('.paging a:first');}
rotate();},7000);};rotateSwitch();$(".paging a").click(function(){$active=$(this);clearInterval(play);rotate();rotateSwitch();return false;});}
this.PowerNav=function(){$("body").click(function(){$("#first").next("span").hide(0);$("#firstDropDown").hide(0);$("#first").removeClass("active");$("#second").next("span").hide(0);$("#secondDropDown").hide(0);$("#second").removeClass("active");$("#third").next("span").hide(0);$("#thirdDropDown").hide(0);$("#third").removeClass("active");});$(".first").click(function(event){$("#first").addClass("active");$("#first").next("span").show(0);$("#firstDropDown").show(0);$("#firstDropDown").addClass("open");event.stopPropagation();$(".active").blur();});$(".second").click(function(event){$("#second").addClass("active");$("#second").next("span").show(0);$("#secondDropDown").show(0);$("#secondDropDown").addClass("open");event.stopPropagation();$(".active").blur();});$(".third").click(function(event){$("#third").addClass("active");$("#third").next("span").show(0);$("#thirdDropDown").show(0);$("#thirdDropDown").addClass("open");event.stopPropagation();$(".active").blur();});$(".first").hover(function(){$("#secondDropDown").removeClass("open");$("#thirdDropDown").removeClass("open");clearHover();addHover("first");},function(){$("#firstDropDown").hover(function(){addHover("first");},function(){clearHover();});clearHover();});$(".second").hover(function(){$("#firstDropDown").removeClass("open");$("#thirdDropDown").removeClass("open");clearHover();addHover("second");},function(){$("#secondDropDown").hover(function(){addHover("second");},function(){clearHover();});clearHover();});$(".third").hover(function(){$("#secondDropDown").removeClass("open");$("#firstDropDown").removeClass("open");clearHover();addHover("third");},function(){$("#thirdDropDown").hover(function(){addHover("third");},function(){clearHover();});clearHover();});$(".selection .separator").last().remove();$(".third").trigger("click");}
this.addHover=function(item){if($("#"+item+"DropDown").hasClass("open")!=true){$("#"+item).addClass("active");$("#"+item).next("span").show(0);$("#"+item+"DropDown").show(0);}}
this.clearHover=function(item){if($("#firstDropDown").hasClass("open")!=true){$("#first").next("span").hide(0);$("#firstDropDown").hide(0);$("#first").removeClass("active");}
if($("#secondDropDown").hasClass("open")!=true){$("#second").next("span").hide(0);$("#secondDropDown").hide(0);$("#second").removeClass("active");}
if($("#thirdDropDown").hasClass("open")!=true){$("#third").next("span").hide(0);$("#thirdDropDown").hide(0);$("#third").removeClass("active");}}
this.checkText=function(el){if(el.value==null||el.value==""){el.value="Search this site";}}
this.SecondMenu=function(){var $x=$(".arrowDown").parent("li").children("ul");if($x){$x.addClass("show");$x.removeClass("hide");$x.show(0);}
$(".subarrow").click(function(){$(this).toggleClass("arrowDown");var $y=$(this).parent("li").children("ul");if($y.hasClass("show")==true){$y.hide(300,function(){$(this).addClass("hide");$(this).removeClass("show");});}
else{$y.show(300,function(){$(this).addClass("show");$(this).removeClass("hide");});}});}
this.ToolBar=function(){$("a.mfb_email_box").click(function(event){event.preventDefault();$("body").append("<div id='mask'></div>");var $pop=$("#popupContact");var maskHeight=$(document).height();var maskWidth=$(window).width();$('#mask').css({'width':maskWidth,'height':maskHeight});$('#mask').fadeTo('fast',.5);var winH=$(window).height();var winW=$(window).width();$pop.css('position','fixed');$pop.css('top',winH/2-$pop.height()/2);$pop.css('left',winW/2-$pop.width()/2);$("#popupContactSubmit").attr("data-to",$(this).attr("href").replace("mailto:",""));$("#m_last").val("");$("#m_first").val("");$("#m_email").val("");$("#m_message").val("");$("#popupContactSubmit").attr('disabled','');$("#popupContactCancel").attr('disabled','');$("#contactMsg").text("");$("#contactMsg").hide();$pop.show();});$("#popupContactCancel").click(function(event){event.preventDefault();$('#mask').fadeOut('fast');$("#popupContact").fadeOut('fast');});$(".email_close").click(function(event){event.preventDefault();$('#mask').fadeOut('fast');$("#popupContact").fadeOut('fast');});$("#popupContactSubmit").click(function(event){event.preventDefault();$("#popupContactSubmit").attr('disabled','true');$("#popupContactCancel").attr('disabled','true');$("#contactMsg").text("Please wait while we send your email...");$("#contactMsg").show();var emailTo=$("#popupContactSubmit").attr("data-to");if($("#m_email").val().length==0)
{$("#contactMsg").text("Please enter in your Email Address and a Message or Comment.");$("#contactMsg").show();$("#popupContactSubmit").attr('disabled','');$("#popupContactCancel").attr('disabled','');}
else
{var params="{'FirstName':'"+$("#m_first").val()+"', 'LastName':'"+$("#m_last").val()+"', 'Email':'"+$("#m_email").val()+"', 'EmailTo':'"+emailTo+"', 'Message':'"+$("#m_message").val()+"'}";mfb_callback("SendEmail",params,function(result){var er=result.d;if(er.ReturnCode==1)
$("#contactMsg").text("Your email has been sent to "+er.SentToAddress+". Thank you.");else
$("#contactMsg").text("Sorry, your email has NOT been sent: "+er.ErrorMessage);$("#popupContactSubmit").attr('disabled','');$("#popupContactCancel").attr('disabled','');setTimeout(function(){$('#mask').fadeOut('fast');$("#popupContact").fadeOut('fast');},4000);});}});$("div.searchBox input[id$=Menu_SearchBox_txtWord]").click(function(evt){if($(this).val()=="Search this site"){$(this).val("")}});}
this.TextSize=function(){var originalFontSize=parseFloat($('body').css('font-size'));var currentFontSize;$("#textSizer a.textSizeUp").click(function(){currentFontSize=parseFloat($("body").css('font-size'));$("body").css('font-size',currentFontSize+2+"px");});$("#textSizer a.textSizeDown").click(function(){currentFontSize=parseFloat($("body").css('font-size'));$("body").css('font-size',currentFontSize-2+"px");});$("div.share, div.menu, div.menuRight, div.breadcrumb, div.footer").css('font-size',"12px");}
this.Images=function(){$("img.image_with_content").wrap("<div class='photo' />");var $p=$(".photo");$p.wrap("<div class='photoContainer' />");$p.before("<div class='photoDescriptionClosed'><span class='photoArrowLeft'></span><p></p></div>");$p.after("<div class='clear'></div>");$(".photoArrowLeft").click(function(){$(this).toggleClass("photoArrowRight");if($(this).parent("div").hasClass("photoDescriptionClosed")==true)
{var src=$(this).parent().next().children("img").attr("src");$(this).next().addClass("capt-loading");$(this).parent("div").removeClass("photoDescriptionClosed");$(this).parent("div").addClass("photoDescriptionOpen");mfb_callback("GetImageCaption","{'SiteName':'MaryFreeBed','ImageAliasPath':'"+src+"'}",function(result){$("p.capt-loading").text(result.d).removeClass("capt-loading");});}
else
{$(this).parent("div").removeClass("photoDescriptionOpen");$(this).parent("div").addClass("photoDescriptionClosed");}});}
this.VideoPopUp=function(){$('a.poplight[href^=#]').click(function(){var $this=$(this).parent('li');var link=$this.children('.poplight').detach();var strHTML=$this.html();link=link.prependTo($this);var popID=$this.children('.poplight').attr('rel');var popURL=$this.children('.poplight').attr('href');var query=popURL.split('?');var dim=query[1].split('&');var popWidth=dim[0].split('=')[1];$('#'+popID).fadeIn().css({'width':Number(popWidth)}).prepend('<a href="#" class="close"><img src="/MaryFreeBed/media/layout/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');$('.transcriptContainer').css('overflow-y','hidden');$('.transcriptContainer').css('overflow-x','hidden');$('.transcriptLink').remove();$('.transcript').remove();var params="{'MediaFileCode':'"+popID+"'}";mfb_callback("GetTranscript",params,function(result){var transcript=result.d;if(transcript.length>0){$('#'+popID).append('<span class="transcriptLink"><a href="#">View the transcript <span class="arrowDown"></span></a></span><div class="transcript">'+transcript+'</div>');if($('#'+popID+' .transcriptContainer').length===0){$('#'+popID+' .transcript').wrapAll('<div class="transcriptContainer"></div>');$('#'+popID+' .transcriptContainer').css({'width':Number(popWidth)});}
$('.transcript').css('display','none');$('.transcriptLink a').click(function(){if($('.transcriptLink a').hasClass('open')){$('.transcriptLink a').html('View the transcript <span class="arrowDown"></span>');$('.transcriptLink a').removeClass('open');$('.transcriptContainer').css('overflow-y','hidden');$('.transcript').fadeOut();}
else{$('.transcriptLink a').html('Close the transcript <span class="arrowUp"></span>');$('.transcriptLink a').addClass('open');$('.transcript').fadeIn();$('.transcriptContainer').css('overflow-x','hidden');$('.transcriptContainer').css('overflow-y','scroll');}});}});var popMargTop=($('#'+popID).height()+80)/2;var popMargLeft=($('#'+popID).width()+80)/2;$('#'+popID).css({'margin-top':-popMargTop,'margin-left':-popMargLeft});$('body').append('<div id="fade"></div>');$('#fade').css({'filter':'alpha(opacity=80)'}).fadeIn();return false;});$('.podcast, .youtube').click(function(){var link=$(this).children('.poplight').detach();var strHTML=$(this).html();link=link.prependTo($(this));var popID=$(this).children('.poplight').attr('rel');var popURL=$(this).children('.poplight').attr('href');var query=popURL.split('?');var dim=query[1].split('&');var popWidth=dim[0].split('=')[1];$('#'+popID).fadeIn().css({'width':Number(popWidth)}).prepend('<a href="#" class="close"><img src="/MaryFreeBed/media/layout/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');$('.transcriptContainer').css('overflow-y','hidden');$('.transcriptContainer').css('overflow-x','hidden');$('.transcriptLink').remove();$('.transcript').remove();var params="{'MediaFileCode':'"+popID+"'}";mfb_callback("GetTranscript",params,function(result){var transcript=result.d;if(transcript.length>0){$('#'+popID).append('<span class="transcriptLink"><a href="#">View the transcript <span class="arrowDown"></span></a></span><div class="transcript">'+transcript+'</div>');if($('#'+popID+' .transcriptContainer').length===0){$('#'+popID+' .transcript').wrapAll('<div class="transcriptContainer"></div>');$('#'+popID+' .transcriptContainer').css({'width':Number(popWidth)});}
$('.transcript').css('display','none');$('.transcriptLink a').click(function(){if($('.transcriptLink a').hasClass('open')){$('.transcriptLink a').html('View the transcript <span class="arrowDown"></span>');$('.transcriptLink a').removeClass('open');$('.transcriptContainer').css('overflow-y','hidden');$('.transcript').fadeOut();}
else{$('.transcriptLink a').html('Close the transcript <span class="arrowUp"></span>');$('.transcriptLink a').addClass('open');$('.transcript').fadeIn();$('.transcriptContainer').css('overflow-x','hidden');$('.transcriptContainer').css('overflow-y','scroll');}});}});var popMargTop=($('#'+popID).height()+80)/2;var popMargLeft=($('#'+popID).width()+80)/2;$('#'+popID).css({'margin-top':-popMargTop+"px",'margin-left':-popMargLeft+"px"});$('body').append('<div id="fade"></div>');$('#fade').css({'filter':'alpha(opacity=80)'}).fadeIn();return false;});$('a.close, #fade').live('click',function(){$('#fade, .popup_block').fadeOut();$('#fade').remove();$('a.close').remove();return false;});}
this.Growl=function(){if($(".menuRight .arrow").length!=0){if(GetCookie("dontShowNotification")==false){$.gritter.add({title:'Note:',text:'For additional menu options, please click the arrow <span class="gritterArrow">&nbsp;</span> to expand the section. <span class="dontShow">Don\'t show this message again.</span>',image:'',sticky:true,time:'',class_name:''});$(".gritter-without-image").prepend("<div class='gritter-close'></div>");}}
$(".dontShow").click(function(){document.cookie="dontShowNotification"+"=";$("#gritter-notice-wrapper").hide();var date=new Date();date.setMonth(date.getMonth()+11);document.cookie+=("; expires="+date.toUTCString());});}
function GetCookie(sName)
{var aCookie=document.cookie.split("; ");for(var i=0;i<aCookie.length;i++)
{var aCrumb=aCookie[i].split("=");if(sName==aCrumb[0])
return true;}
return false;}
this.init=function(){if(typeof(oFCKeditor)=="undefined")
{ToolBar();Join();MainMenu();PowerNav();SecondMenu();LoadRotator();Images();TextSize();VideoPopUp();Growl();}
else{$(".navigation .menu").css("display","none");}}
$(document).ready(function(){init();});
