$(document).ready(function(){
  	//click on the selected item div to toggle menu
  	$('.selectedCategoryDiv').click(function(e)
  	{
  		$(this).siblings('.selectOptions').slideToggle('fast');
		e.stopPropagation();
		return false;
  	});
  	
  	//click on the down arrow to toggle menu
	$('.selectDropDownArrow').click(function(e){
		$(this).parent('.selectRight').siblings('.selectLeft').children('.selectOptions').slideToggle('fast');
		e.stopPropagation();
		return false;
	});
	
	//hover on menu item to change color
	$('.selectOptions').children('div').hover(
		function(){
			$(this).addClass('hoverItem');
		},
		function(){
			$(this).removeClass('hoverItem');
		}
	);
	
	//click on menu item to select
	$('.selectOptions').children('div').click(function(e){
		$(this).parent('.selectOptions').siblings('.selectInput').val($(this).attr('value')).trigger('change');
		$(this).parent('.selectOptions').slideUp('fast');
		$(this).parent('.selectOptions').siblings('.selectedCategoryDiv').html($(this).html());
		e.stopPropagation();
		return false;
	});
});
function setSelectedOption(id,ignore)
{
	if(id != '')
	{
		$('.selectOptions').each(function(){
			$(this).children('div').each(function(){
				if($(this).attr('value') == id)
					$(this).click();
				});
		});
	}
}
