$(document).ready(function () { //Remembering what footer tab to show var footerTabToshow = 1; var hash_value = window.location.hash; footerTabToshow = hash_value.substring(4, 5); var MAINFOLDERNAME = "Prototype2"; //Highlight selected Header Menu "| Home | News | Get Involved | AboutNICE |" /* This will be done by Niceguidanceheader.do if (window.location.href.indexOf("bout") > 0) { $("ul#nptHeaderMenu li:nth-child(4)").addClass("active"); } else if (window.location.href.indexOf("nvolved") > 0) { $("ul#nptHeaderMenu li:nth-child(3)").addClass("active"); } else if (window.location.href.indexOf("ews") > 0) { $("ul#nptHeaderMenu li:nth-child(2)").addClass("active"); } else if (window.location.href.indexOf("MediaCentre") > 0) { $("ul#nptHeaderMenu li:nth-child(2)").addClass("active"); } else if (window.location.href.indexOf("ome") > 0) { $("ul#nptHeaderMenu li:nth-child(1)").addClass("active"); } if (window.location.href.indexOf("uality") > 0) { $("div#nptLowerHeader div:nth-child(3)").addClass("selected"); } else if (window.location.href.indexOf("ractice") > 0) { $("div#nptLowerHeader div:nth-child(4)").addClass("selected"); } else if (window.location.href.indexOf("QOF") > 0) { $("div#nptLowerHeader div:nth-child(5)").addClass("selected"); } else if (window.location.href.indexOf("Guidance") > 0) { $("div#nptLowerHeader div:nth-child(1)").addClass("selected"); } */ //Add the hover affect to the nptHeaderMenu $("#nptHeaderMenu li").hover(function () { $(this).addClass("hover"); }); $("#nptHeaderMenu li").mouseleave(function () { $(this).removeClass("hover"); }); //NOT TO GO LIVE - just some we could mimic a real search /* $("div#searchBoxButton #searchButton").click(function () { var searchtext = $("#searchTextBox").val(); var searchpage = "SearchResults.htm"; if (searchtext.indexOf("iet") > 0) { searchpage = "Healthy_Diet_Search_list.htm"; } if (searchtext.indexOf("ube") > 0) { searchpage = "Tube_feeding_Search_list.htm"; } searchpage = searchpage += "?query="; window.location.href = '/Search/' + searchpage + searchtext; }); */ //Search auto complete $("#searchTextBox").keypress(function() { if($("#searchTextBox").val().length >= 2){ var position = $("#searchTextBox").position(); var top = position.top + 26; var left = position.left; $(".ui-autocomplete").css('top', top + 'px') $(".ui-autocomplete").css('left', left + 'px') $(".ui-autocomplete").css("display", "block"); } }); $(".ui-autocomplete").mouseleave(function () { $(this).css("display", "none"); }); //START////// //Code to be added by SA for eLog 11520 $(".ui-autocomplete").removeClass("ui-corner-all").removeClass("ui-widget-content"); $('.ui-autocomplete li a').each(function (index) { $(this).removeClass("ui-corner-all"); $(this).hover(function () { $(this).addClass("ui-state-hover"); }); $(this).mouseleave(function () { $(this).removeClass("ui-state-hover"); }); }); //END////// //Show guidance formats tooltip on mouseover or click of image $("img.formatstooltip").click(function (e) { var position = $(this).position(); $("div#formatstooltip").show(); }); $("div#formatstooltip").mouseleave(function (event) { $("div#formatstooltip").hide(); }); //Show guidance types tooltip on mouseover or click of image $("img.GuidanceByType").click(function (e) { var position = $(this).position(); var top = position.top + -80; var left = position.left - 600; $("ul#GuidanceByType").css('top', top + 'px') $("ul#GuidanceByType").css('left', left + 'px') $("ul#GuidanceByType").show(); }); $("ul#GuidanceByType").mouseleave(function (event) { $("ul#GuidanceByType").hide(); }); // hide any popup box $("a.cancelbutton").click(function (event){ event.preventDefault(); $(this).parent().parent().hide(); }); //Find guidance button $("#nptFindGuidance").click(function (event) { showBrowseOverlay(); }); $("#nptFindGuidance a").click(function (event) { event.preventDefault(); }); $("#headerOverlay a.cancelbutton").click(function (event) { $("#headerOverlay").fadeOut(200, "linear"); $("#nptFindGuidance").removeClass("selected"); }); $("#nptFindGuidance").mouseover(function () { $("#nptFindGuidance").addClass("FindGuidanceHover"); }).mouseout(function () { $("#nptFindGuidance").removeClass("FindGuidanceHover"); }); $("body").click(function (e) { var clickedOn = $(e.target); //alert($("#headerOverlay").css('display')); if (clickedOn.parents().andSelf().is('#headerOverlay') != true && $("#headerOverlay").css('display') == 'block' && clickedOn.parents().andSelf().is('#nptFindGuidance') != true) { hideBrowseOverlay(); } }); $("div#nptLowerHeader div").mouseover(function () { if ($(this).attr("id").indexOf("npt") >= 0) { $(this).addClass("hover"); } }).mouseout(function () { if ($(this).attr("id").indexOf("npt") >= 0) { $(this).removeClass("hover"); } }); //Configure AddThis var addthis_config = { pubid: "ra-4ece5c0322a94244" } //Create the footer tabs $("#tabs-nohdr").tabs({ selected: footerTabToshow, select: function(event, ui) { if(ui.index == 0){ var i=0; // dcsMultiTrack("DCS.dcssip","www.nice.org.uk","DCS.dcsuri", location.pathname + "/tabs-0","WT.ti","ExploreNICE_Footer","WT.dl","0","DCSext.Panel","ExploreNICE_Footer"); } else if(ui.index == 1){ var i=0; // dcsMultiTrack("DCS.dcssip","www.nice.org.uk","DCS.dcsuri", location.pathname + "/tabs-1","WT.ti","NHSEvidence_Footer","WT.dl","0","DCSext.Panel","NHSEvidence_Footer"); } else if(ui.index == 2){ $('#NiceTweets').empty(); JQTWEET.loadTweets(); initAddThis(); //dcsMultiTrack("DCS.dcssip","www.nice.org.uk","DCS.dcsuri",location.pathname + "/tabs-2","WT.ti","NICECommunity_Footer","WT.dl","0","DCSext.Panel","NICECommunity_Footer"); } //Set hash to remember the tab the user is/was on window.location.hash = "tab" + ui.index; } }); $("#FooterSearchButton").click(function (event) { $(location).attr('href', 'http://www.evidence.nhs.uk/search?q=' + $("#FooterSearchTextBox").val()); }); $("#searchTextBox").autocomplete({ source: function(request, response) { var term = jQuery.trim(request["term"]); term = term.replace(/[^a-zA-Z 0-9]+/g,''); var arrWords = term.split(" "); var prefix = arrWords[arrWords.length-1]; var q = ""; var qVal = "*:*"; arrWords.splice(arrWords.length-1,1); if (arrWords.length > 0) { q = arrWords.join(" "); qVal = arrWords.join(" "); } $.ajax({ url: 'http://www.nice.org.uk/' + "/solr/live/select?indent=on&facet=on&facet.limit=10&facet.mincount=1&facet.field=SPELL&wt=json&json.wrf=?", dataType: "jsonp", data: { rows: 0, q: qVal, qt: "standard", "facet.prefix" : prefix }, success: function(data) { var i = 0; response( $.map(data.facet_counts.facet_fields.SPELL, function(facet,i) { if (i % 2 === 0) { return { data: jQuery.trim(facet), value: jQuery.trim(q) + " " + jQuery.trim(facet), result: jQuery.trim(q) + " " + jQuery.trim(facet) }; } })); } }); }, width: 300, minLength: 2, select: function(event, doc) { //return true; } }); var thisLocation = location.href.split("#")[0]; $('#tabs-nohdr #tab1').attr('href', thisLocation + '#tabs-nohdr-1'); $('#tabs-nohdr #tab2').attr('href', thisLocation + '#tabs-nohdr-2'); $('#tabs-nohdr #tab3').attr('href', thisLocation + '#tabs-nohdr-3'); }); function showBrowseOverlay() { if($("#headerOverlay").css('display') == 'none'){ var p = $("#nptFindGuidance"); var offset = p.offset(); var left = offset.left; $("#headerOverlay").css('left', left + 'px') $("#headerOverlay").css('top', '107px') $("#headerOverlay").show(); $("#nptFindGuidance").addClass("selected"); $("#headerOverlay ul#MainList li a:first").focus(); }else{ hideBrowseOverlay(); } } function hideBrowseOverlay(){ $("#headerOverlay").hide(); $("#nptFindGuidance").removeClass("selected"); } function initAddThis(){ addthis.init(); }