function getID(strID)
{
	return strID.replace(/[^0-9]/gi, '');
}

$(document).ready( function()
{
	/****************************************** dynamic forms ************************************************/
	
	$('#dynamicformnojavascriptsubmit').hide();
	$('#dynamicformjavascriptsubmit').show();

	$('#dynamicform textarea').each( function() {
		if (' '==$(this).text())
			$(this).text('');
	}
	);
	
	/****************************************** product index ************************************************/
	
	$('#productcategories li a').each( function () {
		var top = ( $(this).height() - $('span', $(this)).height() ) / 2;
		$('span', $(this)).css('margin-top', top);
	});
	
	/****************************************** image gallery ************************************************/
	
	$('.imagegallery li a').lightBox();
	
	/****************************************** news nav ************************************************/

	if ($('#newsnav').length)
	{
		applySelectors($('#newsnav'));
	}
	/******************************************* Search input field*******************************************/
	var searchText = "Product Search";
	$('#quick-search form #query').val(searchText)
	.focus(function(){
		if($(this).val() == searchText){
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == ''){
			$(this).val(searchText);
		}
	});
	/******************************************* Search results **********************************************/
	$('.searchResult').each(function(){
		var ahtml = $('.thetext a.read-more',this);
		$(".thetext p:last",this).append(" ")
			.append(ahtml);
	});

}
);

function applySelectors(newsnav)
{
	$('ul.years li.open a.year', newsnav).livequery('click',function(){
	    var theparent = $(this).parent();
		theparent.addClass('closed');
		theparent.removeClass('open');
		$('ul.months',theparent).addClass('collapse');

		return false;
	});
	$('ul.years li.closed a.year', newsnav).livequery('click',function(){
		var theparent = $(this).parent();
		theparent.addClass('open');
		theparent.removeClass('closed');
		$('ul.months',theparent).removeClass('collapse');
		$('ul.months',theparent).removeClass('hide');

		return false;
	});

	$('ul.months li.open a.month', newsnav).livequery('click',function(){
		var theparent = $(this).parent();
		theparent.attr('class','closed');
		$('ul',theparent).addClass('collapse');

		return false;
	});

	$('ul.months li.closed a.month', newsnav).livequery('click',function(){
		var theparent = $(this).parent();
		theparent.attr('class','open');
		$('ul',theparent).removeClass('collapse');
		$('ul.articles',theparent).removeClass('hide');

		return false;
	});
}