var arrAges = new Array();
var arrPrices = new Array();
var arrCats = new Array();

arrAges['All Ages'] = "on";
arrPrices['All Prices'] = "on";
arrCats['All Categories'] = "on";

function changeAgeSearchCriteria(key)
{
	if(key == "All Ages")
	{
		if(arrAges[key] == "on")
		{
			arrAges[key] = "";
			document.presentfinderform.allage.checked = false;
		}
		else
		{
			for (var i in arrAges)
			{
				arrAges[i] = "";
			}
			document.presentfinderform.age[0].checked = false;
			document.presentfinderform.age[1].checked = false;
			document.presentfinderform.age[2].checked = false;
			document.presentfinderform.age[3].checked = false;
			document.presentfinderform.allage.checked = true;
			arrAges[key] = "on";
		}
	}
	else
	{
		arrAges['All Ages'] = "";
		document.presentfinderform.allage.checked = false;
		if(arrAges[key] == "on")
		{
			arrAges[key] = "";
		}
		else
		{
			arrAges[key] = "on";
		}
	}
}

function changePriceSearchCriteria(key)
{
	if(key == "All Prices")
	{
		if(arrPrices[key] == "on")
		{
			arrPrices[key] = "";
			document.presentfinderform.allprice.checked = false;
		}
		else
		{
			for (var i in arrPrices)
			{
				arrPrices[i] = "";
			}
			document.presentfinderform.price[0].checked = false;
			document.presentfinderform.price[1].checked = false;
			document.presentfinderform.price[2].checked = false;
			document.presentfinderform.price[3].checked = false;
			document.presentfinderform.price[4].checked = false;
			document.presentfinderform.price[5].checked = false;
			document.presentfinderform.allprice.checked = true;
			arrPrices[key] = "on";
		}
	}
	else
	{
		arrPrices['All Prices'] = "";
		document.presentfinderform.allprice.checked = false;
		if(arrPrices[key] == "on")
		{
			arrPrices[key] = "";
		}
		else
		{
			arrPrices[key] = "on";
		}
	}
}

function changeCatSearchCriteria(key)
{
	if(key == "All Categories")
	{
		if(arrCats[key] == "on")
		{
			arrCats[key] = "";
			document.presentfinderform.allcat.checked = false;
		}
		else
		{
			for (var i in arrCats)
			{
				arrCats[i] = "";
			}
			document.presentfinderform.cat[0].checked = false;
			document.presentfinderform.cat[1].checked = false;
			document.presentfinderform.cat[2].checked = false;
			document.presentfinderform.cat[3].checked = false;
			document.presentfinderform.cat[4].checked = false;
			document.presentfinderform.cat[5].checked = false;
			document.presentfinderform.cat[6].checked = false;
			document.presentfinderform.cat[7].checked = false;
			document.presentfinderform.cat[8].checked = false;
			document.presentfinderform.cat[9].checked = false;
			document.presentfinderform.allcat.checked = true;
			arrCats[key] = "on";
		}
	}
	else
	{
		arrCats['All Categories'] = "";
		document.presentfinderform.allcat.checked = false;
		if(arrCats[key] == "on")
		{
			arrCats[key] = "";
		}
		else
		{
			arrCats[key] = "on";
		}
	}
}

function buildQuery()
{
	document.presentfinderform.scAge.value = "";
	document.presentfinderform.scPrice.value = "";
	document.presentfinderform.scCat.value = "";
	for (var i in arrAges)
	{
		if(arrAges[i] == "on")
		{
			document.presentfinderform.scAge.value = document.presentfinderform.scAge.value + "<span class=bodycopysmallblue>" + i + "</span>, ";
		}
	}
	document.presentfinderform.scAge.value = document.presentfinderform.scAge.value.substring(0, (document.presentfinderform.scAge.value.length - 2))
	for (var i in arrPrices)
	{
		if(arrPrices[i] == "on")
		{
			document.presentfinderform.scPrice.value = document.presentfinderform.scPrice.value + "<span class=bodycopysmallblue>" + i + "</span>, ";
		}
	}
	document.presentfinderform.scPrice.value = document.presentfinderform.scPrice.value.substring(0, (document.presentfinderform.scPrice.value.length - 2))
	for (var i in arrCats)
	{
		if(arrCats[i] == "on")
		{
			document.presentfinderform.scCat.value = document.presentfinderform.scCat.value + "<span class=bodycopysmallblue>" + i + "</span>, ";
		}
	}
	document.presentfinderform.scCat.value = document.presentfinderform.scCat.value.substring(0, (document.presentfinderform.scCat.value.length - 2))

	if(!document.presentfinderform.age[0].checked && !document.presentfinderform.age[1].checked && !document.presentfinderform.age[2].checked && !document.presentfinderform.age[3].checked && !document.presentfinderform.allage.checked)
	{
		alert("Please select an age range");
		return;
	}
	if(!document.presentfinderform.price[0].checked && !document.presentfinderform.price[1].checked && !document.presentfinderform.price[2].checked && !document.presentfinderform.price[3].checked && !document.presentfinderform.price[4].checked && !document.presentfinderform.price[5].checked && !document.presentfinderform.allprice.checked)
	{
		alert("Please select a price range");
		return;
	}
	if(!document.presentfinderform.cat[0].checked && !document.presentfinderform.cat[1].checked && !document.presentfinderform.cat[2].checked && !document.presentfinderform.cat[3].checked && !document.presentfinderform.cat[4].checked && !document.presentfinderform.cat[5].checked && !document.presentfinderform.cat[6].checked && !document.presentfinderform.cat[7].checked && !document.presentfinderform.cat[8].checked && !document.presentfinderform.cat[9].checked && !document.presentfinderform.allcat.checked)
	{
		alert("Please select at least 1 category");
		return;
	}
	document.presentfinderform.submit();
}

/*
This code is from Dynamic Web Coding
at http://www.dyn-web.com/
Copyright 2001-2 by Sharon Paine
See Terms of Use at http://www.dyn-web.com/bus/terms.html
Permission granted to use this code
as long as this entire notice is included.
*/


// dw_tooltip.js contains onresize and onload handlers
// Put tooltip div and script tags for external js files at end of document

// avoid error of passing event object from link in older browsers
if (!document.getElementById && !document.all && !document.layers)
	event = "";

function hideTip() {} // avoid errors until loaded

var tooltip;
function doTooltip(evt,txt) {
	if (!tooltip) return;
	var cntnt = wrapTip(txt);
	goTooltip(evt,cntnt);
}

// wrap tip content for formatting
function wrapTip(txt) {
	var cntnt = "";
	if (document.layers) {
		cntnt = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + tipBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td><div style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + txt  + '</div></td></tr></table></td></tr></table>';
	} else cntnt = txt;
	return cntnt;
}

///////////////////////  CUSTOMIZE TOOLTIP HERE   ///////////////////////
// settings for tooltip (don't remove any of these variables!)

// Do you want tooltip to move when mouse moves over link?
var tipFollowMouse = true;
// be sure to set tooltip width wide enough for widest image!
// take into account border and padding
var tipWidth = 240;	// width of tooltip in pixels

// how far from mouse to show tooltip
var tipOffX	= 8;	// horizontal offset
var tipOffY	= 12; // vertical offset

var tipFontFamily = "Verdana, arial, helvetica, sans-serif";
var tipFontSize	= "11px";	// string with pixels or points (px or pt)
// tooltip content line-height
var tipLineHeight	= 1.2;	// number	(recommend 1 to 1.3)
var tipFontColor = "#26709D";
var tipBgColor = "#D4E2EB";	// tooltip background color
// background image for tooltip (leave empty string if no bg image)
var tipBgImg = "";
// "breathing room" around tooltip content
var tipPadding = 4;	// integer (pixel value)

// leave a color in here even if you don't want a border
var tipBorderColor = "#000080";

// if you don't want a border, set tipBorderWidth to 0
var tipBorderWidth = 1; // integer (pixel value)

// if you don't want a border, set tipBorderStyle to "none"
// options for border style: "none", "solid", "ridge", "outset",
// "inset", "groove", "double", "dashed"
// (they won't look the same in all browsers though!)
var tipBorderStyle = "groove";

// NOTES:
// Adding a large amount of padding and thick borders will
// result in a noticeable difference in the tooltip width
// between browsers that are standards-compliant and those
// that are not. For best results, keep these values small.
// Background image, line-height and border style settings
// for the tooltip are not supported for ns4.


// preload images to be placed in tooltip
// place your images in this array
var imgAr = new Array(
	"images/sm-duck.gif"
);

if (document.images) {
	var imgs = new Array();
	for (var i=0; i<imgAr.length; i++) {
  	imgs[i] = new Image();
		imgs[i].src = imgAr[i];
  }
}

// variables for tooltip content
// name them whatever you want, add as many as you need
var tip1 = "<b>Infants</b>: At this age, baby's developing senses and motor skills are the basis for play.  Baby wants to touch, mouth, and feast her eyes on everything.  The best toys incorporate cause and effect, bold patterns, interesting textures, gentle sounds, and supple chewing surfaces.";
var tip2 = "<b>Toddlers</b>: Endless repetition of newly learned skills - like shape sorters and stacking toys - is fascinating to toddlers. Manipulative toys with lots of buttons to turn and push, delight a child (especially when they incorporate cause and effect surprises) at the same time as they help develop coordination and strengthen hand and finger muscles.  Active toys such as ride-ons and push-alongs, compliment a toddler's new-found mobility.";
var tip3 = "<b>Preschool</b>: Use make-believe to explore the world around them, both real and imaginary, and to help give expression to things they cannot yet articulate with words.  Props, such as figures and dress-up accessories, enhance their imaginative play. The best toys encourage early social encounters as kids begin to play together, rather than side by side.";
var tip4 = "<b>School-Age</b>: Once they enter school, children meet new friends and begin to enjoy more socially-based play. Toys and games with more structured rules compliment developing social relationships. Toys that encourage physical activity help develop physical competence, and balance the quiet hours spent at school.";
var tip5 = "<b>Preteens</b>: At this age children have distinct preferences. The number one tween obsession - especially for boys - is electronics: computer and video games.  But there are still activities that can drag them away from the screen. Activity-related toys, such as board games, puzzles, construction sets and craft kits continue to be popular. Preteens begin spending more leisure time with sports and hobbies, interests that may well continue into adult hood. The best toys reflect teen interests: craft kits to make jewellery and personal care products, toys that incorporate pop culture, electronic gadgets, as well as journals and clever (cool) new ways to communicate with friends.";
