function wdig_show(something){
  wdig_getObj(something).style.display="block";
}
function wdig_hide(something){
  wdig_getObj(something).style.display="none";
}
function wdig_getObj(idOrObject) {
  if ( typeof idOrObject == "string" || idOrObject instanceof String  ) {
    return document.getElementById(idOrObject);
  }
  return idOrObject;
}

// Function for switching tabs
function Accordian(target) {
  typeof target == "object" ? this.element = target : this.element = document.getElementById(target); if (!this.element) return false;  
  this.div = this.element.getElementsByTagName("div")[0]; 
  this.tabs = this.div.getElementsByTagName("a");
  this.tabContent = this.getTabContent();
  this.bind();
}

Accordian.prototype.getTabContent = function() {
  tabContent= new Array();    
  this.divs = this.element.getElementsByTagName("div");
  for(var i = 0; i < this.divs.length; i++) {
    if(this.divs[i].id) {
      tabContent.push(this.divs[i]);
    }
  }
  return tabContent;
}


Accordian.prototype.bind = function() {    
  var o = this;
  for(var i = 0; i < this.tabs.length; i++) {
    this.tabs[i].onclick = function() {
      var classeNames = this.className.split('_');
      if (classeNames[1] != '_active') {
        o.open(this); return false;
        var a = this.getElementsByTagName("a")[0];
        if (a) a.onclick = function() { 
         return false; 
        }
      }
    } 
  }
}

Accordian.prototype.open = function(caller) {
  for(var i = 0; i < this.tabs.length; i++) {
    var tab = this.tabs[i]; 
    var classNames = this.tabs[i].className.split('_');
    if (tab == caller) {  
      this.collapse();
      //alert(classNames[0]);
      tab.className = classNames[0]+"_active";
      this.tabContent[i].style.display = "block";
    }
  }
}

Accordian.prototype.collapse = function() {
  for(var i = 0; i < this.tabs.length; i++) {
    var classNames = this.tabs[i].className.split('_');
    this.tabs[i].className = classNames[0];
    this.tabContent[i].style.display = "none";
  }                                                                
}



// Function show next hide current
function ShowNext(container, elementsClass, toggler){
  this.container = document.getElementById(container);
  if (this.container == null) return;
  this.elements = document.getElementsByClassName(elementsClass, container);
  this.prev = document.getElementsByClassName('prev', toggler)[0];
  this.next = document.getElementsByClassName('next', toggler)[0];
  this.create();
}

ShowNext.prototype.create = function(){
  var next = this.next;
  var prev = this.prev;
  var element = this.elements;
  var index = this.getShown();
  
  for(var i = 0; i < element.length; i++){
    if(i > 0){
      this.elements[i].style.display = 'none';
    }
  }
  next.onclick = function(){
    element[index].style.display = 'none';
    index = (index + 1);
    if(index >= element.length) index = 0;
    element[index].style.display = 'block';
    return false;
  }

  prev.onclick = function(){
    element[index].style.display = 'none';
    if(index == 0) index = element.length;
    index = (index - 1);
    element[index].style.display = 'block';
    return false;
  }
}

ShowNext.prototype.getShown = function(){
  var element = this.elements;
  for(var i = 0; i < element.length; i++){
    if(element[i].style.display == '' || element[i].style.display == 'block'){
      return i;
    }
  }
}

//simple class to give make a search field clear out its default value when focused
function PpSearch(fieldId, defaultText) {
  this.field = document.getElementById(fieldId);
  this.field.onfocus = function() {
    if (this.value==defaultText) this.value = "";
  }
}

//class to control the header search form
function HeaderSearch(id) {
  this.form = document.getElementById(id);
  if (this.form.elements["defaultURL"] == null)
    return;
  this.rootURL = "http://family.go.com/";
  if (location.href.indexOf("beta.family.go.com") > -1)
    this.rootURL = "http://beta.family.go.com/";
  if (location.href.indexOf("family.go.com:9080") > -1)
    this.rootURL = "http://family.go.com:9080/";
  this.f1kURL = "http://family1000.family.go.com/";
  this.defaultURL = this.form.elements["defaultURL"].value;
  this.defaultValue = this.form.elements["searchKeyword"].value;
  this.URL = this.defaultURL;
  this.bindControls();
}

HeaderSearch.prototype.bindControls = function() {
  var o = this;
  var controls = this.form.getElementsByTagName("input");
  for (i=0; i<controls.length; i++) {
    switch (controls[i].type) {
      case "text":
        controls[i].onfocus = function() {
          o.URL = o.defaultURL;
          if (this.value=="Enter a search term") this.value = "";
        }
        break;
      case "image":
        controls[i].onfocus = function() {
          o.URL = this.value;
        }
        break;
    }
  }
}

HeaderSearch.prototype.submit = function() {
  var keyword = "";

  if (this.URL == "family1000"){
  keyword = encodeURIComponent(this.form.elements["searchKeyword"].value.replace(/\//g,' ')).replace(/%20/g,'+');
}
  else  
    {
    if (this.form.elements["searchKeyword"] != null) 
      {
      keyword = encodeURIComponent(encodeURIComponent(this.form.elements["searchKeyword"].value));
      keyword = keyword.replace(/%252F/gi, "");
      }
    else 
      return;
  }
  if(this.form.elements["searchKeyword"].value != this.defaultValue) {
   switch (this.URL) {
    case "web":
      url = this.rootURL + "websearch/" + keyword+"/";
      break;
      default:
    case "internal":
      url = this.rootURL + "search-familycom/" + keyword+"/";
      break;
    case "family.com":
      url = this.rootURL + "search-familycom/" + keyword+"/";
      break;
    
    case "family1000":
    if (keyword.length>0)
      url = this.f1kURL + keyword+"/";
    else 
      url = this.f1kURL;
      break;
    }
    
    top.document.location.href = url;
    return false;
  }
}

// global disclaimer function for ad served elements
function deliverPopDisclaimer( mLink )       
{
  var popDisclaimer=window.open( "", "disclaimer", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=370,height=210,top=100,left=150,screenX=180,screenY=100" );
  popDisclaimer.document.write ( '<html><head><title>Family.go.com - Disclaimer</title>' );
  popDisclaimer.document.write ( '<SCR'+'IPT TYPE="text/javascript" LANGUAGE="JavaScript">' );
  popDisclaimer.document.write ( 'sendTimer = setTi'+'meout("sendToClientSide()",1500);closeTimer = setT'+'imeout("window.close()",15000);' );
  popDisclaimer.document.write ( 'func'+'tion sendToCl'+'ientSide(){window.op'+'en("'+mLink+'"); this.focus();}' );
  popDisclaimer.document.write ( '</scr'+'ipt>' );
  popDisclaimer.document.write ( '</head><body bgcolor="#FFFFFF" text="#0065CE" link="#FFFF80" vlink="#FFFF80" alink="#FFFF80" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>' );
  popDisclaimer.document.write ( '<table width="370" height="100%" border="0" cellspacing="0" cellpadding="0"><td><table width="330" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td><br><FONT FACE="Verdana,sans-serif" SIZE="2" COLOR="#0065CE"><b>The web site you are about to link to is not controlled by Family.go.com and different terms of use and privacy policy will apply. By proceeding you agree and understand that Family.go.com is not responsible for the site you are about to access.</b></FONT><br><br></td></tr></table>' );
  popDisclaimer.document.write ( '</td></tr><tr bgcolor="#ffffff"><td align="center" height="20"><a href="javascript:window.close();"><FONT FACE="Verdana,sans-serif" SIZE="1" COLOR="#006699"><b>Close this window</b></font></a><BR></td></tr></table>' );
  popDisclaimer.document.write ( '</body></html>' );
  popDisclaimer.document.close();
}

// global functions for determining an element's x/y position
function _findPosX(obj) {
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  
  return curleft;
}

function _findPosY(obj) {
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;

  return curtop;
}
function com_wdig_style_any(obj,styleName) {
  if ( obj.style[styleName]!=null && obj.style[styleName].length>0 ) {
    return obj.style[styleName];
  }
  if ( obj.currentStyle!=null && 
      obj.currentStyle[styleName]!=null &&
      obj.currentStyle[styleName].length>0 ) {
    return obj.currentStyle[styleName];
  }
  if ( obj.computedStyle!=null ) {
    return obj.computedStyle[styleName];
  }
  if ( obj.currentStyle ) {
    return obj.currentStyle[styleName];
  }
  if ( document.defaultView.getComputedStyle ) {
    return document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleName);
  }
  return null;
}

function com_wdig_wh_styleWHSet(obj,w,h,suffix) {
  if ( w!=null ) {
    obj.style.width= w + (suffix==null ? "px" : suffix);
  }
  if ( h!=null ) {
    obj.style.height= h + (suffix==null ? "px" : suffix);
  }
}
function com_wdig_wh_styleWH(obj) {
  //TODO : check if image and use alternate style names.
  //    obj.style.pixelWidth
  //    obj.style.pixelHeight
  var width = com_wdig_style_any(obj,"width");
  var height = com_wdig_style_any(obj,"height");

  if ( isNaN(width) || isNaN(height) ) {
    return null;
  }
  if ( width!=null || height!=null ) {
    return [parseInt(width) , parseInt(height)];
  } 
  return null;
}
function com_wdig_wh_windowInnerWHSS() {
  if ( document.all && !window.opera ) {
    var src =  document.compatMode=="CSS1Compat" ? document.documentElement : document.body;
    return [src.clientWidth, src.clientHeight, src.scrollLeft, src.scrollTop];
  }
  return [window.innerWidth, window.innerHeight, window.pageXOffset, window.pageYOffset];
}
function com_wdig_wh_WH(obj) {
  if ( obj.getImageWidth  ) {
    //TODO : account for border
    return [obj.getImageWidth,obj.getImageHeight];
  }
  if ( obj.offsetWidth ) {
    return [obj.offsetWidth,obj.offsetHeight];
  }
  if ( obj.clip && obj.clip.width ) {
    return [obj.clip.width,obj.clip.height];
  }
  return null;
}
function wdig_fadeOut(id,percent) {
  if ( percent==null ) {
    setTimeout("document.getElementById('" + id  + "').style.display='none';",110);
    percent = 90;
  } else {
    percent = percent - 10;
  }
  wdig_setOpacity(id,percent);
  if ( percent > 0 ) {
    var foo = "wdig_fadeOut('" + id + "'," + percent + ");";
    window.setTimeout(foo,10);
  }
}
function wdig_fadeIn(id,percent) {
  document.getElementById(id).style.display='block';
  percent = ( percent==null ) ? 10 : (percent + 10);
  wdig_setOpacity(id,percent);
  if ( percent < 100 ) {
    window.setTimeout("wdig_fadeIn('" + id + "'," + percent + ");",10);
  }
}
function wdig_setOpacity(id,opacityPercent) {
  var obj = document.getElementById(id);
  //Mozilla
  
  //quick fix (we don't need fade transition - don't want to break other functions)
  //obj.style.MozOpacity = opacityPercent/100;
  
  //Explorer
  
  //quick fix (we don't need fade transition - don't want to break other functions)
  //wdig_addMSFilterValue(obj,"alpha","opacity",opacityPercent);
  
  //force a reload if it is an image.
  obj.src = obj.src;
}

function wdig_addMSFilterValue(obj,filter,prop,value) {
  if ( obj.filters ) {
    if ( obj.filters[filter] ) {
      obj.filters[filter][prop] = value;
    } else {
      var track = filter + "." + prop;

      //Explorer is funky about setting filters
      //  this code is intended to keep all the old filters, while adding our new one.
      
      switch(filter) {
        case 'alpha':
          value = "progid:DXImageTransform.Microsoft.Alpha(" + prop + "=" + value + ")";
          break;
        //case 'iris':
        //  value = "progid:DXImageTransform.Microsoft.Iris(" + prop + "='" + value + "',duration=4)";
        //  break;
        default:
          throw "filter (" + filter + ") not handled by wdig_addMSFilterValue()";
      }
      // track stuff
      //    so we can rebuild from scratch
      //    and not have repeated settings of things cause a failure

      if ( obj.msBrowserFilterStorage == null ) {
        obj.msBrowserFilters = new Object();
        obj.msBrowserFilterStorage = new Array();
        if ( obj.style.filter.length > 0 ) {
          obj.msBrowserFilters["original"] = obj.msBrowserFilterStorage.length;
          obj.msBrowserFilterStorage[obj.msBrowserFilters["original"]] = obj.style.filter;
        }
      }

      //have we tracked the current thing?
      if ( obj.msBrowserFilters[track]==null ) {
        obj.msBrowserFilters[track] = obj.msBrowserFilterStorage.length;
      }
      //set the str
      obj.msBrowserFilterStorage[obj.msBrowserFilters[track]] = value;
      //do a join of all valid settings.
      obj.style.filter = obj.msBrowserFilterStorage.join(" ");
    }
  }
}


/*  VERY TEMPORARY INCLUSION OF JAVACRIPT TO BE REMOVED AFTER LAUNCH AUGUST 8th 2007 */
function showCouponInstructions(theLinksId) {
  var divId = "id-couponInstructionDiv";
  var theLink = document.getElementById(theLinksId);
  var ciDiv = document.getElementById(divId);

  if ( ciDiv == null ) {
    var docBody = document.getElementsByTagName("body")[0];
    var req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    
    if(document.all){ // FOR ID
      docBody.insertAdjacentHTML("beforeEnd",'<div id="' +divId + '"></div>');
      ciDiv = document.getElementById(divId);
    }else{ // FOR OTHERS
      ciDiv = document.createElement("div"); // create the div
      ciDiv.setAttribute("id",divId); // add the id
    }
    req.open("GET","/html/coupons/instructionsDiv.html",false);
    req.send(null);
    ciDiv.innerHTML = req.responseText;
    ciDiv.className = "couponPositionalDiv";

    // put on the body (divs don't belong inside text)
    docBody.appendChild(ciDiv);
  }
  // move it on top of the link.
  ciDiv.style.top = _findPosY(theLink) + "px";
  ciDiv.style.left = _findPosX(theLink) + "px";

  var descendents = ciDiv.getElementsByTagName("*");
  for ( var rat in descendents ) {
    var ele = descendents[rat];
    if ( ele.id!=null ) {
      var foo = ele.id.split("-");
      if ( foo[1]=="couponData" ) {
        switch(foo[2]) {
        case "Image":
          ele.src = theLink.getAttribute("cImage");
          ele.alt = theLink.getAttribute("cTitle");
          break;
        default:
          ele.innerHTML = theLink.getAttribute("c" + foo[2]);
          break;
        }
      }
    }
  }
  wdig_fadeIn(divId);
  wdig_slideFullyOn(divId);
}

function wdig_slideFullyOn(targetId) {
  var target = document.getElementById(targetId);
  var whss = com_wdig_wh_windowInnerWHSS();
  var again = false;
  var hei = com_wdig_style_any(target,"maxHeight");
    hei = hei==null ? com_wdig_style_any(target,"height") : hei;
    hei = hei==null ? 0 : parseInt(hei);
  var wid = com_wdig_style_any(target,"maxWidth");
    wid = wid==null ? com_wdig_style_any(target,"width") : wid;
    wid = wid==null ? 0 : parseInt(wid);
  var x = _findPosX(target);
  var y = _findPosY(target);

  if ( (x - whss[2]) < 10 ) {
    target.style.left = (parseInt(target.style.left) + 16) + "px";
    again = true;
  } else if ( (whss[0] - (x - whss[2]) - wid) < 10 ) {
    target.style.left = (parseInt(target.style.left) - 16) + "px";
    again = true;
  }
  if ( (y - whss[3]) < 10 ) {
    target.style.top = (parseInt(target.style.top) + 16) + "px";
    again = true;
  } else if ( (whss[1] - (y - whss[3]) - hei) < 10 ) {
    target.style.top = (parseInt(target.style.top) - 16) + "px";
    again = true;
  }
  if ( again ) {
    setTimeout("wdig_slideFullyOn('" + targetId  + "')",25);
  }
}



/* BEGIN FUNCTIONS FOR RATINGS
-------------------------------------------------- */ 
/*
    new "improved" javascript  (by Gene Smith)
      all the HTML and CSS has been stripped out of it
      it can be used in multiple places very easily
      it is faster because it avoids some heavy handed scriptaculus calls
      it has uses on need initialization
        so it does not dependent on complete page load
        and page load does not depend on it
      it uses direct EL settings of login state
  putting rating_attachOver(...) 
      here lets it load when needed (or not at all). 
    it will replace itself on the event handler as its last setup act,
      so if it failes due to unloaded content, it can naturally retry.
*/


//Collect a group of elements with ids differing by just an appended number.
function wdig_collectIdGroup(idBase,start,stop) {
  var arr = new Array();
  for(var i=start; i<= stop; i++) {
    arr[arr.length] = document.getElementById(idBase + i);
  }
  return arr;
}
//This runs faster than getting a full list from scriptaculus and then taking the first one.
function wdig_firstElementByClassName(className, parentElement) {
    var children = (parentElement || document.body).getElementsByTagName('*');
    for (var i = 0, length = children.length; i < length; i++) {
      var child = children[i];
      if (Element.hasClassName(child, className))
        return child;
    }
    return null;
}
//Show the sorryMessage...
//   ...a shared atomic method, especially if you want to use a fixed HTML Element id in it.
function wdig_sorryMessage(sorryMsgId,putOn) {
  var sorryMsg = document.getElementById(sorryMsgId==undefined ? "sorryMessage" : sorryMsgId);

  if ( putOn!=null ) {
    putOn.appendChild(sorryMsg);
  }
  sorryMsg.style.display = "block";
}

//These can go in the current ratings library

//  no conflict with just adding for now
function rating_submit(info,value) {
  var cattitle = "/" + info.categoryId + "/" + info.articleTitle;
  if( info.loggedin ) {
    info.disabled = true;
    info.rated.innerHTML = info.rater.innerHTML;
    info.rated.className = info.rater.className;
    info.rating = value;
    var str = "ratingValue=" + value + "&contentRefId=" + info.id + "&contentType=" + info.type;
    AJAXRequest('POST', '/createRating.do', str, function(){});
    _dolWAObjSubmitLink('ratingThanks', cattitle, null);
  } else {
    wdig_sorryMessage(info.sorryMsgId,wdig_firstElementByClassName(info.loginMsgCN, info.container));
    _dolWAObjSubmitLink('ratingSorry', cattitle, null);
  }
}
//does the setup, and the first over.
function rating_attachOver(info) {
  rating_attach(info);
  if (!info.disabled) {
    Element.show(info.rater);
    Element.hide(info.rated);
  }
}
//does the setup.
function rating_attach(info) {
  //delayed setup
  info.container  = document.getElementById(info.containerId);
  info.stars    = wdig_collectIdGroup(info.starsIdBase,1,5);
  info.starSpan = document.getElementById(info.starSpanId);
  info.rated    = wdig_firstElementByClassName("rated", info.container);
  info.rater    = wdig_firstElementByClassName("rater", info.container);
  info.disabled = false;
  //attach functions to the stars.
  for(var i=1; i<=info.stars.length; i++) {
    var img = info.stars[i-1];
    
    img.name = info.loggedin ? info.loggedInImgName : info.loggedOutImgName;
    img.src = (info.rating >= i) ? info.imageFresh : info.imageRotten;
    img.value = i;
    img.ratingInfo = info;
  
    img.onmouseover = function() {
      if (! info.disabled) {
       rating_setStars(this.ratingInfo,this.value,this.ratingInfo.ratingPhrases[this.value-1]);
      }
    }
    img.onmouseout = function() {
     rating_setStars(this.ratingInfo, this.ratingInfo.rating, this.ratingInfo.defaultText);
    }
    img.onclick = function() {
      rating_submit(this.ratingInfo,this.value);
    }
  }
  //attach functions to the container...
  //  do onmouseover last
  //     because in normal operation until it is done the setup can be redone
  //     so failures can recover.
  info.container.ratingInfo = info;
  info.container.onmouseout = function() {
    Element.show(this.ratingInfo.rated);
    Element.hide(this.ratingInfo.rater);
  }
  info.container.onmouseover = function() {
    if (!this.ratingInfo.disabled) {
      Element.show(this.ratingInfo.rater);
      Element.hide(this.ratingInfo.rated);
    }
  }


}
function rating_setStars(info,value,text) {
    for(var i=1; i<=info.stars.length; i++) {
      img = info.stars[i-1].src = (i <= value) ? info.imageFresh : info.imageRotten;
    }
    info.lastValueSet=value;
    info.starSpan.innerHTML = text;
}
/* END FUNCTIONS FOR RATINGS
-------------------------------------------------- */ 

/* BEGIN LOGIN POPUP JAVASCRIPT
----------------------------------------------------*/
function createLoginPopups(elementId, className){
  var mustBeLoggedInLinks = YAHOO.util.Dom.getElementsByClassName(className, null, document.getElementById(elementId));
  var sorry = 'sorryMsg';
  //var loginMessage = YAHOO.util.Dom.getElementsByClassName('loginMessage', null, elementId);
  for(var i=0; i<mustBeLoggedInLinks.length; i++) {
    YAHOO.util.Event.addListener(mustBeLoggedInLinks[i], 'click', function () {
      document.getElementById(sorry).style.display = "block";
      document.getElementById(sorry).style.left = _findPosX(this) - 10 + "px";
      document.getElementById(sorry).style.top = _findPosY(this) - 40 + "px";
      //loginMessage.appendChild(o.sorry);
      //loginMessage.style.zIndex = 9999;
      return false;
    });
  }
}
function closeLogin(){
  document.getElementById('sorryMsg').style.display = 'none';
}
/* END LOGIN POPUP JAVASCRIPT
-------------------------------------------------- */ 

/* BEGIN NAV JS 
---------------------------------------------------*/
try{
YAHOO.util.Event.onContentReady('navBar_container', function() { var navObject = new FamilyNav('navBar_container'); });
} catch(e) {}
function FamilyNav(id) {
  this.element = document.getElementById(id);
  if(document.getElementById('navBar')){this.navElements = document.getElementById('navBar').getElementsByTagName('li');} 
  this.createNavObjects();
}

FamilyNav.prototype.createNavObjects = function (){
  this.navObjects = new Array();
  if(this.navElements) {
    for (var i=0; i<this.navElements.length; i++){
    if(i==0){
      YAHOO.util.Dom.addClass(this.navElements[i], 'first');
    } else if (i==(this.navElements.length-1)) {
      YAHOO.util.Dom.addClass(this.navElements[i], 'last');
    }
    this.navObjects[i] = new FamilyNavItem(this.navElements[i], i, this);
    }
   }
}

FamilyNav.prototype.deactivateAllOtherNavItems = function (index){
  for (var i=0; i<this.navObjects.length; i++){
    if(i == index) continue;
    this.navObjects[i].deactivate();
  }
}

function FamilyNavItem(element, index, navManager){
  this.element = element;
  this.index = index;
  this.navManager = navManager;
  if (YAHOO.util.Dom.hasClass(this.element, 'first')){
    this.hoverClass = 'first_hover';
  } else if (YAHOO.util.Dom.hasClass(this.element, 'last')){
    this.hoverClass = 'last_hover';
  } else {
    this.hoverClass = 'li_hover';
  }
  //alert(''+this.index+this.element.id);
  this.mouseOverDelay = 50;
  this.mouseOutDelay = 1000;
  this.subNavElement = null;
  var subNavElement = YAHOO.util.Dom.getElementsByClassName('navBar_subNav', null, 'navContainerContent')[this.index];
  if(subNavElement != undefined){
    var links = subNavElement.getElementsByTagName('a');  
    if (links.length > 0) {
      this.subNavElement = subNavElement;
    }
  }
  this.setUpActiveStates();
  this.createMouseBehavior();
}
FamilyNavItem.prototype.setUpActiveStates = function(){
  if (this.subNavElement != null){
    if (YAHOO.util.Dom.hasClass(this.element, 'first')){
      this.hoverClass = 'first_hover';
    } else if (YAHOO.util.Dom.hasClass(this.element, 'last')){
      this.hoverClass = 'last_hover';
    } else {
      this.hoverClass = 'li_hover';
    }
  }else{
    if (YAHOO.util.Dom.hasClass(this.element, 'first')){
      this.hoverClass = 'selected_first';
    } else if (YAHOO.util.Dom.hasClass(this.element, 'last')){
      this.hoverClass = 'selected_last';
    } else {
      this.hoverClass = 'selected';
    }
  }
}
FamilyNavItem.prototype.createMouseBehavior = function (){
  //alert('create mouse behavior');
  YAHOO.util.Event.addListener(this.element, 'mouseover', function(){ this.mouseOver(); }, this, true);
  if(YAHOO.util.Dom.hasClass(this.element, this.hoverClass)){
    //the mouseout is different if we are dealing with the nav element corresponding to the current site context
    YAHOO.util.Event.addListener(this.element, 'mouseout', function(){ this.currentCategoryMouseOut(); }, this, true);
  }else{
    YAHOO.util.Event.addListener(this.element, 'mouseout', function(){ this.mouseOut(); }, this, true);
  }
  if (this.subNavElement != null){
    //alert('adding sub-nav behavior');
    YAHOO.util.Event.addListener(this.subNavElement, 'mouseover', function(){ this.mouseOver(); }, this, true);
    YAHOO.util.Event.addListener(this.subNavElement, 'mouseout', function(){ this.mouseOut(); }, this, true);
  }
}
FamilyNavItem.prototype.mouseOver = function (){
  this.navManager.deactivateAllOtherNavItems(this.index);
  //alert('mouseover'+this.index);
  var timeoutObject = this;
  clearTimeout(this.mouseOutTimeout);
  this.mouseOverTimeout = setTimeout(
    function () {
      YAHOO.util.Dom.addClass(timeoutObject.element, timeoutObject.hoverClass);
      if(timeoutObject.subNavElement != null){
        document.getElementById('breadcrumbs').style.display = 'none';
        timeoutObject.subNavElement.style.display = 'block';
      }
    }, this.mouseOverDelay
  );
}
FamilyNavItem.prototype.mouseOut = function (){
  var timeoutObject = this;
  clearTimeout(this.mouseOverTimeout);
  this.mouseOutTimeout = setTimeout(
    function () {
      timeoutObject.deactivate();
    }, this.mouseOutDelay
  );
}
FamilyNavItem.prototype.deactivate = function (){
  YAHOO.util.Dom.removeClass(this.element, this.hoverClass);
  //document.getElementById('breadcrumbs').style.display = 'block';
  //moved the above line into the IF statement below to fix an IE display error -- Travis 12-12-2007
  if(this.subNavElement != null){
    this.subNavElement.style.display = 'none';
    document.getElementById('breadcrumbs').style.display = 'block';
  }
}
FamilyNavItem.prototype.currentCategoryMouseOut = function (){
  var timeoutObject = this;
  clearTimeout(this.mouseOverTimeout);
  this.mouseOutTimeout = setTimeout(
    function () {
      document.getElementById('breadcrumbs').style.display = 'block';
      if(timeoutObject.subNavElement != null){
        YAHOO.util.Dom.removeClass(timeoutObject.element, timeoutObject.hoverClass);
        timeoutObject.subNavElement.style.display = 'none';
      }
    }, this.mouseOverDelay
  );
}

/*
 * Set of classes for managing content tabs.
 * Further documentation TBD
 */

function Tab(navigation, content) {
  this.navigation = navigation;
  this.content = content;
  return this;
}

Tab.prototype.select= function() {
  if(!this.isSelected()) {
    YAHOO.util.Dom.addClass(this.navigation, 'selected');
    YAHOO.util.Dom.addClass(this.content, 'selected');
  }
  return this;
}

Tab.prototype.unselect = function() {
  if(this.isSelected()){
    YAHOO.util.Dom.removeClass(this.navigation, 'selected');
    YAHOO.util.Dom.removeClass(this.content, 'selected');
  }
}

Tab.prototype.isSelected = function() { 
  return YAHOO.util.Dom.hasClass(this.navigation, 'selected');
}

function TabGroup(tabContentClass, tabNavClass) {
  // Get the content tabs
  var tabCollection = YAHOO.util.Dom.getElementsByClassName(tabContentClass);
  // Get the navigation for the tabs
  var navCollection = YAHOO.util.Dom.getElementsByClassName(tabNavClass);
  
  this.change = new YAHOO.util.CustomEvent('change', this);
  this.collection = new Array();
  this.selectedIndex = -1;
  this.selectedTab = null;
  
  if(tabCollection.length == navCollection.length) {
    for(var i=0;i<tabCollection.length;i++) {
      this.collection[i] = new Tab(navCollection[i], tabCollection[i]);
    }
  } 
}

TabGroup.prototype.setSelectedTab = function(index) {
  var result = -1;
  if(this.collection.length >= (parseInt(index)+1)) {
    if(this.selectedTab != null)
      this.selectedTab.unselect();
    this.selectedTab = this.collection[index].select();
    this.selectedIndex = index;
    result = index;
    
    // This event should actually be moved into the Tab object when a select is called. Will add later
    this.change.fire(new TabGroupEvent('change', index)); // Fire the change event passing the new selectedIndex
  }  
  return result;
}

TabGroup.prototype.getTab = function(index) {
  return this.collection[index];
}

function TabGroupEvent(name, selectedIndex) {
  this.name = name;
  this.selectedIndex = selectedIndex;
}

// the code below is for running surveys accross the site  
if( window.location.href.indexOf( "/contests/cake-recipes/" ) == -1)
{
   // don't use akami for pages behind https
   if(window.location.href.substring(0,7).indexOf("https") != -1){
      document.write( '<script type="text/javascript" src="https://family.go.com/js/cookies.js"></script>' );
      document.write( '<script type="text/javascript" src="https://family.go.com/js/survey.js"></script>' );
   }
   
   else{
      document.write( '<script type="text/javascript" src="http://family.go.com/js/cookies.js"></script>' );
      document.write( '<script type="text/javascript" src="http://family.go.com/js/survey.js"></script>' );
   }
}


/* Note: the obj parameter is optional - it represents the object of the element that is clicked on for the Omniture Click Map tool.
 * For more info, see http://dol.online.disney.com/wiki/index.php/Web_Analytics:Link_Tracking */
function trackLink( lid, lpos, obj )
{
  try
  {
    if( obj != undefined ) cto.linkObj = obj;
    cto.linkId = lid;
    cto.linkPosition = lpos;
    cto.linkType = 'o';
    cto.trackLink();
   }
   catch( e ) {}
}

//makes pop-up bubbles appear
function showBubble(element, bubble, xOffset, yOffset) {
    var element = document.getElementById(element);
    //captures the position of the clicked button
    var x = YAHOO.util.Dom.getX(element);
    var y = YAHOO.util.Dom.getY(element);
    var xLoc = x + xOffset;
    var yLoc = y + yOffset;
    var bubble = document.getElementById(bubble);
      bubble.style.display = "block";
      YAHOO.util.Dom.setX(bubble, xLoc);
      YAHOO.util.Dom.setY(bubble, yLoc);
}

//toggles visibility of an element
function showHide(obj) {
  obj = document.getElementById(obj);
  obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
}

//toggles visibility of an element and changes the class name of the element clicked
function showHideClassSwap(obj,toggleId) {
  var obj = document.getElementById(obj);
  var toggleIdent = document.getElementById(toggleId);
  
  obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
  if (obj.style.display == 'block') {
      toggleIdent.className = toggleId+"_open";
    } else {
      toggleIdent.className = toggleId+"_closed"; 
  } 
}

//force a line break to split up words that are too long. Pass in the class name of the string(s) you want to break up, and max characters per line
function forceLineBreaks(className, charCount) {
  var originalTextStrings = YAHOO.util.Dom.getElementsByClassName(className);
  
  for (var i=0; i < originalTextStrings.length; i++) {
    var newTextString = "";
    var words = originalTextStrings[i].innerHTML.split(' ');
    for(var j=0; j < words.length; j++) {
      if(words[j].length > charCount) {
        var howManySplits = Math.floor(words[j].length / charCount);
        for(var k=0; k < howManySplits; k++) {
          var cutWordAt = charCount * k;
          var addSpaceAt = charCount * (k + 1);
          var wordPiece = words[j].slice(cutWordAt, addSpaceAt) + "-<br /> ";
          newTextString += wordPiece;
        }
        var leftoverLetters = words[j].slice(howManySplits * charCount);
        newTextString += leftoverLetters + " ";
      } else  {
        newTextString += words[j] + " ";
      }
    }
     originalTextStrings[i].innerHTML = newTextString; 
  }
}

//temp function to add default images
function defaultVideoThumb() {
  var thumbContainer = YAHOO.util.Dom.getElementsByClassName('video_feed_single')[0];
  if(typeof thumbContainer != 'undefined') {
    var allImages = thumbContainer.getElementsByTagName('img');
    for(var i=0; i<allImages.length; i++) {
      var imgSrc = allImages[i].getAttribute('src');
      imgSrc = imgSrc.replace(/\s/g, '');
      if(imgSrc == "" || imgSrc == location.href) {
        allImages[i].src = 'http://family.go.com/images/video/img/video_generic.png';
      }
    }
  }
}

if(typeof YAHOO != 'undefined') {
YAHOO.util.Event.onContentReady('main_container_wrapper_videos', defaultVideoThumb);
}

function checkForEmptyCsarAd( csarAdType, csarAdContainer ) {
  if( csarAdType == "TextBox1" )
  {
    // in this case, show the text box ads as long as at least one of them are active
    if( ( digAdData[ 'TextBox1' ] != undefined && digAdData[ 'TextBox1' ][ 'creative' ][ 'text' ] != "<!-- Blank -->" ) ||
        ( digAdData[ 'TextBox2' ] != undefined && digAdData[ 'TextBox2' ][ 'creative' ][ 'text' ] != "<!-- Blank -->" ) ||
        ( digAdData[ 'TextBox3' ] != undefined && digAdData[ 'TextBox3' ][ 'creative' ][ 'text' ] != "<!-- Blank -->" ) )
    { document.getElementById( csarAdContainer ).style.display = 'block'; }
  }
  else
  {
    if( digAdData[ csarAdType ] != undefined && digAdData[ csarAdType ][ 'creative' ][ 'text' ].indexOf("<!-- Blank -->") == -1)
    { document.getElementById( csarAdContainer ).style.display = 'block'; }
  }
}

function removeDuplicateDiv() {            
 //create an array of all the divs within the aColumn div            
 var allDivsArray = document.getElementById('aColumn').getElementsByTagName('div');
 
 //create an empty array where the divs with the id of sweepsBody will go            
 var sweepsBodyArray = new Array;                        

 //loop through the array of all divs and add the ones with the id of sweepsBody into the empty array            
 for(i=0; i<allDivsArray.length; i++) {                
  if(allDivsArray[i].getAttribute('id') == 'sweepsBody') {                    
  sweepsBodyArray.push(allDivsArray[i]);                
  }            
 }                        

 //If there is are 2 elements in the sweepsBodyArray, remove the 2nd one or empty its contents.            
 if(sweepsBodyArray[1] != null && typeof(sweepsBodyArray[1]) != "undefined") {                
 sweepsBodyArray[1].innerHTML = "";                
 sweepsBodyArray[1].style.display = "none";            
 }        
} 

YAHOO.util.Event.onContentReady('aColumn',removeDuplicateDiv);