function navloadNew (category, ishomepage) {
var catIsDefined = 0;
  cats = new Array("activ", "food", "ecards", "pets",  "travel", "shop", "entertain", "baby", "health", "parent", "learn", "hmbtn" );
  for ( i = 0; i < cats.length; i++ )
  {
    cat = cats[i];
    if ( category == cat ) { catIsDefined++; }
  }
  if ( ( !document.images ) || ( !catIsDefined ) )
  {
    return;
  }
	document.images[category].src = "http://family.go.com/Resources/NavBar/" + category + "_on.gif";
}
	
function goPets() {
  isFromGo = (parent.location.href.indexOf("pets=go") != -1);

  if (isFromGo) {
    location.href = "http://pets.go.com";
  } else {
    location.href = "/Categories/pets";
  }

  return true;
}

function randomSurvey(category)
{
  var percentOfferedSurvey = 10; // CHANGE THIS PARAMETER TO CONTROL SAMPLING RATE
  var inviteLocation = "/CategorySurvey/popup.html?cat=" + category;
  var popupNewWindow = true;  //or show the survey in the same window.
	
  var dd=new Date();
  cn= Math.round(dd.getTime() / 100) % 100;
  if (cn <= percentOfferedSurvey)
  {
    window.open(inviteLocation,'survey_invitation','width=372,height=292,resizable=no,scrollbars=yes');
  }
}

var loaded = 0;
var section;
var graphic = new Array();
function navload (category, ishomepage) {
  if ( !document.images )
  {
    return;
  }
  
  if (category == 'local') { return; }
	
  section = category;

  cats = new Array("activ", "food", "ecards", "pets", "holiday",  "travel", "shop", "entertain", "baby", "health", "parent", "learn", "boards", "hmbtn");

  for ( i = 0; i < cats.length; i++ )
  {
    cat = cats[i];
      
    imgOn = cat + "On";
    imgOff = cat + "Off";
    imgMid = cat + "Mid";

    graphic[imgOn] = new Image;
    graphic[imgOn].src = "http://family.go.com/Resources/NavBar/"+cat+"_on_01.gif";
    graphic[imgOff] = new Image;
    graphic[imgOff].src = "http://family.go.com/Resources/NavBar/"+cat+"_off_01.gif";

    graphic[imgMid] = new Image;

    if ( ishomepage )
    {
      graphic[imgMid].src = "http://family.go.com/Resources/NavBar/"+cat+"_mid_02h.gif";
    }
    else
    {
      graphic[imgMid].src = "http://family.go.com/Resources/NavBar/"+cat+"_mid_01.gif";
    }
  }

//  if ( category != 'local' ) {
  	// Set up the default category
  	imgOn = category + "On";
  	imgMid = category + "Mid";

  	document.images[category].src = graphic[imgOn].src;
  	document.images["midbar"].src = graphic[imgMid].src;
//  	}

  loaded = 1;
}

function overcat(cellname){
  if ( document.images && loaded == 1 && cellname != section)
  {
    imgOn = cellname + "On";
    imgMid = cellname + "Mid";
    document.images[cellname].src = graphic[imgOn].src;
    document.images["midbar"].src = graphic[imgMid].src;
  }
}

function offcat(cellname){
  if ( document.images && loaded == 1 && cellname != section)
  {
    imgOff = cellname + "Off";
    sectionOn = section + "On";
    sectionMid = section + "Mid";
    document.images[cellname].src = graphic[imgOff].src;
    document.images[section].src = graphic[sectionOn].src;
    document.images["midbar"].src = graphic[sectionMid].src;
  }
}

function getAd(spacedesc,business_entity,tier_1,tier_2,tier_3,site,ad_size,page_position)
{
  var descString = "";
  var u = navigator.userAgent;
  var moreThanV3 = 3 < parseInt( navigator.appVersion );
  var now = new Date();
  var idString = now.getTime() + Math.random(); //generates a relatively unique id number

  descString = 'transactionID=' + idString + '&spacedesc=' + spacedesc + '&business_entity=' + business_entity + '&tier_1=' + tier_1 + '&tier_2=' + tier_2 + '&tier_3=' + tier_3 + '&site=' + site + '&ad_size=' + ad_size + '&page_position=' + page_position + '>';

  if ( (u.substring(25,29) == "MSIE") && moreThanV3 ) //IFRAME include for IE 4+
  {
    // parses argument ad_size to get width and height of IFRAME
    // this relies on convention of ad_size being WIDTHxHEIGHT
    var xLocation = ad_size.indexOf("x");
    var iFrameWidth = ad_size.substr(0,xLocation);
    var iFrameHeight = ad_size.substr(xLocation+1);

    if ( iFrameHeight == "link" ) {
      iFrameWidth = "110";
    }
    document.write('<NOLAYER><IFRAME WIDTH=' + iFrameWidth + ' HEIGHT=' + iFrameHeight + ' MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=#000000 SRC=http:\/\/ngads.go.com/html.ng/' + descString);
    document.write('<SCRIPT LANGUAGE=JavaScript SRC=http:\/\/ngads.go.com/js.ng/Params.richmedia=yes&' + descString);
    document.write('</SC'+'RIPT>');
    document.write('</IFRAME></NOLAYER>');
  } else if ( (u.substring(25,29) == "MSIE") && !moreThanV3 ) { // IE3 hardcoded ad. No ad impression
  } else { // JS include for everything else
    document.write('<SCRIPT LANGUAGE=JavaScript SRC=http:\/\/ngads.go.com/js.ng/Params.richmedia=yes&' + descString);
    document.write('</SC'+'RIPT>');
  }
}

// action tags
var cachebuster = parseInt(Math.random() * 1e8);
var activeTagsArray = new Array(
'family_homepage_new',
'family_activities_new',
'family_food_new',
'family_holiday_new',
'family_pets_new',
'family_travel_new',
'family_shopping_new',
'family_baby_preg_new',
'family_health_new',
'family_parenting_new',
'family_learning_new',
'family_ecards_new',
'family_messageboard_new',
'family_feature_new',
'family_entertainment_new'
);

function actiontagMatch(x) {
	for (i = 0; i < activeTagsArray.length ; i++ ) {
		if ( x == activeTagsArray[i] ) { return true }
	}
	return false;
}

function writeActionTag(x) {
	if ( actiontagMatch(x) ) { 
		document.write('<img height=1 width=1 src="http://switch.avenuea.com/action/' + x + '/' + cachebuster + '">');
	}
} 

function writeSecureActionTag(x) {
	if ( actiontagMatch(x) ) { 
		document.write('<img height=1 width=1 src="https://switch.avenuea.com/action/' + x + '/' + cachebuster + '">');
	}
} 
