// preload function and images
function pixPath(depth)
	{

		preload('bn_arrow',depth+'images/retail/bn_arrow.gif');
		preload('bn_arrow_roll',depth+'images/retail/bn_arrow_roll.gif');

		preload('bn_hd_go',depth+'images/retail/bn_hd_go.gif');
		preload('bn_hd_go_roll',depth+'images/retail/bn_hd_go_roll.gif');

		preload('tab_departments',depth+'images/sub_navigation/departments_pink.gif');
		preload('tab_departments_roll',depth+'images/sub_navigation/departments_green.gif');

		preload('tab_brands',depth+'images/sub_navigation/brands_pink.gif');
		preload('tab_brands_roll',depth+'images/sub_navigation/brands_green.gif');

		preload('tab_craft_type',depth+'images/sub_navigation/craft_type_pink.gif');
		preload('tab_craft_type_roll',depth+'images/sub_navigation/craft_type_green.gif');

		preload('tab_item_type',depth+'images/sub_navigation/item_type_pink.gif');
		preload('tab_item_type_roll',depth+'images/sub_navigation/item_type_green.gif');

		preload('tab_holidays_seasons',depth+'images/sub_navigation/holiday_and_seasons_pink.gif');
		preload('tab_holidays_seasons_roll',depth+'images/sub_navigation/holiday_and_seasons_green.gif');

		preload('tab_themes_occasions',depth+'images/sub_navigation/themes_and_occasions_pink.gif');
		preload('tab_themes_occasions_roll',depth+'images/sub_navigation/themes_and_occasions_green.gif');

		preload('tab_featured',depth+'images/sub_navigation/featured_products_pink.gif');
		preload('tab_featured_roll',depth+'images/sub_navigation/featured_products_green.gif');

		//preload('tab_contacts',depth+'images/sub_navigation/tab_contacts.gif');
		//preload('tab_contacts_roll',depth+'images/sub_navigation/tab_contacts_roll.gif');

}

function preload(imgObj,imgSrc) 
	{
	eval(imgObj+' = new Image()');
	eval(imgObj+'.src = "'+imgSrc+'"');
	}

// rollover function =============================== 
function changeImage(imgName,imgObj) 
	{
	document.images[imgName].src = eval(imgObj+".src");
	}
// /rollover function =============================== 

// popup windows ================================
function pop1(url,winName)
	{
	window.open(url,winName,'top=30,left=30,width=300,height=450,chrome=no,resizable=yes,scrollbars=auto')
	}

function popInfo(url,winName,W,H)
	{
	window.open(url,winName,'top=30,left=30,width='+W+',height='+H+',resizable=yes,scrollbars')
	}

function popAddToCart(url,winName)
	{
	window.open(url,winName,'top=30,left=30,width=567,height=375,resizable=yes,scrollbars')
	}

// /popup windows ================================


// Image rotator =================================	
function adRotator(depth)
{
	var time = new Date();
	var time = time.getTime();

	ad = new Array();
		ad[0] = "freeShipping.gif";
		ad[1] = "freeShipping.gif";
		ad[2] = "freeShipping.gif";
		ad[3] = "freeShipping.gif";
		ad[4] = "freeShipping.gif";
		ad[5] = "100shopping.gif";
		ad[6] = "100shopping.gif";
		ad[7] = "100shopping.gif";
		ad[8] = "100shopping.gif";
		ad[9] = "100shopping.gif";
		//ad[10] = "inventory 20080123.gif";
		//ad[11] = "inventory 20080123.gif";
		//ad[12] = "inventory 20080123.gif";
		//ad[13] = "inventory 20080123.gif";
		//ad[14] = "inventory 20080123.gif";
		//ad[5] = "cf_top_left_5.gif";
		//ad[6] = "cf_top_left_6.gif";
		//ad[7] = "cf_top_left_7.gif";
		//ad[8] = "cf_top_left_8.gif";
		//ad[9] = "cf_top_left_9.gif";
		//ad[10] = "cf_top_left_10.gif";

	var n = Math.floor(Math.random() * (ad.length-1));
	
	if(n < 5)
	{
		document.writeln('<a href="/customer-service/order-shipping-assistance.aspx" title="Free Shipping When you spend $100 or more."><img src="/images/retail/random/'+ad[n]+'" alt="Free Shipping When you spend $100 or more." title="Free Shipping When you spend $100 or more." width="226" height="85" /></a>');
	}
	else if(n > 4 && n < 10)
	{
		document.writeln('<a href="/contact-us/email-newsletter-sign-up.aspx" target="NewsletterSignup" onclick="return popAd()" title="Email newsletter sign up. Win a $100 shopping spree."><img SRC="/images/retail/random/'+ad[n]+'" alt="Email newsletter sign up. Win a $100 shopping spree." title="Email newsletter sign up. Win a $100 shopping spree." width="226" height="85" /></a>');
	}
	else
	{
		//document.writeln('<a href="/customer-service/order-shipping-assistance.aspx" title="Warehouse Closed for Inventory"><img src="/images/retail/random/'+ad[n]+'" width="226" height="85" title="Warehouse Closed for Inventory" alt="Warehouse Closed for Inventory" /></a>');
	}
}

function popAd()
{
	if (!popAdWin || popAdWin.closed){
		var strUrl = "/contact-us/email-newsletter-sign-up.aspx";
		var popAdWin = window.open(strUrl, "NewsletterSignup", "width=450,height=680,status=0,menubar=0,location=0,resizable=1,left=150,top=150,toolbar=0,scrollbars=0");
	}
		popAdWin.focus()
		return false;
}
// /Image rotator =================================

// Right-side Includes rotator =======================
function rsRotator(depth,loc)
	{
	if(loc == "account")
		{
		var rs = new Array();
			rs[0] = "rs1_account.js";
		}
	else if (loc == "signinup")
		{
		var rs = new Array();
			rs[0] = "rs1_signinup.js"; 
		}
	else if (loc == "search")
		{
		var rs = new Array();
			rs[0] = "rs1_search.js"; 
		}
	else if (loc == "prodlocator")
		{
		var rs = new Array();
			rs[0] = "rs1_prodlocator.js";
		}
	else if (loc == "help_home")
		{
		var rs = new Array();
			rs[0] = "rs1_help_home.js";
		}
	else if (loc == "help")
		{
		var rs = new Array();
			rs[0] = "rs1_help.js";
		}
	else if (loc == "sections")
		{
		var rs = new Array();
			rs[0] = "rs1_sections.js";
		}
	else if (loc == "sectionsb")
		{
		var rs = new Array();
			rs[0] = "rs1_sectionsb.js";
		}
	else if (loc == "pop")
		{
		var rs = new Array();
			rs[0] = "rs1_pop.js";
		}
	else if (loc == "advice")
		{
		var rs = new Array();
			rs[0] = "rs1_advice.js";
		}
	else if (loc == "cust_serv")
		{
		var rs = new Array();
			rs[0] = "rs1_cust_serv.js";
		}
	else if (loc == "faq")
		{
		var rs = new Array();
			rs[0] = "rs1_faq.js";
		}
	else if (loc == "contact")
		{
		var rs = new Array();
			rs[0] = "rs1_contact.js";
		}
	else if (loc == "affiliates")
		{
		var rs = new Array();
			rs[0] = "rs1_affiliates.js";
		}
		
	var n = Math.floor(Math.random() * rs.length);
	document.writeln('<script src="'+depth+"retail_content/"+rs[n]+'"></script>');
	}
// /Right-side Includes rotator =======================


// pop tabs ======================================
function poptabs(depth, loc)
	{
document.writeln('<TABLE border="0" cellspacing="0" cellpadding="0" width="100%" class="bg2">');
document.writeln('<TR>');
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="1" HEIGHT="2" BORDER="0" ALT=""></TD>');
document.writeln('</TR>');
document.writeln('<TR>');
document.writeln('<TD align="center">');
document.writeln('<TABLE border="0" cellspacing="0" cellpadding="0">');
document.writeln('<TR>');
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "departments") {document.writeln('<TD><A javascript:searchTab(\'1\', \'departments\')"><IMG name="tab_pop_depart" SRC="'+depth+'images/retail/tab_pop_depart_roll.gif" WIDTH="67" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:searchTab(\'1\', \'departments\')" onMouseOver="changeImage(\'tab_pop_depart\',\'tab_pop_depart_roll\')" onMouseOut="changeImage(\'tab_pop_depart\',\'tab_pop_depart\')"><IMG name="tab_pop_depart" SRC="'+depth+'images/retail/tab_pop_depart.gif" WIDTH="67" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "craft") {document.writeln('<TD><A HREF="javascript:searchTab(\'2\', \'craft\')"><IMG name="tab_pop_craft" SRC="'+depth+'images/retail/tab_pop_craft_roll.gif" WIDTH="60" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:searchTab(\'2\', \'craft\')" onMouseOver="changeImage(\'tab_pop_craft\',\'tab_pop_craft_roll\')" onMouseOut="changeImage(\'tab_pop_craft\',\'tab_pop_craft\')"><IMG name="tab_pop_craft" SRC="'+depth+'images/retail/tab_pop_craft.gif" WIDTH="60" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "item") {document.writeln('<TD><A HREF="javascript:searchTab(\'8\', \'item\')"><IMG name="tab_pop_item" SRC="'+depth+'images/retail/tab_pop_item_roll.gif" WIDTH="55" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:searchTab(\'8\', \'item\')" onMouseOver="changeImage(\'tab_pop_item\',\'tab_pop_item_roll\')" onMouseOut="changeImage(\'tab_pop_item\',\'tab_pop_item\')"><IMG name="tab_pop_item" SRC="'+depth+'images/retail/tab_pop_item.gif" WIDTH="55" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "brands") {document.writeln('<TD><A HREF="javascript:searchTab(\'3\', \'brands\')"><IMG name="tab_pop_brands" SRC="'+depth+'images/retail/tab_pop_brands_roll.gif" WIDTH="43" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:javascript:searchTab(\'3\', \'brands\')" onMouseOver="changeImage(\'tab_pop_brands\',\'tab_pop_brands_roll\')" onMouseOut="changeImage(\'tab_pop_brands\',\'tab_pop_brands\')"><IMG name="tab_pop_brands" SRC="'+depth+'images/retail/tab_pop_brands.gif" WIDTH="43" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "holidays") {document.writeln('<TD><A HREF="javascript:searchTab(\'6\', \'holidays\')"><IMG name="tab_pop_holiday" SRC="'+depth+'images/retail/tab_pop_holiday_roll.gif" WIDTH="91" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:javascript:searchTab(\'6\', \'holidays\')" onMouseOver="changeImage(\'tab_pop_holiday\',\'tab_pop_holiday_roll\')" onMouseOut="changeImage(\'tab_pop_holiday\',\'tab_pop_holiday\')"><IMG name="tab_pop_holiday" SRC="'+depth+'images/retail/tab_pop_holiday.gif" WIDTH="91" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');

if(loc == "themes") {document.writeln('<TD><A HREF="javascript:javascript:searchTab(\'7\', \'themes\')"><IMG name="tab_pop_occ" SRC="'+depth+'images/retail/tab_pop_occ_roll.gif" WIDTH="96" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
else {document.writeln('<TD><A HREF="javascript:javascript:searchTab(\'7\', \'themes\')" onMouseOver="changeImage(\'tab_pop_occ\',\'tab_pop_occ_roll\')" onMouseOut="changeImage(\'tab_pop_occ\',\'tab_pop_occ\')"><IMG name="tab_pop_occ" SRC="'+depth+'images/retail/tab_pop_occ.gif" WIDTH="96" HEIGHT="16" BORDER="0" ALT=""></A></TD>');}
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="7" HEIGHT="1" BORDER="0" ALT=""></TD>');
document.writeln('</TR>');
document.writeln('</TABLE>');
document.writeln('</TD>');
document.writeln('</TR>');
document.writeln('<TR>');
document.writeln('<TD><IMG SRC="'+depth+'images/retail/shim.gif" WIDTH="1" HEIGHT="2" BORDER="0" ALT=""></TD>');
document.writeln('</TR>');
document.writeln('</TABLE>');
	}
// /pop tabs ======================================





// various functions ================================

function fillYear(formName, selectName)
	{
	// get the current year
	if (window.navigator.appVersion.substring(0,1) >= "4")
		{
		var year = new Date();
		var year = year.getFullYear();
		}
	else
		{
		var year = new Date();
		var year = year.getYear();
		}
	
	// fill select list
	var SL = eval("document."+formName+"."+selectName);
	SL.options.length = 1;
	var n = 0
	while(n < 8)
		{
		SL.options[SL.options.length] = new Option(year,year);
		n++;
		year++;
		}
	}

function copyFields(formName)
	{
	var F = eval("document."+formName);	
	F.txtShippingFirstName.value = F.txtBillingFirstName.value;
	F.txtShippingInitial.value = F.txtBillingInitial.value;
	F.txtShippingLastName.value = F.txtBillingLastName.value;
	F.txtShippingCompanyName.value = F.txtBillingCompanyName.value;
	F.txtShippingAddress1.value = F.txtBillingAddress1.value;
	F.txtShippingAddress2.value = F.txtBillingAddress2.value;
	F.txtShippingCity.value = F.txtBillingCity.value;
	F.lstShippingState.selectedIndex = F.lstBillingState.selectedIndex;
	F.txtShippingCountry.value = F.txtBillingCountry.value;
	F.txtShippingZip.value = F.txtBillingZip.value;
	F.txtShippingPhone.value = F.txtBillingPhone.value;
	}
// /various functions ================================	

//Search Functions ==================================
function topSearch(){
	window.location.href = "/search/results.aspx?txtSearch=" + encodeURIComponent(document.topSearchForm.txtSearch.value);
	//window.location.href = "/'" + encodeURIComponent(document.topSearchForm.txtSearch.value) + "'-srch-/results.aspx";
	return false;
}
	
	
//This function cancels the submission and instead calls a function
function checkSearch(functionCall){
	eval(functionCall)
	return false;
}
	
//Browse Search
	function popBrowse(){
		if (!popBrowseWin || popBrowseWin.closed){
			var strUrl = "/search/popBrowse.asp?pType=craft+supplies";
			var popBrowseWin = window.open(strUrl, "Browse", "top=30,left=30,width=580,height=380,resizable=yes,scrollbars");
		}
		popBrowseWin.focus()
		return false;
	}
		
//End Search Functions