// JavaScript Document

var cpss = window;

cpsnippet_shopsearch_x_IdList = cpss.cpsnippet_shopsearch_shopids.split(/ *\, */);

if (cpss.cpsnippet_shopsearch_shopnames) {
	var cpsnippet_shopsearch_x_NameList = cpsnippet_shopsearch_shopnames.split(/ *\, */);
	if (cpsnippet_shopsearch_x_NameList.length != cpsnippet_shopsearch_x_IdList.length) {
		cpsnippet_shopsearch_x_NameList = cpsnippet_shopsearch_shopids.split(/ *\, */);
	}
} else {
	var cpsnippet_shopsearch_x_NameList = cpsnippet_shopsearch_shopids.split(/ *\, */);
}

var cpsnippet_shopsearch_x_DefaultId = "";
if (cpss.cpsnippet_shopsearch_defaultid) {
	cpsnippet_shopsearch_x_DefaultId = cpsnippet_shopsearch_defaultid;
}

var cpsnippet_shopsearch_x_StartTerm = "";
if (cpss.cpsnippet_shopsearch_startterm) {
	cpsnippet_shopsearch_x_StartTerm = cpsnippet_shopsearch_startterm;
}

var cpsnippet_shopsearch_x_BeforeText = "Search: ";
if (cpss.cpsnippet_shopsearch_beforetext) {
	cpsnippet_shopsearch_x_BeforeText = cpsnippet_shopsearch_beforetext;
}

var cpsnippet_shopsearch_x_ButtonText = "go";
if (cpss.cpsnippet_shopsearch_buttontext) {
	cpsnippet_shopsearch_buttontext = cpsnippet_shopsearch_buttontext;
}

var cpsnippet_shopsearch_x_MiddleText = " in ";
if (cpss.cpsnippet_shopsearch_middletext) {
	cpsnippet_shopsearch_x_MiddleText = cpsnippet_shopsearch_middletext;
}

var cpsnippet_shopsearch_x_AfterText = "";
if (cpss.cpsnippet_shopsearch_aftertext) {
	cpsnippet_shopsearch_x_AfterText = cpsnippet_shopsearch_aftertext;
}

var cpsnippet_shopsearch_x_ClearOnFocus = false;
if (cpss.cpsnippet_shopsearch_clearonfocus) {
	if (cpsnippet_shopsearch_clearonfocus == 'yes') {
		cpsnippet_shopsearch_x_ClearOnFocus = true;
	}
}

function cpsnippet_shopsearch_x_checkClear(fieldtocheck) {
	if (fieldtocheck.value == cpsnippet_shopsearch_x_StartTerm) {
		fieldtocheck.value = "";
	}
}

document.write("<div id='cpSearchFormContainer' class='cpSearchFormInHeader'>");
document.write("<form id='cpSnippetSearchForm' name='cpSnippetSearchForm' action='http://www.cafepress.com/cp/storesearchresults.aspx' method='post'>");
document.write("<span id='searchBoxLabel'>" + cpsnippet_shopsearch_x_BeforeText + "</span><br />");
document.write("<input type='text' style='width:100px;' ");
if (cpsnippet_shopsearch_x_ClearOnFocus == true) {
	document.write("onFocus='cpsnippet_shopsearch_x_checkClear(this)'");
}
document.write("id='searchterm' name='searchterm' value='" + cpsnippet_shopsearch_x_StartTerm + "'/>");

if (cpsnippet_shopsearch_x_IdList.length > 1) {
	var sil;
	document.write("<span id='searchBoxIn'>" + cpsnippet_shopsearch_x_MiddleText + "</span>");
	document.write("<select name='s' id='s'>");
	for(sil=0;sil<cpsnippet_shopsearch_x_IdList.length;sil++) {
		document.write("<option value='" + cpsnippet_shopsearch_x_IdList[sil] + "'");
		if (cpsnippet_shopsearch_x_DefaultId == cpsnippet_shopsearch_x_IdList[sil]) {
			document.write(" selected");
		}
		document.write(">" + cpsnippet_shopsearch_x_NameList[sil] + "</option>");
	}
	document.write("</select>");
} else {
	document.write("<input type='hidden' id='s' name='s' value='" + cpsnippet_shopsearch_x_NameList[0] + "' />");
}
document.write("<span id='searchBoxLabel2'>" + cpsnippet_shopsearch_x_AfterText + "</span>");
document.write("<input id='submitSearch' type='submit' style='width:30px;' value='" + cpsnippet_shopsearch_x_ButtonText + "' />");
document.write("</form>");
document.write("</div>");