/* header and footer search box */
(function(a){a.fn.globalHeader=function(d){var c={activeTab:null,moreLinks:[],morePromoCount:6,moreText:"You might also like:",moreAnd:"and",moreMore:"More",moreTextHeadline:"More Sites You Might Like",uiHat:"#GH_hat",uiHatLinks:"#GH_hat_links",uiHatTools:"#GH_hat_tools",uiNavLi:"li.GH_nav_LI",uiNavADd:".GH_nav_dd_A",auth:{doAuth:false,authenticated:false,authState:null,unauthState:null},search:{uiSearch:"#GH_search",params:{}},fn:{}},e={},h=this,g={},f={activeTab:null,moreLinksBuilt:false},b={init:function(i){g.$d=a(document);g.$c=a(i);g.hat=a(e.uiHat)[0];g.hatLinks=a(e.uiHatLinks)[0];g.$hatTools=a(e.uiHatTools);g.$search=a(e.search.uiSearch);g.$searchInput=g.$search.find("input:first");g.$searchSubmit=g.$search.find("input:last");g.$navLi=g.$c.find(e.uiNavLi);g.$navADd=g.$c.find(e.uiNavADd);b.setActiveTab(null,e.activeTab);if(e.auth.doAuth){b.buildAuth()}b.buildMoreLinks();b.buildDropDowns();g.$c.bind("setActiveTab",function(k,j){b.setActiveTab(k,j)});g.$c.bind("setAuthState",function(k,j){b.buildAuth(k,j)});if(e.search.params.initFocus!==undefined&&e.search.params.initFocus){g.$search.globalSearchBox(e.search.params)}else{g.$searchInput.bind("focus.GH",function(j){b.buildSearch(j)}).attr("autocomplete","off");g.$searchSubmit.bind("mouseover.GH",function(j){b.buildSearch(j)});if(e.search.params.searchText!==undefined&&e.search.params.searchText!==""){g.$searchInput.val(e.search.params.searchText)}}},getVars:function(){return{options:e,ui:g,local:f}},buildSearch:function(i){g.$searchInput.unbind("focus.GH");g.$searchSubmit.unbind("mouseover.GH");if(i.target===g.$searchInput[0]){g.$searchInput.addClass("GH_search_active").attr("value","")}g.$search.globalSearchBox(e.search.params)},buildAuth:function(j,i){if(i!==undefined){a.extend(true,e.auth,i)}g.$hatTools.empty().append((e.auth.authenticated)?e.auth.authState:e.auth.unauthState)},buildMoreLinks:function(){var o=e.moreLinks,m=0,j=o.length;if(j>=e.morePromoCount){var n,k=a("<li />").addClass("GH_hat_LI").append(n=a("<ul />").attr("id","GH_hat_more").addClass("GH_hat_UL").append(a("<li />").addClass("GH_hat_LI").text(e.moreText+"\xa0 ")));for(;m<e.morePromoCount;m++){n.append(a("<li />").addClass("GH_hat_LI").append(a("<a />").attr({href:o[m][1],target:(o[m][2]!==undefined)?o[m][2]:"_self"}).addClass("GH_hat_A GH_hat_more_A").text(o[m][0])).append((m<e.morePromoCount-1)?",\xa0":""))}if(j>e.morePromoCount){n.append(g.$hatLIMore=a("<li />").addClass("GH_hat_LI GH_hat_LI_more").append("\xa0"+e.moreAnd+"\xa0").append(g.$hatMoreLink=a("<a />").attr({id:"GH_hat_more_link",href:"#"}).addClass("GH_hat_A GH_hat_more_A").text(e.moreMore).bind("mouseover.GH",function(i){b.showMoreLinks(i)})))}k.appendTo(g.hatLinks)}},showMoreLinks:function(p){p.preventDefault();if(f.moreLinksBuilt===false){var n=e.moreLinks.slice(e.morePromoCount),o=0,m=n.length,j=Math.ceil(m/3),k=Math.ceil(m/3*2),s,r,q,t;g.$hatMoreList=a("<div />").attr("id","GH_more_list").append(a("<b />").attr("id","GH_more_list_lab").text(e.moreTextHeadline)).append(s=a("<ul />").addClass("GH_more_list_UL")).append(r=a("<ul />").addClass("GH_more_list_UL")).append(q=a("<ul />").addClass("GH_more_list_UL"));for(;o<m;o++){t=a("<li />").append(a("<a />").attr({href:n[o][1],target:(n[o][2]!==undefined)?n[o][2]:"_self"}).text(n[o][0]));if(o<j){t.appendTo(s)}else{if(o<k){t.appendTo(r)}else{t.appendTo(q)}}}g.$hatMoreList.css("left",g.$hatLIMore.offset().left-g.$c.offset().left+14).appendTo(g.hat);f.moreLinksBuilt=true}if(g.$hatMoreList.css("display")==="none"){g.$d.bind("mousemove.GHTEMP",function(i){b.kill(i)});g.$hatMoreList.fadeIn("fast")}},kill:function(j){var i=a(j.target);if(i.closest("#GH_hat_more_link").length===0&&i.closest("#GH_more_list").length===0){g.$d.unbind("mousemove.GHTEMP");g.$hatMoreList.fadeOut("fast")}},setActiveTab:function(j,i){if(i!==undefined&&i!==null){if(f.activeTab!==null){f.activeTab.removeAttr("id");if(f.activeTab.hasClass("GH_nav_list")){a("#GH_nav_act_B").removeAttr("id")}}f.activeTab=g.$navLi.eq(i).attr("id","GH_nav_act");f.activeTab.children().eq(0).css("clear","both");if(f.activeTab.hasClass("GH_nav_list")){f.activeTab.children().eq(0).wrapInner('<b id="GH_nav_act_B"></b>')}}},buildDropDowns:function(){g.$navLi.each(function(){var i=a(this);if(i.hasClass("GH_nav_list")){i.mouseover(function(){if(i.showtimer){clearInterval(i.showtimer);i.showtimer=null}i.addClass("GH_nav_list_open").find("ul").fadeIn("fast")}).mouseout(function(){i.showtimer=setTimeout(function(){if(i.showtimer){clearInterval(i.showtimer);i.showtimer=null}i.removeClass("GH_nav_list_open").find("ul").fadeOut("fast")},250)})}})}};a.extend(true,e,c,d);a.extend(true,b,e.fn);b.init(h);return h}})(jQuery);(function(a){a.fn.globalSearchBox=function(d){var c={apiUrl:"http://autocomplete.search.aol.com/autocomplete/get",apiIt:"ops-test",apiOutput:"json",apiCount:8,apiQueryParam:"q",apiDictionary:"",ui_form:"#GH_search_form",ui_input:"#GH_search_field",ui_submit:"#GH_search_button",ui_output:"#GH_search_results",initSmartSearch:true,searchText:"",preserveGhostText:false,initFocus:false,fn:{}},e={},h=this,g={},f={ghostText:"",query:"",results:[],highlight:-1,$highlight:null,timer:null},b={init:function(i){g.$c=a(i);g.$input=a(e.ui_input);g.$output=a(e.ui_output);g.form=a(e.ui_form)[0];g.submit=a(e.ui_submit)[0];f.ghostText=g.$input.attr("defaultValue");g.$input.attr("autocomplete","off").bind("focus.GH",function(j){b.processInputFocus(j)}).bind("blur.GH",function(j){b.processInputBlur(j)});a(g.form).bind("submit.GH",function(j){b.selectSuggestion(j)});if(e.initSmartSearch){e.apiUrl=e.apiUrl+"?it="+e.apiIt+"&count="+e.apiCount+"&output="+e.apiOutput;if(e.apiDictionary!==""){e.apiUrl=e.apiUrl+"&dict="+e.apiDictionary}g.$input.bind("keyup.GH",function(j){b.processKeyPress(j)});g.$output.bind("mouseover.GH",function(j){b.moveHighlightMouse(j)}).bind("mouseover.GH",function(j){b.suspendBlurDetection(j)}).bind("mouseleave.GH",function(j){b.resumeBlurDetection(j)}).bind("click.GH",function(j){b.selectSuggestion(j)})}if(e.initFocus){g.$input.focus()}if(e.preserveGhostText){g.$label=a("<label />").attr("id","GH_search_label").text(f.ghostText).appendTo(g.form);g.$label.bind("click.GH_SL",function(j){b.preserveGhostText(true)});g.$input.bind("keyup.GH_SL",function(j){b.preserveGhostText(j)}).bind("click.GH_SL",function(j){b.preserveGhostText(j)}).bind("blur.GH_SL",function(j){setTimeout(function(){b.preserveGhostText(j)},250)})}if(e.searchText!==""){g.$input.val(e.searchText)}},getVars:function(){return{options:e,ui:g,local:f}},processInputFocus:function(i){g.$input.addClass("GH_search_active").val((g.$input.val()===f.ghostText)?"":g.$input.val())},processInputBlur:function(i){g.$input.removeClass("GH_search_active").val((g.$input.val()==="")?f.ghostText:g.$input.val());b.displaySuggestions()},preserveGhostText:function(i){if(typeof i==="boolean"&&i){g.$input.focus()}g.$input.unbind("keyup.GH_SL").unbind("click.GH_SL").unbind("blur.GH_SL");g.$label.remove()},processKeyPress:function(l){var j=l.keyCode;if(j===38){b.moveHighlightKey(-1)}else{if(j===40){b.moveHighlightKey(1)}else{var i=l.target,k=a.trim(i.value);if(k!==""){if(f.timer!==null){clearTimeout(f.timer)}f.timer=setTimeout(function(){b.getSuggestions(k)},200)}else{b.displaySuggestions()}}}},moveHighlightKey:function(j){if(f.$highlight!==null){f.$highlight.removeClass("GH_highlight")}f.highlight=f.highlight+j;if(f.highlight>=f.results.length||f.highlight===-1){f.highlight=-1;g.$input.val(f.query)}else{if(f.highlight<-1){f.highlight=f.results.length-1}}if(f.highlight>-1){f.$highlight=a(f.results[f.highlight]);f.$highlight.addClass("GH_highlight");g.$input.val(f.$highlight.text())}},moveHighlightMouse:function(j){var i=j.target;if(i.nodeName==="B"){i=i.parentNode}if(f.$highlight!==null){f.$highlight.removeClass("GH_highlight")}f.highlight=f.results.index(i);f.$highlight=a(i).addClass("GH_highlight")},selectSuggestion:function(j){j.preventDefault();if(j!==undefined&&j.type==="click"){var i=j.target;if(i.nodeName==="B"){i=i.parentNode}g.$input.val(a(i).text())}g.$input.val(a.trim(g.$input.val()));if(g.$input.val()!==""&&g.$input.val()!==f.ghostText){g.form.submit()}},getSuggestions:function(j){var i=e.apiUrl+"&"+e.apiQueryParam+"="+j;a.ajax({dataType:"jsonp",url:i,jsonp:"cb",success:function(k){b.displaySuggestions(k)},error:function(){b.displaySuggestions()}})},suspendBlurDetection:function(){g.$input.unbind("blur.GH")},resumeBlurDetection:function(){g.$input.bind("blur.GH",function(i){b.processInputBlur(i)})},displaySuggestions:function(p){f.highlight=-1;f.$highlight=null;if(p!==undefined&&p[1].length>0){f.query=p[0];var o=p[1],j=a("<ul />"),m,k=o.length,n=new RegExp(f.query,"i"),q="<b>"+f.query+"</b>";for(m=0;m<k;m++){a("<li />").html(o[m].replace(n,q)).appendTo(j)}f.results=j.find("li");g.$output.empty().append(j).fadeIn("fast")}else{f.query="";f.results=[];g.$output.fadeOut("fast").empty()}}};a.extend(true,e,c,d);a.extend(true,b,e.fn);b.init(h);return h}})(jQuery);
(function(a){a.fn.globalSearchBox=function(d){var c={apiUrl:"http://autocomplete.search.aol.com/autocomplete/get",apiIt:"ops-test",apiOutput:"json",apiCount:8,apiQueryParam:"q",apiDictionary:"",ui_form:"#GH_search_form",ui_input:"#GH_search_field",ui_submit:"#GH_search_button",ui_output:"#GH_search_results",initSmartSearch:true,searchText:"",preserveGhostText:false,initFocus:false,fn:{}},e={},h=this,g={},f={ghostText:"",query:"",results:[],highlight:-1,$highlight:null,timer:null},b={init:function(i){g.$c=a(i);g.$input=a(e.ui_input);g.$output=a(e.ui_output);g.form=a(e.ui_form)[0];g.submit=a(e.ui_submit)[0];f.ghostText=g.$input.attr("defaultValue");g.$input.attr("autocomplete","off").bind("focus.GH",function(j){b.processInputFocus(j)}).bind("blur.GH",function(j){b.processInputBlur(j)});a(g.form).bind("submit.GH",function(j){b.selectSuggestion(j)});if(e.initSmartSearch){e.apiUrl=e.apiUrl+"?it="+e.apiIt+"&count="+e.apiCount+"&output="+e.apiOutput;if(e.apiDictionary!==""){e.apiUrl=e.apiUrl+"&dict="+e.apiDictionary}g.$input.bind("keyup.GH",function(j){b.processKeyPress(j)});g.$output.bind("mouseover.GH",function(j){b.moveHighlightMouse(j)}).bind("mouseover.GH",function(j){b.suspendBlurDetection(j)}).bind("mouseleave.GH",function(j){b.resumeBlurDetection(j)}).bind("click.GH",function(j){b.selectSuggestion(j)})}if(e.initFocus){g.$input.focus()}if(e.preserveGhostText){g.$label=a("<label />").attr("id","GH_search_label").text(f.ghostText).appendTo(g.form);g.$label.bind("click.GH_SL",function(j){b.preserveGhostText(true)});g.$input.bind("keyup.GH_SL",function(j){b.preserveGhostText(j)}).bind("click.GH_SL",function(j){b.preserveGhostText(j)}).bind("blur.GH_SL",function(j){setTimeout(function(){b.preserveGhostText(j)},250)})}if(e.searchText!==""){g.$input.val(e.searchText)}},getVars:function(){return{options:e,ui:g,local:f}},processInputFocus:function(i){g.$input.addClass("GH_search_active").val((g.$input.val()===f.ghostText)?"":g.$input.val())},processInputBlur:function(i){g.$input.removeClass("GH_search_active").val((g.$input.val()==="")?f.ghostText:g.$input.val());b.displaySuggestions()},preserveGhostText:function(i){if(typeof i==="boolean"&&i){g.$input.focus()}g.$input.unbind("keyup.GH_SL").unbind("click.GH_SL").unbind("blur.GH_SL");g.$label.remove()},processKeyPress:function(l){var j=l.keyCode;if(j===38){b.moveHighlightKey(-1)}else{if(j===40){b.moveHighlightKey(1)}else{var i=l.target,k=a.trim(i.value);if(k!==""){if(f.timer!==null){clearTimeout(f.timer)}f.timer=setTimeout(function(){b.getSuggestions(k)},200)}else{b.displaySuggestions()}}}},moveHighlightKey:function(j){if(f.$highlight!==null){f.$highlight.removeClass("GH_highlight")}f.highlight=f.highlight+j;if(f.highlight>=f.results.length||f.highlight===-1){f.highlight=-1;g.$input.val(f.query)}else{if(f.highlight<-1){f.highlight=f.results.length-1}}if(f.highlight>-1){f.$highlight=a(f.results[f.highlight]);f.$highlight.addClass("GH_highlight");g.$input.val(f.$highlight.text())}},moveHighlightMouse:function(j){var i=j.target;if(i.nodeName==="B"){i=i.parentNode}if(f.$highlight!==null){f.$highlight.removeClass("GH_highlight")}f.highlight=f.results.index(i);f.$highlight=a(i).addClass("GH_highlight")},selectSuggestion:function(j){j.preventDefault();if(j!==undefined&&j.type==="click"){var i=j.target;if(i.nodeName==="B"){i=i.parentNode}g.$input.val(a(i).text())}g.$input.val(a.trim(g.$input.val()));if(g.$input.val()!==""&&g.$input.val()!==f.ghostText){g.form.submit()}},getSuggestions:function(j){var i=e.apiUrl+"&"+e.apiQueryParam+"="+j;a.ajax({dataType:"jsonp",url:i,jsonp:"cb",success:function(k){b.displaySuggestions(k)},error:function(){b.displaySuggestions()}})},suspendBlurDetection:function(){g.$input.unbind("blur.GH")},resumeBlurDetection:function(){g.$input.bind("blur.GH",function(i){b.processInputBlur(i)})},displaySuggestions:function(p){f.highlight=-1;f.$highlight=null;if(p!==undefined&&p[1].length>0){f.query=p[0];var o=p[1],j=a("<ul />"),m,k=o.length,n=new RegExp(f.query,"i"),q="<b>"+f.query+"</b>";for(m=0;m<k;m++){a("<li />").html(o[m].replace(n,q)).appendTo(j)}f.results=j.find("li");g.$output.empty().append(j).fadeIn("fast")}else{f.query="";f.results=[];g.$output.fadeOut("fast").empty()}}};a.extend(true,e,c,d);a.extend(true,b,e.fn);b.init(h);return h}})(jQuery);

(function(a){a.fn.globalFooter=function(d){var c={activeTab:null,moreLinks:[],morePromoCount:6,moreText:"You might also like:",uiHat:"#GF_hat",uiHatLinks:"#GF_hat_links",uiHatTools:"#GF_hat_tools",uiNavLi:"li.GF_nav_LI",uiNavADd:".GF_nav_dd_A",auth:{doAuth:false,authenticated:false,authState:null,unauthState:null},search:{uiSearch:"#GF_search",params:{initOnDemand:true}},fn:{}},e={},i=this,h={},f={activeTab:null,moreLinksBuilt:false},g=e.fn||{},b={init:function(j){h.$c=a(j);h.hat=a(e.uiHat)[0];h.hatLinks=a(e.uiHatLinks)[0];h.$hatTools=a(e.uiHatTools);h.$search=a(e.search.uiSearch);h.$searchInput=h.$search.find("input:first");h.$searchSubmit=h.$search.find("input:last");h.$navLi=h.$c.find(e.uiNavLi);h.$navADd=h.$c.find(e.uiNavADd);b.setActiveTab(null,e.activeTab);(e.auth.doAuth)?b.buildAuth():false;b.buildMoreLinks();b.buildDropDowns();h.$c.bind("setActiveTab",b.setActiveTab);h.$searchInput.bind("focus.GF",b.buildSearch).attr("autocomplete","off");h.$searchSubmit.bind("mouseover.GF",b.buildSearch)},getVars:function(){return{options:e,ui:h,local:f}},buildSearch:function(j){h.$searchInput.unbind("focus.GF");h.$searchSubmit.unbind("mouseover.GF");if(j.target===h.$searchInput[0]){h.$searchInput.addClass("GF_search_active").attr("value","")}h.$search.globalSearchBoxFooter(e.search.params)},buildAuth:function(){if(e.auth.authenticated){h.$hatTools.append(e.auth.authState)}else{h.$hatTools.append(e.auth.unauthState)}},buildMoreLinks:function(){var o=e.moreLinks,m=0,j=o.length;if(j>=e.morePromoCount){var n,k=a("<li />").addClass("GF_hat_LI").append(n=a("<ul />").attr("id","GF_hat_more").addClass("GF_hat_UL").append(a("<li />").addClass("GF_hat_LI").text(e.moreText+"\xa0 ")));for(;m<e.morePromoCount;m++){n.append(a("<li />").addClass("GF_hat_LI").append(a("<a />").attr({href:o[m][1],target:(o[m][2]!==undefined)?o[m][2]:"_self"}).addClass("GF_hat_A GF_hat_more_A").text(o[m][0])).append((m<e.morePromoCount-1)?",\xa0":""))}if(j>e.morePromoCount){n.append(a("<li />").addClass("GF_hat_LI").append("\xa0and\xa0").append(a("<a />").attr({id:"GF_hat_more_link",href:"#"}).addClass("GF_hat_A GF_hat_more_A").text("More").bind("click.GF",b.toggleMoreLinks)))}k.appendTo(h.hatLinks)}},toggleMoreLinks:function(p){p.preventDefault();if(f.moreLinksBuilt===false){var n=e.moreLinks.slice(e.morePromoCount),o=0,m=n.length,j=Math.ceil(m/3),k=Math.ceil(m/3*2),s,r,q,t;h.$hatMoreList=a("<div />").attr("id","GF_more_list").append(a("<b />").attr("id","GF_more_list_lab").text("More Sites You Might Like")).append(s=a("<ul />").addClass("GF_more_list_UL")).append(r=a("<ul />").addClass("GF_more_list_UL")).append(q=a("<ul />").addClass("GF_more_list_UL"));for(;o<m;o++){t=a("<li />").append(a("<a />").attr({href:n[o][1],target:(n[o][2]!==undefined)?n[o][2]:"_self"}).text(n[o][0]));if(o<j){t.appendTo(s)}else{if(o<k){t.appendTo(r)}else{t.appendTo(q)}}}h.$hatMoreList.appendTo(h.hat);f.moreLinksBuilt=true}if(h.$hatMoreList.css("display")==="none"){h.$hatMoreList.fadeIn("fast")}else{h.$hatMoreList.fadeOut("fast")}return false},setActiveTab:function(k,j){if(j!==null){if(f.activeTab!==null){f.activeTab.removeClass("GF_nav_act")}f.activeTab=h.$navLi.eq(j).addClass("GF_nav_act")}},buildDropDowns:function(){h.$navLi.each(function(){var j=a(this);if(j.hasClass("GF_nav_list")){j.mouseover(function(){if(j.showtimer){clearInterval(j.showtimer);j.showtimer=null}j.addClass("GF_nav_list_open").find("ul").fadeIn("fast")}).mouseout(function(){j.showtimer=setTimeout(function(){if(j.showtimer){clearInterval(j.showtimer);j.showtimer=null}j.removeClass("GF_nav_list_open").find("ul").fadeOut("fast")},250)})}})}};a.extend(true,b,g);a.extend(true,e,c,d);b.init(i);return i}})(jQuery);
(function(a){a.fn.globalSearchBoxFooter=function(d){var c={apiUrl:"http://autocomplete.search.aol.com/autocomplete/get",apiIt:"ops-test",apiOutput:"json",apiCount:8,apiQueryParam:"q",ui_form:"#GF_search_form",ui_input:"#GF_search_field",ui_submit:"#GF_search_button",ui_output:"#GF_search_results",initOnDemand:false,initSmartSearch:true,fn:{}},e={},i=this,h={},f={ghostText:"",query:"",results:[],highlight:-1,$highlight:null,timer:null},g=e.fn||{},b={init:function(j){h.$c=a(j);h.form=a(e.ui_form)[0];h.input=a(e.ui_input)[0];h.submit=a(e.ui_submit)[0];h.output=a(e.ui_output)[0];f.ghostText=h.input.value;a(h.input).attr("autocomplete","off").bind("focus.GF",b.processInputFocus).bind("blur.GF",b.processInputBlur);a(h.form).bind("submit.GF",b.selectSuggestion);if(e.initSmartSearch){a(h.input).bind("keyup.GF",b.processKeyPress);a(h.output).bind("mouseover.GF",b.moveHighlightMouse).bind("mouseover.GF",b.suspendBlurDetection).bind("mouseout.GF",b.resumeBlurDetection).bind("click.GF",b.selectSuggestion)}},getVars:function(){return{options:e,ui:h,local:f}},processInputFocus:function(j){a(h.input).addClass("GF_search_active").attr("value","")},processInputBlur:function(j){a(h.input).removeClass("GF_search_active").attr("value",(h.input.value==="")?f.ghostText:h.input.value);b.displaySuggestions()},processKeyPress:function(n){var l=n.keyCode;if(l===38){b.moveHighlightKey(-1)}else{if(l===40){b.moveHighlightKey(1)}else{var j=n.target,m=a.trim(j.value);if(m!==""){if(f.timer!==null){clearTimeout(f.timer)}var k=(function(){f.timer=null;b.getSuggestions(m)});f.timer=setTimeout(function(){b.getSuggestions(m)},200)}else{b.displaySuggestions()}}}},moveHighlightKey:function(j){if(f.$highlight!==null){f.$highlight.removeClass("GF_highlight")}f.highlight=f.highlight+j;if(f.highlight>=f.results.length||f.highlight===-1){f.highlight=-1;h.input.value=f.query}else{if(f.highlight<-1){f.highlight=f.results.length-1}}if(f.highlight>-1){f.$highlight=a(f.results[f.highlight]);f.$highlight.addClass("GF_highlight");h.input.value=f.$highlight.text()}},moveHighlightMouse:function(k){var j=k.target;if(j.nodeName==="B"){j=j.parentNode}if(f.$highlight!==null){f.$highlight.removeClass("GF_highlight")}f.highlight=f.results.index(j);f.$highlight=a(j).addClass("GF_highlight")},selectSuggestion:function(k){k.preventDefault();if(k!==undefined&&k.type==="click"){var j=k.target;if(j.nodeName==="B"){j=j.parentNode}h.input.value=a(j).text()}if(h.input.value!==""&&h.input.value!==f.ghostText){h.form.submit()}},getSuggestions:function(k){var j=e.apiUrl+"?it="+e.apiIt+"&count="+e.apiCount+"&output="+e.apiOutput+"&"+e.apiQueryParam+"="+k;a.ajax({dataType:"jsonp",url:j,jsonp:"cb",success:function(l){b.displaySuggestions(l)},error:function(){b.displaySuggestions()}})},suspendBlurDetection:function(){a(h.input).unbind("blur.GF")},resumeBlurDetection:function(){a(h.input).bind("blur.GF",function(j){b.displaySuggestions()});h.input.focus()},displaySuggestions:function(q){f.highlight=-1;f.$highlight=null;if(q!==undefined&&q[1].length>0){f.query=q[0];var p=q[1],j=a("<ul />"),n,k=p.length,o=new RegExp(f.query,"i"),r="<b>"+f.query+"</b>";for(n=0;n<k;n++){var m=a("<li />").html(p[n].replace(o,r)).appendTo(j)}f.results=j.find("li");a(h.output).empty().append(j).fadeIn("fast")}else{f.query="";f.results=[];a(h.output).fadeOut("fast").empty()}}};a.extend(true,b,g);a.extend(true,e,c,d);b.init(i);return i}})(jQuery);

// jquery.jsonp 1.1.3 (c)2010 Julian Aubourg | MIT License
// http://code.google.com/p/jquery-jsonp/
(function(d){var b=function(n){return n!==undefined&&n!==null},m=function(p,n,o){b(p)&&p.apply(n,o)},e=function(n){setTimeout(n,0)},f="",a="&",k="?",l="success",g="error",i=d("head"),h={},c={callback:"C",url:location.href},j=function(s){s=d.extend({},c,s);var r=s.beforeSend,A=0;s.abort=function(){A=1};if(b(r)&&(r(s,s)===false||A)){return s}var q=s.success,o=s.complete,v=s.error,C=s.dataFilter,G=s.callbackParameter,w=s.callback,D=s.cache,n=s.pageCache,t=s.url,I=s.data,x=s.timeout,z,H,F,E;t=b(t)?t:f;I=b(I)?((typeof I)=="string"?I:d.param(I)):f;b(G)&&(I+=(I==f?f:a)+escape(G)+"=?");!D&&!n&&(I+=(I==f?f:a)+"_"+(new Date()).getTime()+"=");z=t.split(k);if(I!=f){H=I.split(k);E=z.length-1;E&&(z[E]+=a+H.shift());z=z.concat(H)}F=z.length-2;F>0&&(z[F]+=w+z.pop());var p=z.join(k),B=function(J){b(C)&&(J=C.apply(s,[J]));m(q,s,[J,l]);m(o,s,[s,l])},y=function(J){m(v,s,[s,J]);m(o,s,[s,J])},u=h[p];if(n&&b(u)){e(function(){b(u.s)?B(u.s):y(g)});return s}e(function(){if(A){return}var J=d("<iframe style='display:none' />").appendTo(i),L=J[0],N=L.contentWindow||L.contentDocument,P=N.document,K,Q,R=function(S,T){n&&!b(T)&&(h[p]=f);K();y(b(T)?T:g)},M=function(T){N[T]=undefined;try{delete N[T]}catch(S){}},O=w=="E"?"X":"E";if(!b(P)){P=N;N=P.getParentNode()}P.open();N[w]=function(S){A=1;n&&(h[p]={s:S});e(function(){K();B(S)})};N[O]=function(S){(!S||S=="complete")&&!A++&&e(R)};s.abort=K=function(){clearTimeout(Q);P.open();M(O);M(w);P.write(f);P.close();J.remove()};P.write(['<html><head><script src="',p,'" onload="',O,'()" onreadystatechange="',O,'(this.readyState)"><\/script></head><body onload="',O,'()"></body></html>'].join(f));P.close();x>0&&(Q=setTimeout(function(){!A&&R(f,"timeout")},x))});return s};j.setup=function(n){d.extend(c,n)};d.jsonp=j})(jQuery);

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function sendSuccess(){
var Comments = "Email: " + $('[name=AuthorEmail]').val()+ "\n";
Comments += "Age: " + $('[name=age]').val()+ "\n";
Comments += "Height: " + $('[name=height]').val()+ "\n";
Comments += "Old Weight: " + $('[name=oldWeight]').val()+ "\n";
Comments += "Current Weight: " + $('[name=curWeight]').val()+ "\n";
Comments += "How You Gained: " + $('[name=gainedWeight]').val()+ "\n";
Comments += "Break Point: " + $('[name=breakingPoint]').val()+ "\n";
Comments += "How Long You've Maintained Your Weight Loss: " + $('[name=lostWeight]').val()+ "\n\n";
Comments += "How You Lost: " + $('[name=howLostWeight]').val()+ "\n";
$('[name=Comments]').val(Comments);
}
function sendRecipe(){
var Comments = "Email: " + $('[name=AuthorEmail]').val()+ "\n";
Comments += "Recipe: " + $('[name=recipe]').val()+ "\n";
$('[name=Comments]').val(Comments);
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



// date format

var abbrevMonthName = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

function formatTime(count){
for(var i=0;i<count;i++){
	var date= new Date($("#rtnNews .item .timeStamp").eq(i).text());
	var hour=date.getHours();
	var minute = date.getMinutes();
	var day = date.getDate();
	var month = date.getMonth();
	var tag = "PM";
	if (hour > 12) {
	hour = hour - 12;
	tag = "PM";
	}else {
	tag = "AM";
	}
	if (isNaN(hour)){
	}else{
	$("#rtnNews .item .timeStamp").eq(i).html(hour +":"+minute+"&nbsp;"+tag+ " <span>&middot;</span> "+ abbrevMonthName[month]+" "+ day+" <span>&middot;</span> ");
	//$("#rtnNews .item .date").eq(i).html(abbrevMonthName[month]+"<br />"+ day);
	}
	}
}


function displayTopic(pgCnt, relevancy, newsTopic){
var topics = readCookie('hURTopic');
if (topics) {
	var splitTopics = unescape(topics).split("::");
	var yourTopics = "";
		if (splitTopics != null){
		for(var i = 0; i< splitTopics.length; i++){
			if (splitTopics[i]!=''){
				var splitTopicData = splitTopics[i].split("|");
				var topicID = '';
				if(splitTopicData[1] == ''){splitTopicData[1] =splitTopicData[0];}
				yourTopics += '<li><a title="Read ' + splitTopicData[0] + '" id="add'+escape(splitTopicData[1]) +'" class="add">' + splitTopicData[0] + '</a><a title="Delete ' + splitTopicData[0] + '" id="del'+escape(splitTopicData[1])+'" class="delete">&middot;</a></li>';
			}
		}
	
		$("#yourTopicList ul").html(yourTopics);
		if (!newsTopic){
		newsRelegenceAjax(rtnHost +"&dPgCnt="+ pgCnt +"&fRelMn="+ relevancy +"&c=?&qTxt="+$("#yourTopicList li a").eq(0).attr("id").substring(3));
		}else{
		newsRelegenceAjax(rtnHost +"&dPgCnt="+ pgCnt +"&fRelMn="+ relevancy +"&c=?&qTxt="+ newsTopic);
		}
		bindYourTopics(pgCnt, relevancy);	
		}
	}else {noStories();}
	
}
function noStories(){
	$("#rtnNews").html(rtnDefaultHTML);$("#rtnNews .infoSignin,#rtnNews .infoYourNews").css("display","block");$("#yourTopicList, #tabPanel .more, #tabPanel #showMore").css("display","none");$("#yourTopicList"). removeClass("yourTopicListEdit");$("#yourTopicList ul").text('');
}
function errorOut(){
	var recommendation='<div id="errorNews"><h5>We couldn\'t find any news on '+ $("#topicsList li.selected a.add").text()+'</h5><span>Here are some suggestions:</span><div class="infoSmall">'+ noResultsFoundList+"</div></div>";
	$("#yourTopicTxt").val("Sorry, No Results Found");
	//$("#tabPanel .more, #tabPanel #showMore").css("display","none");
	$("#rtnNews").html(recommendation);
}

function bindYourTopics(pgCnt, relevancy){
	$("#yourTopicList li a.add").unbind("click");
	$("#yourTopicList li a.add").bind("click", function(){
	$("#yourTopicList li").removeClass("selected");
	$(this).parent().addClass("selected");
		$('#rtnNews').text('');
		var unescapedTopicId = unescape($(this).attr("id").substring(3));
		newsRelegenceAjax(rtnHost+"&fRelMn="+ relevancy +"&c=?&qTxt="+escape(unescapedTopicId)+"&dPgCnt="+ pgCnt);
		
	});
}

function deleteTopic(topicEscaped){
var topics = unescape(readCookie('hURTopic'));
	var phoneRegex = new RegExp(topicEscaped+".*?::");
	var topicMatch = topics.match(phoneRegex);
	var cookieString = topics.split(topicMatch);
	cookieString = cookieString[0]+cookieString[1];
	createCookie('hURTopic',escape(cookieString),365);
	displayTopic($("#rtnNews .item").length);
}

function newsRelegenceAjax(URLstr){
$("#tabPanel .more, #tabPanel #showMore").css("display","none");
$.jsonp({type: "GET", url: URLstr,dataType: "jsonp", timeout:3000,success:function(dataset){
var relegenceCollection='';
  $.each(dataset.data.metaResponse.queryRslts, function(i,item){
            if (item.queryRslt.errorCode){return errorCode = item.queryRslt.errorCode;}
            	queryTerm = item.queryRslt.id;  
            	$.each(item.queryRslt.clusters, function(i, item){
            		$.each(item.cluster.assets, function(i, item){
            			relegenceCollection+='<div class="item"><div class="content"><h6><a href="'+item.url+'" class="title" rel="nofollow" target="_blank">'+item.headline+'</a></h6> <span class="timeStamp">'+item.publishDate+'</span> <span class="source">Source: <a href="'+item.url+'" target="_blank" rel="nofollow">'+item.source+'</a></span> <p class="snippet">'+((item.snippet)?item.snippet:"")+' <a href="'+item.url+'" class="readMore" target="_blank" rel="nofollow">Read More</a></p></div></div>';
            		});
            	});
            	//more than 15 records ad page handle
            		if (item.queryRslt.pageHandle){
            			$("#tabPanel #showMore").html('<a rel="nofollow">Show 15 More</a>');
            			pageHandle = item.queryRslt.pageHandle;
            			$("#tabPanel #showMore").unbind('click');
            			$("#tabPanel #showMore").bind("click", function(){
	            			if($("#yourTopicList li.selected a.add").length>0){
		            			newsRelegenceAjax(rtnHost+"&dPgCnt=6&fRelMn=65&c=?&qTxt="+$("#yourTopicList li.selected a.add").attr("id").substring(3)+"&dPgHnd="+pageHandle);
	            			}else{
	            				newsRelegenceAjax(rtnHost+"&dPgCnt=6&fRelMn=0&c=?&qTxt="+ healthMainTopic +"&dPgHnd="+pageHandle);
	            			}
            			});
            	
            		}else{$("#tabPanel #showMore").html('');$("#tabPanel #showMore").unbind('click')}
          });
                     	if (relegenceCollection !='' || errorCode ==''){
                     		$("#tabPanel .more, #tabPanel #showMore").css("display","block");
		        	 $("#rtnNews").append(relegenceCollection);
		        	 //$("#rtnNews").append(showMore);
		        	 formatTime($("#rtnNews .item").length);
		        	 return true;
		         }else {
		         	errorOut();
				return false;
		         }
 }
	
	,error:function (xOptions, textStatus){errorOut();}});
}	

	function categoryRelegenceAjax(qText){
		$.jsonp({type: "GET", url: qText,dataType: "jsonp", timeout:3000, success:function(dataset){
				var relegenceCollection='';
				var noNews='';
		         $.each(dataset.data.metaResponse.queryRslts, function(i,item){
		            $.each(item.queryRslt.clusters, function(i, item){
		            		
		            		$.each(item.cluster.assets, function(i, item){
		            		relegenceCollection+='<div class="item"><h6><a href="'+item.url+'" target="_blank">'+item.headline+'</a></h6><a class="urlFmt" href="'+item.url+'">'+((item.url.length> 37)?item.url.substring(0,37)+"...":item.url)+'</a></div>';
		            		});
		            	});
		            
		          });
		         if (relegenceCollection !=''){
		        	 $("#rtnNews").html(relegenceCollection);
		         }else{
		        	 $("#rtnNews").text("No News Available");
		        	 }
		         
		    }
		,error:function (xOptions, textStatus){$("#rtnNews").text("No News Available");}});
		
	}	
 
var rtnDefaultHTM;
var noResultsFoundList;
var newsArticleCount;
var rtnHost="http://newsrunner-rtn.web.aol.com/rdg/getAssetsMetaClustered?appId=HEALTH&qTyp=any&sPubDt=1&sUrl=1&sSrc=1&sHdln=1&sSnipt=1&f=json&fLng=en&sRelv=1"
var healthMainTopic= "healthsources:main";

$(function(){

$(document).ajaxError(function(event, request, settings){ alert("Error");});

if($("body.template-1").length){
    for (i=0;i<document.getElementsByTagName('img').length;i++) {
      document.getElementsByTagName('img')[i].removeAttribute('vspace');
      document.getElementsByTagName('img')[i].removeAttribute('hspace');
    }
}


	$('#GH_').globalHeader({
		moreLinks : 
			[['That’s Fit', 'http://www.thatsfit.com'],
			['Parenting','http://www.parentdish.com/'],
			['Recipes', 'http://www.kitchendaily.com/'],
			['Games','http://www.games.com/'],
			['Slashfood','http://www.slashfood.com/'],
			['ShelterPop','http://www.shelterpop.com/'],
			['AisleDash','http://www.aisledash.com/'],
			['AOL Horoscopes','http://horoscopes.aol.com/'],
			['DIY Life','http://www.diylife.com/'],
			['MyDaily','http://www.mydaily.com/'],
			['Holidash','http://www.holidash.com/'],
			['Lemondrop','http://www.lemondrop.com/'],
			['Morning Rush','http://www.morningrush.com/'],			
			['Paw Nation','http://www.pawnation.com/'],
			['StyleList','http://www.stylelist.com/'],
			['WalletPop','http://www.walletpop.com/'],
			['Shortcuts','http://shortcuts.com/'],
			['Shopping','http://shopping.aol.com/']],
		auth : {
			doAuth : true,
			authenticated: false,
			authState : '<li class="GH_hat_LI"><b class="GH_hat_links_A">Hi, User</b></li><li class="GH_hat_LI"><a href="/profile/" class="GH_hat_links_A" title="Profile">Profile</a></li><li class="GH_hat_LI"><a href="/profile/playlists/" class="GH_hat_links_A" title="Playlists">Playlists</a></li><li class="GH_hat_LI"><a href="http://my.screenname.aol.com/_cqr/logout/mcLogout.psp" class="jSignOut GH_hat_more" title="Sign Out">Sign Out</a></li>',
			unauthState : '<li class="GH_hat_LI"><a href="/signin" id="GH_signIn" title="Sign In / Register">Sign In / Register</a></li>'
		}			
	}); updateHeader();

		$('#GH_').globalFooter({});






$('#categories ul li:first, #family-health ul li:first, #healthy-living ul li:first, #subsubCategoryListLeftNav ul li:first, #relatedArticlesListLeftNav ul li:first, div.list ul li:last, #news .item:last ').css('border','none');

	rtnDefaultHTML = $("#rtnNews").html();
	noResultsFoundList = $("#rtnNews .infoSmall").html();

//initialize relegence call for category
if ($("#catRealTimeNews .body").length){
	categoryRelegenceAjax(rtnHost +'&dPgCnt=5&fRelMn=0&c=?&qTxt='+ healthMainTopic);
}

//initialize relegence call for News page

if ($("#healthRTnews #tabPanel").length){
	newsArticleCount = 6;
	newsRelegenceAjax(rtnHost +'&dPgCnt='+ newsArticleCount +'&fRelMn=0&c=?&qTxt='+ healthMainTopic);
}
// initialize health news relegence on Main Page
if ($("#healthNews #tabPanel").length){
	newsArticleCount = 3;
	newsRelegenceAjax(rtnHost +'&dPgCnt='+ newsArticleCount +'&fRelMn=0&c=?&qTxt='+ healthMainTopic);
}
//bind tab1
$("#healthRTnews .tab1, #healthNews .tab1").bind("click", function(){
$("#yourTopicList li a.add").unbind("click");
	$(this).siblings().removeClass("selected");
	$(this).addClass("selected");
	$('#rtnNews').text('');
	$("#yourTopicList").css("display", "none");
	newsRelegenceAjax(rtnHost +'&dPgCnt='+newsArticleCount +'&fRelMn=0&c=?&qTxt='+ healthMainTopic);
});

// bind tab2
$("#healthRTnews .tab2, #healthNews .tab2").bind("click", function(){
	$(this).siblings().removeClass("selected");
	$(this).addClass("selected");
	$("#yourTopicList").css("display", "block");
	$('#rtnNews').text('');
	displayTopic(newsArticleCount,65);
	$("#yourTopicList li").removeClass("selected");
	$("#yourTopicList li:first").addClass("selected");
	$("#yourTopicList li:last").addClass("last");
});

//add topics button
$("#addTopic").bind("click", function(){
if ($("#yourTopicTxt").val() != '' && $("#yourTopicTxt").val() != 'Enter a topic of interest'){
	$(this).parent(".tabs li").removeClass("selected");
	$(this).parent(".tab2").addClass("selected");
	$("#yourTopicList").css("display", "block");
	
		$('#rtnNews').text('');
		var topics = readCookie('hURTopic');
		if (topics){
	 		var splitTopics = unescape(topics).split("::");
	 		for(var i=0;i<splitTopics.length;i++){
	 		if (splitTopics[i] == $("#yourTopicTxt").val()){return false;}}		
	 		topicsUnescaped = unescape(topics);
			topics = topicsUnescaped + $("#yourTopicTxt").val() + "|" + $("#yourTopicHidden").val()+ "::";
		 
	 	}else{
	 		topics = $("#yourTopicTxt").val()+ "|" + $("#yourTopicHidden").val()+"::";	 
		}
		var relegenceTopicSearch=$("#yourTopicHidden").val();
		if ($('#yourTopicHidden').val() == ''){relegenceTopicSearch = $("#yourTopicTxt").val()}
			createCookie('hURTopic',escape(topics),365);
			displayTopic(newsArticleCount ,65, relegenceTopicSearch);
		$("#yourTopicList ul li").removeClass("selected");
		$("#yourTopicList ul li:last").addClass("selected");
		$("#yourTopicTxt").val('');
		$("#yourTopicHidden").val('');	
	}
});
//  suggestion searches
$("#healthRTnews .infoSmall li a, #healthNews .infoSmall li a").live("click", function(){
var entity;
var suggestionEntity=$(this).attr("href").split("http://");
if(suggestionEntity.length >1){entity=suggestionEntity[1]}else{entity=suggestionEntity[0]}
	$("#yourTopicList").css("display", "block");
	$('#rtnNews').text('');
	var topics = readCookie('hURTopic');
		if (topics){
	 		var splitTopics = unescape(topics).split("::");
	 		for(var i=0;i<splitTopics.length;i++){
	 		if (splitTopics[i] == $("#yourTopicTxt").val()){return false;}}		
	 		topicsUnescaped = unescape(topics);
			topics = topicsUnescaped + $(this).text() + "|" + entity + "::";
		 
	 	}else{
	 		topics = $(this).text() + "|" + entity+"::";	 
	}
	createCookie('hURTopic',escape(topics),365);
	displayTopic(newsArticleCount,65);
	$("#yourTopicList ul li:last").addClass("selected");
	$("#yourTopicTxt").val('');
	$("#yourTopicHidden").val('');
	return false;
});


/*  adds selected tag for navigation
var pageURL = new String(document.location);
var pageContext = pageURL.split("aolhealth.com");

$("#headerBottom .chNav li a").each(function(){
	if (pageContext[1] == $(this).attr("href")){
		$(this).addClass("selected");
	}});
*/


//search box for relegence module
	$("#yourTopicTxt").val("Enter a topic of interest");
	$("#yourTopicTxt").bind("focus", function(){
		if ($("#yourTopicTxt").val() == 'Enter a topic of interest'|| $("#yourTopicTxt").val()=='Sorry, No Results Found'){
		$("#yourTopicTxt").val('');$("#yourTopicTxt").addClass("active");
		}

	});
// edit topics for relgence module
$("#yourTopicList #topicsEditStart").bind("click", function(){
$("#yourTopicList li a.delete").live("click", function(){
	 	deleteTopic($(this).attr("title").substring(7));
	});
	$("#yourTopicList").addClass("yourTopicListEdit");
	return false;
});
$("#yourTopicList #topicsEditComplete").bind("click", function(){
$("#yourTopicList li a.delete").die("click");
	$("#yourTopicList"). removeClass("yourTopicListEdit");
	return false;
});


// for autocomplete feature which located on health main
	if($("#yourTopicTxt").autocomplete) {
	$("#yourTopicTxt").autocomplete("http://o.aolcdn.com/dashboard/SBG/REST/",
	{dataType: 'jsonp',
   	parse: function(data) {
     	var rows = new Array();
     	data = data.ud;
	     for(var i=0; i<data.length; i++){
	       rows[i] = {data:data[i], value:data[i].k, result:data[i].n };

	     }

       return rows;
     },
     formatItem: function(row, i, n) {
       return row.n;
     },
	extraParams:{q:'', f:'json',c:11,feeds:'t',appId:'health' ,n: function () { return $("#yourTopicTxt").val()} },
	max:11,
	width:168
});
}
if($("#yourTopicTxt").result) {
$("#yourTopicTxt").result(function(event, data, formatted) {
	if (data)$("#yourTopicHidden").val(data.k);
});
}


});

function __TABBLO_TPT_LOAD(){
	Tabblo.embedded.sites.SettingsObject.preprocess.apply({Properties:{template:'news'},FixedContent:{'logo':'http://www.blogsmithmedia.com/www.aolhealth.com/media/aolbody_logo.gif'},Content:{'pagetitle':{ match: 'css', selector:'h1.posttitle' },'text':{ match: 'css', selector:'.byline,.postbody', outputTagToo: true, recurse: true }, 'image': { match: 'css', selector:'.postbody img', nodeContentType: 'image' }} }, []); Tabblo.embedded.printabulous();
}
function MakePDF() {
	var tpS = document.createElement('script');tpS.setAttribute('type','text/javascript');tpS.setAttribute('charset','utf-8'); tpS.setAttribute('src','http://h30405.www3.hp.com/edit/tptboot/1.0');document.getElementsByTagName('body').item(0).appendChild(tpS);
}
function pdfPrint(url){
	MakePDF();
}
function showHpPop(iShow, cntr){
    if (iShow == 1) {
        document.getElementById(cntr).innerHTML = "<p>With HP wireless printers, you could have printed this from any room in the house. Live wirelessly. Print wirelessly.</p>";
        document.getElementById(cntr).style.display = "block";
    } else {
        document.getElementById(cntr).style.display = "none";
    }
}
// set channel specific omniture vars for print

function TrackPDF(){
    var s_265=s_gi('us.health'); 
    s_265.linkTrackVars='none';
    s_265.tl(this,'o','HP Print');   // where 'HP Print' is the name of the custom Omniture item.
}


// remove addthis print button from popup window
var addthis_config = {
	username: 'aolhealth', 
	services_exclude: 'print'
}

//Cross Promo
var d=document; var w=window;var docHg;
var range=400;
var cod_arr=new Array();
var arrLen = 0;
var modSpan = 6;
var currId = 0;
var opt = {
	ae:function(o,et,fn){if(o.addEventListener)o.addEventListener(et,fn,false);else if(o.attachEvent)o.attachEvent("on"+et,fn);},
	gt:function(t,o){o=o?o:document;return o.getElementsByTagName(t)},
	gc:function(c,t,s,o){var r=new Array();var os=opt.gt(t,o);for(var i=0,j=0,l=os.length;i<l;i++){var sc = s + os[i].className + s;if(sc.indexOf(s+c+s)!=-1){r[j] = os[i];j++;}}return r;},
        nview:function(obj,i) {
                if (obj.loaded==null) {
                    obj.loaded=0;
                }
                if (obj.loaded==0) {

                    if(document.all) {
                        var relTop=obj.offsetParent.offsetTop-(w.scrollY||d.documentElement.scrollTop);
                    } else {
                        var relTop=obj.offsetTop-(w.scrollY||d.documentElement.scrollTop);
                    }

                    if((relTop-docHg-20)<range) {
                      var codUrl=opt.gt('a',obj)[0].href;
                      opt.xhr(codUrl,obj,i);
                    }
                }
        },
        doCod:function(){
                var l=cod_arr.length;
                for (var i=0;i<l;i++) {
                        opt.nview(cod_arr[i],i);
                }
        },
        xhr:function(u,obj,i){
                obj.loaded=1;
                var f,r,m='GET';
                f=function(){if(r.readyState>3)opt.update(obj,r,i);}
                r= window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
                r.onreadystatechange=f;
                r.open(m,u,1);
                r.setRequestHeader('content-type','text/xml');
                r.send('');
        },
        update:function(obj,r,i) {
                if(r.status==200){
                        obj.innerHTML=r.responseText;
                } else {obj.loaded=0;}
        },
        init:function() {
                        cod_arr=opt.gc('cod','div','',document);
                        docHg=w.innerHeight||d.documentElement.offsetHeight;
                        opt.doCod();
                        opt.ae(window,'scroll',opt.doCod);
        },
        res:function(){
                docHg=w.innerHeight||d.documentElement.offsetHeight;
                opt.doCod();
        }

}
opt.ae(window,'resize',opt.res);
opt.ae(window,'load',opt.init);
function countCartridges() {
   var cartCount = 0;
   end = false;
   do {
      if(document.getElementById('cart'+cartCount)) {
         cartCount++;
      } else {
         end = true;
      }
   } while (end == false)
   arrLen = cartCount;
}
function showCartridges( startId ) {
  if(arrLen == 0) {
    countCartridges(); 
  }
  var i,j;
  for (i=0,j=startId; i < modSpan; i++,j++) {
     var strCart = j%arrLen;
     document.getElementById('cartridge'+i).innerHTML = document.getElementById('cart'+strCart).innerHTML;
  }
}
function isModFetched (modId) {
  if(document.getElementById('cart'+modId).innerHTML.length>0) {
      return true;
  } else {
      return false;
  }
}
function nextCartridge () {
  if(arrLen == 0) {
     countCartridges(); 
  }
  currId = currId + 1;
  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}
function prevCartridge () {
  if(arrLen == 0) {
    countCartridges(); 
  }  
  if(currId!=0) {
      currId = currId - 1
  } else {
      currId=arrLen-1;
  }

  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}
// Crosspromo end
//left nav highlighted    
function selNavTab() {
 var loc = window.location.toString().toLowerCase();
 var links = document.getElementById("leftRail").getElementsByTagName("ul");
 for(j=0;j<links.length;j++) {	
	var links1 = links[j].getElementsByTagName("li");		
	 for(i=0;i<links1.length;i++) {
	var links2 = links1[i].getElementsByTagName("a");	
		for(k=0;k<links2.length;k++){
		  var temp = links2[k].href.toLowerCase().replace("http://"+document.domain,"").toLowerCase();		  
		   (loc.indexOf(temp)>-1)?links1[i].className = "selected":"";
		   }
	  }
   }
} 
//left nav highlighted for asset page    
function assetSelNavTab(link1) {
 var loc = link1;
 var links = document.getElementById("leftRail").getElementsByTagName("ul");
 for(j=0;j<links.length;j++) {	
	var links1 = links[j].getElementsByTagName("li");		
	 for(i=0;i<links1.length;i++) {
	var links2 = links1[i].getElementsByTagName("a");	
		for(k=0;k<links2.length;k++){
		  var temp = links2[k].href.replace("http://"+document.domain,"").toLowerCase();		  
		   links1[i].className = (loc.indexOf(temp)>-1)?"selected":"";
		   }
	  }
   }
}
function showHide(showdiv,hidediv,tab1,tab2){
$('#'+showdiv).show();
$('#'+hidediv).hide();
$('#'+tab1).addClass("selected");
$('#'+tab2).removeClass("selected");
}

// Feeback JS

// fbLink v1.0d

var _fBr=encodeURIComponent(window.location.href);
var _fBh=362;
var _fBw=452;
var _fByt=(((screen.height-_fBh)/2)-100);
var _fBxl=((screen.width-_fBw)/2);

function _fBsG () {
	var _chG = typeof 's_channel' == 'undefined'? s_channel : '' ;
	return _chG;
}

function _fBsH () {
	var _chH = 'channel' in s_265? s_265.channel : "";
	_chH = _chH=='undefined'?'':_chH;
	return _chH;
}

function fBch() {
	var _ch = typeof s_265 == 'undefined'?_fBsG():_fBsH();
	return _ch;
}


function fBo(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
	return false;
}

function fBo2(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openFBHelp(href) {
	var _fBHelph=520;
	var _fBHelpw=794;
	var _fBHelpyt=(((screen.height-_fBHelph)/2)-100);
	var _fBHelpxl=((screen.width-_fBHelpw)/2);
	var href2=(href.indexOf('?')==-1?href+'?':href+'&');
    
	window.open(href2+'referer='+_fBr+'&ch='+fBch(),'feedback_help','width='+_fBHelpw+',height='+_fBHelph+',screenX='+_fBHelpxl+',screenY='+_fBHelpyt+',top='+_fBHelpyt+',left='+_fBHelpxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openStandard(href) {
	window.open(href,'','screenX=0,screenY=0,top=0,left=0,location=yes,toolbar=yes,resizable=yes,copyhistory=yes,scrollbars=yes');
}


//Profile JS

var attemptCount=0;
var isScrolling=0;

function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function getCookie(name) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ((!start)&&(name!= document.cookie.substring(0,name.length))) {
		return null;
	}
	if (start== -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

function showChangeProfile(name,websiteURL,private) {
	var space = document.getElementById("changeSpace");
        var memberid  = document.getElementById("memberid").value;
        //name = name.replace(/\'/gi, '\\\'');
	if (private == '-1') { isChecked="checked=\"checked\""; } else { isChecked = ""; }
	if (attemptCount < 3) {
		space.innerHTML = '<div id="formerrors" class="formerrors"></div><div id="profile_prochange"><div><label for="newname">Name:</label><input type="text" value="'+name+'" name="newname" id="newname" /></div><div><label for="newurl">Website:</label><input type="text" value="'+websiteURL+'" name="newurl" id="newurl" /></div><div id="pro_priv"><input type="checkbox" id="profilePrivate" '+isChecked+' /><label for="profilePrivate" class="checklabel">Make My Profile Private</label></div></div><div class="profile_buttons"><input type="button" id="profileButton" value="Save" onclick="updateProfile(); return false;" />&nbsp;&nbsp;<a href="#" onclick="emptySpace(); return false;">Cancel</a></div>';
	} else {
		space.innerHTML = '<div><div id="formerrors" class="formerrors">Disabled</div>';
	}
return false; 
}

function showPicUpload(url) {
	var space = document.getElementById("changeSpace");
	var memberid = document.getElementById("memberid").value;
	if (attemptCount < 3) {
		space.innerHTML = '<iframe scrolling="no" id="special_place" name="special_place" style="padding:0px;margin:0px;width:1px;height:1px;border:none;position:absolute;bottom:0px;left:0px;"></iframe> <form action="http://media.blogsmith.com/avatar/upload/" method="POST" enctype="multipart/form-data" target="special_place"><div id="uploadfile"><input type="file" name="Filedata" id="uploadimg" /><input type="hidden" name="i" value="'+escape(getCookie('DATA'))+'" /><input type="hidden" name="profileURL" value="'+url+'" /></div><div class="profile_buttons" id="uploadbuttons"><input id="uploadBtn" type="submit" value="Upload" onclick="document.getElementById(\'uploadBtn\').disabled = \'DISABLED\'; window.setTimeout(\'avatarUploadOK(true)\',2500);" /> <a href="#" onclick="cancelPicUpload(); return false;">Cancel</a></div></form>';
	}
	else {
		space.innerHTML = '<div><div id="formerrors" class="formerrors">Disabled</div>';
	}
}

function cancelPicUpload() {
	document.getElementById("changeSpace").innerHTML = "";
}

function showChangePassword() {
	var space = document.getElementById("changeSpace");
        if (attemptCount < 3) {
		space.innerHTML = '<div id="formerrors" class="formerrors"></div><div id="profile_passchange"><div><label for="oldpassword">Old Password:</label><input type="password" name="oldpassword" id="oldpassword" /></div><div><label for="newpassword">New Password:</label><input type="password" name="newpassword" id="newpassword" /></div><div><label for="confirmpassword">Confirm New:</label><input type="password" name="confirmpassword" id="confirmpassword" /></div><div class="profile_buttons"><input id="profileButton" type="button" onclick="changePassword()"; return false;" value="Change Password"><a href="#" onclick="emptySpace(); return false;">Cancel</a></div>';
        //getUserInfo();
        } else {
                space.innerHTML = '<div><div id="formerrors" class="formerrors">Disabled</div>';
        }
}

function showLogin() {
        var welcomeText = document.getElementById("profile_change");
        welcomeText.innerHTML = "";

        var loginText = document.getElementById("loginDiv");
        loginText.innerHTML = '<span id="pwStatus"></span><form name="login" onsubmit="profileLogin(); return false;"><label for="confirmpassword">Password: </label><input type="password" name="confirmpassword" id="pwLogin" /><input id="loginButton" type="submit" onClick="profileLogin();" value="Login"></form>';
        return false;
}

function profileLogin() {
        var loginValue = document.getElementById("pwLogin").value;
        var memberid  = document.getElementById("memberid").value;
	var loginBtn  = document.getElementById("loginButton");
	
	loginBtn.disabled = "disabled";
        postURL("/?a=ajax-user-login","f1="+escape(loginValue)+"&f2="+escape(memberid));
        return false;
}

function loginOK() {
        var space = document.getElementById("loginDiv");
	space.innerHTML = "<div id=\"loggingIn\">Now Logging you In.</div>";
	setTimeout("window.location.reload(false)",500);
	return false;
}

function loginERR() {
        var space = document.getElementById("pwStatus");
        var loginValue = document.getElementById("pwLogin");
        var loginButton = document.getElementById("loginButton");
	if (attemptCount < 3) {
                loginButton.disabled = "";
	        loginButton.value = "Login";
		loginValue.value = "";
        	space.innerHTML = "Invalid Password. Please Try Again.";
		loginValue.value = "";
	} else {
                space.innerHTML = "Too Many Attempts. Please Try Again Later.";
		loginValue.disabled = "DISABLED";
                loginButton.disabled = "DISABLED";
        }
	attemptCount++;
	return false;
}

function logOut() {
        getURL("/?a=ajax-logout");
	return(false);
}

function logoutOK() {
	window.location.reload(false);
	return false;
}

function changeNotify(commentid) {
	var notify    = document.getElementById("cn"+commentid);
        var memberid  = document.getElementById('memberid').value;
	var newNotify = '0';
        var error     = document.getElementById("formerrors"+commentid);
	if (notify.checked) { newNotify = '1'; } 
        getURL("/?a=ajax-update-comment-notify&commentid="+commentid+"&status="+newNotify+"&memberid="+memberid);

	return false;
}

function changeNotifyOK(commentid,result) {
	var space = document.getElementById("Result"+commentid);
        if (result == "Enabled") {
	     space.innerHTML = "<strong>Notify "+result+" </strong>";
        } else {
	     space.innerHTML = "<strong>Notify "+result+" </strong>";
        }
	return false;
}

function changeNotifyERR(commentid) {
	var error     = document.getElementById("formerrors"+commentid);	
        var password  = document.getElementById("pw"+commentid).value;

	error.innerHTML = "<strong>Invalid Password. Please try again.</strong>";
	password.value  = "";
}

function emptySpace() {
	var space = document.getElementById("changeSpace");
	space.innerHTML = "";
}

function emptyCommentSpace(commentid) {
        var space = document.getElementById("pwb"+commentid);
        space.innerHTML = "";
}

function avatarUploadOK(status, msg) {
	if (status) { 
		var avatar = document.getElementById('avatar');
		var src = avatar.src;
		var clean = src.split("?");
		avatar.src = clean[0] + "?nocache&ver=" + (Math.floor(Math.random()*10000));
	} 
	else {
		alert(msg);
                return false;
	}
        var space   = document.getElementById("changeSpace");
        space.innerHTML = '<div id="updatetext"><span class="updateText">Upload Successful. Avatars may take up to 5 minutes to update on blogs.</span></div>';
        //setTimeout("emptySpace()",5000);
        setTimeout("scrollUp('changeSpace',-999,0,1,40)",5000);
        return false;
}

function changePassword() {
        var errorField  = document.getElementById("formerrors");
	var memberid    = document.getElementById('memberid').value;
	var oldPassword = document.getElementById('oldpassword').value;
	var newPassword = document.getElementById('newpassword').value;
	var cnfPassword = document.getElementById('confirmpassword').value; 
	var pwdButton   = document.getElementById('profileButton').value;

	if (oldPassword=="" || newPassword=="" || cnfPassword ==""){ errorField.innerHTML = "<strong>Please fill out all the form fields</strong>"; return false; }
 	if (newPassword.length < 6) { errorField.innerHTML = "<strong>New Password Must be atleast 6 Characters in Length</strong>"; newPassword=""; cnfPassword=""; return false; }
	if (newPassword != cnfPassword) { errorField.innerHTML = "<strong>New Password and Confirm Password fields don't match.</strong>"; return false; }

        errorField.innerHTML = "";
	pwdButton.value = "Processing...";
        postURL("/?a=ajax-update-account","memberid="+memberid+"&f1="+escape(oldPassword)+"&f2="+escape(newPassword));	
	return false;
}

function changePasswordOK() {
        var space = document.getElementById("changeSpace");
	space.innerHTML = '<div id="updatetext"><span class="updateText">Password Updated. </span></div>';
	return false;
        attemptCount = 0;
}

function changePasswordERR() {
	var errorField = document.getElementById("formerrors");
        var pwdButton   = document.getElementById('profileButton').value;

	errorField.innerHTML = '<strong>Invalid Attempt. Please try again.</strong>';
        document.getElementById('oldpassword').value = "";
        document.getElementById('newpassword').value = "";
        document.getElementById('confirmpassword').value = "";
	pwdButton.value = 'Change Password';
	attemptCount++;

	if (attemptCount >= 3) {
        	document.getElementById('oldpassword').disabled = "DISABLED";
        	document.getElementById('newpassword').disabled = "DISABLED";
        	document.getElementById('confirmpassword').disabled = "DISABLED";
		document.getElementByID('profileButton').disabled = "DISABLED";
		pwdButton.value = "Disabled";
	 	errorField.innerHTML = "<strong>Too Many Attempts. Please try later.</strong>";
	}
	return false;
}

function updateProfile() {
	var name       = document.getElementById('newname').value;
	var website    = document.getElementById('newurl').value;
        var memberid   = document.getElementById('memberid').value;
	var private    = document.getElementById('profilePrivate');
        var errorField = document.getElementById('formerrors');
        var pwdButton  = document.getElementById('profileButton');

	if(trim(name)==""){ errorField.innerHTML = "You need a name. If you can't think of anything, just use an old car's nickname."; return false }
	if(private.checked) { var privateValue='-1'; } else { var privateValue='0'; }
        pwdButton.value = "Saving...";
        pwdButton.disabled = "DISABLED";
	postURL("/?a=ajax-update-profile","memberid="+escape(memberid)+"&name="+escape(name)+"&website="+escape(website)+"&private="+privateValue);

	return false;
}

function updateProfileOK(name, newurl, private) {
        var space   = document.getElementById("changeSpace");
        var memName = document.getElementById("memberName");
        var memSite = document.getElementById("memberUrl");
        var memPrivate = document.getElementById("privacy_status");
        var privateBox = document.getElementById("profilePrivate");
        var profileBtn = document.getElementById("changeProfile");

        memName.innerHTML = "<strong>"+name+"</strong>";
        document.title = "Profile for: "+name;
        memSite.innerHTML =  "<a href=\""+newurl+"\">"+newurl+"</a>";
        if(private==-1){
                memPrivate.innerHTML = "Private Profile";
        } else {
                memPrivate.innerHTML = "Public Profile"
        }
        //name = name.replace(/\'/gi, '\\\'');
        //profileBtn.attributes["onclick"].value = "showChangeProfile('"+name+"','"+newurl+"','"+private+"'); return false;";
        profileBtn.onclick = function() { showChangeProfile(name,newurl,private); return false; }
        space.innerHTML = '<div id="updatetext"><span class="updateText">Profile Updated. </span></div>';
        setTimeout("scrollUp('changeSpace',-999,0,1,40)",2500);
        return false;
}


function updateProfileERR() {
        var errorField = document.getElementById("formerrors");
        var pwdButton   = document.getElementById('profileButton');

        errorField.innerHTML = '<strong>Invalid Attempt. Please try again.</strong>';
        document.getElementById('password').value = "";
        pedButton.disabled = "";
        pwdButton.value = 'Save';
        attemptCount++;

        if (attemptCount >= 3) {
                document.getElementById('password').disabled = "disabled";
                document.getElementById('newname').disabled = "disabled";
                document.getElementById('newurl').disabled = "disabled";
                pwdButton.value = "Disabled";
                errorField.innerHTML = "<strong>Too Many Attempts. Please try later.</strong>";
        }
        return false;
}

function scrollUp(field,old,max,speed,delay) {

        var id = document.getElementById(field);
        if (old == -999) { old = document.getElementById(field).offsetHeight; }
        if (old > max) {
                isScrolling = 1;
                var current = parseInt(old)-parseInt(speed);
                if (current >= old) {
                       id.style.height = "";
                       isScrolling = 0;
                       return false;
                }
                id.style.height = current+"px";
                setTimeout("scrollUp('"+field+"',"+current+","+max+","+speed+","+delay+")", delay);
        } else {
                isScrolling = 0;
                id.innerHTML = "";
                id.style.height = "";
        }
        return false;
}
function changetext(param) {
    var textSize = param=="small"?12:param=="medium"?14:param=="large"?16:12;
    $(".postbody").animate({fontSize: textSize+"px"},400);
    return false;
}
    (function($) {
        $(document).ready(function() {

            var $pictureUrl = $('#picture-url');

            $('#authLink').multiAuth({
                devId: 'ao1atoKNL9675h',
                tabs: ['aol', 'aim'],
                getTokenCallback: function(json) {

                    var $elem = $(this.authLink),
                            response = json.response,
                            userAttr;

                    if (response.statusCode === 200) {

                        userAttr = response.data.userData.attributes;
                        $elem.html('Welcome ' + userAttr.displayName + '! Sign out.');
                        $("#headerSignIn").html($elem.html());

                        if (userAttr.pictureUrl) {
                            $pictureUrl.html('<img src="' + userAttr.pictureUrl + '" />');
                        }

                        $('#gcp_comments').comments('auth', {devId : 'ao1atoKNL9675h', authToken : response.data.token.a});

                    } else {
                        $("#headerSignIn").html("Sign In / Register");
                        $("#headerSignIn").length==0?$elem.html('Sign In / Register'):$elem.html('Sign in to add your comment');
                        $pictureUrl.html('');
                        $('#gcp_comments').comments('unauth');
                    }
                }
            });

	var config = {
                "max_reply_depth":1,
    		"channel_id" : 4, 
    		"topic_id" : gcp_topic_id, 
    		"topic_title" : document.title, 
    		"permalink" : document.URL, 
    		"topic_description": document.title,
                "sort":"new",
                "count":20,
                "authSelector":"authLink",
                "comment_count_selector" : ".miniCount"
    	};
    $('#gcp_comments').comments(config);
        });
    })(jQuery);