	$(document).ready(function() {		// array of types with frosting		// the words used to indicate types with frosting must be a 		// unique identifying string from the cupcake type		// these values are linked to those in the order processor		var hasFrosting = ['child','boys'];		// on page load, hide frosting colour select if not applicable		$('select[@name^=type]').each(function(){			var selected = $(this).attr('name');			var selectedVal = $(this).val().toLowerCase();			var frostingOpts = 'select[@name=frostingcolour-'+selected+']';			var showFlag = 0;			// look for any of valid types that need frosting			for( var cupcake in hasFrosting ) {				if (selectedVal.indexOf(hasFrosting[cupcake]) != -1) {					showFlag = 1;				}			} 			// if none were found, hide the frosting options			if (showFlag == 0) {					$(frostingOpts).hide();						}					});		// add behaviour to cupcake selectors		// to show frosting options when relevant values are chosen		$('select[@name^=type]').change(function(){			var currentSelection = $(this).attr('name');			var currentSelectionValue = $(this).val().toLowerCase();			var frostingSelector = 'select[@name=frostingcolour-'+currentSelection+']';						var showFlag = 0;			var show;			// loop through types with frosting to check whether to show options or not			for( var cupcake in hasFrosting ) {				if(currentSelectionValue.indexOf(hasFrosting[cupcake]) != -1) {					showFlag = 1;					show = hasFrosting[cupcake];				}			}			if(showFlag == 1) {				$(frostingSelector).show();				$(frostingSelector+' option').hide(); // hide all options				$(frostingSelector+' option.'+show).show(); // show ones with relevant class				$(frostingSelector+' option.label').show().attr('selected', true); // show frosting label as top selection				$(frostingSelector+' option.label').show().attr('disabled', true); // disabel label value from being selected			} else {				$(frostingSelector).hide();			}		});	});		// date picker with disabled days	$(function() {	$('.date-pick')		.datePicker(			{				createButton:false,				renderCallback:function($td, thisDate, month, year)				{					if (thisDate.getDayName() !='Friday' && thisDate.getDayName() !='Saturday') {						$td.addClass('weekend');						$td.addClass('disabled');					}					else {						$td.removeClass('weekend');					}				}			}		)		.bind('click',			function(thisDate)			{				$(this).dpDisplay();				this.blur();				return false;			}		)	});