function addNewPropertiesSelect(properties) {
	// check if the previous filter is already setup accordingly
	var show = false; 
	if ($('.propertyfilter:last')[0]) {
		var selects = $('.propertyfilter:last select');
		if(selects.length > 1 && $(selects[1]).val() !== "") {
			show = true;
		} else {
			$('.propertyfilter:last').effect("shake", {distance:10, times:3, direction: 'up'}, 80);
		}
	} else {
		show = true;
	}

	// if previous filter is ready, then show
	if (show) {
		// create new div
		var div = $('<div class="propertyfilter"></div>').appendTo('#filter');

		// append delete button and install delete handler
		var deletediv = $('<div class="delete"><a class="red_button" href="#">x</a></div>').appendTo($(div));
		$(deletediv).click(function() {
			startSpinner();
			var property = $(this).siblings('select:first').val();
			$.ajax({
				type:     'DELETE',
				url:      '/c3po/filter?property=' + property,
				timeout:  5000,
				success:  function(oData) {
					stopSpinner();
					window.location.reload();
				}
			});
			$(this).parent().remove();

		});

		// for each property add an option in the html select
		var sel = $('<select>').appendTo($(div));
		$(sel).append($('<option>').text("").attr('value',''));
		$.each(properties, function(i, value) {
			$(sel).append($('<option>').text(value).attr('value', value));
		});

		// if the select is clicked then get the values for the current
		// option.
		$(sel).change(function() {
			var property = $(this).val();
			if (property) {
				var old = $(this).parent().attr('oldValue');
				$(this).parent().attr('oldValue', property);
				$.ajax ({
					type:     'DELETE',
					async:    false,
					url:      '/c3po/filter?property='+old,
					timeout:  5000
				});

				var collection = "";
				$.ajax ({
					type:     'GET',
					async:    false,
					url:      '/c3po/settings?key=current.collection',
					timeout:  5000,
					success: function (oData) {
						collection = oData;
					}
				});

				var url = '/c3po/filter/values?filter='+property+'&collection=' + collection;

				$.ajax ({
					type:     'GET',
					async:    false,
					url:      '/c3po/property?name=' + property,
					timeout:  5000,
					success: function (oData) {
						if (oData.type == 'INTEGER') {
							showIntegerPropertyDialog('getValuesForProperty("' + url + '")');

						} else { 
							showOtherProperty(url, div);
						}	    
					}
				});


			} else {
				$(sel).effect("highlight", {color:'#FF1400'} , "slow");
				if ($(div).children('select').length > 1) {
					($(div).children('select:last')).remove();
				}
			}
		});
	}
}
//adds a new select with all properties for the next filter selection
adds a new select with all properties for the next filter selection
adds a new select with all properties for the next filter selection
function addNewPropertiesSelect(properties) {
	var show = false; 
	if ($('.propertyfilter:last')[0]) {
		var selects = $('.propertyfilter:last select');
		if(selects.length > 1 && $(selects[1]).val() !== "") {
			show = true;
		} else {
			$('.propertyfilter:last').effect("shake", {distance:10, times:3, direction: 'up'}, 80);
		}
	} else {
		show = true;
	}
	if (show) {
		var div = $('<div class="propertyfilter"></div>').appendTo('#filter');
		var deletediv = $('<div class="delete"><a class="red_button" href="#">x</a></div>').appendTo($(div));
		$(deletediv).click(function() {
			startSpinner();
			var property = $(this).siblings('select:first').val();
			$.ajax({
				type:     'DELETE',
				url:      '/c3po/filter?property=' + property,
				timeout:  5000,
				success:  function(oData) {
					stopSpinner();
					window.location.reload();
				}
			});
			$(this).parent().remove();
		});
		var sel = $('<select>').appendTo($(div));
		$(sel).append($('<option>').text("").attr('value',''));
		$.each(properties, function(i, value) {
			$(sel).append($('<option>').text(value).attr('value', value));
		});
		$(sel).change(function() {
			var property = $(this).val();
			if (property) {
				var old = $(this).parent().attr('oldValue');
				$(this).parent().attr('oldValue', property);
				$.ajax ({
					type:     'DELETE',
					async:    false,
					url:      '/c3po/filter?property='+old,
					timeout:  5000
				});
				var collection = "";
				$.ajax ({
					type:     'GET',
					async:    false,
					url:      '/c3po/settings?key=current.collection',
					timeout:  5000,
					success: function (oData) {
						collection = oData;
					}
				});
				var url = '/c3po/filter/values?filter='+property+'&collection=' + collection;
				$.ajax ({
					type:     'GET',
					async:    false,
					url:      '/c3po/property?name=' + property,
					timeout:  5000,
					success: function (oData) {
						if (oData.type == 'INTEGER') {
							showIntegerPropertyDialog('getValuesForProperty("' + url + '")');
						} else { 
							showOtherProperty(url, div);
						}	    
					}
				});
			} else {
				$(sel).effect("highlight", {color:'#FF1400'} , "slow");
				if ($(div).children('select').length > 1) {
					($(div).children('select:last')).remove();
				}
			}
		});
	}
}
function addNewPropertiesSelect ( properties ) { var show = false ; if ( $ ( '.propertyfilter:last' ) [ 0 ] ) { var selects = $ ( '.propertyfilter:last select' ) ; if ( selects . length > 1 && $ ( selects [ 1 ] ) . val ( ) !== "" ) { show = true ; } else { $ ( '.propertyfilter:last' ) . effect ( "shake" , { distance : 10 , times : 3 , direction : 'up' } , 80 ) ; } } else { show = true ; } if ( show ) { var div = $ ( '<div class="propertyfilter"></div>' ) . appendTo ( '#filter' ) ; var deletediv = $ ( '<div class="delete"><a class="red_button" href="#">x</a></div>' ) . appendTo ( $ ( div ) ) ; $ ( deletediv ) . click ( function ( ) { startSpinner ( ) ; var property = $ ( this ) . siblings ( 'select:first' ) . val ( ) ; $ . ajax ( { type : 'DELETE' , url : '/c3po/filter?property=' + property , timeout : 5000 , success : function ( oData ) { stopSpinner ( ) ; window . location . reload ( ) ; } } ) ; $ ( this ) . parent ( ) . remove ( ) ; } ) ; var sel = $ ( '<select>' ) . appendTo ( $ ( div ) ) ; $ ( sel ) . append ( $ ( '<option>' ) . text ( "" ) . attr ( 'value' , '' ) ) ; $ . each ( properties , function ( i , value ) { $ ( sel ) . append ( $ ( '<option>' ) . text ( value ) . attr ( 'value' , value ) ) ; } ) ; $ ( sel ) . change ( function ( ) { var property = $ ( this ) . val ( ) ; if ( property ) { var old = $ ( this ) . parent ( ) . attr ( 'oldValue' ) ; $ ( this ) . parent ( ) . attr ( 'oldValue' , property ) ; $ . ajax ( { type : 'DELETE' , async : false , url : '/c3po/filter?property=' + old , timeout : 5000 } ) ; var collection = "" ; $ . ajax ( { type : 'GET' , async : false , url : '/c3po/settings?key=current.collection' , timeout : 5000 , success : function ( oData ) { collection = oData ; } } ) ; var url = '/c3po/filter/values?filter=' + property + '&collection=' + collection ; $ . ajax ( { type : 'GET' , async : false , url : '/c3po/property?name=' + property , timeout : 5000 , success : function ( oData ) { if ( oData . type == 'INTEGER' ) { showIntegerPropertyDialog ( 'getValuesForProperty("' + url + '")' ) ; } else { showOtherProperty ( url , div ) ; } } } ) ; } else { $ ( sel ) . effect ( "highlight" , { color : '#FF1400' } , "slow" ) ; if ( $ ( div ) . children ( 'select' ) . length > 1 ) { ( $ ( div ) . children ( 'select:last' ) ) . remove ( ) ; } } } ) ; } }
adds a new select with all properties for the next filter selection
adds a new select with all properties for the next filter selection
// check if the previous filter is already setup accordingly // if previous filter is ready, then show // create new div // append delete button and install delete handler // for each property add an option in the html select // if the select is clicked then get the values for the current // option.