/* productNav.js: write out prev/next navigation links */

var vAllStyleNums = new Array(); /* a multi-dimensional array containg all categories, and all styleNums within those categories */
var vCategories = new Array(); /* all category names */
var vPinkStyleNums = new Array(); /* all styleNums within Hats */
var vSportStyleNums = new Array(); /* all styleNums within Hats */
var vKnitsStyleNums = new Array(); /* all styleNums within Knits */
var vWovensStyleNums = new Array(); /* all styleNums within Wovens */
var vOuterwearStyleNums = new Array(); /* all styleNums within Outerwear */
var vHatsStyleNums = new Array(); /* all styleNums within Hats */
var vBagsStyleNums = new Array(); /* all styleNums within Hats */

/* all category names; order independent */
vCategories = ['Pink','Sport','Knits','Wovens','Outerwear','Hats','Bags'];

/* the following arrays are ORDER-DEPENDENT  in that
   the products should be arranged in the arrays in 
	 the same order that they are navigated on the site */
	 
vPinkStyleNums = ['DP305W','DP155W','DP135W','DP145W','DP935W','DP925W']; 
vSportStyleNums = ['DG125','D330','DG345','DG335','DG930','DG910','DG940W','DG105W','DG105','DG955','DG705']; 
vKnitsStyleNums = ['D100','D100W','D110','D100Y','D120','D120W','D300','D140','D140W','D140S','D440','D440W','D190','D210','D340','D150','D150W','D400','D180S','D180L','D420','D905','D915'];
vWovensStyleNums = ['D500','D500W','D500S','D510','D610W','D610','D650','D650W','D520','D530W','D540','D540W','D580','D660','D560','D570','D560W'];
vOuterwearStyleNums = ['D750','D760','D980','D990','D990W','D970','D999','D730','D700','D920','D950','D900','D850','D960','D740'];
vHatsStyleNums = ['D835','D820','D825','D830','D800','D840','DG805','DG815'];
vBagsStyleNums = ['D870','D895','D890','D880','D860'];

/* all styleNums within all categories */
vAllStyleNums = [vPinkStyleNums,vSportStyleNums,vKnitsStyleNums,vWovensStyleNums,vOuterwearStyleNums,vHatsStyleNums,vBagsStyleNums];

function writePrevNext(vCategory,vStyleNum) {
	var vCategoryIndex;
	var vProductInxex;
	var vPrevStyleNum;
	var vNextStyleNum;
	var i;
	var vHtmlOut;

	/* find this page's category in the vCategories array */
	for (i=0; i < vCategories.length; i++) {
		/* if we found vCategory in the vCategories array */
		if (vCategories[i] == vCategory) {
			vCategoryIndex = i;
			break;
		} /* if we found vCategory in the vCategories array */
	} /* find this page's category in the vCategories array */
	
	/* find this page's styleNum in the vAllStyleNums array */
	for (i=0; i < vAllStyleNums[vCategoryIndex].length; i++) {
		/* if we found vStyleNum in the proper category array */
		if (vAllStyleNums[vCategoryIndex][i] == vStyleNum) {
			vProductIndex = i;
			break;
		} /* if we found vStyleNum in the proper category array */
	} /* find this page's styleNum in the vAllStyleNums array */
	
	/* we now know this product's location via vAllStyleNums[vCategoryIndex][vProductIndex] */

	vPrevStyleNum = vAllStyleNums[vCategoryIndex][vProductIndex - 1];
	vNextStyleNum = vAllStyleNums[vCategoryIndex][vProductIndex + 1];

	/* write out the proper prev/next links */	
	vHtmlOut = '<span class="lateralNavigationPage">';
	/* if this isn't the first styleNum in the category, write out a prev link */
	vHtmlOut += vProductIndex > 0 ? '<< <a href="' + vPrevStyleNum + '.htm">PREV</a>' : '';
	/* if both PREV and NEXT exist, write out a seperator */
	vHtmlOut += vPrevStyleNum != null && vNextStyleNum != null ? ' | ' : '';
	/* if this isn't the last styleNum in the category, write out a next link */
	vHtmlOut += vProductIndex < vAllStyleNums[vCategoryIndex].length - 1 ? '<a href="' + vNextStyleNum + '.htm">NEXT</a> >>' : '';
	vHtmlOut += '</span>';

	document.write(vHtmlOut);
	
} /* function writePrevNext */