﻿jQuery.fn.dnkl_option = function(optionSettings) {
	/*
	PLUGIN:	dnkl_option([visible, value, text])
	DESC:	hide/show option in select list
	URL:         dnkl.se
	USAGE:	$('#mySelectID').dnkl_option({ visible: false, value: '1' });
	*/
	var settings = $.extend({ visible: false, value: '', text: '' }, optionSettings || {});
	if (settings.value == '' && settings.text == '') {
		return $(this);
	}
	var os = $(this).data('options');
	if ($(os).length == 0) {
		$(this).data('options', $('#' + $(this).attr('id') + ' option'));
		os = $(this).data('options');
	}
	var o = null; var a = null; var b = null;
	for (var i = 0; o == null && i < $(os).length; i++) {
		if ($(os[i]).val() == settings.value || $(os[i]).text() == settings.text) {
			if (i - 1 >= 0) {
				a = os[i - 1];
			}
			else if (i + 1 < $(os).length) {
				b = os[i + 1];
			}
			o = os[i];
		}
	}
	if (settings.visible) {
		if ($($('#' + $(this).attr('id') + ' option[value=' + $(o).val() + ']')).length == 0) {
			if (a !== null) {
				$(a).after(o);
			}
			else if (b !== null) {
				$(b).before(o);
			}
			else {
				$(this).append(o);
			}
		}
	}
	else {
		if ($(o).length > 0) {
			$(o).remove();
		}
	}
	return $(this);
}

//for hiding the unwanted ingredients

$(function(){
  var array_ingred=[2000,546,2004,2007,2008,2009,2010,2012,2013,2014,2015,2016,2019,2020,2021,2022,2023,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,
  ,2037,2038,2039,2040,2041,2042,2083,2044,2050,2051,2052,2053,2054,2057,2060,2061,2062,2063,2065,2150,2066,2068,2070,2103,2155,2072,2074,2076,20772078,
  2079,2080,2081,2082,2085,2088,2089,2092,2093,2094,2100];
  for(i=0;i<array_ingred.length;i++)
 $('#ddlIngredientListFull').dnkl_option({ visible: false, value:array_ingred[i] });
});



