var tmp = "sidebar my_quick_tips my_video my_calendar my_message_boards my_preferences " + 
	"talk_to_other_moms product_recalls product_reviews your_baby_now essential_guides";
var image_ids = tmp.split(" ");
// preload over images
var imgPrefix = "https://a248.e.akamai.net/f/248/822/1d/i.ivillage.com/PBP/shared/";
function preLoadOverImages() {
	for (i in image_ids) {
		new Image().src = imgPrefix + image_ids[i] + "_over.gif";
	}
}
function preLoadAndResize_old() {
	// preload over images ...
	for (i in image_ids) {
		new Image().src = imgPrefix + image_ids[i] + "_over.gif";
	}

	// ... and resize variable width block according to photo width
	var photo = window.document.getElementById("photo");
	var block = window.document.getElementById("varWidthBlock");
	var varWidth = 0;
	if (photo) {
		varWidth = (photo.offsetWidth ? photo.offsetWidth : photo.width);
		if (block) { block.style.width = varWidth + "px"; }
	} 
	var topnavDiv = window.document.getElementById("topnavDiv");
	if (photo && topnavDiv) {
		topnavDiv.style.width = (639 - 70 - varWidth) + "px"; // 639 - 20 - 20 - 20 - 10 - pw
	}
	
	var storyDiv = window.document.getElementById("storyDiv");
	var sideBlockNoImage = window.document.getElementById("noImage");
	if (sideBlockNoImage) {
		if (topnavDiv) 
			sideBlockNoImage.style.marginTop = topnavDiv.offsetTop + "px";
		else 
			sideBlockNoImage.style.marginTop = storyDiv.offsetTop + "px";
	}
}


 // rewritten for: no need to resize varWidthBlock since the article photo
 // will now be either 150 or 300 wide which is styled in the global css

function preLoadAndResize() {
	// preload over images ...
	for (i in image_ids) {
		new Image().src = imgPrefix + image_ids[i] + "_over.gif";
	}

	// ... and resize variable width block according to photo width
	var varWidthBlock = window.document.getElementById("sideBlock150") || 
						window.document.getElementById("sideBlock300") || 
						window.document.getElementById("noImage");
	var topnavDiv = window.document.getElementById("topnavDiv");
	if (varWidthBlock && topnavDiv) {
		var tmp = varWidthBlock.offsetWidth ? varWidthBlock.offsetWidth : varWidthBlock.width;
		topnavDiv.style.width = (639 - 70 - tmp) + "px"; // 639 - 20 - 20 - 20 - 10 - tmp
	}
	
	var storyDiv = window.document.getElementById("storyDiv");
	var sideBlockNoImage = window.document.getElementById("noImage");
	if (sideBlockNoImage) {
		var tmp;
		if (topnavDiv) 
			tmp = topnavDiv.offsetTop - 5;
		else 
			tmp = storyDiv.offsetTop;
		tmp -= 11;
		sideBlockNoImage.style.marginTop = tmp + "px";
	}
}


function MOver(imgElement) {
	imgElement.src = imgPrefix + imgElement.id + "_over.gif";
}
function MOut(imgElement) {
	imgElement.src = imgPrefix + imgElement.id + ".gif";
}

function setPersonalImage() {
  iv_cImg = document.getElementById("customImg");
  var iv_customImgURL = "http://acx.prospero.com/dir-app/bbcard/bbmemberpicture.aspx?webtag=ivillagez&loginCode=" + iv_memName;
  iv_cImg.src = iv_customImgURL;
}

function initMainPage() {
	preLoadAndResize();	
	setPersonalImage();
	createSliders();
	iv_checkBandwidth();
	
}

function initVideoPage() {
	preLoadAndResize();	
	// in the video page, createSlider() is called in the HTML 
	iv_checkBandwidth();
}

function iv_verifyPBPSearch (frm) {
  var mt = frm.q.value;

  if (mt.length == 0) {
      alert('Your search could not be completed because no search words were entered.');
      frm.q.focus();
      frm.q.select();
      return false;
  }
}