
function popIt(width,height,scrollbars){
	if(!width)width="335";
	if(!height)height="460";
	var windowString='width='+width+',height='+height+',resizable=1,status=0,toolbar=no,scrollbars='+scrollbars+',scrolling=auto';
	var popItWindow=open('',"popIt",windowString);
	return false;
}
function abbreviateDescription(description,endMarker,paragraphCount){
	if(!endMarker)endMarker="<br><br>";
	if(!paragraphCount)paragraphCount=1;
	description=String(description);
	var searchText=description.toLowerCase();
	var firstParagraphEnd=0;
	var tempEnd;
	for(var i=0;i<paragraphCount;i++){
		tempEnd=searchText.indexOf(endMarker);
		if(tempEnd>-1){
			firstParagraphEnd+=tempEnd;
			searchText=searchText.substring(firstParagraphEnd+=endMarker.length,searchText.length);
		}
	}
	if(firstParagraphEnd<=0)firstParagraphEnd=description.length;
	else firstParagraphEnd-=endMarker.length;
	description=description.substring(0,firstParagraphEnd);
	return description;
}
function showFullDescription(){
	document.getElementById("pageDescription").innerHTML=description;
	return false;
}
function trim(str){
	str=String(str);
	return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}
function popUpImage(img,name,wid,hi,autoSize){
	features="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,scrolling=yes,resizable=yes,width="+wid+",height="+hi;
	dlg=open("","Details",features);
	dlg.document.write('<htm');
	dlg.document.write('l><he');
	dlg.document.write('ad>');
	dlg.document.write('<tit');
	dlg.document.write('le>'+name+' Zoom</title>');
	dlg.document.write('<scr');
	dlg.document.write('ipt>');
	dlg.document.write('function autoSizeWhenReady() {');
	dlg.document.write('if(document.images[0].complete) {');
	dlg.document.write(' autoSize();');
	dlg.document.write('}');
	dlg.document.write('else setTimeout(autoSizeWhenReady(), 500);');
	dlg.document.write('}');
	dlg.document.write('function autoSize() {');
	dlg.document.write('var width=document.images[0].width + 100;');
	dlg.document.write('var height=document.images[0].height + 100;');
	dlg.document.write('if(height > screen.availHeight ) height = screen.availHeight  - 100;');
	dlg.document.write('window.resizeTo(width, height);');
	dlg.document.write('}');
	dlg.document.write('</scri');
	dlg.document.write('pt>');
	dlg.document.write('</he');
	dlg.document.write('ad>');
	dlg.document.write('<bo');
	dlg.document.write('dy bgcolor=white onload="self.focus();');
	if(autoSize==true&&!browserIsSafari())dlg.document.write('autoSizeWhenReady();');
	dlg.document.write('">');
	dlg.document.write('<table border="0" width="100%">');
	dlg.document.write('<tr><td align=center valign=top>');
	dlg.document.write('<a href=# onClick=window.close();>');
	dlg.document.write('<img src='+img+' border=0 alt="Click Image to Close">');
	dlg.document.write('<br>');
	dlg.document.write('<font face="arial" size="2">Click to Close</font>');
	dlg.document.write('</a></td></tr>');
	dlg.document.write('</table>');
	dlg.document.write('</bo');
	dlg.document.write('dy></ht');
	dlg.document.write('ml>');
	dlg.document.close();
}
currentImage="standard";
function swapCurrentImage(){
	if(currentImage=="standard")currentImage="inset";
	else currentImage="standard";
	if(browserIsSafari()){document.getElementById("currentImage").src="/lib/duematernity/spacer.gif";
		document.getElementById("currentImage").alt=productImages[currentImage].title;
		document.getElementById("currentImage").src=productImages[currentImage].url;
	} else {
		document.getElementById("currentImage").src=productImages[currentImage].url;
		document.getElementById("currentImage").alt=productImages[currentImage].title;
	}
}
function zoomCurrentImage(){
	var windowWidth=500;
	var windowHeight=screen.availHeight-100;
	popUpImage(productImages[currentImage].zoomUrl,productImages[currentImage].title,windowWidth,windowHeight,false);
}
function browserIsSafari(){
	var userAgent=navigator.userAgent.toLowerCase();
	if(userAgent.indexOf("safari")>-1) return true;
	else return false;
}
function jumpToUrl(url){
	if(url!=""&&String(url)!="undefined") location=url;
	return false;
}
function resetFooterDisplay(){
	document.getElementById('footerCustServDiv').className='footerTabContentOff';
	document.getElementById('footerDesignersDiv').className='footerTabContentOff';
	document.getElementById('footerDepartmentsDiv').className='footerTabContentOff';
	document.getElementById('footerSpecialsDiv').className='footerTabContentOff';
	document['footerCustServ'].src='http://files.duematernity.com/v3/images/footerCustServ.gif';
	document['footerDesigners'].src='http://files.duematernity.com/v3/images/footerDesigners.gif';
	document['footerDepartments'].src='http://files.duematernity.com/v3/images/footerDepartments.gif';
	document['footerSpecials'].src='http://files.duematernity.com/v3/images/footerSpecials.gif';
}

function switchFooterContent(which){switch(which){case'service':resetFooterDisplay();
document['footerCustServ'].src='http://files.duematernity.com/v3/images/footerCustServOn.gif';
document.getElementById('footerCustServDiv').className="footerTabContentOn";
break;
case'designers':resetFooterDisplay();
document['footerDesigners'].src='http://files.duematernity.com/v3/images/footerDesignersOn.gif';
document.getElementById('footerDesignersDiv').className="footerTabContentOn";
break;
case'departments':resetFooterDisplay();
document['footerDepartments'].src='http://files.duematernity.com/v3/images/footerDepartmentsOn.gif';
document.getElementById('footerDepartmentsDiv').className="footerTabContentOn";
break;
case'specials':resetFooterDisplay();
document['footerSpecials'].src='http://files.duematernity.com/v3/images/footerSpecialsOn.gif';
document.getElementById('footerSpecialsDiv').className="footerTabContentOn";
break}}activemenu=false;
activemenuhighlight=false;
menutimeout=false;

function changeImagesOff(imageName){
	document[imageName].src='http://files.duematernity.com/v3/images/'+imageName+'.gif'
}

function changeImagesOn(imageName){
	document[imageName].src='http://files.duematernity.com/v3/images/'+imageName+'On.gif'
}

function showMenu(menuid,menuidhighlight){
if(activemenu==menuid){
	myClearTimeout();
	return;
}
hideMenu();
var menuDiv=document.getElementById(menuid);
menuDiv.style.display='block';
activemenu=menuid;
if(menuidhighlight){
	var menuDiv=document.getElementById(menuidhighlight);
	menuDiv.style.display='block';
	activemenuhighlight=menuidhighlight;
}

if(menuid=="topsmenu")document.images.tabTops.src="http://files.duematernity.com/v3/images/tabTopsOn.gif";
else if(menuid=="bottomsmenu")document.images.tabBottoms.src="http://files.duematernity.com/v3/images/tabBottomsOn.gif";
else if(menuid=="dressesmenu")document.images.tabDresses.src="http://files.duematernity.com/v3/images/tabDressesOn.gif";
else if(menuid=="sleepwearmenu")document.images.tabNursing.src="http://files.duematernity.com/v3/images/tabNursingOn.gif";
else if(menuid=="swimwearmenu")document.images.tabActivewear.src="http://files.duematernity.com/v3/images/tabActivewearOn.gif";
else if(menuid=="skincaremenu")document.images.tabSkinCare.src="http://files.duematernity.com/v3/images/tabSkinCareOn.gif";
else if(menuid=="diaperbagsmenu")document.images.tabDiaperBags.src="http://files.duematernity.com/v3/images/tabDiaperBagsOn.gif";
else if(menuid=="onsalemenu")document.images.tabOnSale.src="http://files.duematernity.com/v3/images/tabOnSaleOn.gif";
else if(menuid=="babymenu")document.images.tabBaby.src="http://files.duematernity.com/v3/images/tabBabyOn.gif";
else if(menuid=="maternitygiftsmenu")document.images.tabGifts.src="http://files.duematernity.com/v3/images/tabGiftsOn.gif"}

function mySetTimeout(){
	if(!activemenu) return;
	menutimeout=setTimeout("hideMenu()",350);
}

function myClearTimeout(){if(!menutimeout)return;
clearTimeout(menutimeout);
menutimeout=false}

function hideMenu(){if(!activemenu)return;
myClearTimeout();
var menuDiv=document.getElementById(activemenu);
menuDiv.style.display='none';
if(activemenuhighlight){var menuDiv=document.getElementById(activemenuhighlight);
menuDiv.style.display='none'}document.images.tabTops.src="http://files.duematernity.com/v3/images/tabTops.gif";
document.images.tabBottoms.src="http://files.duematernity.com/v3/images/tabBottoms.gif";
document.images.tabDresses.src="http://files.duematernity.com/v3/images/tabDresses.gif";
document.images.tabNursing.src="http://files.duematernity.com/v3/images/tabNursing.gif";
document.images.tabActivewear.src="http://files.duematernity.com/v3/images/tabActivewear.gif";
document.images.tabSkinCare.src="http://files.duematernity.com/v3/images/tabSkinCare.gif";
document.images.tabDiaperBags.src="http://files.duematernity.com/v3/images/tabDiaperBags.gif";
document.images.tabOnSale.src="http://files.duematernity.com/v3/images/tabOnSale.gif";
document.images.tabGifts.src="http://files.duematernity.com/v3/images/tabGifts.gif";
document.images.tabBaby.src="http://files.duematernity.com/v3/images/tabBaby.gif";
activemenu=false;
activemenuhighlight=false}


function parseProductArray(itemsPerPage){var i=0;
var productArray=new Array();
var productIdString="";
var productWrapper=document.getElementById("productWrapper");
if(!isBlank(productWrapper)){if(productWrapper.firstChild){var oChild=productWrapper.firstChild;
while(oChild){if(oChild.nodeType==1&&String(oChild.id).indexOf("productDisplay")>-1){productArray[i]=new Object();
productArray[i].id=oChild.id;
productArray[i].html=document.getElementById(oChild.id).innerHTML;
var subChild=oChild.firstChild;
while(subChild){if(subChild.nodeType==1){if(subChild.id=="name")productArray[i].title=subChild.title;
if(subChild.id=="id")productArray[i].productId=subChild.title;
if(subChild.id=="price")productArray[i].price=subChild.title-0}subChild=subChild.nextSibling}if(productArray[i].productId)productIdString+=productArray[i].productId+",";
i++}oChild=oChild.nextSibling}}}if(!isBlank(productIdString)){productIdString=String(productIdString).substring(0,productIdString.length-1);
pdSetCookie("pd_currentProductList",productIdString,"","","");
}return productArray}

function renderProductArray(productArray,currentPageNumber,itemsPerPage){var html="";
var pageNumber=1;
var i=1;
var item=new Object();
var tempHtml="";
var rowItemCount=1;
var isOpen=false;
var productIdList="";
for(item in productArray){productIdList+=productArray[item].id;
tempHtml="";
if(pageNumber==currentPageNumber||currentPageNumber=="all"){if(rowItemCount==1){tempHtml+='<table border="0"><tr>\r\n';
isOpen=true}tempHtml+='<td valign="top"><div id="'+productArray[item].id+'" class="displayDiv">';
tempHtml+=productArray[item].html;
tempHtml+='</div></td>';
rowItemCount++;
if(rowItemCount>itemsPerRow){tempHtml+='</tr></table>';
rowItemCount=1;
isOpen=false}}i++;
pageNumber=Math.ceil(i/itemsPerPage);
html+=tempHtml}if(isOpen)html+='\r\n</tr></table>\r\n';
return html}

function sortProductArrayByPrice(productArray){productArray=productArray.sort(compareId);
productArray=productArray.sort(comparePrice);
sortBy="price";
return productArray}

function sortProductArrayByTitle(productArray){productArray=productArray.sort(compareId);
productArray=productArray.sort(compareTitle);
sortBy="title";
return productArray}

function compareTitle(item1,item2){if(item1.title>item2.title)return 1;
else if(item1.title<item2.title)return-1;
else return 0}

function comparePrice(item1,item2){if(item1.price>item2.price)return 1;
else if(item1.price<item2.price)return-1;
else return 0}

function compareId(item1,item2){if(item1.id>item2.id)return 1;
else if(item1.id<item2.id)return-1;
else return 0}

function displayProductArray(productArray,currentPageNumber,itemsPerPageRequest,sortByField){if(productArray.length==0)return false;
if(!isBlank(sortByField))sortBy=sortByField;
itemsPerPage=itemsPerPageRequest;
pdSetCookie("pd_currentPageNumber",currentPageNumber);
pdSetCookie("pd_pagingSortBy",sortBy);
if(sortBy=="title")productArray=sortProductArrayByTitle(productArray);
else if(sortBy=="price")productArray=sortProductArrayByPrice(productArray);
if(isBlank(currentPageNumber))currentPageNumber=1;
document.getElementById("productWrapper").innerHTML=renderProductArray(productArray,currentPageNumber,itemsPerPage);
document.getElementById("pageInfo").innerHTML=renderPageInfo(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("pageInfoBottom").innerHTML=renderPageInfo(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("sortLinks").innerHTML=renderSortLinks(currentPageNumber,sortBy);
document.getElementById("previousButton").innerHTML=renderPreviousButton(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("previousButtonBottom").innerHTML=renderPreviousButton(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("pageNumberLinks").innerHTML=renderPageNumberLinks(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("pageNumberLinksBottom").innerHTML=renderPageNumberLinks(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("nextButton").innerHTML=renderNextButton(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("nextButtonBottom").innerHTML=renderNextButton(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("viewAllButton").innerHTML=renderViewAllButton(productArray.length,currentPageNumber,itemsPerPage);
document.getElementById("viewAllButtonBottom").innerHTML=renderViewAllButton(productArray.length,currentPageNumber,itemsPerPage);
return false}

function getCurrentPageNumber(){var pageNumber=1;
var currentSection=pdGetCookie("pd_stickyBreadcrumbSection");
if(lastSection==currentSection){pageNumber=pdGetCookie("pd_currentPageNumber");
}pdSetCookie("pd_lastPageNumber",pageNumber);
if(isBlank(pageNumber))pageNumber=1;
return pageNumber}

function getCurrentSortBy(){var sortBy="";
var currentSection=pdGetCookie("pd_stickyBreadcrumbSection");
if(lastSection==currentSection){sortBy=pdGetCookie("pd_pagingSortBy");
}if(isBlank(sortBy))sortBy="";
return sortBy}

function renderPageNumberLinks(productCount,currentPageNumber,itemsPerPage,position){var pageCount=Math.ceil(productCount/itemsPerPage);
if(pageCount==1)return"";
var html="";
if(currentPageNumber!="all"){var pagesToDisplay=5;
var extraPages=0;
var firstPageNumber=currentPageNumber-Math.floor(pagesToDisplay/2);
if(firstPageNumber<1){extraPages=1-firstPageNumber;
firstPageNumber=1}var lastPageNumber=(currentPageNumber-0)+Math.floor(pagesToDisplay/2)+extraPages;
if(lastPageNumber>pageCount)lastPageNumber=pageCount;
for(var i=firstPageNumber;i<=lastPageNumber;i++){if(currentPageNumber==i){html+='<font class="pageNumOn">'+i+'</font>&nbsp;<font class="pageNum"> | </font>&nbsp;'}else{html+='<a href="#" class="pageNum" onClick="return(displayProductArray(productArray, '+i+', '+itemsPerPage+'))">'+i+'</a>&nbsp;<font class="pageNum"> | </font>&nbsp;'}}}return html}

function renderPageInfo(productCount,currentPageNumber,itemsPerPage){var pageCount=Math.ceil(productCount/itemsPerPage);
if(pageCount==1)return"";
var html="";
if(currentPageNumber!="all"){html+='<font class="pageInfo">Page '+currentPageNumber+' of '+pageCount+'</font>'}return html}

function renderPreviousButton(productCount,currentPageNumber,itemsPerPage){var html="";
if(currentPageNumber!="all"){if(currentPageNumber>1){var previousPage=currentPageNumber-1;
html+='<a href="#" onClick="return(displayProductArray(productArray, '+previousPage+', '+itemsPerPage+'))"><img src="http://files.duematernity.com/v3/images/pageArrowPrevious.gif" border="0"></a>'}else{html+=''}}return html}

function renderNextButton(productCount,currentPageNumber,itemsPerPage){var pageCount=Math.ceil(productCount/itemsPerPage);
var html="";
if(currentPageNumber!="all"){var nextPage=currentPageNumber+1;
if(nextPage<=pageCount){html+='<a href="#" onClick="return(displayProductArray(productArray, '+nextPage+', '+itemsPerPage+'))"><img src="http://files.duematernity.com/v3/images/pageArrowNext.gif" border="0"></a>'}else{html+=''}}return html}

function renderViewAllButton(productCount,currentPageNumber,itemsPerPage){var pageCount=Math.ceil(productCount/itemsPerPage);
if(pageCount==1)return"";
var html="";
if(currentPageNumber=="all"){html+='<a href="#" onClick="return(displayProductArray(productArray, 1, itemsPerPage))" class="viewAllLink">Return to Paged View</a>'}else{html+='<a href="#" onClick="return(displayProductArray(productArray, \'all\', itemsPerPage))" class="viewAllLink">View All Items</a>'}return html}

function renderSortLinks(currentPageNumber,sortBy){if(currentPageNumber!="all"&&currentPageNumber>1)currentPageNumber=1;
var html="";
if(sortBy=="title"){html+='<font class="sortLinkOn">Sort By Designer</font>'}else{html+='<img src="http://files.duematernity.com/v3/images/pageSortArrows.gif">&nbsp;<a href="#" class="sortLink" onClick="return(displayProductArray(productArray, \''+currentPageNumber+'\',itemsPerPage, \'title\'))">Sort By Designer</a>'}html+='  &nbsp; &nbsp; &nbsp; ';
if(sortBy=="price"){html+='<font class="sortLinkOn">Sort By Price</font>'}else{html+='<img src="http://files.duematernity.com/v3/images/pageSortArrows.gif">&nbsp;<a href="#" class="sortLink" onClick="return(displayProductArray(productArray, \''+currentPageNumber+'\',itemsPerPage, \'price\'))">Sort By Price</a>'}return html}

function renderPreviousNextProductButtons(currentProductId){var html="";
var productListString=pdGetCookie("pd_currentProductList");
if(!isBlank(productListString)){if(String(productListString).indexOf(currentProductId)>-1){var productArray=String(productListString).split(",");
var item=new Object();
var i=0;
for(item in productArray){if(currentProductId==productArray[item])break;
i++}if(i>0){html+='<a href="#" onclick="return(jumpToUrl(\''+productArray[i-1]+'.html\'))" class="previousNextLink">Previous Item</a><span class="previousNextLink"> &nbsp;|&nbsp; </span>'}if(i+1<productArray.length){html+='<a href="#" onclick="return(jumpToUrl(\''+productArray[i+1]+'.html\'))" class="previousNextLink">Next Item</a>'}}}document.getElementById("previousNextProductButtons").innerHTML=html;
return false}

function pdGetCookie(cookieName){var allCookies=document.cookie;
var cookieStart=allCookies.indexOf(cookieName);
if(cookieStart==-1)return"";
cookieStart+=cookieName.length+1;
var cookieEnd=allCookies.indexOf(";",cookieStart);
if(cookieEnd==-1)cookieEnd=allCookies.length;
var cookieValue=unescape(allCookies.substring(cookieStart,cookieEnd));
return cookieValue}

function pdSetCookie(cookieName,cookieValue,cookieDomain,cookiePath,expirationDate){if(isBlank(cookieDomain))cookieDomain=getCurrentDomainName();
if(isBlank(cookiePath))cookiePath="/";
var cookieString=cookieName+"="+escape(cookieValue)+";domain="+cookieDomain+";path="+cookiePath;
if(!isBlank(expirationDate)){
cookieString+=";expires="+expirationDate.toGMTString();
}document.cookie=cookieString;
return true}

function getCurrentDomainName(){var url=String(location);
var domainName=extractDomain(url);
return domainName}

function extractDomain(url){var url=url.replace("http://","");
var slashIndex=url.indexOf("/");
if(slashIndex==-1)slashIndex=url.length;
var url=url.substring(0,slashIndex);
var urlSectionArray=url.split('.');
var urlSectionArrayLength=urlSectionArray.length;
var domainName="";
for(var i=urlSectionArrayLength-2;i<urlSectionArrayLength;i++){domainName+="."+urlSectionArray[i]}return domainName}

function isBlank(item){item=String(item).toLowerCase();
if(item=="undefined"||item==""||item=="null")return true;
else return false}

function preloadImages(){loadImage("http://files.duematernity.com/v3/images/tabTopsOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabBottomsOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabDressesOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabNursingOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabActivewearOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabSkinCareOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabDiaperBagsOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabOnSaleOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabGiftsOn.gif");
loadImage("http://files.duematernity.com/v3/images/footerCustServOn.gif");
loadImage("http://files.duematernity.com/v3/images/footerDesignersOn.gif");
loadImage("http://files.duematernity.com/v3/images/footerDepartmentsOn.gif");
loadImage("http://files.duematernity.com/v3/images/footerSpecialsOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabMenuBg.gif");
loadImage("http://files.duematernity.com/v3/images/tabMenuBot.gif");
loadImage("http://files.duematernity.com/v3/images/tabBabyOn.gif");
loadImage("http://files.duematernity.com/v3/images/tabCommunityOn.gif");
return true}

function loadImage(src){var tempImage=new Image();
tempImage.src=src}preloadImages();

function displayStickyBreadcrumb(){var currentSection=pdGetCookie("pd_stickyBreadcrumbSection");
currentSection=currentSection.replace("&amp;","");
currentSection=currentSection.replace("&","");
var pathArray=parseBreadcrumbArray();
var matchFound=false;
var shortestPathIndex=0;
if(isBlank(currentSection)){document.getElementById(pathArray[0].id).style.display="block"}else{var item=new Object();
for(item in pathArray){if(String(pathArray[item].breadCrumbString).indexOf(currentSection)>-1){matchFound=true;
document.getElementById(pathArray[item].id).style.display="block";
break}if(pathArray[item].breadCrumbString.length<pathArray[shortestPathIndex].breadCrumbString.length){shortestPathIndex=item}}}if(!matchFound){document.getElementById(pathArray[shortestPathIndex].id).style.display="block"}return false}

function saveStickyBreadcrumbSection(section){lastSection=pdGetCookie("pd_stickyBreadcrumbSection");
pdSetCookie("pd_stickyBreadcrumbSection",section);
return false}

function parseBreadcrumbArray(){var i=0;
var elementArray=new Array();
var wrapper=document.getElementById("stickyBreadcrumbList");
if(wrapper.firstChild){var oChild=wrapper.firstChild;
while(oChild){elementArray[i]=new Object();
elementArray[i].id="stickybreadCrumb-"+i;
oChild.id=elementArray[i].id;
elementArray[i].breadCrumbString=oChild.innerHTML;
elementArray[i].breadCrumbString=String(elementArray[i].breadCrumbString).replace("&amp;","");
elementArray[i].breadCrumbString=String(elementArray[i].breadCrumbString).replace("&","");
i++;
oChild=oChild.nextSibling}}return elementArray}lastSection="";

