

function selectOption(itemToSelect,formField)	{
	itemToSelect = itemToSelect.replace('%3A',':')
// Get a reference to the drop-down
	var myDropdownList = formField;

// Loop through all the items
	for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)	{    
		if (myDropdownList.options[iLoop].id == itemToSelect)	{
// Item is found. Set its selected property, and exit the loop
			myDropdownList.options[iLoop].selected = true;
			break;
			}
		}
	}


function toggle(ID)	{
	d = document.getElementById(ID);
	if(d.style.display == 'block')
		d.style.display='none';
	else
		d.style.display = 'block';
	
	}




function openWindow(url,w,h) {
	adviceWin = window.open(url,'advice','status=no,width='+w+',height='+h+',menubar=no,scrollbars=yes');
	adviceWin.focus(true);
	}


	

/* used on the 7 col cat layout */

//Larger thumbnail preview on mouseover.
//od = original dimensions
function handleCatThumbs(od)	{
	if(!od)	{
		od = '82px';
		}
	$("ul.thumb li").hover(function() {
		$(this).css({'z-index' : '10'});
		$(this).find('img').addClass("hover").stop()
			.animate({
				marginTop: '-40px', 
				marginLeft: '-40px', 
				top: '25%', 
				left: '25%', 
				width: '120px', 
				height: '120px',
				padding: '0px',
				border: '1px solid #ddd'
			}, 50);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: od, 
			height: od, 
			padding: '0px'
		}, 100);
	});

//Swap Image on Click
	$("ul.thumb li a").click(function() {});
 
	}

/* used to limit the number of bullet points/links in a list to 5 and create a more/less link as needed */

function handleCustomCatList()	{
	
	// Let's tame the facets that have tons of options
	$(".facet ul").each(function(){
	  
	  // If there are less than 5 list items, don't do anything
	  if($(this).children('li').size() <= 5) return;
	  
	  // Hide all list items after the 5th one
	  var listElements = $('li:gt(4)', this).hide();
	  
	  // If there are hidden elements:
	  if (listElements.size() > 0){
	  
		// Set the toggler link text to "... nn More Choices" where nn is equal to the number of hidden choices
		// var linkText = '- Show All ' + listElements.size() + ' Categories';
		// Set the toggler link text to "- Show All Categories"
		var linkText = 'View More ...';
	  
		// Insert the toggler link as the very first last element
		$(this).append(
	  
		  // Create the toggler list elemenet and make it toggle
		  $('<li><a class="showmore" href="#">' + linkText + '</a></li>')
	  
		  // Toggle the display list element text when the toggler is clicked.
			.toggle(
			  function() { 
				listElements.show();
				$("a", this).text('View Less ...');
			  }, 
			  function() { 
				listElements.hide();
				$("a", this).text(linkText);
			  }
			)
		);
	  }
	});
	
	}
	





/* used in homepage layout 20110109 */



/* default zoovy slideshow functions  (DYNIMAGE) */
function iList () {
	this.name = '';
	this.img = new Array();
	this.url = new Array();
	this.zum = new Array();
	this.pause = new Array();
	this.last = null;
	this.current = null;
	this.defaultpause = 2000;
	this.buttons = false;
	this.stopped = false;
	this.loaded = false;
	this.startstop = false;
	}
function iLoad (i) {
	if (i.loaded == true) { return; }
	i.loaded = true;
	iRotate(i);
	}
function iLink (i) {
	if (!i.loaded) { return; }
	if (typeof(i.url[i.current]) != "undefined") { window.location.href = i.url[i.current]; }
	else if (typeof(i.zum[i.current]) != "undefined") { zoom(i.zum[i.current]); }
	else if (i.startstop) { iSwitch(i); }
	}
function iSwitch (i) {
	if (!i.loaded) { return; }
	if (i.stopped) { i.stopped = false; iRotate(i); }
	else { i.stopped = true; }
	}
function iRotate (i) {
	if (i.stopped) { return; }
	iNext(i);
	var pause = i.defaultpause;
	if (typeof(i.pause[i.current]) != "undefined") { pause = i.pause[i.current]; }
	setTimeout("iRotate("+i.name+")",pause);
	}
function iNext (i) {
	if (!i.loaded||!document['image_'+i.name]) { return; }
	if (i.buttons) { document['form_'+i.name].nextButton.value = "Loading..."; }
	i.current++; if (i.current > i.last) { i.current = 0; }
	document['image_'+i.name].src = i.img[i.current].src;
	if (i.buttons) { document['form_'+i.name].nextButton.value = "Next Image"; }
	}
function iPrev (i) {
	if (!i.loaded||!document['image_'+i.name]) { return; }
	if (i.buttons) { document['form_'+i.name].prevButton.value = "Loading..."; }
	i.current--; if (i.current < 0) { i.current = i.last; }
	document['image_'+i.name].src = i.img[i.current].src;
	if (i.buttons) { document['form_'+i.name].prevButton.value = "Previous Image"; }
	}
function zoom (url) {
	z = window.open('','zoom_popUp','status=0,directories=0,toolbar=0,menubar=0,resizable=1,scrollbars=1,location=0');
	z.document.write("<html>\n<head>\n<title>Picture Zoom</title>\n</head>\n<body>\n<div align=\"center\">\n<img src=\"" + url + "\"><br>\n<form><input type=\"button\" value=\"Close Window\" onClick=\"self.close(true)\"></form>\n</div>\n</body>\n</html>\n");
	z.document.close();
	z.focus(true);
	}
