var dresses_off = new Array();
var dresses_on = new Array();

function preLoadDresses()
{
	for( var ix = 0; ix < arguments.length; ix++ )
	{
		var style = arguments[ix];
		var offImg = new Image();
		offImg.src = 'images/dresses/medium_off/front/' + style + '.jpg';
		dresses_off[style] = offImg;
		var onImg = new Image();
		onImg.src = 'images/dresses/medium_on/front/' + style + '.jpg';
		dresses_on[style] = onImg;
	}
}

function swapDress(oImg, style, isOver)
{
	var dress = isOver ? dresses_on[style] : dresses_off[style];
	if( dress )
	{
		oImg.src = dress.src;
	}
}

function styleBoxFocus()
{
	var oBox = document.getElementById(keywordTextBoxId);
	if( oBox.value == keywordPrompt )
	{
		oBox.value = '';
	}
}

function styleBoxBlur()
{
	var oBox = document.getElementById(keywordTextBoxId);
	oBox.value = TrimAll(oBox.value);
	if( oBox.value == '' )
	{
		oBox.value = keywordPrompt;
	}
}

function showHideMoreOptions()
{
	var checked = document.getElementById(moreOptionsCheckBoxId).checked;
	if( checked && !searchOptionsLoaded )
	{
		document.getElementById(moreOptionsCheckBoxId).disabled = true;
		eval(moreOptionsCallbackObjectName).Callback('');
	}
	else
	{
		document.getElementById('moreOptionsRow').style.display = (checked ? '' : 'none');
	}
}

function searchOptionsCallbackComplete()
{
	document.getElementById(moreOptionsCheckBoxId).disabled = false;
	searchOptionsLoaded = true;
	showHideMoreOptions();
}

function showSearchTips()
{
	var searchTipsDiv = document.getElementById('searchTipsDiv');
	var coordinates = getAnchorPosition('searchTipsLink');
	searchTipsDiv.style.left = coordinates.x - 150;
	searchTipsDiv.style.top = coordinates.y - 1;
	searchTipsDiv.style.visibility = 'visible';
}

function hideSearchTips()
{
	document.getElementById('searchTipsDiv').style.visibility = 'hidden';
}

function gotoPage(page)
{
	var url = gotoPageUrl + page + getMoreOptionsParam();
	window.location.href = url;
}

function pageSizeChange(oList)
{
	var pageSize = oList.options[oList.selectedIndex].value;
	var url = pageSizeChangeUrl + pageSize + getMoreOptionsParam();
	window.location.href = url;
}

function showAll()
{
	var url = showAllUrl + getMoreOptionsParam();
	window.location.href = url;
}

function viewDress(style)
{
	var url = viewDressUrl + style + getMoreOptionsParam();
	window.location.href = url;
}

function viewStory(id)
{
	var url = viewStoryUrl + id;
	window.location.href = url;
}

function getMoreOptionsParam()
{
	if (typeof(moreOptionsCheckBoxId) == 'undefined')
	{
		return '';
	}
	
	var x = document.getElementById(moreOptionsCheckBoxId);
	if (x)
	{
		return x.checked ? '&moreOptions=1' : '';
	}
	return '';
}

function printSearchTipsContent()
{
	var searchTips = "" +
		"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"500\" style=\"margin-top:5px;margin-left: 10px; margin-right:10px;\">" +
		"	<tr>" +
		"		<td>" +
		"			<b>Search Tips</b></td>" +
		"		<td align=\"right\">" +
		"			<a href=\"javascript:hideSearchTips()\">Hide Search Tips</a></td>" +
		"	</tr>" +
		"	<tr>" +
		"		<td colspan=\"2\">" +
		"			<ul>" +
		"				<li><b>Keywords:</b> Enter your search terms into the textbox. Item Name, Number and" +
		"					Description are searched upon. Use the pulldown menu to select the type of keyword" +
		"					search to use." +
		"					<ul>" +
		"						<li><b>Any of the words:</b> If multiple keywords are entered, the search returns items" +
		"							that contain any of those keywords. For instance, if the phrase \"White Corset\" was" +
		"							entered, products that contained the word \"White\" OR the word \"Corset\" would be" +
		"							return. </li>" +
		"						<li><b>All of the words:</b> If multiple keywords are entered, the search returns items" +
		"							that contain any of those keywords. For instance, if the phrase \"White Corset\" was" +
		"							entered, products that contained the word \"White\" AND the word \"Corset\" would be" +
		"							return. </li>" +
		"						<li><b>Exact phrase:</b> If multiple keywords are entered, the search returns items" +
		"							that contain the exact phrase that was entered. For instance, if the phrase \"White" +
		"							Corset\" was entered, products that contained the exact phrase \"White Corset\" would" +
		"							be returned. </li>" +
		"					</ul>" +
		"				</li>" +
		"				<li><b>More Search Options:</b> Clicking this checkbox displays a categorized search" +
		"					to the user. When the additional search options are being displayed, selecting the" +
		"					desired dress attributes and clicking \"Search\" will refersh the page, displaying" +
		"					only those dresses matching the specified serach criteria. </li>" +
		"				<li><b>Page Numbers:</b> Use the page numbers to change which page of dresses to display." +
		"				</li>" +
		"				<!--li><b>Show All:</b> By clicking the \"Show All\" link, every dress matching the specified" +
		"					search criteria will be displayed.<br>" +
		"					NOTE: this may take several minutes to load over a slow connection. </li-->" +
		"				<li><b>Dresses Per Page:</b> By default, 12 dresses are displayed per page. Use the drop-down" +
		"					list to select a different number of dresses to display per page. </li>" +
		"			</ul>" +
		"		</td>" +
		"	</tr>" +
		"</table>";
	document.write(searchTips);
}