(function(a){a.fn.globalFooter=function(d){var c={activeTab:null,moreLinks:[],morePromoCount:2,moreText:"You might also like:",moreAnd:"and",moreMore:"More",moreTextHeadline:"More Sites You Might 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:{}},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.globalSearchBoxFooter(e.search.params)}else{g.$searchInput.bind("focus.GF",function(j){b.buildSearch(j)}).attr("autocomplete","off");g.$searchSubmit.bind("mouseover.GF",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.GF");g.$searchSubmit.unbind("mouseover.GF");if(i.target===g.$searchInput[0]){g.$searchInput.addClass("GF_search_active").attr("value","")}g.$search.globalSearchBoxFooter(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 p=e.moreLinks,n=0,j=p.length;if(j>=e.morePromoCount){var k=a("#GF_hat_more"),o,m;if(!k.length){m=a("<li />").addClass("GF_hat_LI").append(o=a("<ul />").attr("id","GF_hat_more").addClass("GF_hat_UL").append(a("<li />").addClass("GF_hat_LI").text(e.moreText+"\xa0 ")));for(;n<e.morePromoCount;n++){o.append(a("<li />").addClass("GF_hat_LI").append(a("<a />").attr({href:p[n][1],target:(p[n][2]!==undefined)?p[n][2]:"_self"}).addClass("GF_hat_A GF_hat_more_A").text(p[n][0])).append((n<e.morePromoCount-1)?",\xa0":""))}if(j>e.morePromoCount){o.append(g.$hatLIMore=a("<li />").addClass("GF_hat_LI GF_hat_LI_more").append("\xa0"+e.moreAnd+"\xa0").append(g.$hatMoreLink=a("<a />").attr({id:"GF_hat_more_link",href:"#"}).addClass("GF_hat_A GF_hat_more_A").text(e.moreMore)))}m.appendTo(g.hatLinks)}else{g.$hatMoreLink=a("#GF_hat_more_link");g.$hatLIMore=g.$hatMoreLink.parent()}g.$hatMoreLink.bind("mouseover.GF",function(i){b.showMoreLinks(i)})}},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","GF_more_list").append(a("<b />").attr("id","GF_more_list_lab").text(e.moreTextHeadline)).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)}}}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.GFTEMP",function(i){b.kill(i)});g.$hatMoreList.fadeIn("fast")}},kill:function(j){var i=a(j.target);if(i.closest("#GF_hat_more_link").length===0&&i.closest("#GF_more_list").length===0){g.$d.unbind("mousemove.GFTEMP");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("GF_nav_list")){a("#GF_nav_act_B").removeAttr("id")}}f.activeTab=g.$navLi.eq(i).attr("id","GF_nav_act");f.activeTab.children().eq(0).css("clear","both");if(f.activeTab.hasClass("GF_nav_list")){f.activeTab.children().eq(0).wrapInner('<b id="GF_nav_act_B"></b>')}}},buildDropDowns:function(){g.$navLi.each(function(){var i=a(this);if(i.hasClass("GF_nav_list")){i.mouseover(function(){if(i.showtimer){clearInterval(i.showtimer);i.showtimer=null}i.addClass("GF_nav_list_open").find("ul").fadeIn("fast")}).mouseout(function(){i.showtimer=setTimeout(function(){if(i.showtimer){clearInterval(i.showtimer);i.showtimer=null}i.removeClass("GF_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);
/*	name : globalSearchBoxFooter
	file : jquery.globalsearchbox-d.js
	author : Ali Hasan
	(c) Copyright 2009 AOL LLC
	$LastChangedDate: 2009-11-20 14:21:28 -0500 (Fri, 20 Nov 2009) $
	$Rev: 133745 $
*/
(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",apiDictionary:"",ui_form:"#GF_search_form",ui_input:"#GF_search_field",ui_submit:"#GF_search_button",ui_output:"#GF_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.GF",function(j){b.processInputFocus(j)}).bind("blur.GF",function(j){b.processInputBlur(j)});a(g.form).bind("submit.GF",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.GF",function(j){b.processKeyPress(j)});g.$output.bind("mouseover.GF",function(j){b.moveHighlightMouse(j)}).bind("mouseover.GF",function(j){b.suspendBlurDetection(j)}).bind("mouseleave.GF",function(j){b.resumeBlurDetection(j)}).bind("click.GF",function(j){b.selectSuggestion(j)})}if(e.initFocus){g.$input.focus()}if(e.preserveGhostText){g.$label=a("<label />").attr("id","GF_search_label").text(f.ghostText).appendTo(g.form);g.$label.bind("click.GF_SL",function(j){b.preserveGhostText(true)});g.$input.bind("keyup.GF_SL",function(j){b.preserveGhostText(j)}).bind("click.GF_SL",function(j){b.preserveGhostText(j)}).bind("blur.GF_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("GF_search_active").val((g.$input.val()===f.ghostText)?"":g.$input.val())},processInputBlur:function(i){g.$input.removeClass("GF_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.GF_SL").unbind("click.GF_SL").unbind("blur.GF_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.GF")},resumeBlurDetection:function(){g.$input.bind("blur.GF",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);

$(document).ready(function() {
 $('#GH_').globalHeader({
  morePromoCount: 2,
  moreLinks: 
   			[["That's Fit", 'http://www.thatsfit.com'],
			['Parenting','http://www.parentdish.com/'],
			['Games','http://www.games.com/'],
			['Slashfood','http://www.slashfood.com/'],
			['ShelterPop','http://www.shelterpop.com/'],
			['AisleDash','http://www.aisledash.com/'],
			['BlackVoices','http://www.blackvoices.com/'],
			['DIY Life','http://www.diylife.com/'],
			['MyDaily','http://www.mydaily.com/'],
			['Holidash','http://www.holidash.com/'],
			['Recipes', 'http://www.kitchendaily.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/'],
			['AOL Latino','http://www.aollatino.com/']],	
  auth: {
   doAuth: false,
   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" class="jSignIn" title="Sign In / Register">Sign In / Register</a></li>'
  }
 });
 $('#GH_').globalFooter({});
});
function fn_miniSignIn(obj, parentUrl, sitedomain,contextPath){
    
    //if(obj) {		
    var parDiv = document.createElement("div");
    parDiv.style.position="absolute";
    parDiv.style.zIndex="100";
    parDiv.style.display="inline";
    parDiv.style.margin="22 -17";
    //var sitedomain1 = "bodydev.office.aol.com";
    var innerHtml = ajaxCall(contextPath+"/miniSignInPopup.jsp?parentUrl="+encodeURL(parentUrl)+"&sitedomain="+sitedomain);
    //flgFly = obj.parentNode.rowIndex;
    parDiv.innerHTML= "<div id='snsMiniUI' style='left: -103px; top: -49px; position: relative; z-index: 5000; display: block;'>"+innerHtml+"</div>";
    obj.appendChild(parDiv);
    //}
    
}
function ajaxCall(url) {
	var page_request = false;
	if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
			}
		}
	else if (window.XMLHttpRequest) {// if Mozilla, Safari etc
		page_request = new XMLHttpRequest();}
	else{
		return false;}
	page_request.open('GET', url, false); //get page synchronously
	page_request.send(null);
	return page_request.responseText;

	
}
function encodeURL (string) {
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";

    for (var n = 0; n < string.length; n++) {

        var c = string.charCodeAt(n);

        if (c < 128) {
            utftext += String.fromCharCode(c);
        }
        else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        }
        else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }

    }

    return utftext;
}

function decodeURL(utftext) {
    var string = "";
    var i = 0;
    var c = c1 = c2 = 0;

    while ( i < utftext.length ) {

        c = utftext.charCodeAt(i);

        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        }
        else if((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        }
        else {
            c2 = utftext.charCodeAt(i+1);
            c3 = utftext.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }

    }

    return string;
}


function cntCheckOfCommnts()
{
var	cnt=document.getElementById("commentsMaxLength");
var	field=document.getElementById("typcomnthere").value;
var len=field.length;
if(len > 1000){
	document.getElementById("typcomnthere").value=field.substring(0,1000);
	}
	else
	{
	cnt.innerHTML=1000-len+"/1000";
	}
}

function fn_notify(obj,channelURN,galleryId,photoURN,userName,userGUID,ipAddr,contextPath){				
	if(obj && document.getElementById("notPop") && obj.parentNode.rowIndex==flgFly) {return;}
	if(document.getElementById("notPop")){
		var x=document.getElementById("notPop").parentNode;
		x.parentNode.removeChild(x);
	}
	if(obj) {
		var parDiv = document.createElement("div");
		parDiv.style.position="absolute";		
		var innerHtml = ajaxCall(contextPath+"/reportAboutAsset.jsp/?channelURN="+channelURN+"&galleryURN="+galleryId+"&photoURN="+photoURN+"&userName="+userName+"&ipAddr="+ipAddr+"&contextPath="+contextPath+"&userGUID="+userGUID);
		flgFly = obj.parentNode.rowIndex;
		parDiv.innerHTML= '<div id="notPop"><a onclick="fn_notify();" class="closeBut">CLOSE</a><div class="notPMain">'+innerHtml+'</div></div>';
		obj.parentNode.insertBefore(parDiv,obj);
	}
}

//REPORT THIS TOP POP UP
function comment_report_popup(obj, coco, violator, clip, deleteInfo,contextPath){
    if(obj && document.getElementById("notPop") && obj.parentNode.rowIndex==flgFly) {return;}
    if(document.getElementById("notPop")){
            var x=document.getElementById("notPop").parentNode;
            x.parentNode.removeChild(x);
    }
    if(obj) {
            var parDiv = document.createElement("div");
            parDiv.style.position="absolute";
            var innerHtml = ajaxCall(contextPath+"/commentReport.jsp?coco="+coco+"&violator="+violator+"&clip="+clip+"&dinfo="+deleteInfo+"&url="+document.location);
            flgFly = obj.parentNode.rowIndex;
            parDiv.innerHTML= '<div id="notPop"><a onclick="comment_report_popup()" class="closeBut">CLOSE</a><div class="notPMain">'+innerHtml+'</div></div>';
            obj.parentNode.insertBefore(parDiv,obj);
    }
}

//SUBMIT REPORT THIS FORM VIA POP UP
function reportThisComment(umtHost, coco, violator, clip, deleteInfo, contextPath,umtProduct) {
umtProduct1 = "livinghealth%20comments";
    var yourEmailAddr=document.getElementById("yourEmailAddr").value;
    if (yourEmailAddr == null) {
    	yourEmailAddr = 'living_null@aol.com';
    }
    var userComment=document.getElementById("additComments").value;
    var reportType=document.getElementById("reportType").value;
var comment = encodeURIComponent(userComment + "<br>Report Type: " + reportType);
    clip = encodeURIComponent(clip + "<br><br>" + deleteInfo);
    //umtHost = "http://qaccare-ql02.tops.aol.com:9180/umt/queued_add.jsp";
    //umtHost = "/lyratest.jsp";        
var reportAbuseData = "action=insert&reporter=" + yourEmailAddr + "&product="+umtProduct1+"&violator=" + violator + "&coco=" + coco + "&violator_url=" + encodeURIComponent(document.location) + "&clip=" + clip  + "&comment=" + comment;

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                    // set type accordingly to anticipated content type
                    //http_request.overrideMimeType('text/xml');
                    http_request.overrideMimeType('text/html');
            }
    } else if (window.ActiveXObject) { // IE
            try {
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                    try {
                            http_request = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {}
            }
    }
    if (!http_request) {
            //alert('Cannot create XMLHTTP instance');
            return false;
    }
    
    http_request.open('POST', umtHost, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", reportAbuseData.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(reportAbuseData);
    comment_report_popup();
}
function reportThisCommentCancel() {
    //alert("test");
    comment_report_popup();
}

function reportThisNotify(channelURN,galleryId,photoURN,userName,userGUID,ipAddr,contextPath) {	
	//alert("test");
	var yourEmailAddr=document.getElementById("yourEmailAddr").value;
	var additComments=document.getElementById("additComments").value;
	var reportType=document.getElementById("reportType").value;
	var res=ajaxCall(contextPath+"/submitNotification.jsp?channelURN="+channelURN+"&galleryURN="+galleryId+"&photoURN="+photoURN+"&userName="+userName+"&userGUID="+userGUID+"&ipAddr="+ipAddr+"&yourEmailAddr="+yourEmailAddr+"&auditComments="+additComments+"&reportType="+reportType);
	javascript:fn_notify();
}
function reportThisNotifyCancel() {
	//alert("test");
	javascript:fn_notify();
}
function cntCheckOfCommntsInNotify()
{
	var	cnt=document.getElementById("notifyCommentsMaxLength");
	var	field=document.getElementById("additComments").value;
	var len=field.length;
	if(len > 1024){
		document.getElementById("additComments").value=field.substring(0,1024);
		cnt.innerText=0;
		cnt.innerHTML=0;
	}else{
	    cnt.innerText=1024-len;
	    cnt.innerHTML=1024-len;
	}
}
String.prototype.trim = function() {  
	   return this.replace(/^\s+/,"").replace(/\s+$/,"");  
}  

function checkComment(){

	var browser=navigator.appName;
	
	var b_version=navigator.appVersion;
	
	var version=parseFloat(b_version);
	
   
    var commTxt=document.getElementById("typcomnthere").value.trim();
  
    if(commTxt=='Type Your Comment Here' || commTxt==null || commTxt=='') {
    	return;
    }
    else{
    		
			document.commts.typcomnthere.value = document.commts.typcomnthere.value.replace(/\"/g,"");
			document.commts.typcomnthere.value = document.commts.typcomnthere.value.replace(/^\s*/, "").replace(/\s*$/, "").replace(/\\/g,"");
        	document.commts.submit();
		              
    }
}
function clearTxtArea()
{
	document.getElementById("typcomnthere").value="";
	document.getElementById("commentsMaxLength").innerHTML="1000";
}
function makeRequest(url) {
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
    request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    request.open('POST', url, true);
    request.onreadystatechange = reqStatus;
    request.send(url);
}

function sendDisabled(val,btnId) {
    if (val == 1) {
        document.getElementById(btnId).disabled=true;  
    }
    if (val == 0) {
       document.getElementById(btnId).disabled=false;  
    }                
}

//Share Javascript
function submitEmail() {
  if (document.forms[0].emailTo.value =='' || document.forms[0].emailMsg.value =='') {
      alert('To and Message fields are required.');
      return;
  }
  var emailMsg = document.forms[0].emailMsg.value +"\n"+document.forms[0].emailUrl.value;
  var emailTo = document.forms[0].emailTo.value;                
  var emailFrom = document.forms[0].emailFrom.value;
  var emailSubject = document.forms[0].emailSubject.value;
  makeRequest('/gardening/ajax_handlers/sendEmail.jsp?emailMsg=' + escape(emailMsg) + '&emailFrom=' + escape(emailFrom)+ '&emailTo=' + escape(emailTo)+ '&emailSubject=' + escape(emailSubject));
}

function noImage(){
	$(this).attr("src", "http://o.aolcdn.com/art/ch_home/gardening/images/profilepic-default.gif");
}

function __TABBLO_TPT_LOAD(){
	Tabblo.embedded.sites.SettingsObject.preprocess.apply({Properties:{template:'news'},FixedContent:{'logo':'http://o.aolcdn.com/os/living/health/images/aolbody_logo.gif'},Content:{'pagetitle':{ match: 'css', selector:'h2' }, 'text':{ match: 'css', selector:'.articleContainer', outputTagToo: true, recurse: true }, 'image': { match: 'css', selector:'#mainArtNavHead .left 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'
}



var flgFly = "";
function fn_addItem(obj,msg) {
	if(obj && document.getElementById("popupQuestionMark") && obj.parentNode.rowIndex==flgFly) {return;}

	if(document.getElementById("popupQuestionMark")){
		var x=document.getElementById("popupQuestionMark").parentNode;
		x.parentNode.removeChild(x);

	}
	if(obj) {
		var parDiv = document.createElement("div");
		parDiv.style.position="absolute";
		parDiv.style.zIndex="100";
		parDiv.style.display="inline";
      parDiv.style.margin="27px 10px";
		var innerHtml = ajaxCall("/gardening/popupQuestion.jsp?msg="+msg);
		flgFly = obj.parentNode.rowIndex;
		parDiv.innerHTML= "<div id='popupQuestionMark'><a href='javascript:void(0);' onclick='javascript:fn_addItem();'>&nbsp;</a><div class='popupContentPart'>"+innerHtml+"</div></div>";
	obj.parentNode.insertBefore(parDiv,obj);
	}
}


function getEl( id ){ return document.getElementById( id ); }
function p_o(o){return getEl(o);}

function URLEncode(textToEncode)
{
  // The Javascript escape and unescape functions do not correspond
  // with what browsers actually do...
  var SAFECHARS = "0123456789" +					// Numeric
  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
  "abcdefghijklmnopqrstuvwxyz" +
      "-_.!~*'()";					// RFC2396 Mark characters
  var HEX = "0123456789ABCDEF";
  
  var plaintext = textToEncode;
  var encoded = "";
  for (var i = 0; i < plaintext.length; i++ ) {
      var ch = plaintext.charAt(i);
      if (ch == " ") {
          encoded += "+";				// x-www-urlencoded, rather than %20
      } else if (SAFECHARS.indexOf(ch) != -1) {
          encoded += ch;
      } else {
          var charCode = ch.charCodeAt(0);
          if (charCode > 255) {
              alert( "Unicode Character '" 
                  + ch 
                  + "' cannot be encoded using standard URL encoding.\n" +
                  "(URL encoding only supports 8-bit characters.)\n" +
                  "A space (+) will be substituted." );
              encoded += "+";
          } else {
              encoded += "%";
              encoded += HEX.charAt((charCode >> 4) & 0xF);
              encoded += HEX.charAt(charCode & 0xF);
          }
      }
  } // for
  return encoded;
};
function onFieldFocus(id,msg) {
  if(document.getElementById(id).value == msg){
      document.getElementById(id).value = ''; 
  }
}

function onFieldBlur(id,msg) {
  if(document.getElementById(id).value == ''){
      document.getElementById(id).value = msg; 
  }
}
function doClear(theText){
	if (theText.value == theText.defaultValue){
		theText.value = "";
	}
}


//SL JS -------------
function set_variable(var1) {
  if(var1 == 'var_redirUrl')
      return '';
  if(var1 == 'start')
  	return '<div class="sponsor2">' + '<div class="header">' + 'Sponsored Links</div><div class="body">';
  if(var1 == 'end')
      return '';
  	//return '<a href="http://about-search.aol.com/#csl" class="info">(What Is This?)</a></div></div>';
  return;
}

function languageText(sponsorData) {
  var languageText2 = new Object(3);
  if (params.language2 != 0) {
      languageText2[0] = 'Mira M&aacute;s Ofertas';
      languageText2[1] = 'M&aacute;s Ofertas ';
      languageText2[2] = '';
  } else {
      languageText2[0] = 'See More Offers';
      languageText2[1] = 'See More ';
      languageText2[2] = ' Offers';
  }
  return languageText2;
}
function set_prms_see_more(kw_offer, campaign) {
  var params2 = {
          query:'',
          sbrand:'',
          sch:'',
          sclient:'aol-landing',
          scoco:'',
          snum:10,
          ssch:'',
          sview:''
  };

  params2.query = kw_offer;
  params2.sch = params.sch;
  params2.ssch = params.ssch;
  params2.spch = campaign;
  params2.sview = params.sview;
  var s = '';
  for (var anItem in params2) {
      if (params2[anItem] != '') s+= '&'+anItem+'=' + escape(params2[anItem]);
  }
  return s.slice(1);
}

function show_horizontal_dmn(sponsorData) {

  if (params.target==null) {
      params.target='target=_blank'
  }
  var languageText2 = new Object(3);
  languageText2 = languageText();
  var s = '';
  var sfooter = '';
  
  //if we have at least one result then build up sponsored links
  if (sponsorData.length>0) {
  
      //Build up a string of HTML to display the results
      s = set_variable('start');
     
      var web_offers = 'http://aolsearch.aol.com/aol/weboffers';
      var trackedSUrl = '';
      var temp1 = '<span class="smalltext" style="both; position:absolute; right: 20px;">';
     
     // if not KW skip See More xxxx Offers
     
     if ((params.skw2 != null) && (params.skw2.length > 0)) {
          var see_more = web_offers + '?' +'invocationType=campaign7&' + set_prms_see_more(params.skw2, 'campaign7');
          s+= temp1;
          s+= '<a href="' + see_more +'">' + languageText2[1] + params.skw2 + languageText2[2] + ' >>></a></span>';
      } else {
      // See More Offers (with sHints words)
          if (sponsorData.length >= params.snum) {
             var see_more = web_offers + '?' + 'invocationType=campaign6&' + set_prms_see_more(params.squery, 'campaign6');
    		    sfooter = '<div class="footer"><a '+ params.target + ' href="' + see_more + '">' +  languageText2[0] + ' >>></a></span></div>';
          }
      }
      
      //s+= '</div><div class="body">';
      var sDivClass = '<div class="box"><a class="arrow" ' + params.target + ' href="'
      //For each sponsored link in the results array, add a list item to the unordered list
		if (sponsorData.length >= params.snum){
			maxCount = params.snum;
		}else {
			maxCount = sponoredData.length;
		}
      for (var i=0; i<maxCount; i++) {
          var vTitle = sponsorData[i].title
          var vURL = null;
          if (sponsorData[i].url != null)
          {
              vURL = sponsorData[i].url;
              if (vURL.substring(0,7) == 'http://') {
                      vURL = vURL.substring(7)
              }
              if (vURL.substring(0,4) == 'www.') {
                      vURL = vURL.substring(4)
              }
              if (vURL.length >= 52) {
                  vURL = vURL.substring(0,50) + '..'
              }
          }
          if (vTitle.length > 51) {
              vTitle = vTitle.substring(0,50)
          }
          trackedSUrl = sponsorData[i].redirect_url;
          s+= sDivClass + trackedSUrl
          + '" onmouseover="self.status=\''
          + sponsorData[i].url
          + '\'; return true" onmouseout="self.status=\'\'; return true">'
          + sponsorData[i].title
          + '</a><br />';
          s+= sponsorData[i].d1 + ' ' + sponsorData[i].d2 + '<br />';
          if (vURL != null)
          {
                  s+= '<a class="sponsorURL" ' + params.target + ' href="' + trackedSUrl
                  + '" onmouseover="self.status=\''
                  + sponsorData[i].url
                  + '\'; return true" onmouseout="self.status=\'\'; return true">'
                  + vURL
                  + '</a></br>';
          }
          if (sponsorData[i].address != null)
              s += sponsorData[i].address + '</br> ';
          if(sponsorData[i].phone != null)
              s+=  'Call ' + sponsorData[i].phone;
          s+= '</div>';
      }
      s+= set_variable('end');
  } else {
      //We got an empty result set so make up an ad
      s = '';
  }
          //document.write(s);
  //Insert HTML string into DIV
  s+=sfooter;
  document.getElementById('horizontal_dmn_results').innerHTML = s;
}

function show_horizontal_dmn_bottom(sponsorData) {

  if (params.target==null) {
      params.target='target=_blank'
  }
  var languageText2 = new Object(3);
  languageText2 = languageText();
  var s = '';
  var sfooter = '';
  
  //if we have at least one result then build up sponsored links
  if (sponsorData.length>0) {
  
      //Build up a string of HTML to display the results
      s = set_variable('start');
     
      var web_offers = 'http://aolsearch.aol.com/aol/weboffers';
      var trackedSUrl = '';
      var temp1 = '<span class="smalltext" style="both; position:absolute; right: 20px;">';
     
     // if not KW skip See More xxxx Offers
     
     if ((params.skw2 != null) && (params.skw2.length > 0)) {
          var see_more = web_offers + '?' +'invocationType=campaign7&' + set_prms_see_more(params.skw2, 'campaign7');
          s+= temp1;
          s+= '<a href="' + see_more +'">' + languageText2[1] + params.skw2 + languageText2[2] + ' >>></a></span>';
      } else {
      // See More Offers (with sHints words)
          if (sponsorData.length >= params.snum) {
             var see_more = web_offers + '?' + 'invocationType=campaign6&' + set_prms_see_more(params.skw, 'campaign6');
    		    sfooter = '<div class="footer"><a '+ params.target +' href="' + see_more + '">' +  languageText2[0] + ' >>></a></div>';
          }
      }
      
      //s+= '</div><div class="body">';
      var sDivClass = '<div class="box"><a class="arrow" ' + params.target + ' href="'
      //For each sponsored link in the results array, add a list item to the unordered list
		if (sponsorData.length >= params.snum){
			maxCount = params.snum;
		}else {
			maxCount = sponoredData.length;
		}
      for (var i=0; i<maxCount; i++) {
          var vTitle = sponsorData[i].title
          var vURL = null;
          if (sponsorData[i].url != null)
          {
              vURL = sponsorData[i].url;
              if (vURL.substring(0,7) == 'http://') {
                      vURL = vURL.substring(7)
              }
              if (vURL.substring(0,4) == 'www.') {
                      vURL = vURL.substring(4)
              }
              if (vURL.length >= 52) {
                  vURL = vURL.substring(0,50) + '..'
              }
          }
          if (vTitle.length > 51) {
              vTitle = vTitle.substring(0,50)
          }
          trackedSUrl = sponsorData[i].redirect_url;
          s+= sDivClass + trackedSUrl
          + '" onmouseover="self.status=\''
          + sponsorData[i].url
          + '\'; return true" onmouseout="self.status=\'\'; return true">'
          + sponsorData[i].title
          + '</a><br />';
          s+= sponsorData[i].d1 + ' ' + sponsorData[i].d2 + '<br />';
          if (vURL != null)
          {
                  s+= '<a class="sponsorURL" ' + params.target + ' href="' + trackedSUrl
                  + '" onmouseover="self.status=\''
                  + sponsorData[i].url
                  + '\'; return true" onmouseout="self.status=\'\'; return true">'
                  + vURL
                  + '</a></br>';
          }
          if (sponsorData[i].address != null)
              s += sponsorData[i].address + '</br> ';
          if(sponsorData[i].phone != null)
              s+=  'Call ' + sponsorData[i].phone;
          s+= '</div>';
      }
      s+= set_variable('end');
  } else {
      //We got an empty result set so make up an ad
      s = '';
  }
          //document.write(s);
  //Insert HTML string into DIV
  s+=sfooter;
  document.getElementById('horizontal_dmn_results_bottom').innerHTML = s;
}



 
	function setCalories (num, myDay) {
		$("#tabNav li").removeClass("selected");
		$("#ca" + num).addClass("selected");
		$("#dayLink  ul").empty();
		for(i=1; i<=28; i++) {	
			$('<li id="day' + i +'"><a href="/condition-center/diabetes/diabetes-meal-plan/'+ num + '-' + i + '">'+ i +'</a></li>').appendTo("#dayLink ul");
			if(i == myDay){$('#day' +i).addClass("selected");}
			}
	}		
	var relTimer=10000;
	function relegenceAjax(qText, pageCount){
		$.ajax({type: "GET", timeout:3000, url: qText,dataType: "jsonp", 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 !=''){
		        	 $("#realTimeNews .body").html(relegenceCollection);
		         }else{
		        	 $("#realTimeNews .body").text("No News Available");
		        	 }
  
		    }
		});
		
	}	
	
	$(document).ready(function(){

		// adds selected class for left navigation
		var pageURL = new String(document.location);
		var newPageURL=pageURL.replace(/\/$/,"");
		var pageContext = newPageURL.split(".com");
		$("#leftRailTools .bdy ul li a").each(function(){
		var linkURL= $(this).attr("href").replace(/\/$/,"");
		if (pageContext[1].indexOf(linkURL)>=0 && linkURL.length>1){
			$(this).addClass("select");
		}
		else if (pageContext[1]==linkURL){
			$(this).addClass("select");
		}

		})
		
		//drugs and supplement page right rail remove the first module of the border top for the drugs and supplement new module.
		$('#rtnNews div.item:first, #alphabetGrpTop li:last, #alphabetGrpBot li:last, #leftNavRelArt ul li:first, #leftNavRelArt ul li:last').css('background','none');
		
		//initialize relegence call
		if ($("#realTimeNews .body").length){
			var rtnURL = '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&dPgCnt='+$("#realTimeNews #pageCount").text()+'&fRelMn=65&c=?&qTxt='+escape($("#realTimeNews #topic").text());
			var pageCount = $("#realTimeNews .item").length;
			relegenceAjax(rtnURL);
			}		    		
		
		//  Report this help function
		$("#rptMoreInfo").bind("mouseover", function() {fn_addItem(this,6);});
		$("#rptMoreInfo").bind("mouseout", function() {fn_addItem();});
		
		
		// comment text area
		$("#typcomnthere").bind("focus", function(){doClear(this)});
		
	});	

// JS code for Feed MomLogic starts

	  function loadMomLogic(feedUrlMomLogic,feedTitleMomLogic){
	    $.post("/condition-center/feedHandlerMomLogic",{feedUrl:feedUrlMomLogic,feedTitle:feedTitleMomLogic},

	      function(data){
		$("#feedAjaxLoaderMomLogic").append(data);
	      }
	    );
	    $("#feedLoadingMomLogic").ajaxStart(function(){$(this).show();});
	    $("#feedLoadingMomLogic").ajaxError(function(event, request, settings){$(this).hide();$("#feedErrorMomLogic").show();})
	    $("#feedLoadingMomLogic").ajaxSuccess(function(evt, request, settings){$(this).hide();$("#feedErrorMomLogic").hide();});
	  }

// JS code for Feed MomLogic ends

// JS code for Feed ParentDish starts

  function loadParentDish(feedUrlParentDish, feedTitleParentDish){
    $.post("/condition-center/feedHandlerParentDish",{feedUrl:feedUrlParentDish,feedTitle:feedTitleParentDish},
     
      function(data){
        $("#feedAjaxLoaderParentDish").append(data);
      }
    );
    $("#feedLoadingParentDish").ajaxStart(function(){$(this).show();});
    $("#feedLoadingParentDish").ajaxError(function(event, request, settings){$(this).hide();$("#feedErrorParentDish").show();})
    $("#feedLoadingParentDish").ajaxSuccess(function(evt, request, settings){$(this).hide();$("#feedErrorParentDish").hide();});
  }

// JS code for Feed ParentDish ends


//JS code for Feed caring.com starts

function loadCaring(feedUrlCaring,feedTitleCaring){
  $.post("/condition-center/feedHandlerMomLogic",{feedUrl:feedUrlCaring,feedTitle:feedTitleCaring},

    function(data){
	$("#feedAjaxLoaderCaring").append(data);
    }
  );
  $("#feedLoadingCaring").ajaxStart(function(){$(this).show();});
  $("#feedLoadingCaring").ajaxError(function(evt, request, settings){$(this).show();$("#feedErrorCaring").hide();});
  $("#feedLoadingCaring").ajaxSuccess(function(evt, request, settings){$(this).hide();$("#feedErrorCaring").hide();});
}

//JS code for Feed caring.com ends


// JS code for Feed AOL Health News starts

  function loadAolHealthNews(feedUrlAolHealthNews, feedTitleAolHealthNews){
    $.post("/condition-center/feedHandlerParentDish",{feedUrl:feedUrlAolHealthNews,feedTitle:feedTitleAolHealthNews},
     
      function(data){
        $("#feedAjaxLoaderAolHealthNews").append(data);
      }
    );
    $("#feedLoadingAolHealthNews").ajaxStart(function(){$(this).show();});
    $("#feedLoadingAolHealthNews").ajaxError(function(event, request, settings){$(this).hide();$("#feedErrorAolHealthNews").show();})
    $("#feedLoadingAolHealthNews").ajaxSuccess(function(evt, request, settings){$(this).hide();$("#feedErrorAolHealthNews").hide();});
  }

// JS code for Feed AOL Health News ends
