/*
Syntax:
rule : keyword ':' condition
keyword: <identifier>
505316
private static Rule parseRule(String description) throws ParseException {
        if (description.length() == 0) {
            return DEFAULT_RULE;
        }

        description = description.toLowerCase(Locale.ENGLISH);

        int x = description.indexOf(':');
        if (x == -1) {
            throw new ParseException("missing ':' in rule description '" +
                    description + "'", 0);
        }

        String keyword = description.substring(0, x).trim();
        if (!isValidKeyword(keyword)) {
            throw new ParseException("keyword '" + keyword +
                    " is not valid", 0);
        }

        description = description.substring(x+1).trim();
        String[] constraintOrSamples = AT_SEPARATED.split(description);
        boolean sampleFailure = false;
        FixedDecimalSamples integerSamples = null, decimalSamples = null;
        switch (constraintOrSamples.length) {
        case 1: break;
        case 2:
            integerSamples = FixedDecimalSamples.parse(constraintOrSamples[1]);
            if (integerSamples.sampleType == SampleType.DECIMAL) {
                decimalSamples = integerSamples;
                integerSamples = null;
            }
            break;
        case 3:
            integerSamples = FixedDecimalSamples.parse(constraintOrSamples[1]);
            decimalSamples = FixedDecimalSamples.parse(constraintOrSamples[2]);
            if (integerSamples.sampleType != SampleType.INTEGER || decimalSamples.sampleType != SampleType.DECIMAL) {
                throw new IllegalArgumentException("Must have @integer then @decimal in " + description);
            }
            break;
        default:
            throw new IllegalArgumentException("Too many samples in " + description);
        }
        if (sampleFailure) {
            throw new IllegalArgumentException("Ill-formed samples—'@' characters.");
        }

        // 'other' is special, and must have no rules; all other keywords must have rules.
        boolean isOther = keyword.equals("other");
        if (isOther != (constraintOrSamples[0].length() == 0)) {
            throw new IllegalArgumentException("The keyword 'other' must have no constraints, just samples.");
        }

        Constraint constraint;
        if (isOther) {
            constraint = NO_CONSTRAINT;
        } else {
            constraint = parseConstraint(constraintOrSamples[0]);
        }
        return new Rule(keyword, constraint, integerSamples, decimalSamples);
    }
337107
function _getRule(attribute, rules) {
    rules = rules || [];

    if ( ! rules[attribute]) {
      return;
    }

    for(var i in rules[attribute]) {
      var value = rules[attribute][i];
      parsedRule = _parseRule(rule);

      if (in_array(parsedRule.rule, rules))
        return [parsedRule.rule, parsedRule.parameters];
    }
  }
930565
function(ruleConfig) {
			var severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;

			if (typeof severity === "string") {
				severity = severity.toLowerCase();
			}
			return VALID_SEVERITIES.indexOf(severity) !== -1;
		}
1198787
def build_valid_keywords_grammar(keywords=None):
    """"""
    from invenio_query_parser.parser import KeywordQuery, KeywordRule, \
        NotKeywordValue, SimpleQuery, ValueQuery

    if keywords:
        KeywordRule.grammar = attr('value', re.compile(
            r"(\d\d\d\w{{0,3}}|{0})\b".format("|".join(keywords), re.I)))

        NotKeywordValue.grammar = attr('value', re.compile(
            r'\b(?!\d\d\d\w{{0,3}}|{0}:)\S+\b:'.format(
                ":|".join(keywords))))

        SimpleQuery.grammar = attr(
            'op', [NotKeywordValue, KeywordQuery, ValueQuery])
    else:
        KeywordRule.grammar = attr('value', re.compile(r"[\w\d]+(\.[\w\d]+)*"))
        SimpleQuery.grammar = attr('op', [KeywordQuery, ValueQuery])
1168660
function condition(file){
    var suffix = file.path.substr(file.base.length);
    var re = new RegExp(specialChars);
    var flag = service === "hosting" && re.test(suffix);
    var warning = "Warning: Cannot sync files with characters: " + specialChars + " in the file name: ";
    if (flag){
      var message = warning + suffix;
      console.log(message.red);
    }
    return flag;
  }
269914
function processValues(rules) {

		if (OPTIONS.verbose) { console.log(info('Process - Values')); }

		rulesCount = rules.length;

		for (i = 0; i < rulesCount; ++i) {


			if (rules[i] !== undefined && rules[i].declarations !== undefined  && rules[i].type == 'rule') {

				dCount = rules[i].declarations.length;

				//font
				if (OPTIONS.shorten_font || OPTIONS.shorten) {
					font = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'font-style' 
					  		|| obj.property == 'font-variant'
					  		|| obj.property == 'font-weight'
					  		|| obj.property == 'font-stretch'
					  		|| obj.property == 'font-size'
					  		|| obj.property == 'line-height'
					  		|| obj.property == 'font-family'
					  		|| obj.property == 'font'
					  ;
					});

					//font-weight shortening
					if ((fontIndex = font.map(function(o) { return o.property; }).indexOf('font-weight')) != -1) {
						
						switch(font[fontIndex].value.toLowerCase()) {
							case 'thin': 
							case 'hairline': fontTmp = '100';
								break;
							case 'extra light':
							case 'ultra light': fontTmp = '200';
								break;
							case 'light': fontTmp = '300';
								break;
							case 'normal': fontTmp = '400';
								break;
							case 'medium': fontTmp = '500';
								break;
							case 'semi bold':
							case 'demi bold': fontTmp = '600';
								break;
							case 'bold': fontTmp = '700';
								break;
							case 'extra bold':
							case 'ultra bold': fontTmp = '800';
								break;
							case 'black':
							case 'heavy': fontTmp = '900';
								break;
							default: fontTmp = font[fontIndex].value;
								break;
						}

						font[fontIndex] = {
							'type': font[fontIndex].type,
							'property': font[fontIndex].property,
							'value': fontTmp,
							'position': font[fontIndex].position
						};
					}

					//special - convert rem
					if (OPTIONS.special_convert_rem && OPTIONS.special_convert_rem_font_size) {

						//for singular declaration
						for (j = 0; j < dCount; ++j) {

							if (rules[i].declarations !== undefined && rules[i].declarations[j].property == 'font-size') {

								fontTmpVal = rules[i].declarations[j].value.toLowerCase();

								if (fontTmpVal.indexOf('px') != -1) {
									fontTmpVal = fontTmpVal.substr(0, fontTmpVal.length-2)/OPTIONS.special_convert_rem_desired_html_px + 'rem';
								}

								rules[i].declarations[j] = {
									'type': rules[i].declarations[j].type,
									'property': rules[i].declarations[j].property,
									'value': fontTmpVal,
									'position': rules[i].declarations[j].position
								};
							}
						}

						//for combined declaration
						if ((fontIndex = font.map(function(o) { return o.property; }).indexOf('font-size')) != -1) {
							
							fontTmpVal = font[fontIndex].value.toLowerCase();

							if (fontTmpVal.indexOf('px') != -1) {
								fontTmpVal = fontTmpVal.substr(0, fontTmpVal.length-2)/OPTIONS.special_convert_rem_desired_html_px + 'rem';
							}

							font[fontIndex] = {
								'type': font[fontIndex].type,
								'property': font[fontIndex].property,
								'value': fontTmpVal,
								'position': font[fontIndex].position
							};
						}
					}

					fontProps = font.map(function(o) { return o.property; });

					if (OPTIONS.format_font_family || OPTIONS.format) {

						//make sure multi-worded families have quotes
						if (fontProps.indexOf('font-family') != -1) {

							for (j = 0, jlen = rules[i].declarations.length; j < jlen; ++j) {

								if (rules[i].declarations[j].property == 'font-family') {

									fontVal = rules[i].declarations[j].value.split(',');
									fontTmpVal = '';
									for (k = 0, klen = fontVal.length; k < klen; ++k) {
										
										fontVal[k] = fontVal[k].trim();
										if (
											fontVal[k].indexOf(' ') != -1
											&& (
												fontVal[k].indexOf('"') == -1
											)
										) {
											fontTmpVal += '"' + fontVal[k].trim() + '",';
										} else {
											fontTmpVal += fontVal[k].trim() + ',';
										}
									}
									fontTmpVal = fontTmpVal.substring(0, fontTmpVal.length - 1);

									rules[i].declarations[j] = {
										'type': 'declaration',
										'property': 'font-family',
										'value': fontTmpVal,
										'position': rules[i].declarations[j].position
									};
								}
							}
						}
					}


					//reduce to font
					if (
						fontProps.indexOf('font-size') != -1 
						&& fontProps.indexOf('font-family') != -1
						|| fontProps.indexOf('font') != -1
					) {

						if (OPTIONS.verbose) { console.log(success('Process - Values - Font : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }

						fontHasInherit = false;
						fontValues = font.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								fontHasInherit = true;
							}
							return o.value; 
						});

						if (fontHasInherit == false) {
							fontPositions = font.map(function(o) { return o.position; });
							fontPropsOutput = ['font-style', 'font-variant', 'font-weight', 'font-stretch', 'font-size', 'line-height', 'font-family'];
							fontValuesOutput = [
								(fontValues[fontProps.indexOf('font-style')]?fontValues[fontProps.indexOf('font-style')]:''), 
								(fontValues[fontProps.indexOf('font-variant')]?fontValues[fontProps.indexOf('font-variant')]:''), 
								(fontValues[fontProps.indexOf('font-weight')]?fontValues[fontProps.indexOf('font-weight')]:''), 
								(fontValues[fontProps.indexOf('font-stretch')]?fontValues[fontProps.indexOf('font-stretch')]:''), 
								(fontValues[fontProps.indexOf('font-size')]?fontValues[fontProps.indexOf('font-size')]:''), 
								(fontValues[fontProps.indexOf('line-height')]?fontValues[fontProps.indexOf('line-height')]:''), 
								(fontValues[fontProps.indexOf('font-family')]?fontValues[fontProps.indexOf('font-family')]:''), 
							];

							//existing font check
							fontTmpIdx = fontProps.indexOf('font')
							if (fontTmpIdx != -1) {
								fontTmp = fontValues[fontTmpIdx];

								//fill missing attribute with existing font
								if (fontProps.indexOf('font-size') > fontTmpIdx) {
									fontValuesOutput[4] = fontValues[fontProps.indexOf('font-size')];
								} else {
									
									fontValuesOutput[4] = getValueOfFontProp(fontTmp, 'size', fontPositions[fontProps.indexOf('font')]);
									
									if (fontValuesOutput[4] == 'check family') {
										//check required font-family property exists
										if (
											fontValues[fontProps.indexOf('font-family')] !== '' 
											&& fontValues[fontProps.indexOf('font-family')] !== undefined) {
											fontValuesOutput[4] = fontTmp;
											fontTmp = fontTmp + ' ' + fontValues[fontProps.indexOf('font-family')];
										} else {
											//throw error
											console.log(error('Error Parsing Font Declaration'));
											console.log(error2('Source: ' + fontPositions[fontProps.indexOf('font')].source))
											console.log(error2('Line: ' + fontPositions[fontProps.indexOf('font')].start.line + ', column: ' + fontPositions[fontProps.indexOf('font')].start.column))
											console.log('Required: font-family');
											process.exit(1);
										}
									} else if (fontValuesOutput[4] == 'check size') {
										//check required font-size property exists
										if (
											fontValues[fontProps.indexOf('font-size')] !== ''
											&& fontValues[fontProps.indexOf('font-size')] !== undefined
										) {
											fontValuesOutput[4] = fontTmp;
											fontTmp = fontValues[fontProps.indexOf('font-size')] + ' ' + fontTmp;
										} else {
											if (fontTmp == 'inherit') {
												fontValuesOutput[4] = fontTmp;
											} else {
												//throw error
												console.log(error('Error Parsing Font Declaration'));
												console.log(error2('Source: ' + fontPositions[fontProps.indexOf('font')].source))
												console.log(error2('Line: ' + fontPositions[fontProps.indexOf('font')].start.line + ', column: ' + fontPositions[fontProps.indexOf('font')].start.column))
												console.log('Required: font-size');
												process.exit(1);	
											}
											
										}
										
									}
								}

								if (fontProps.indexOf('font-family') > fontTmpIdx) {
									fontValuesOutput[6] = fontValues[fontProps.indexOf('font-family')];
									
								} else {
									fontValuesOutput[6] = getValueOfFontProp(fontTmp, 'family', fontPositions[fontProps.indexOf('font')]);
									
									if (fontValuesOutput[6] == 'check size') {
										//check required font-size property exists
										if (
											fontValues[fontProps.indexOf('font-size')] !== ''
											&& fontValues[fontProps.indexOf('font-size')] !== undefined
										) {
											fontValuesOutput[6] = fontTmp;
											fontTmp = fontValues[fontProps.indexOf('font-size')] + ' ' + fontTmp;
										} else {

											if (fontTmp == 'inherit') {
												if (fontValuesOutput[4] == 'inherit') {
													fontValuesOutput[6] = '';	
												}
											} else {
												//throw error
												console.log(error('Error Parsing Font Declaration'));
												console.log(error2('Source: ' + fontPositions[fontProps.indexOf('font')].source))
												console.log(error2('Line: ' + fontPositions[fontProps.indexOf('font')].start.line + ', column: ' + fontPositions[fontProps.indexOf('font')].start.column))
												console.log('Required: font-size');
												process.exit(1);
											}
										}
										
									} else if (fontValuesOutput[6] == 'check family') {
										//check required font-family property exists
										if (
											fontValues[fontProps.indexOf('font-family')] !== '' 
											&& fontValues[fontProps.indexOf('font-family')] !== undefined) {
											fontValuesOutput[6] = fontTmp;
											fontTmp = fontTmp + ' ' + fontValues[fontProps.indexOf('font-family')];
										} else {
											//throw error
											console.log(error('Error Parsing Font Declaration'));
											console.log(error2('Source: ' + fontPositions[fontProps.indexOf('font')].source))
											console.log(error2('Line: ' + fontPositions[fontProps.indexOf('font')].start.line + ', column: ' + fontPositions[fontProps.indexOf('font')].start.column))
											console.log('Required: font-family');
											process.exit(1);
										}
									} else {
										//make sure multi-worded families have quotes
										if (OPTIONS.format_font_family || OPTIONS.format) {

											fontVal = fontValuesOutput[6];
											fontTmpVal = '';
											for (k = 0, klen = fontVal.length; k < klen; ++k) {
												
												fontVal[k] = fontVal[k].trim();
												if (
													fontVal[k].indexOf(' ') != -1
													&& (
														fontVal[k].indexOf('"') == -1
													)
												) {
													fontTmpVal += '"' + fontVal[k].trim() + '",';
												} else {
													fontTmpVal += fontVal[k].trim() + ',';
												}
											}
											fontTmpVal = fontTmpVal.substring(0, fontTmpVal.length - 1);
											fontValuesOutput[6] = fontTmpVal;

										} //end of format
									} //end of font-family checks
								} //end of font-family

								if (fontProps.indexOf('font-style') > fontTmpIdx) {
									fontValuesOutput[0] = fontValues[fontProps.indexOf('font-style')];
								} else {
									fontValuesOutput[0] = getValueOfFontProp(fontTmp, 'style', fontPositions[fontProps.indexOf('font')]);
									if (
										fontValuesOutput[0] == 'check size'
										|| fontValuesOutput[0] == 'check family'
									) {
										fontValuesOutput[0] = '';
									}
								}
								if (fontProps.indexOf('font-variant') > fontTmpIdx) {
									fontValuesOutput[1] = fontValues[fontProps.indexOf('font-variant')];
								} else {
									fontValuesOutput[1] = getValueOfFontProp(fontTmp, 'variant', fontPositions[fontProps.indexOf('font')]);

									if (
										fontValuesOutput[1] == 'check size'
										|| fontValuesOutput[1] == 'check family'
									) {
										fontValuesOutput[1] = '';
									}
								}
								if (fontProps.indexOf('font-weight') > fontTmpIdx) {
									fontValuesOutput[2] = fontValues[fontProps.indexOf('font-weight')];
								} else {
									fontValuesOutput[2] = getValueOfFontProp(fontTmp, 'weight', fontPositions[fontProps.indexOf('font')]);
									if (
										fontValuesOutput[2] == 'check size'
										|| fontValuesOutput[2] == 'check family'
									) {
										fontValuesOutput[2] = '';
									}
								}
								if (fontProps.indexOf('font-stretch') > fontTmpIdx) {
									fontValuesOutput[3] = fontValues[fontProps.indexOf('font-stretch')];
								} else {
									fontValuesOutput[3] = getValueOfFontProp(fontTmp, 'stretch', fontPositions[fontProps.indexOf('font')]);
									if (
										fontValuesOutput[3] == 'check size'
										|| fontValuesOutput[3] == 'check family'
									) {
										fontValuesOutput[3] = '';
									}
								}
								if (fontProps.indexOf('line-height') > fontTmpIdx) {
									fontValuesOutput[5] = fontValues[fontProps.indexOf('line-height')];
								} else {
									fontValuesOutput[5] = getValueOfFontProp(fontTmp, 'lineHeight', fontPositions[fontProps.indexOf('font')]);
									if (
										fontValuesOutput[5] == 'check size'
										|| fontValuesOutput[5] == 'check family'
									) {
										fontValuesOutput[5] = '';
									}
								}

							}
							// console.log(fontPropsOutput)
							// console.log(fontValuesOutput)


							if (
								fontValuesOutput[0] == ''
								&& fontValuesOutput[1] == ''
								&& fontValuesOutput[2] == ''
								&& fontValuesOutput[3] == ''
								&& fontValuesOutput[4] == ''
								&& fontValuesOutput[5] == ''
							) {

							} else {

								fontProps = fontPropsOutput;
								fontValues = fontValuesOutput;
							}
							// console.log(fontProps)
							// console.log(fontValues)

							//check for !important
							fontHasImportant = false;
							for (k = 0, klen = fontValues.length; k < klen; ++k) {
									
								fontValues[k] = fontValues[k].toString().replace(/(!important)/g, function(capture){
									fontHasImportant = true;
									return '';
								});
							}

							if (fontHasImportant) {
									fontValues[fontValues.length-1] += ' !important';
							}
							

							//merge line-height with font-size
							if (fontValues[fontProps.indexOf('line-height')] !== '') {
								fontValues[fontProps.indexOf('font-size')] = fontValues[fontProps.indexOf('font-size')] + '/' + fontValues[fontProps.indexOf('line-height')];
								fontValues.splice(fontProps.indexOf('line-height'), 1);
							}

							//remove any spaces from empty values
							fontValues = fontValues.filter(Boolean);

							//add declaration
							fontTmpIdx = rules[i].declarations.length;
							for (j = 0; j < fontTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'font-style': 
									case 'font-variant': 
									case 'font-weight': 
									case 'font-stretch': 
									case 'font-size': 
									case 'font-family': 
									case 'line-height': 
									case 'font': 
										fontIndex = j;
										if (fontIndex < fontTmpIdx && fontIndex != -1) { fontTmpIdx = fontIndex; }
										break;
								}
							}

							rules[i].declarations.splice(fontTmpIdx, 0, {
								type: 'declaration',
								property: 'font',
								value: fontValues.join(' ')
							});

							dCount+=1;
				    	summary.stats.summary.noFontsShortened += 1;

				    	//remove existing originals
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-style');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-variant');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-weight');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-stretch');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-size');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('line-height');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}
							fontIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('font-family');
							if (fontIndex != -1) { rules[i].declarations.splice(fontIndex, 1); dCount-=1;	}

							//remove existing fonts
							font = rules[i].declarations.filter(function( obj ) { return obj.property });
							fontProps = font.map(function(o) { return o.property; });
							noPreviousFonts = fontProps.filter(function(value){ return value === 'font'; }).length - 1;
							if (noPreviousFonts > 0) {
								for (j = 0; j < noPreviousFonts; ++j) {
									fontTmpIdx = fontProps.indexOf('font',(fontProps.indexOf('font')+1));
									rules[i].declarations.splice(fontTmpIdx, 1); 
									dCount-=1;	
								}
							}

						} //end of inherit check

					} 
				}
				//end of font






				//background
				if (OPTIONS.shorten_background || OPTIONS.shorten) {
					background = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'background-color' 
					  		|| obj.property == 'background-image'
					  		|| obj.property == 'background-repeat'
					  		|| obj.property == 'background-attachment'
					  		|| obj.property == 'background-position'
					  		// || obj.property == 'background-size'
					  		// || obj.property == 'background-origin'
					  		// || obj.property == 'background-clip'
					  		|| obj.property == 'background'
					  ;
					});
					backgroundProps = background.map(function(o) { return o.property; });

					if (
						backgroundProps.length >= OPTIONS.shorten_background_min
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Background : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }

						backgroundHasInherit = false;
						backgroundValues = background.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								backgroundHasInherit = true;
							}
							return o.value; 
						});

						if (backgroundHasInherit == false) {
							backgroundPropsOutput = ['background-color', 'background-image', 'background-repeat', 'background-attachment', 'background-position'];
							backgroundValuesOutput = [
								(backgroundValues[backgroundProps.indexOf('background-color')]?backgroundValues[backgroundProps.indexOf('background-color')]:''), 
								(backgroundValues[backgroundProps.indexOf('background-image')]?backgroundValues[backgroundProps.indexOf('background-image')]:''), 
								(backgroundValues[backgroundProps.indexOf('background-repeat')]?backgroundValues[backgroundProps.indexOf('background-repeat')]:''), 
								(backgroundValues[backgroundProps.indexOf('background-attachment')]?backgroundValues[backgroundProps.indexOf('background-attachment')]:''), 
								(backgroundValues[backgroundProps.indexOf('background-position')]?backgroundValues[backgroundProps.indexOf('background-position')]:''), 
							];
							hasMultipleBackgrounds = false;
							hasGradient = false;

							if (backgroundValues[0].match(/([^0-9]),([^0-9])/g) !== null) {
								hasMultipleBackgrounds = true;
							}

							// console.log(backgroundProps)
							// console.log(backgroundValues)
							//existing background check
							for (j = 0; j < backgroundProps.length; ++j) {

								if (backgroundValues[j].indexOf('gradient') != -1) {

									hasGradient = true;
								}

								if (backgroundProps[j] == 'background') {
									backgroundTmpIdx = j;
									backgroundTmp = backgroundValues[backgroundTmpIdx];

									if (backgroundTmp.indexOf('gradient') == -1) {
										//fill missing attribute with existing background props
										if (backgroundProps.indexOf('background-color') > backgroundTmpIdx) {
											backgroundValuesOutput[0] = backgroundValues[backgroundProps.indexOf('background-color')];
										} else {
											backgroundValuesOutput[0] = (backgroundTmp2 = getBackgroundProp(backgroundTmp, 'color')) ? backgroundTmp2 : backgroundValuesOutput[0];
										}
										if (backgroundProps.indexOf('background-image') > backgroundTmpIdx) {
											backgroundValuesOutput[1] = backgroundValues[backgroundProps.indexOf('background-image')];
										} else {
											backgroundValuesOutput[1] = (backgroundTmp2 = getBackgroundProp(backgroundTmp, 'image')) ? backgroundTmp2 : backgroundValuesOutput[1];
										}
										if (backgroundProps.indexOf('background-repeat') > backgroundTmpIdx) {
											backgroundValuesOutput[2] = backgroundValues[backgroundProps.indexOf('background-repeat')];
										} else {
											backgroundValuesOutput[2] = (backgroundTmp2 = getBackgroundProp(backgroundTmp, 'repeat')) ? backgroundTmp2 : backgroundValuesOutput[2];
										}
										if (backgroundProps.indexOf('background-attachment') > backgroundTmpIdx) {
											backgroundValuesOutput[3] = backgroundValues[backgroundProps.indexOf('background-attachment')];
										} else {
											backgroundValuesOutput[3] = (backgroundTmp2 = getBackgroundProp(backgroundTmp, 'attachment')) ? backgroundTmp2 : backgroundValuesOutput[3];
										}
										if (backgroundProps.indexOf('background-position') > backgroundTmpIdx) {
											backgroundValuesOutput[4] = backgroundValues[backgroundProps.indexOf('background-position')];
										} else {
											backgroundValuesOutput[4] = (backgroundTmp2 = getBackgroundProp(backgroundTmp, 'position')) ? backgroundTmp2 : backgroundValuesOutput[4];

										}
									}
								}
							}

							if (hasMultipleBackgrounds && hasGradient == false) {
								// console.log('hi')
								backgroundTmp = '';
								backgroundTmp2 = '';
								for (j = 0; j < backgroundValuesOutput.length; ++j) {
									backgroundTmpIdx = backgroundValuesOutput[j].split(',');
									backgroundTmp += (backgroundTmpIdx[0]) ? backgroundTmpIdx[0].trim() + ' ' : '';
									backgroundTmp2 += (backgroundTmpIdx[1]) ? backgroundTmpIdx[1].trim() + ' ' : '';
									backgroundValuesOutput[j] = '';
								}
								backgroundTmp = backgroundTmp.trim();
								backgroundTmp += ', ' + backgroundTmp2.trim();
								backgroundValuesOutput[0] = backgroundTmp;
							}
							// console.log(backgroundPropsOutput)
							// console.log(backgroundValuesOutput)

							if (hasGradient == false) {


								// console.log(backgroundProps)
								// console.log(backgroundValues)

								if (
									backgroundValuesOutput[0] == ''
									&& backgroundValuesOutput[1] == ''
									&& backgroundValuesOutput[2] == ''
									&& backgroundValuesOutput[3] == ''
									&& backgroundValuesOutput[4] == ''
								) {

								} else {

									backgroundProps = backgroundPropsOutput;
									backgroundValues = backgroundValuesOutput;
								}
								// console.log(backgroundProps)
								// console.log(backgroundValues)

								//check for !important
								backgroundHasImportant = false;
								for (k = 0, klen = backgroundValues.length; k < klen; ++k) {

									backgroundValues[k] = backgroundValues[k].toString().replace(/(!important)/g, function(capture){
										backgroundHasImportant = true;
										return '';
									});
								}

								if (backgroundHasImportant) {
										backgroundValues[backgroundValues.length-1] += ' !important';
								}


								//remove any spaces from empty values
								backgroundValues = backgroundValues.filter(Boolean);

								//add new declaration to highest property position
								backgroundTmpIdx = rules[i].declarations.length;
								for (j = 0; j < backgroundTmpIdx; ++j) {
									
									switch(rules[i].declarations[j].property) {
										case 'background-color': 
										case 'background-image': 
										case 'background-position': 
										case 'background-repeat': 
										case 'background-attachment': 
										// case 'background-size': 
										// case 'background-origin': 
										// case 'background-clip': 
										case 'background': 
											backgroundIndex = j;
											if (backgroundIndex < backgroundTmpIdx && backgroundIndex != -1) { backgroundTmpIdx = backgroundIndex; }
											break;
									}
								}
								rules[i].declarations.splice(backgroundTmpIdx, 0, {
									type: 'declaration',
									property: 'background',
									value: backgroundValues.join(' ')
								})
								dCount+=1;
					    	summary.stats.summary.noBackgroundsShortened += 1;

								//remove originals
								backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-color');
								if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-image');
								if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-position');
								if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-repeat');
								if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-attachment');
								if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								// backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-size');
								// if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								// backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-origin');
								// if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}
								// backgroundIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('background-clip');
								// if (backgroundIndex != -1) { rules[i].declarations.splice(backgroundIndex, 1); dCount-=1;	}

								//remove existing backgrounds
								background = rules[i].declarations.filter(function( obj ) { return obj.property });
								backgroundProps = background.map(function(o) { return o.property; });
								noPreviousBackgrounds = backgroundProps.filter(function(value){ return value === 'background'; }).length - 1;
								if (noPreviousBackgrounds > 0) {
									for (j = 0; j < noPreviousBackgrounds; ++j) {
										backgroundTmpIdx = backgroundProps.indexOf('background',(backgroundProps.indexOf('background')+1));
										rules[i].declarations.splice(backgroundTmpIdx, 1); 
										dCount-=1;	
									}
								}
							}

						} //end of inherit check
					}
				} //end of background




				//listStyle
				if (OPTIONS.shorten_list_style || OPTIONS.shorten) {
					listStyle = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'list-style-type' 
					  		|| obj.property == 'list-style-position'
					  		|| obj.property == 'list-style-image'
					  		|| obj.property == 'list-style'
					  ;
					});
					listStyleProps = listStyle.map(function(o) { return o.property; });
					if (
						listStyleProps.indexOf('list-style-type') != -1 
						|| listStyleProps.indexOf('list-style-position') != -1 
						|| listStyleProps.indexOf('list-style-image') != -1 
						|| listStyleProps.indexOf('list-style') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - List-style : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }

						listStyleHasInherit = false;
						listStyleValues = listStyle.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								listStyleHasInherit = true;
							}
							return o.value; 
						});

						if (listStyleHasInherit == false) {

							listStylePropsOutput = ['list-style-type', 'list-style-position', 'list-style-image'];
							listStyleValuesOutput = [
								(listStyleValues[listStyleProps.indexOf('list-style-type')]?listStyleValues[listStyleProps.indexOf('list-style-type')]:''), 
								(listStyleValues[listStyleProps.indexOf('list-style-position')]?listStyleValues[listStyleProps.indexOf('list-style-position')]:''), 
								(listStyleValues[listStyleProps.indexOf('list-style-image')]?listStyleValues[listStyleProps.indexOf('list-style-image')]:''), 
							];

							//existing listStyle check
							listStyleTmpIdx = listStyleProps.indexOf('list-style')
							if (listStyleTmpIdx != -1) {
								listStyleTmp = listStyleValues[listStyleTmpIdx];

								if (listStyleTmp != 'none') {

									//fill missing attribute with existing listStyle
									if (listStyleProps.indexOf('list-style-type') > listStyleTmpIdx) {
										listStyleValuesOutput[0] = listStyleValues[listStyleProps.indexOf('list-style-type')];
									} else {
										listStyleValuesOutput[0] = (listStyleTmp2 = getValueOfTriProp(listStyleTmp, 'type')) ? listStyleTmp2 : listStyleValuesOutput[0];
									}
									if (listStyleProps.indexOf('list-style-position') > listStyleTmpIdx) {
										listStyleValuesOutput[1] = listStyleValues[listStyleProps.indexOf('list-style-position')];
									} else {
										listStyleValuesOutput[1] = (listStyleTmp2 = getValueOfTriProp(listStyleTmp, 'position')) ? listStyleTmp2 : listStyleValuesOutput[1];
									}
									if (listStyleProps.indexOf('list-style-image') > listStyleTmpIdx) {
										listStyleValuesOutput[2] = listStyleValues[listStyleProps.indexOf('list-style-image')];
									} else {
										listStyleValuesOutput[2] = (listStyleTmp2 = getValueOfTriProp(listStyleTmp, 'image')) ? listStyleTmp2 : listStyleValuesOutput[2];
									}

								} else {
									listStyleValuesOutput[0] = listStyleTmp;
									listStyleValuesOutput[1] = '';
									listStyleValuesOutput[2] = '';
								}
							}


							if (
								listStyleValuesOutput[0] == ''
								&& listStyleValuesOutput[1] == ''
								&& listStyleValuesOutput[2] == ''
							) {

							} else {

								listStyleProps = listStylePropsOutput;
								listStyleValues = listStyleValuesOutput;
							}
							// console.log(listStyleProps)
							// console.log(listStyleValues)

							//check for !important
							listStyleHasImportant = false;
							for (k = 0, klen = listStyleValues.length; k < klen; ++k) {

								listStyleValues[k] = listStyleValues[k].toString().replace(/(!important)/g, function(capture){
									listStyleHasImportant = true;
									return '';
								});
							}

							if (listStyleHasImportant) {
									listStyleValues[listStyleValues.length-1] += ' !important';
							}


							//remove any spaces from empty values
							listStyleValues = listStyleValues.filter(Boolean);

							//add declaration
							listStyleTmpIdx = rules[i].declarations.length;
							for (j = 0; j < listStyleTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'list-style-type': 
									case 'list-style-position': 
									case 'list-style-image': 
									case 'list-style': 
										listStyleIndex = j;
										if (listStyleIndex < listStyleTmpIdx && listStyleIndex != -1) { listStyleTmpIdx = listStyleIndex; }
										break;
								}
							}
							rules[i].declarations.splice(listStyleTmpIdx, 0, {
								type: 'declaration',
								property: 'list-style',
								value: listStyleValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noListStylesShortened += 1;

							listStyleIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('list-style-type');
							if (listStyleIndex != -1) { rules[i].declarations.splice(listStyleIndex, 1); dCount-=1;	}
							listStyleIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('list-style-position');
							if (listStyleIndex != -1) { rules[i].declarations.splice(listStyleIndex, 1); dCount-=1;	}
							listStyleIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('list-style-image');
							if (listStyleIndex != -1) { rules[i].declarations.splice(listStyleIndex, 1); dCount-=1;	}

							//remove existing listStyles
							listStyle = rules[i].declarations.filter(function( obj ) { return obj.property });
							listStyleProps = listStyle.map(function(o) { return o.property; });
							noPreviousMargins = listStyleProps.filter(function(value){ return value === 'list-style'; }).length;
							
							if (noPreviousMargins > 1) {
								for (j = 1; j < noPreviousMargins; ++j) {
									listStyleTmpIdx = listStyleProps.indexOf('list-style',(listStyleProps.indexOf('list-style')+1));
									
									rules[i].declarations.splice(listStyleTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} // end of inherit check
					}
				} //end of listStyle



				//outline
				if (OPTIONS.shorten_outline || OPTIONS.shorten) {
					outline = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'outline-width' 
					  		|| obj.property == 'outline-style'
					  		|| obj.property == 'outline-color'
					  		|| obj.property == 'outline'
					  ;
					});
					outlineProps = outline.map(function(o) { return o.property; });
					if (
						outlineProps.indexOf('outline-style') != -1 
						|| outlineProps.indexOf('outline') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Outline : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }


						outlineHasInherit = false;
						outlineValues = outline.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								outlineHasInherit = true;
							}
							return o.value; 
						});

						if (outlineHasInherit == false) {

							outlineValues = outline.map(function(o) { return o.value; });
							outlinePropsOutput = ['outline-width', 'outline-style', 'outline-color'];
							outlineValuesOutput = [
								(outlineValues[outlineProps.indexOf('outline-width')]?outlineValues[outlineProps.indexOf('outline-width')]:''), 
								(outlineValues[outlineProps.indexOf('outline-style')]?outlineValues[outlineProps.indexOf('outline-style')]:''), 
								(outlineValues[outlineProps.indexOf('outline-color')]?outlineValues[outlineProps.indexOf('outline-color')]:''), 
							];

							//existing outline check
							outlineTmpIdx = outlineProps.indexOf('outline')
							if (outlineTmpIdx != -1) {
								outlineTmp = outlineValues[outlineTmpIdx];
								if (outlineTmp != 'none') {

									//fill missing attribute with existing outline
									if (outlineProps.indexOf('outline-width') > outlineTmpIdx) {
										outlineValuesOutput[0] = outlineValues[outlineProps.indexOf('outline-width')];
									} else {
										outlineValuesOutput[0] = (outlineTmp2 = getValueOfTriProp(outlineTmp, 'width')) ? outlineTmp2 : outlineValuesOutput[0];
									}
									if (outlineProps.indexOf('outline-style') > outlineTmpIdx) {
										outlineValuesOutput[1] = outlineValues[outlineProps.indexOf('outline-style')];
									} else {
										outlineValuesOutput[1] = (outlineTmp2 = getValueOfTriProp(outlineTmp, 'style')) ? outlineTmp2 : outlineValuesOutput[1];
									}
									if (outlineProps.indexOf('outline-color') > outlineTmpIdx) {
										outlineValuesOutput[2] = outlineValues[outlineProps.indexOf('outline-color')];
									} else {
										outlineValuesOutput[2] = (outlineTmp2 = getValueOfTriProp(outlineTmp, 'color')) ? outlineTmp2 : outlineValuesOutput[2];
									}

								} else {
									outlineValuesOutput[0] = '0';
									outlineValuesOutput[1] = '';
									outlineValuesOutput[2] = '';
								}
							}

							if (
								outlineValuesOutput[0] == ''
								&& outlineValuesOutput[1] == ''
								&& outlineValuesOutput[2] == ''
							) {

							} else {

								outlineProps = outlinePropsOutput;
								outlineValues = outlineValuesOutput;
							}

							//check for !important
							outlineHasImportant = false;
							for (k = 0, klen = outlineValues.length; k < klen; ++k) {

								outlineValues[k] = outlineValues[k].toString().replace(/(!important)/g, function(capture){
									outlineHasImportant = true;
									return '';
								});
							}

							if (outlineHasImportant) {
									outlineValues[outlineValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							outlineValues = outlineValues.filter(Boolean);

							//add declaration
							outlineTmpIdx = rules[i].declarations.length;
							for (j = 0; j < outlineTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'outline-width': 
									case 'outline-style': 
									case 'outline-color': 
									case 'outline': 
										outlineIndex = j;
										if (outlineIndex < outlineTmpIdx && outlineIndex != -1) { outlineTmpIdx = outlineIndex; }
										break;
								}
							}
							rules[i].declarations.splice(outlineTmpIdx, 0, {
								type: 'declaration',
								property: 'outline',
								value: outlineValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noOutlinesShortened += 1;

							outlineIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('outline-width');
							if (outlineIndex != -1) { rules[i].declarations.splice(outlineIndex, 1); dCount-=1;	}
							outlineIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('outline-style');
							if (outlineIndex != -1) { rules[i].declarations.splice(outlineIndex, 1); dCount-=1;	}
							outlineIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('outline-color');
							if (outlineIndex != -1) { rules[i].declarations.splice(outlineIndex, 1); dCount-=1;	}

							//remove existing outlines
							outline = rules[i].declarations.filter(function( obj ) { return obj.property });
							outlineProps = outline.map(function(o) { return o.property; });
							noPreviousOutline = outlineProps.filter(function(value){ return value === 'outline'; }).length - 1;
							if (noPreviousOutline > 0) {
								for (j = 0; j < noPreviousOutline; ++j) {
									outlineTmpIdx = outlineProps.indexOf('outline',(outlineProps.indexOf('outline')+1));
									rules[i].declarations.splice(outlineTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					}
				} //end of outline




				//borderTop
				if (OPTIONS.shorten_border_top || OPTIONS.shorten) {
					borderTop = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-top-width' 
					  		|| obj.property == 'border-top-style'
					  		|| obj.property == 'border-top-color'
					  		|| obj.property == 'border-top'
					  ;
					});
					borderTopProps = borderTop.map(function(o) { return o.property; });
					if (
						borderTopProps.indexOf('border-top-style') != -1 
						|| borderTopProps.indexOf('border-top') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Border Top : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }

						borderTopHasInherit = false;
						borderTopValues = borderTop.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderTopHasInherit = true;
							}
							return o.value; 
						});

						if (borderTopHasInherit == false) {

							borderTopPropsOutput = ['border-top-width', 'border-top-style', 'border-top-color'];
							borderTopValuesOutput = [
								(borderTopValues[borderTopProps.indexOf('border-top-width')]?borderTopValues[borderTopProps.indexOf('border-top-width')]:''), 
								(borderTopValues[borderTopProps.indexOf('border-top-style')]?borderTopValues[borderTopProps.indexOf('border-top-style')]:''), 
								(borderTopValues[borderTopProps.indexOf('border-top-color')]?borderTopValues[borderTopProps.indexOf('border-top-color')]:''), 
							];

							//existing borderTop check
							borderTopTmpIdx = borderTopProps.indexOf('border-top')
							if (borderTopTmpIdx != -1) {
								borderTopTmp = borderTopValues[borderTopTmpIdx];

								if (borderTopTmp != 'none') {
									//fill missing attribute with existing borderTop
									if (borderTopProps.indexOf('border-top-width') > borderTopTmpIdx) {
										
										borderTopValuesOutput[0] = borderTopValues[borderTopProps.indexOf('border-top-width')];
									} else {
										borderTopValuesOutput[0] = (borderTopTmp2 = getValueOfTriProp(borderTopTmp, 'width')) ? borderTopTmp2 : borderTopValuesOutput[0];
									}
									if (borderTopProps.indexOf('border-top-style') > borderTopTmpIdx) {
										
										borderTopValuesOutput[1] = borderTopValues[borderTopProps.indexOf('border-top-style')];
									} else {
										borderTopValuesOutput[1] = (borderTopTmp2 = getValueOfTriProp(borderTopTmp, 'style')) ? borderTopTmp2 : borderTopValuesOutput[1];
									}
									if (borderTopProps.indexOf('border-top-color') > borderTopTmpIdx) {
										
										borderTopValuesOutput[2] = borderTopValues[borderTopProps.indexOf('border-top-color')];
									} else {
										borderTopValuesOutput[2] = (borderTopTmp2 = getValueOfTriProp(borderTopTmp, 'color')) ? borderTopTmp2 : borderTopValuesOutput[2];
									}

								} else {
									borderTopValuesOutput[0] = '0';
									borderTopValuesOutput[1] = '';
									borderTopValuesOutput[2] = '';
								}
							}

							if (
								borderTopValuesOutput[0] == ''
								&& borderTopValuesOutput[1] == ''
								&& borderTopValuesOutput[2] == ''
							) {

							} else {

								borderTopProps = borderTopPropsOutput;
								borderTopValues = borderTopValuesOutput;
							}


							//check for !important
							borderTopHasImportant = false;
							for (k = 0, klen = borderTopValues.length; k < klen; ++k) {

								borderTopValues[k] = borderTopValues[k].toString().replace(/(!important)/g, function(capture){
									borderTopHasImportant = true;
									return '';
								});
							}

							if (borderTopHasImportant) {
									borderTopValues[borderTopValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderTopValues = borderTopValues.filter(Boolean);

							//add declaration
							borderTopTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderTopTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-top-width': 
									case 'border-top-style': 
									case 'border-top-color': 
									case 'border-top': 
										borderTopIndex = j;
										if (borderTopIndex < borderTopTmpIdx && borderTopIndex != -1) { borderTopTmpIdx = borderTopIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderTopTmpIdx,0,{
								type: 'declaration',
								property: 'border-top',
								value: borderTopValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noBorderTopsShortened += 1;

							borderTopIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top-width');
							if (borderTopIndex != -1) { rules[i].declarations.splice(borderTopIndex, 1); dCount-=1;	}
							borderTopIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top-style');
							if (borderTopIndex != -1) { rules[i].declarations.splice(borderTopIndex, 1); dCount-=1;	}
							borderTopIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top-color');
							if (borderTopIndex != -1) { rules[i].declarations.splice(borderTopIndex, 1); dCount-=1;	}
							
							//remove existing borderTops
							borderTop = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderTopProps = borderTop.map(function(o) { return o.property; });
							noPreviousBorderTop = borderTopProps.filter(function(value){ return value === 'border-top'; }).length - 1;
							if (noPreviousBorderTop > 0) {
								for (j = 0; j < noPreviousBorderTop; ++j) {
									borderTopTmpIdx = borderTopProps.indexOf('border-top',(borderTopProps.indexOf('border-top')+1));
									rules[i].declarations.splice(borderTopTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit
					}
				} //end of borderTop


				//borderRight
				if (OPTIONS.shorten_border_top || OPTIONS.shorten) {
					borderRight = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-right-width' 
					  		|| obj.property == 'border-right-style'
					  		|| obj.property == 'border-right-color'
					  		|| obj.property == 'border-right'
					  ;
					});
					borderRightProps = borderRight.map(function(o) { return o.property; });
					if (
						borderRightProps.indexOf('border-right-style') != -1 
						|| borderRightProps.indexOf('border-right') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Border Right : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						
						borderRightHasInherit = false;
						borderRightValues = borderRight.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderRightHasInherit = true;
							}
							return o.value; 
						});
						
						if (borderRightHasInherit == false) {

							borderRightPropsOutput = ['border-right-width', 'border-right-style', 'border-right-color'];
							borderRightValuesOutput = [
								(borderRightValues[borderRightProps.indexOf('border-right-width')]?borderRightValues[borderRightProps.indexOf('border-right-width')]:''), 
								(borderRightValues[borderRightProps.indexOf('border-right-style')]?borderRightValues[borderRightProps.indexOf('border-right-style')]:''), 
								(borderRightValues[borderRightProps.indexOf('border-right-color')]?borderRightValues[borderRightProps.indexOf('border-right-color')]:''), 
							];

							//existing borderRight check
							borderRightTmpIdx = borderRightProps.indexOf('border-right')
							if (borderRightTmpIdx != -1) {
								hasBorderRight = true;
								borderRightTmp = borderRightValues[borderRightTmpIdx];

								if (borderRightTmp != 'none') {
									//fill missing attribute with existing borderRight
									if (borderRightProps.indexOf('border-right-width') > borderRightTmpIdx) {
										borderRightValuesOutput[0] = borderRightValues[borderRightProps.indexOf('border-right-width')];
									} else {
										borderRightValuesOutput[0] = getValueOfTriProp(borderRightTmp, 'width');
									}
									if (borderRightProps.indexOf('border-right-style') > borderRightTmpIdx) {
										borderRightValuesOutput[1] = borderRightValues[borderRightProps.indexOf('border-right-style')];
									} else {
										borderRightValuesOutput[1] = getValueOfTriProp(borderRightTmp, 'style');
									}
									if (borderRightProps.indexOf('border-right-color') > borderRightTmpIdx) {
										borderRightValuesOutput[2] = borderRightValues[borderRightProps.indexOf('border-right-color')];
									} else {
										borderRightValuesOutput[2] = getValueOfTriProp(borderRightTmp, 'color');
									}

								} else {
									borderRightValuesOutput[0] = '0';
									borderRightValuesOutput[1] = '';
									borderRightValuesOutput[2] = '';
								}
							}

							if (
								borderRightValuesOutput[0] == ''
								&& borderRightValuesOutput[1] == ''
								&& borderRightValuesOutput[2] == ''
							) {

							} else {

								borderRightProps = borderRightPropsOutput;
								borderRightValues = borderRightValuesOutput;
							}

							//check for !important
							borderRightHasImportant = false;
							for (k = 0, klen = borderRightValues.length; k < klen; ++k) {

								borderRightValues[k] = borderRightValues[k].toString().replace(/(!important)/g, function(capture){
									borderRightHasImportant = true;
									return '';
								});
							}

							if (borderRightHasImportant) {
									borderRightValues[borderRightValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderRightValues = borderRightValues.filter(Boolean);

							//add declaration
							borderRightTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderRightTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-right-width': 
									case 'border-right-style': 
									case 'border-right-color': 
									case 'border-right': 
										borderRightIndex = j;
										if (borderRightIndex < borderRightTmpIdx && borderRightIndex != -1) { borderRightTmpIdx = borderRightIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderRightTmpIdx,0,{
								type: 'declaration',
								property: 'border-right',
								value: borderRightValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noBorderRightsShortened += 1;

							borderRightIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-right-width');
							if (borderRightIndex != -1) { rules[i].declarations.splice(borderRightIndex, 1); dCount-=1;	}
							borderRightIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-right-style');
							if (borderRightIndex != -1) { rules[i].declarations.splice(borderRightIndex, 1); dCount-=1;	}
							borderRightIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-right-color');
							if (borderRightIndex != -1) { rules[i].declarations.splice(borderRightIndex, 1); dCount-=1;	}
							
							//remove existing borderRights
							borderRight = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderRightProps = borderRight.map(function(o) { return o.property; });
							noPreviousBorderRight = borderRightProps.filter(function(value){ return value === 'border-right'; }).length - 1;
							if (noPreviousBorderRight > 0) {
								for (j = 0; j < noPreviousBorderRight; ++j) {
									borderRightTmpIdx = borderRightProps.indexOf('border-right',(borderRightProps.indexOf('border-right')+1));
									rules[i].declarations.splice(borderRightTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit
					}
				} //end of borderRight


				//borderBottom
				if (OPTIONS.shorten_border_top || OPTIONS.shorten) {
					borderBottom = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-bottom-width' 
					  		|| obj.property == 'border-bottom-style'
					  		|| obj.property == 'border-bottom-color'
					  		|| obj.property == 'border-bottom'
					  ;
					});
					borderBottomProps = borderBottom.map(function(o) { return o.property; });
					if (
						borderBottomProps.indexOf('border-bottom-style') != -1 
						|| borderBottomProps.indexOf('border-bottom') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Border Bottom : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }

						borderBottomHasInherit = false;
						borderBottomValues = borderBottom.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderBottomHasInherit = true;
							}
							return o.value; 
						});
						
						if (borderBottomHasInherit == false) {

							borderBottomPropsOutput = ['border-bottom-width', 'border-bottom-style', 'border-bottom-color'];
							borderBottomValuesOutput = [
								(borderBottomValues[borderBottomProps.indexOf('border-bottom-width')]?borderBottomValues[borderBottomProps.indexOf('border-bottom-width')]:''), 
								(borderBottomValues[borderBottomProps.indexOf('border-bottom-style')]?borderBottomValues[borderBottomProps.indexOf('border-bottom-style')]:''), 
								(borderBottomValues[borderBottomProps.indexOf('border-bottom-color')]?borderBottomValues[borderBottomProps.indexOf('border-bottom-color')]:''), 
							];

							//existing borderBottom check
							borderBottomTmpIdx = borderBottomProps.indexOf('border-bottom')
							if (borderBottomTmpIdx != -1) {
								borderBottomTmp = borderBottomValues[borderBottomTmpIdx];

								if (borderBottomTmp != 'none') {
									//fill missing attribute with existing borderBottom
									if (borderBottomProps.indexOf('border-bottom-width') > borderBottomTmpIdx) {
										borderBottomValuesOutput[0] = borderBottomValues[borderBottomProps.indexOf('border-bottom-width')];
									} else {
										borderBottomValuesOutput[0] = (borderBottomTmp2 = getValueOfTriProp(borderBottomTmp, 'width')) ? borderBottomTmp2 : borderBottomValuesOutput[0];
									}
									if (borderBottomProps.indexOf('border-bottom-style') > borderBottomTmpIdx) {
										borderBottomValuesOutput[1] = borderBottomValues[borderBottomProps.indexOf('border-bottom-style')];
									} else {
										borderBottomValuesOutput[1] = (borderBottomTmp2 = getValueOfTriProp(borderBottomTmp, 'style')) ? borderBottomTmp2 : borderBottomValuesOutput[1];
									}
									if (borderBottomProps.indexOf('border-bottom-color') > borderBottomTmpIdx) {
										borderBottomValuesOutput[2] = borderBottomValues[borderBottomProps.indexOf('border-bottom-color')];
									} else {
										borderBottomValuesOutput[2] = (borderBottomTmp2 = getValueOfTriProp(borderBottomTmp, 'color')) ? borderBottomTmp2 : borderBottomValuesOutput[2];
									}

								} else {
									borderBottomValuesOutput[0] = '0';
									borderBottomValuesOutput[1] = '';
									borderBottomValuesOutput[2] = '';
								}
							}

							if (
								borderBottomValuesOutput[0] == ''
								&& borderBottomValuesOutput[1] == ''
								&& borderBottomValuesOutput[2] == ''
							) {

							} else {

								borderBottomProps = borderBottomPropsOutput;
								borderBottomValues = borderBottomValuesOutput;
							}

							//check for !important
							borderBottomHasImportant = false;
							for (k = 0, klen = borderBottomValues.length; k < klen; ++k) {

								borderBottomValues[k] = borderBottomValues[k].toString().replace(/(!important)/g, function(capture){
									borderBottomHasImportant = true;
									return '';
								});
							}

							if (borderBottomHasImportant) {
									borderBottomValues[borderBottomValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderBottomValues = borderBottomValues.filter(Boolean);

							//add declaration
							borderBottomTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderBottomTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-bottom-width': 
									case 'border-bottom-style': 
									case 'border-bottom-color': 
									case 'border-bottom': 
										borderBottomIndex = j;
										if (borderBottomIndex < borderBottomTmpIdx && borderBottomIndex != -1) { borderBottomTmpIdx = borderBottomIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderBottomTmpIdx,0,{
								type: 'declaration',
								property: 'border-bottom',
								value: borderBottomValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noBorderBottomsShortened += 1;

							borderBottomIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom-width');
							if (borderBottomIndex != -1) { rules[i].declarations.splice(borderBottomIndex, 1); dCount-=1;	}
							borderBottomIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom-style');
							if (borderBottomIndex != -1) { rules[i].declarations.splice(borderBottomIndex, 1); dCount-=1;	}
							borderBottomIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom-color');
							if (borderBottomIndex != -1) { rules[i].declarations.splice(borderBottomIndex, 1); dCount-=1;	}
							
							//remove existing borderBottoms
							borderBottom = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderBottomProps = borderBottom.map(function(o) { return o.property; });
							noPreviousBorderBottom = borderBottomProps.filter(function(value){ return value === 'border-bottom'; }).length - 1;
							if (noPreviousBorderBottom > 0) {
								for (j = 0; j < noPreviousBorderBottom; ++j) {
									borderBottomTmpIdx = borderBottomProps.indexOf('border-bottom',(borderBottomProps.indexOf('border-bottom')+1));
									rules[i].declarations.splice(borderBottomTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit
					}
				} //end of borderBottom


				//borderLeft
				if (OPTIONS.shorten_border_left || OPTIONS.shorten) {
					borderLeft = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-left-width' 
					  		|| obj.property == 'border-left-style'
					  		|| obj.property == 'border-left-color'
					  		|| obj.property == 'border-left'
					  ;
					});
					borderLeftProps = borderLeft.map(function(o) { return o.property; });
					if (
						borderLeftProps.indexOf('border-left-style') != -1 
						|| borderLeftProps.indexOf('border-left') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Border Left : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						
						borderLeftHasInherit = false;
						borderLeftValues = borderLeft.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderLeftHasInherit = true;
							}
							return o.value; 
						});
						
						if (borderLeftHasInherit == false) {

							borderLeftPropsOutput = ['border-left-width', 'border-left-style', 'border-left-color'];
							borderLeftValuesOutput = [
								(borderLeftValues[borderLeftProps.indexOf('border-left-width')]?borderLeftValues[borderLeftProps.indexOf('border-left-width')]:''), 
								(borderLeftValues[borderLeftProps.indexOf('border-left-style')]?borderLeftValues[borderLeftProps.indexOf('border-left-style')]:''), 
								(borderLeftValues[borderLeftProps.indexOf('border-left-color')]?borderLeftValues[borderLeftProps.indexOf('border-left-color')]:''), 
							];


							//existing borderLeft check
							borderLeftTmpIdx = borderLeftProps.indexOf('border-left')
							if (borderLeftTmpIdx != -1) {
								borderLeftTmp = borderLeftValues[borderLeftTmpIdx];

								if (borderLeftTmp != 'none') {
									//fill missing attribute with existing borderLeft
									if (borderLeftProps.indexOf('border-left-width') > borderLeftTmpIdx) {
										borderLeftValuesOutput[0] = borderLeftValues[borderLeftProps.indexOf('border-left-width')];
									} else {
										borderLeftValuesOutput[0] = (borderLeftTmp2 = getValueOfTriProp(borderLeftTmp, 'width')) ? borderLeftTmp2 : borderLeftValuesOutput[0];
									}
									if (borderLeftProps.indexOf('border-left-style') > borderLeftTmpIdx) {
										borderLeftValuesOutput[1] = borderLeftValues[borderLeftProps.indexOf('border-left-style')];
									} else {
										borderLeftValuesOutput[1] = (borderLeftTmp2 = getValueOfTriProp(borderLeftTmp, 'style')) ? borderLeftTmp2 : borderLeftValuesOutput[1];
									}
									if (borderLeftProps.indexOf('border-left-color') > borderLeftTmpIdx) {
										borderLeftValuesOutput[2] = borderLeftValues[borderLeftProps.indexOf('border-left-color')];
									} else {
										borderLeftValuesOutput[2] = (borderLeftTmp2 = getValueOfTriProp(borderLeftTmp, 'color')) ? borderLeftTmp2 : borderLeftValuesOutput[2];
									}
								} else {
									borderLeftValuesOutput[0] = '0';
									borderLeftValuesOutput[1] = '';
									borderLeftValuesOutput[2] = '';
								}
							}

							if (
								borderLeftValuesOutput[0] == ''
								&& borderLeftValuesOutput[1] == ''
								&& borderLeftValuesOutput[2] == ''
							) {

							} else {

								borderLeftProps = borderLeftPropsOutput;
								borderLeftValues = borderLeftValuesOutput;
							}

							//check for !important
							borderLeftHasImportant = false;
							for (k = 0, klen = borderLeftValues.length; k < klen; ++k) {

								borderLeftValues[k] = borderLeftValues[k].toString().replace(/(!important)/g, function(capture){
									borderLeftHasImportant = true;
									return '';
								});
							}

							if (borderLeftHasImportant) {
									borderLeftValues[borderLeftValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderLeftValues = borderLeftValues.filter(Boolean);

							//add declaration
							borderLeftTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderLeftTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-left-width': 
									case 'border-left-style': 
									case 'border-left-color': 
									case 'border-left': 
										borderLeftIndex = j;
										if (borderLeftIndex < borderLeftTmpIdx && borderLeftIndex != -1) { borderLeftTmpIdx = borderLeftIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderLeftTmpIdx,0,{
								type: 'declaration',
								property: 'border-left',
								value: borderLeftValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noBorderLeftsShortened += 1;

							borderLeftIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-left-width');
							if (borderLeftIndex != -1) { rules[i].declarations.splice(borderLeftIndex, 1); dCount-=1;	}
							borderLeftIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-left-style');
							if (borderLeftIndex != -1) { rules[i].declarations.splice(borderLeftIndex, 1); dCount-=1;	}
							borderLeftIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-left-color');
							if (borderLeftIndex != -1) { rules[i].declarations.splice(borderLeftIndex, 1); dCount-=1;	}
							
							//remove existing borderLefts
							borderLeft = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderLeftProps = borderLeft.map(function(o) { return o.property; });
							noPreviousBorderLeft = borderLeftProps.filter(function(value){ return value === 'border-left'; }).length - 1;
							if (noPreviousBorderLeft > 0) {
								for (j = 0; j < noPreviousBorderLeft; ++j) {
									borderLeftTmpIdx = borderLeftProps.indexOf('border-left',(borderLeftProps.indexOf('border-left')+1));
									rules[i].declarations.splice(borderLeftTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					}
				} //end of borderLeft


				//border
				if (OPTIONS.shorten_border || OPTIONS.shorten) {




					border = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-top'
					  		|| obj.property == 'border-right'
					  		|| obj.property == 'border-bottom'
					  		|| obj.property == 'border-left'
					  		|| obj.property == 'border-top-width'
					  		|| obj.property == 'border-right-width'
					  		|| obj.property == 'border-bottom-width'
					  		|| obj.property == 'border-left-width'
					  ;
					});
					borderProps = border.map(function(o) { return o.property; });
					
					if (
						borderProps.indexOf('border-top') != -1 
						&& borderProps.indexOf('border-right') != -1 
						&& borderProps.indexOf('border-bottom') != -1 
						&& borderProps.indexOf('border-left') != -1 
					) {

						if (OPTIONS.verbose) { console.log(success('Process - Values - Border : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						borderHasInherit = false;
						borderValues = border.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderHasInherit = true;
							}
							return o.value; 
						});
						
						if (borderHasInherit == false) {

							borderPropsOutput = ['border-width', 'border-style', 'border-color'];
							borderValuesOutput = [
								(borderValues[borderProps.indexOf('border-width')]?borderValues[borderProps.indexOf('border-width')]:''), 
								(borderValues[borderProps.indexOf('border-style')]?borderValues[borderProps.indexOf('border-style')]:''), 
								(borderValues[borderProps.indexOf('border-color')]?borderValues[borderProps.indexOf('border-color')]:''), 
							];



							if (
								borderValues[0] == borderValues[1]
								&& borderValues[0] == borderValues[2]
								&& borderValues[0] == borderValues[3]
							) {



								borderTmp = borderValues[0];

								if (borderProps.indexOf('border-width') == -1) {
									borderValuesOutput[0] = getValueOfTriProp(borderTmp, 'width');
								} else {
									borderValuesOutput[0] = borderValues[borderProps.indexOf('border-width')];
								}
								if (borderProps.indexOf('border-style') == -1) {
									borderValuesOutput[1] = getValueOfTriProp(borderTmp, 'style');
								} else {
									borderValuesOutput[1] = borderValues[borderProps.indexOf('border-style')];
								}
								if (borderProps.indexOf('border-color') == -1) {
									borderValuesOutput[2] = getValueOfTriProp(borderTmp, 'color');
								} else {
									borderValuesOutput[2] = borderValues[borderProps.indexOf('border-color')];
								}

								if (
									borderValuesOutput[0] == ''
									&& borderValuesOutput[1] == ''
									&& borderValuesOutput[2] == ''
								) {

								} else {

									borderProps = borderPropsOutput;
									borderValues = borderValuesOutput;
								}


								//check for !important
								borderHasImportant = false;
								for (k = 0, klen = borderValues.length; k < klen; ++k) {

									borderValues[k] = borderValues[k].toString().replace(/(!important)/g, function(capture){
										borderHasImportant = true;
										return '';
									});
								}

								if (borderHasImportant) {
										borderValues[borderValues.length-1] += ' !important';
								}

								//remove any spaces from empty values
								borderValues = borderValues.filter(Boolean);

								//add declaration
								borderTmpIdx = rules[i].declarations.length;
								for (j = 0; j < borderTmpIdx; ++j) {
									
									switch(rules[i].declarations[j].property) {
										case 'border-top': 
										case 'border-right': 
										case 'border-bottom': 
										case 'border-left': 
											borderIndex = j;
											if (borderIndex < borderTmpIdx && borderIndex != -1) { borderTmpIdx = borderIndex; }
											break;
									}
								}

								rules[i].declarations.splice(borderTmpIdx, 0, {
									type: 'declaration',
									property: 'border',
									value: borderValues.join(' ')
								})
								
								dCount+=1;

								borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top');
								if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
								borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-right');
								if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
								borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom');
								if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
								borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-left');
								if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
								
							}
						} //end of inherit check
					} //end of combining




					border = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border'
					  || obj.property == 'border-width' 
					  		|| obj.property == 'border-style'
					  		|| obj.property == 'border-color'
					  		
					  ;
					});

					borderProps = border.map(function(o) { return o.property; });
					if (
						(borderProps.indexOf('border-width') != -1 
						&& borderProps.indexOf('border-style') != -1 
						&& borderProps.indexOf('border-color') != -1 )
						|| borderProps.indexOf('border') != -1
					) {
						borderValues = border.map(function(o) { return o.value; });

						borderHasInherit = false;
						borderValues = border.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderHasInherit = true;
							}
							return o.value; 
						});
						
						if (
							borderHasInherit == false
							&& (borderProps.indexOf('border-width') != -1 
							&& borderProps.indexOf('border-style') != -1 
							&& borderProps.indexOf('border-color') != -1 )
							&& borderValues[borderProps.indexOf('border-color')].split(' ').length == 1 //multi-color (border around squares, etc.) check - only do if single
							&& borderValues[borderProps.indexOf('border-width')].split(' ').length == 1 //multi-width values not allowed
						) {

							borderPropsOutput = ['border-width', 'border-style', 'border-color'];
							borderValuesOutput = [
								(borderValues[borderProps.indexOf('border-width')]?borderValues[borderProps.indexOf('border-width')]:''), 
								(borderValues[borderProps.indexOf('border-style')]?borderValues[borderProps.indexOf('border-style')]:''), 
								(borderValues[borderProps.indexOf('border-color')]?borderValues[borderProps.indexOf('border-color')]:''), 
							];

							//existing border check
							borderTmpIdx = borderProps.indexOf('border')
							if (borderTmpIdx != -1) {
								borderTmp = borderValues[borderTmpIdx];

								if (borderTmp != 'none') {
									//fill missing attribute with existing border
									if (borderProps.indexOf('border-width') > borderTmpIdx) {
										borderValuesOutput[0] = borderValues[borderProps.indexOf('border-width')];
									} else {
										borderValuesOutput[0] = (borderTmp2 = getValueOfTriProp(borderTmp, 'width')) ? borderTmp2 : borderValuesOutput[0];
									}
									if (borderProps.indexOf('border-style') > borderTmpIdx) {
										borderValuesOutput[1] = borderValues[borderProps.indexOf('border-style')];
									} else {
										borderValuesOutput[1] = (borderTmp2 = getValueOfTriProp(borderTmp, 'style')) ? borderTmp2 : borderValuesOutput[1];
									}
									if (borderProps.indexOf('border-color') > borderTmpIdx) {
										borderValuesOutput[2] = borderValues[borderProps.indexOf('border-color')];
									} else {
										borderValuesOutput[2] = (borderTmp2 = getValueOfTriProp(borderTmp, 'color')) ? borderTmp2 : borderValuesOutput[2];

									}

								} else {
									borderValuesOutput[0] = '0';
									borderValuesOutput[1] = '';
									borderValuesOutput[2] = '';
								}
							}

							if (
								borderValuesOutput[0] == ''
								&& borderValuesOutput[1] == ''
								&& borderValuesOutput[2] == ''
							) {

							} else {

								borderProps = borderPropsOutput;
								borderValues = borderValuesOutput;
							}

								// console.log(borderProps)
								// console.log(borderValues)

							//check for !important
							borderHasImportant = false;
							for (k = 0, klen = borderValues.length; k < klen; ++k) {

								borderValues[k] = borderValues[k].toString().replace(/(!important)/g, function(capture){
									borderHasImportant = true;
									return '';
								});
							}

							if (borderHasImportant) {
									borderValues[borderValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderValues = borderValues.filter(Boolean);

							//add declaration
							borderTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-width': 
									case 'border-style': 
									case 'border-color': 
									case 'border': 
										borderIndex = j;
										if (borderIndex < borderTmpIdx && borderIndex != -1) { borderTmpIdx = borderIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderTmpIdx, 0, {
								type: 'declaration',
								property: 'border',
								value: borderValues.join(' ')
							})

							dCount+=1;
				    	summary.stats.summary.noBordersShortened += 1;

							borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-width');
							if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
							borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-style');
							if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}
							borderIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-color');
							if (borderIndex != -1) { rules[i].declarations.splice(borderIndex, 1); dCount-=1;	}

							//remove existing borders
							border = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderProps = border.map(function(o) { return o.property; });
							noPreviousBorders = borderProps.filter(function(value){ return value === 'border'; }).length - 1;
							if (noPreviousBorders > 0) {
								for (j = 0; j < noPreviousBorders; ++j) {
									borderTmpIdx = borderProps.indexOf('border',(borderProps.indexOf('border')+1));
									rules[i].declarations.splice(borderTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					}
				} //end of border








				//borderRadius
				if (OPTIONS.shorten_border_radius || OPTIONS.shorten) {
					borderRadius = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'border-top-left-radius' 
					  		|| obj.property == 'border-top-right-radius'
					  		|| obj.property == 'border-bottom-left-radius'
					  		|| obj.property == 'border-bottom-right-radius'
					  		|| obj.property == 'border-radius'
					  ;
					});
					borderRadiusProps = borderRadius.map(function(o) { return o.property; });
					if (
						(borderRadiusProps.indexOf('border-top-left-radius') != -1 
						&& borderRadiusProps.indexOf('border-top-right-radius') != -1
						&& borderRadiusProps.indexOf('border-bottom-left-radius') != -1
						&& borderRadiusProps.indexOf('border-bottom-right-radius') != -1)
						|| borderRadiusProps.indexOf('border-radius') != -1
					) {

						if (OPTIONS.verbose) { console.log(success('Process - Values - Border Radius : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						borderRadiusHasInherit = false;
						borderRadiusValues = borderRadius.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								borderRadiusHasInherit = true;
							}
							return o.value; 
						});
						
						if (borderRadiusHasInherit == false) {

							borderRadiusValues = borderRadius.map(function(o) { return o.value; });
							borderRadiusPropsOutput = ['border-top-left-radius', 'border-top-right-radius', 'border-bottom-left-radius', 'border-bottom-right-radius'];
							borderRadiusValuesOutput = [
								(borderRadiusValues[borderRadiusProps.indexOf('border-top-left-radius')]?borderRadiusValues[borderRadiusProps.indexOf('border-top-left-radius')]:''), 
								(borderRadiusValues[borderRadiusProps.indexOf('border-top-right-radius')]?borderRadiusValues[borderRadiusProps.indexOf('border-top-right-radius')]:''), 
								(borderRadiusValues[borderRadiusProps.indexOf('border-bottom-left-radius')]?borderRadiusValues[borderRadiusProps.indexOf('border-bottom-left-radius')]:''), 
								(borderRadiusValues[borderRadiusProps.indexOf('border-bottom-right-radius')]?borderRadiusValues[borderRadiusProps.indexOf('border-bottom-right-radius')]:''), 
							];
							
							//existing borderRadius check
							borderRadiusTmpIdx = borderRadiusProps.indexOf('border-radius')
							if (borderRadiusTmpIdx != -1) {
								borderRadiusTmp = borderRadiusValues[borderRadiusTmpIdx];

								//fill missing attribute with existing borderRadius
								if (borderRadiusProps.indexOf('border-top-left-radius') > borderRadiusTmpIdx) {
									borderRadiusValuesOutput[0] = borderRadiusValues[borderRadiusProps.indexOf('border-top-left-radius')];
								} else {
									borderRadiusValuesOutput[0] = (borderRadiusTmp2 = getValueOfSquareProp(borderRadiusTmp, 'top')) ? borderRadiusTmp2 : borderRadiusValuesOutput[0];
								}
								if (borderRadiusProps.indexOf('border-top-right-radius') > borderRadiusTmpIdx) {
									borderRadiusValuesOutput[1] = borderRadiusValues[borderRadiusProps.indexOf('border-top-right-radius')];
								} else {
									borderRadiusValuesOutput[1] = (borderRadiusTmp2 = getValueOfSquareProp(borderRadiusTmp, 'right')) ? borderRadiusTmp2 : borderRadiusValuesOutput[1];
								}
								if (borderRadiusProps.indexOf('border-bottom-left-radius') > borderRadiusTmpIdx) {
									borderRadiusValuesOutput[2] = borderRadiusValues[borderRadiusProps.indexOf('border-bottom-left-radius')];
								} else {
									borderRadiusValuesOutput[2] = (borderRadiusTmp2 = getValueOfSquareProp(borderRadiusTmp, 'bottom')) ? borderRadiusTmp2 : borderRadiusValuesOutput[2];
								}
								if (borderRadiusProps.indexOf('border-bottom-right-radius') > borderRadiusTmpIdx) {
									borderRadiusValuesOutput[3] = borderRadiusValues[borderRadiusProps.indexOf('border-bottom-right-radius')];
								} else {
									borderRadiusValuesOutput[3] = (borderRadiusTmp2 = getValueOfSquareProp(borderRadiusTmp, 'left')) ? borderRadiusTmp2 : borderRadiusValuesOutput[3];
								}

							}

							borderRadiusProps = borderRadiusPropsOutput;
							borderRadiusValues = borderRadiusValuesOutput;


							//check for requirements
							borderRadiusLeftIdx = borderRadiusProps.indexOf('border-bottom-right-radius');
							borderRadiusRightIdx = borderRadiusProps.indexOf('border-top-right-radius');
							borderRadiusTopIdx = borderRadiusProps.indexOf('border-top-left-radius');
							borderRadiusBottomIdx = borderRadiusProps.indexOf('border-bottom-left-radius');

							//apply rules
							//1 value
							if (
								borderRadiusTopIdx != -1 && borderRadiusBottomIdx != -1
								&& borderRadiusLeftIdx != -1 && borderRadiusRightIdx != -1
								&& borderRadiusValues[borderRadiusTopIdx] == borderRadiusValues[borderRadiusBottomIdx]
								&& borderRadiusValues[borderRadiusTopIdx] == borderRadiusValues[borderRadiusRightIdx]
								&& borderRadiusValues[borderRadiusTopIdx] == borderRadiusValues[borderRadiusLeftIdx]
							) {
								borderRadiusProps = ['border-radius'];
								borderRadiusValues = [borderRadiusValues[borderRadiusTopIdx]];

								borderRadiusSingleMerge = true;

							} else if ( //2
								borderRadiusTopIdx != -1 && borderRadiusBottomIdx != -1
								&& borderRadiusLeftIdx != -1 && borderRadiusRightIdx != -1
								&& borderRadiusValues[borderRadiusTopIdx] == borderRadiusValues[borderRadiusBottomIdx]
								&& borderRadiusValues[borderRadiusLeftIdx] == borderRadiusValues[borderRadiusRightIdx]
							) {
								borderRadiusTopBottomVal = borderRadiusValues[borderRadiusTopIdx];
								//remove Top + Bottom values
								borderRadiusValues.splice(borderRadiusTopIdx, 1);
								borderRadiusValues.splice(borderRadiusBottomIdx-1, 1);
								//add TopBottom value
								borderRadiusValues.splice(0,0,borderRadiusTopBottomVal);
								
								//remove Top + Bottom properties
								borderRadiusProps.splice(borderRadiusTopIdx, 1);
								borderRadiusProps.splice(borderRadiusBottomIdx-1, 1);
								//add TopBottom property - for alignment sake
								borderRadiusProps.splice(0,0,'border-radius-top-bottom');


								borderRadiusRightLeftVal = borderRadiusValues[borderRadiusRightIdx];
								//remove Right + Left values
								borderRadiusValues.splice(borderRadiusRightIdx, 1);
								borderRadiusValues.splice(borderRadiusLeftIdx-2, 1);
								//add RightLeft value
								borderRadiusValues.splice(1,0,borderRadiusRightLeftVal);
								
								//remove Right + Left properties
								borderRadiusProps.splice(borderRadiusRightIdx, 1);
								borderRadiusProps.splice(borderRadiusLeftIdx-2, 1);
								//add RightLeft property - for alignment sake
								borderRadiusProps.splice(1,0,'border-radius-right-left');


							} else if (	//3 values
								borderRadiusLeftIdx != -1 && borderRadiusRightIdx != -1
								&& borderRadiusTopIdx != -1 && borderRadiusBottomIdx != -1
								&& borderRadiusValues[borderRadiusLeftIdx] == borderRadiusValues[borderRadiusRightIdx]
							) {
								borderRadiusRightLeftVal = borderRadiusValues[borderRadiusRightIdx];

								//remove right + left values
								borderRadiusValues.splice(borderRadiusRightIdx, 1);
								borderRadiusValues.splice(borderRadiusLeftIdx-1, 1);
								//add rightleft value
								borderRadiusValues.splice(1,0,borderRadiusRightLeftVal);

								//remove right + left properties
								borderRadiusProps.splice(borderRadiusRightIdx, 1);
								borderRadiusProps.splice(borderRadiusLeftIdx-1, 1);
								//add rightleft property - for alignment sake
								borderRadiusProps.splice(1,0,'border-radius-left-right');
							}

							//check for !important
							borderRadiusHasImportant = false;
							for (k = 0, klen = borderRadiusValues.length; k < klen; ++k) {

								borderRadiusValues[k] = borderRadiusValues[k].toString().replace(/(!important)/g, function(capture){
									borderRadiusHasImportant = true;
									return '';
								});
							}

							if (borderRadiusHasImportant) {
									borderRadiusValues[borderRadiusValues.length-1] += ' !important';
							}

							//remove any spaces from empty values
							borderRadiusValues = borderRadiusValues.filter(Boolean);

							//add declaration
							borderRadiusTmpIdx = rules[i].declarations.length;
							for (j = 0; j < borderRadiusTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'border-top-left-radius': 
									case 'border-top-right-radius': 
									case 'border-bottom-left-radius': 
									case 'border-bottom-right-radius': 
									case 'border-radius': 
										borderRadiusIndex = j;
										if (borderRadiusIndex < borderRadiusTmpIdx && borderRadiusIndex != -1) { borderRadiusTmpIdx = borderRadiusIndex; }
										break;
								}
							}
							rules[i].declarations.splice(borderRadiusTmpIdx, 0, {
								type: 'declaration',
								property: 'border-radius',
								value: borderRadiusValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noPaddingsShortened += 1;

				    	//remove originals
							borderRadiusIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top-left-radius');
							if (borderRadiusIndex != -1) { rules[i].declarations.splice(borderRadiusIndex, 1); dCount-=1;	}
							borderRadiusIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-top-right-radius');
							if (borderRadiusIndex != -1) { rules[i].declarations.splice(borderRadiusIndex, 1); dCount-=1;	}
							borderRadiusIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom-left-radius');
							if (borderRadiusIndex != -1) { rules[i].declarations.splice(borderRadiusIndex, 1); dCount-=1;	}
							borderRadiusIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('border-bottom-right-radius');
							if (borderRadiusIndex != -1) { rules[i].declarations.splice(borderRadiusIndex, 1); dCount-=1;	}
							
							//remove existing borderRadiuss
							borderRadius = rules[i].declarations.filter(function( obj ) { return obj.property });
							borderRadiusProps = borderRadius.map(function(o) { return o.property; });
							noPreviousBorderRadius = borderRadiusProps.filter(function(value){ return value === 'border-radius'; }).length - 1;
							if (noPreviousBorderRadius > 0) {
								for (j = 0; j < noPreviousBorderRadius; ++j) {
									borderRadiusTmpIdx = borderRadiusProps.indexOf('border-radius',(borderRadiusProps.indexOf('border-radius')+1));
									rules[i].declarations.splice(borderRadiusTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					} 
				} //end of borderRadius








				


				//margin
				if (OPTIONS.shorten_margin || OPTIONS.shorten) {
					margin = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'margin-top' 
					  		|| obj.property == 'margin-right'
					  		|| obj.property == 'margin-bottom'
					  		|| obj.property == 'margin-left'
					  		|| obj.property == 'margin'
					  ;
					});

					//special - convert rem
					// if (OPTIONS.special_convert_rem && OPTIONS.special_convert_rem_margin) {

						// //for singular declaration
						// for (j = 0; j < dCount; ++j) {

						// 	if (rules[i].declarations !== undefined && rules[i].declarations[j].property == 'margin') {

						// 		marginTmpVal = rules[i].declarations[j].value.toLowerCase();

						// 		if (marginTmpVal.indexOf('px') != -1) {
						// 			marginTmpVal = marginTmpVal.substr(0, marginTmpVal.length-2)/OPTIONS.special_convert_rem_desired_html_px + 'rem';
						// 		}

						// 		rules[i].declarations[j] = {
						// 			'type': rules[i].declarations[j].type,
						// 			'property': rules[i].declarations[j].property,
						// 			'value': marginTmpVal,
						// 			'position': rules[i].declarations[j].position
						// 		};
						// 	}
						// }

						// //for combined declaration
						// if ((fontIndex = font.map(function(o) { return o.property; }).indexOf('font-size')) != -1) {
							
						// 	marginTmpVal = font[fontIndex].value.toLowerCase();

						// 	if (marginTmpVal.indexOf('px') != -1) {
						// 		marginTmpVal = marginTmpVal.substr(0, marginTmpVal.length-2)/OPTIONS.special_convert_rem_desired_html_px + 'rem';
						// 	}

						// 	font[fontIndex] = {
						// 		'type': font[fontIndex].type,
						// 		'property': font[fontIndex].property,
						// 		'value': marginTmpVal,
						// 		'position': font[fontIndex].position
						// 	};
						// }
					// }


					marginProps = margin.map(function(o) { return o.property; });
					if (
						(marginProps.indexOf('margin-top') != -1 
						&& marginProps.indexOf('margin-right') != -1
						&& marginProps.indexOf('margin-bottom') != -1
						&& marginProps.indexOf('margin-left') != -1)
						|| marginProps.indexOf('margin') != -1
					) {
						if (OPTIONS.verbose) { console.log(success('Process - Values - Margin : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						marginHasInherit = false;
						marginValues = margin.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								marginHasInherit = true;
							}
							return o.value; 
						});
						
						if (marginHasInherit == false) {

							marginPropsOutput = ['margin-top', 'margin-right', 'margin-bottom', 'margin-left'];
							marginValuesOutput = [
								(marginValues[marginProps.indexOf('margin-top')]?marginValues[marginProps.indexOf('margin-top')]:''), 
								(marginValues[marginProps.indexOf('margin-right')]?marginValues[marginProps.indexOf('margin-right')]:''), 
								(marginValues[marginProps.indexOf('margin-bottom')]?marginValues[marginProps.indexOf('margin-bottom')]:''), 
								(marginValues[marginProps.indexOf('margin-left')]?marginValues[marginProps.indexOf('margin-left')]:''), 
							];

							//existing margin check
							marginTmpIdx = marginProps.indexOf('margin')
							if (marginTmpIdx != -1) {
								marginTmp = marginValues[marginTmpIdx];

								//fill missing attribute with existing margin
								if (marginProps.indexOf('margin-top') > marginTmpIdx) {
									marginValuesOutput[0] = marginValues[marginProps.indexOf('margin-top')];
								} else {
									marginValuesOutput[0] = getValueOfSquareProp(marginTmp, 'top');
								}
								if (marginProps.indexOf('margin-right') > marginTmpIdx) {
									marginValuesOutput[1] = marginValues[marginProps.indexOf('margin-right')];
								} else {
									marginValuesOutput[1] = getValueOfSquareProp(marginTmp, 'right');
								}
								if (marginProps.indexOf('margin-bottom') > marginTmpIdx) {
									marginValuesOutput[2] = marginValues[marginProps.indexOf('margin-bottom')];
								} else {
									marginValuesOutput[2] = getValueOfSquareProp(marginTmp, 'bottom');
								}
								if (marginProps.indexOf('margin-left') > marginTmpIdx) {
									marginValuesOutput[3] = marginValues[marginProps.indexOf('margin-left')];
								} else {
									marginValuesOutput[3] = getValueOfSquareProp(marginTmp, 'left');
								}
							}

							if (
								marginValuesOutput[0] == ''
								&& marginValuesOutput[1] == ''
								&& marginValuesOutput[2] == ''
								&& marginValuesOutput[3] == ''
							) {

							} else {

								marginProps = marginPropsOutput;
								marginValues = marginValuesOutput;
							}
							// console.log(marginProps)
							// console.log(marginValues)

							//check for !important
							marginHasImportant = false;
							for (k = 0, klen = marginValues.length; k < klen; ++k) {

								marginValues[k] = marginValues[k].toString().replace(/(!important)/g, function(capture){
									marginHasImportant = true;
									return '';
								});
							}

							if (marginHasImportant) {
									marginValues[marginValues.length-1] += ' !important';
							}

							//check for requirements
							marginLeftIdx = marginProps.indexOf('margin-left');
							marginRightIdx = marginProps.indexOf('margin-right');
							marginTopIdx = marginProps.indexOf('margin-top');
							marginBottomIdx = marginProps.indexOf('margin-bottom');

							//apply rules
							//1 value
							if (
								marginTopIdx != -1 && marginBottomIdx != -1
								&& marginLeftIdx != -1 && marginRightIdx != -1
								&& marginValues[marginTopIdx] == marginValues[marginBottomIdx]
								&& marginValues[marginTopIdx] == marginValues[marginRightIdx]
								&& marginValues[marginTopIdx] == marginValues[marginLeftIdx]
							) {
								marginProps = ['margin'];
								marginValues = [marginValues[marginTopIdx]];

							} else if ( //2
								marginTopIdx != -1 && marginBottomIdx != -1
								&& marginLeftIdx != -1 && marginRightIdx != -1
								&& marginValues[marginTopIdx] == marginValues[marginBottomIdx]
								&& marginValues[marginLeftIdx] == marginValues[marginRightIdx]
							) {
								marginTopBottomVal = marginValues[marginTopIdx];
								//remove Top + Bottom values
								marginValues.splice(marginTopIdx, 1);
								marginValues.splice(marginBottomIdx-1, 1);
								//add TopBottom value
								marginValues.splice(0,0,marginTopBottomVal);
								
								//remove Top + Bottom properties
								marginProps.splice(marginTopIdx, 1);
								marginProps.splice(marginBottomIdx-1, 1);
								//add TopBottom property - for alignment sake
								marginProps.splice(0,0,'marginTopBottom');


								marginRightLeftVal = marginValues[marginRightIdx];
								//remove Right + Left values
								marginValues.splice(marginRightIdx, 1);
								marginValues.splice(marginLeftIdx-2, 1);
								//add RightLeft value
								marginValues.splice(1,0,marginRightLeftVal);
								
								//remove Right + Left properties
								marginProps.splice(marginRightIdx, 1);
								marginProps.splice(marginLeftIdx-2, 1);
								//add RightLeft property - for alignment sake
								marginProps.splice(1,0,'marginRightLeft');


							} else if (	//3 values
								marginLeftIdx != -1 && marginRightIdx != -1
								&& marginTopIdx != -1 && marginBottomIdx != -1
								&& marginValues[marginLeftIdx] == marginValues[marginRightIdx]
							) {
								marginRightLeftVal = marginValues[marginRightIdx];

								//remove right + left values
								marginValues.splice(marginRightIdx, 1);
								marginValues.splice(marginLeftIdx-1, 1);
								//add rightleft value
								marginValues.splice(1,0,marginRightLeftVal);

								//remove right + left properties
								marginProps.splice(marginRightIdx, 1);
								marginProps.splice(marginLeftIdx-1, 1);
								//add rightleft property - for alignment sake
								marginProps.splice(1,0,'marginLeftRight');
							}

							// console.log(marginProps)
							// console.log(marginValues)
							//remove any spaces from empty values
							marginValues = marginValues.filter(Boolean);

							//add declaration
							marginTmpIdx = rules[i].declarations.length;
							for (j = 0; j < marginTmpIdx; ++j) {
								switch(rules[i].declarations[j].property) {
									case 'margin-top': 
									case 'margin-right': 
									case 'margin-bottom': 
									case 'margin-left': 
									case 'margin': 
										marginIndex = j;
										if (marginIndex < marginTmpIdx && marginIndex != -1) { marginTmpIdx = marginIndex; }
										break;
								}
							}
							rules[i].declarations.splice(marginTmpIdx, 0, {
								type: 'declaration',
								property: 'margin',
								value: marginValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noMarginsShortened += 1;

				    	//remove originals
							marginIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('margin-top');
							if (marginIndex != -1) { rules[i].declarations.splice(marginIndex, 1); dCount-=1;	}
							marginIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('margin-right');
							if (marginIndex != -1) { rules[i].declarations.splice(marginIndex, 1); dCount-=1;	}
							marginIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('margin-bottom');
							if (marginIndex != -1) { rules[i].declarations.splice(marginIndex, 1); dCount-=1;	}
							marginIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('margin-left');
							if (marginIndex != -1) { rules[i].declarations.splice(marginIndex, 1); dCount-=1;	}

							//remove existing margins
							margin = rules[i].declarations.filter(function( obj ) { return obj.property });
							marginProps = margin.map(function(o) { return o.property; });
							noPreviousMargins = marginProps.filter(function(value){ return value === 'margin'; }).length;
							
							if (noPreviousMargins > 1) {
								for (j = 1; j < noPreviousMargins; ++j) {
									marginTmpIdx = marginProps.indexOf('margin',(marginProps.indexOf('margin')+1));
									
									rules[i].declarations.splice(marginTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					} 
				} //end of margin
				


				//padding
				if (OPTIONS.shorten_padding || OPTIONS.shorten) {
					padding = rules[i].declarations.filter(function( obj ) {
					  return obj.property == 'padding-top' 
					  		|| obj.property == 'padding-right'
					  		|| obj.property == 'padding-bottom'
					  		|| obj.property == 'padding-left'
					  		|| obj.property == 'padding'
					  ;
					});
					paddingProps = padding.map(function(o) { return o.property; });
					if (
						(paddingProps.indexOf('padding-top') != -1 
						&& paddingProps.indexOf('padding-right') != -1
						&& paddingProps.indexOf('padding-bottom') != -1
						&& paddingProps.indexOf('padding-left') != -1)
						|| paddingProps.indexOf('padding') != -1
					) {

						if (OPTIONS.verbose) { console.log(success('Process - Values - Padding : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						
						paddingHasInherit = false;
						paddingValues = padding.map(function(o) { 
							if (o.value.toLowerCase().indexOf('inherit') != -1) {
								paddingHasInherit = true;
							}
							return o.value; 
						});
						
						if (paddingHasInherit == false) {

							paddingPropsOutput = ['padding-top', 'padding-right', 'padding-bottom', 'padding-left'];
							paddingValuesOutput = [
								(paddingValues[paddingProps.indexOf('padding-top')]?paddingValues[paddingProps.indexOf('padding-top')]:''), 
								(paddingValues[paddingProps.indexOf('padding-right')]?paddingValues[paddingProps.indexOf('padding-right')]:''), 
								(paddingValues[paddingProps.indexOf('padding-bottom')]?paddingValues[paddingProps.indexOf('padding-bottom')]:''), 
								(paddingValues[paddingProps.indexOf('padding-left')]?paddingValues[paddingProps.indexOf('padding-left')]:''), 
							];
							
							//existing padding check
							paddingTmpIdx = paddingProps.indexOf('padding')
							if (paddingTmpIdx != -1) {
								paddingTmp = paddingValues[paddingTmpIdx];

								//fill missing attribute with existing padding
								if (paddingProps.indexOf('padding-top') > paddingTmpIdx) {
									paddingValuesOutput[0] = paddingValues[paddingProps.indexOf('padding-top')];
								} else {
									paddingValuesOutput[0] = (paddingTmp2 = getValueOfSquareProp(paddingTmp, 'top')) ? paddingTmp2 : paddingValuesOutput[0];
								}
								if (paddingProps.indexOf('padding-right') > paddingTmpIdx) {
									paddingValuesOutput[1] = paddingValues[paddingProps.indexOf('padding-right')];
								} else {
									paddingValuesOutput[1] = (paddingTmp2 = getValueOfSquareProp(paddingTmp, 'right')) ? paddingTmp2 : paddingValuesOutput[1];
								}
								if (paddingProps.indexOf('padding-bottom') > paddingTmpIdx) {
									paddingValuesOutput[2] = paddingValues[paddingProps.indexOf('padding-bottom')];
								} else {
									paddingValuesOutput[2] = (paddingTmp2 = getValueOfSquareProp(paddingTmp, 'bottom')) ? paddingTmp2 : paddingValuesOutput[2];
								}
								if (paddingProps.indexOf('padding-left') > paddingTmpIdx) {
									paddingValuesOutput[3] = paddingValues[paddingProps.indexOf('padding-left')];
								} else {
									paddingValuesOutput[3] = (paddingTmp2 = getValueOfSquareProp(paddingTmp, 'left')) ? paddingTmp2 : paddingValuesOutput[3];
								}

								//fill property above padding
								// for (j = 0; j < paddingTmpIdx; ++j) {

								// 	switch(paddingProps[j]) {
								// 		case 'padding-top':
								// 			paddingValuesOutput[0] = getValueOfSquareProp(paddingTmp, 'top');
								// 			break;
								// 		case 'padding-right':
								// 			paddingValuesOutput[1] = getValueOfSquareProp(paddingTmp, 'right');
								// 			break;
								// 		case 'padding-bottom':
								// 			paddingValuesOutput[2] = getValueOfSquareProp(paddingTmp, 'bottom');
								// 			break;
								// 		case 'padding-left':
								// 			paddingValuesOutput[3] = getValueOfSquareProp(paddingTmp, 'left');
								// 			break;
								// 	}
								// }
							}

							if (
								paddingValuesOutput[0] == ''
								&& paddingValuesOutput[1] == ''
								&& paddingValuesOutput[2] == ''
								&& paddingValuesOutput[3] == ''
							) {

							} else {

								paddingProps = paddingPropsOutput;
								paddingValues = paddingValuesOutput;
							}

							//check for !important
							paddingHasImportant = false;
							for (k = 0, klen = paddingValues.length; k < klen; ++k) {

								paddingValues[k] = paddingValues[k].toString().replace(/(!important)/g, function(capture){
									paddingHasImportant = true;
									return '';
								});
							}

							if (paddingHasImportant) {
									paddingValues[paddingValues.length-1] += ' !important';
							}

							//check for requirements
							paddingLeftIdx = paddingProps.indexOf('padding-left');
							paddingRightIdx = paddingProps.indexOf('padding-right');
							paddingTopIdx = paddingProps.indexOf('padding-top');
							paddingBottomIdx = paddingProps.indexOf('padding-bottom');

							//apply rules
							//1 value
							if (
								paddingTopIdx != -1 && paddingBottomIdx != -1
								&& paddingLeftIdx != -1 && paddingRightIdx != -1
								&& paddingValues[paddingTopIdx] == paddingValues[paddingBottomIdx]
								&& paddingValues[paddingTopIdx] == paddingValues[paddingRightIdx]
								&& paddingValues[paddingTopIdx] == paddingValues[paddingLeftIdx]
							) {
								paddingProps = ['padding'];
								paddingValues = [paddingValues[paddingTopIdx]];

								paddingSingleMerge = true;

							} else if ( //2
								paddingTopIdx != -1 && paddingBottomIdx != -1
								&& paddingLeftIdx != -1 && paddingRightIdx != -1
								&& paddingValues[paddingTopIdx] == paddingValues[paddingBottomIdx]
								&& paddingValues[paddingLeftIdx] == paddingValues[paddingRightIdx]
							) {
								paddingTopBottomVal = paddingValues[paddingTopIdx];
								//remove Top + Bottom values
								paddingValues.splice(paddingTopIdx, 1);
								paddingValues.splice(paddingBottomIdx-1, 1);
								//add TopBottom value
								paddingValues.splice(0,0,paddingTopBottomVal);
								
								//remove Top + Bottom properties
								paddingProps.splice(paddingTopIdx, 1);
								paddingProps.splice(paddingBottomIdx-1, 1);
								//add TopBottom property - for alignment sake
								paddingProps.splice(0,0,'paddingTopBottom');


								paddingRightLeftVal = paddingValues[paddingRightIdx];
								//remove Right + Left values
								paddingValues.splice(paddingRightIdx, 1);
								paddingValues.splice(paddingLeftIdx-2, 1);
								//add RightLeft value
								paddingValues.splice(1,0,paddingRightLeftVal);
								
								//remove Right + Left properties
								paddingProps.splice(paddingRightIdx, 1);
								paddingProps.splice(paddingLeftIdx-2, 1);
								//add RightLeft property - for alignment sake
								paddingProps.splice(1,0,'paddingRightLeft');


							} else if (	//3 values
								paddingLeftIdx != -1 && paddingRightIdx != -1
								&& paddingTopIdx != -1 && paddingBottomIdx != -1
								&& paddingValues[paddingLeftIdx] == paddingValues[paddingRightIdx]
							) {
								paddingRightLeftVal = paddingValues[paddingRightIdx];

								//remove right + left values
								paddingValues.splice(paddingRightIdx, 1);
								paddingValues.splice(paddingLeftIdx-1, 1);
								//add rightleft value
								paddingValues.splice(1,0,paddingRightLeftVal);

								//remove right + left properties
								paddingProps.splice(paddingRightIdx, 1);
								paddingProps.splice(paddingLeftIdx-1, 1);
								//add rightleft property - for alignment sake
								paddingProps.splice(1,0,'paddingLeftRight');
							}


							//remove any spaces from empty values
							paddingValues = paddingValues.filter(Boolean);

							//add declaration
							paddingTmpIdx = rules[i].declarations.length;
							for (j = 0; j < paddingTmpIdx; ++j) {
								
								switch(rules[i].declarations[j].property) {
									case 'padding-top': 
									case 'padding-right': 
									case 'padding-bottom': 
									case 'padding-left': 
									case 'padding': 
										paddingIndex = j;
										if (paddingIndex < paddingTmpIdx && paddingIndex != -1) { paddingTmpIdx = paddingIndex; }
										break;
								}
							}
							rules[i].declarations.splice(paddingTmpIdx, 0, {
								type: 'declaration',
								property: 'padding',
								value: paddingValues.join(' ')
							})
							dCount+=1;
				    	summary.stats.summary.noPaddingsShortened += 1;

				    	//remove originals
							paddingIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('padding-top');
							if (paddingIndex != -1) { rules[i].declarations.splice(paddingIndex, 1); dCount-=1;	}
							paddingIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('padding-right');
							if (paddingIndex != -1) { rules[i].declarations.splice(paddingIndex, 1); dCount-=1;	}
							paddingIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('padding-bottom');
							if (paddingIndex != -1) { rules[i].declarations.splice(paddingIndex, 1); dCount-=1;	}
							paddingIndex = rules[i].declarations.map(function(e) { return e.property; }).indexOf('padding-left');
							if (paddingIndex != -1) { rules[i].declarations.splice(paddingIndex, 1); dCount-=1;	}
							
							//remove existing paddings
							padding = rules[i].declarations.filter(function( obj ) { return obj.property });
							paddingProps = padding.map(function(o) { return o.property; });
							noPreviousPaddings = paddingProps.filter(function(value){ return value === 'padding'; }).length;
							
							if (noPreviousPaddings > 1) {
								for (j = 1; j < noPreviousPaddings; ++j) {
									paddingTmpIdx = paddingProps.indexOf('padding',(paddingProps.indexOf('padding')+1));
									
									rules[i].declarations.splice(paddingTmpIdx, 1); 
									dCount-=1;	
								}
							}
						} //end of inherit check
					} 
				} //end of padding



				if (OPTIONS.shorten_zero || OPTIONS.shorten_hexcolor || OPTIONS.shorten) {

					//declarations
					for (l = 0; l < dCount; ++l) {
						
						//zero check
						if (
							(OPTIONS.shorten_zero || OPTIONS.shorten) 
							&& OPTIONS.zero_ignore_declaration.indexOf(rules[i].declarations[l].property) == -1
						) {
							tmpVal = rules[i].declarations[l].value;

							if (tmpVal !== undefined) {
								
								//leading zeros 000
								if (tmpVal.match(/[^#]\b0+[^1-9a-zA-Z.,;%()\[\]\s\/\\!]/gm)) {
									tmpVal = tmpVal.replace(/\b0+[^1-9a-zA-Z.,;%()\[\]\s\/\\!]/gm,''); //remove single duplicate 0
							    summary.stats.summary.noZerosShortened += 1;
									if (OPTIONS.verbose) { console.log(success('Process - Values - Zero : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
								}
								
								//0px, 0em, etc.
								if (
									tmpVal.substr(0, 1) == '0'
									&& (OPTIONS.zero_units.indexOf(tmpVal.substr(1, tmpVal.length)) != -1)
								) {
									tmpVal = 0;

									if (OPTIONS.verbose) { console.log(success('Process - Values - Zero : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : ''))); }
						    	summary.stats.summary.noZerosShortened += 1;
								}

								rules[i].declarations[l].value = tmpVal;
							}
						}


						//hex color
						/*
						applied to color, 
											 font, font-color,
											 background, background-color, 
											 border, border-color, 
											 outline-color, 
											 box-shadow, text-shadow
						*/
						if (OPTIONS.shorten_hexcolor || OPTIONS.shorten
							&& (
								rules[i].declarations[l].property == 'color'
								|| rules[i].declarations[l].property == 'font'
								|| rules[i].declarations[l].property == 'font-color'
								|| rules[i].declarations[l].property == 'background'
								|| rules[i].declarations[l].property == 'background-color'
								|| rules[i].declarations[l].property == 'outline-color'
								|| rules[i].declarations[l].property == 'box-shadow'
								|| rules[i].declarations[l].property == 'text-shadow'
								|| rules[i].declarations[l].property == 'border-color'
								|| rules[i].declarations[l].property == 'border-top-color'
								|| rules[i].declarations[l].property == 'border-right-color'
								|| rules[i].declarations[l].property == 'border-bottom-color'
								|| rules[i].declarations[l].property == 'border-left-color'
								|| rules[i].declarations[l].property == 'border'
								|| rules[i].declarations[l].property == 'border-top'
								|| rules[i].declarations[l].property == 'border-right'
								|| rules[i].declarations[l].property == 'border-bottom'
								|| rules[i].declarations[l].property == 'border-left'
							)
						) {
							tmpVal = ''+rules[i].declarations[l].value;
							if (tmpVal != 'undefined' && tmpVal.indexOf('Microsoft') == -1) {

								tmpVal = processColor(tmpVal, rules[i].selectors);
								rules[i].declarations[l].value = tmpVal;
								
							}
						} //end of options check

					} //end of loop declarations

				} //end of OPTIONS.shorten_zero || OPTIONS.shorten_hexcolor check

			} //end of undefined check

		} //end of loop rules

	}
1050620
protected void parseIf() {
        String condition = tokenizer.getToken().substring(2).trim();
        if (StringUtil.isEmpty(condition)) {
            throw new TwoWaySQLException("If condition not found.");
        }
        IfNode ifNode = new IfNode(condition);
        peek().addChild(ifNode);
        push(ifNode);
        parseEnd();
    }
865917
public final EObject ruleIfCondition() throws RecognitionException {
        EObject current = null;

        Token lv_elseif_0_0=null;
        Token otherlv_1=null;
        Token otherlv_2=null;
        Token otherlv_4=null;
        Token otherlv_5=null;
        EObject lv_condition_3_0 = null;


         enterRule(); 
            
        try {
            // InternalSimpleExpressions.g:79:28: ( ( ( (lv_elseif_0_0= 'else' ) )? otherlv_1= 'if' otherlv_2= '(' ( (lv_condition_3_0= ruleExpression ) ) otherlv_4= ')' otherlv_5= '{' ) )
            // InternalSimpleExpressions.g:80:1: ( ( (lv_elseif_0_0= 'else' ) )? otherlv_1= 'if' otherlv_2= '(' ( (lv_condition_3_0= ruleExpression ) ) otherlv_4= ')' otherlv_5= '{' )
            {
            // InternalSimpleExpressions.g:80:1: ( ( (lv_elseif_0_0= 'else' ) )? otherlv_1= 'if' otherlv_2= '(' ( (lv_condition_3_0= ruleExpression ) ) otherlv_4= ')' otherlv_5= '{' )
            // InternalSimpleExpressions.g:80:2: ( (lv_elseif_0_0= 'else' ) )? otherlv_1= 'if' otherlv_2= '(' ( (lv_condition_3_0= ruleExpression ) ) otherlv_4= ')' otherlv_5= '{'
            {
            // InternalSimpleExpressions.g:80:2: ( (lv_elseif_0_0= 'else' ) )?
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==11) ) {
                alt1=1;
            }
            switch (alt1) {
                case 1 :
                    // InternalSimpleExpressions.g:81:1: (lv_elseif_0_0= 'else' )
                    {
                    // InternalSimpleExpressions.g:81:1: (lv_elseif_0_0= 'else' )
                    // InternalSimpleExpressions.g:82:3: lv_elseif_0_0= 'else'
                    {
                    lv_elseif_0_0=(Token)match(input,11,FOLLOW_3); 

                            newLeafNode(lv_elseif_0_0, grammarAccess.getIfConditionAccess().getElseifElseKeyword_0_0());
                        

                    	        if (current==null) {
                    	            current = createModelElement(grammarAccess.getIfConditionRule());
                    	        }
                           		setWithLastConsumed(current, "elseif", true, "else");
                    	    

                    }


                    }
                    break;

            }

            otherlv_1=(Token)match(input,12,FOLLOW_4); 

                	newLeafNode(otherlv_1, grammarAccess.getIfConditionAccess().getIfKeyword_1());
                
            otherlv_2=(Token)match(input,13,FOLLOW_5); 

                	newLeafNode(otherlv_2, grammarAccess.getIfConditionAccess().getLeftParenthesisKeyword_2());
                
            // InternalSimpleExpressions.g:103:1: ( (lv_condition_3_0= ruleExpression ) )
            // InternalSimpleExpressions.g:104:1: (lv_condition_3_0= ruleExpression )
            {
            // InternalSimpleExpressions.g:104:1: (lv_condition_3_0= ruleExpression )
            // InternalSimpleExpressions.g:105:3: lv_condition_3_0= ruleExpression
            {
             
            	        newCompositeNode(grammarAccess.getIfConditionAccess().getConditionExpressionParserRuleCall_3_0()); 
            	    
            pushFollow(FOLLOW_6);
            lv_condition_3_0=ruleExpression();

            state._fsp--;


            	        if (current==null) {
            	            current = createModelElementForParent(grammarAccess.getIfConditionRule());
            	        }
                   		set(
                   			current, 
                   			"condition",
                    		lv_condition_3_0, 
                    		"org.eclipse.xtext.xtext.generator.parser.antlr.splitting.SimpleExpressions.Expression");
            	        afterParserOrEnumRuleCall();
            	    

            }


            }

            otherlv_4=(Token)match(input,14,FOLLOW_7); 

                	newLeafNode(otherlv_4, grammarAccess.getIfConditionAccess().getRightParenthesisKeyword_4());
                
            otherlv_5=(Token)match(input,15,FOLLOW_2); 

                	newLeafNode(otherlv_5, grammarAccess.getIfConditionAccess().getLeftCurlyBracketKeyword_5());
                

            }


            }

             leaveRule(); 
        }
         
            catch (RecognitionException re) { 
                recover(input,re); 
                appendSkippedTokens();
            } 
        finally {
        }
        return current;
    }
977635
void ensureCondition(boolean condition, String messageFormat, Object... args) throws SerializationException {
        if (!condition) {
            throw new SerializationException(String.format(messageFormat, args));
        }
    }
1060120
private Condition buildIdCondition(Object argument) {
         if (argument instanceof String && ObjectId.isValid((String) argument)) {
             return new Condition(ID_FIELD, new ObjectId((String) argument));
         } else if (Iterable.class.isAssignableFrom(argument.getClass())) {
             List<Object> objectIds = new ArrayList<Object>();

             //noinspection ConstantConditions
             for (Object argumentItem : (Iterable) argument) {
                 if (argumentItem instanceof String && ObjectId.isValid((String) argumentItem)) {
                     objectIds.add(new ObjectId((String) argumentItem));
                 } else if (argumentItem instanceof ObjectId) {
                     objectIds.add( argumentItem);
                 }
             }

             return new Condition(ID_FIELD, new BasicDBObject("$in", objectIds));
         } else {
             return new Condition(ID_FIELD, argument);
         }
     }
202299
@Override
    public boolean condition(Object input) {
        if (input instanceof String) {
            return !schema.getMetaData(columnIdx).isValid(new Text(input.toString()));
        } else if (input instanceof Double) {
            Double d = (Double) input;
            return !schema.getMetaData(columnIdx).isValid(new DoubleWritable(d));
        } else if (input instanceof Integer) {
            Integer i = (Integer) input;
            return !schema.getMetaData(columnIdx).isValid(new IntWritable(i));
        } else if (input instanceof Long) {
            Long l = (Long) input;
            return !schema.getMetaData(columnIdx).isValid(new LongWritable(l));
        } else if (input instanceof Boolean) {
            Boolean b = (Boolean) input;
            return !schema.getMetaData(columnIdx).isValid(new BooleanWritable(b));
        }

        else
            throw new IllegalStateException("Illegal type " + input.getClass().toString());
    }
690077
function(_condition, _msg /*, params */) {
      if(!_condition) {
        var params = Array.prototype.slice.call(arguments, 2);
        _msg = Utils.format(_msg, params);
        $log.error(_msg); // log error message
        throw new Error(_msg);
      }
    }
416618
public function toCondition()
    {
        $args = func_get_args();
        $first = array_shift($args);
        $cond = $this->condition();

        // already condition.
        if ( $first instanceof Condition\Condition ) {
            return $first;
        }

        // first argument is int ? then it's id.
        if ( is_numeric($first) ) {
            $cond->where->add(sprintf('%s = ?', $this->getPrimaryKey()), $first);

        // first argument is string ? then simple where.
        } elseif( is_string($first) ) {
            array_unshift($args, $first);
            call_user_func_array(array($cond->where, 'add'), $args);

        // first argument is array ? then id list or array condition.
        } elseif( is_array($first) ) {
            // when id list.
            if ( isset($first[0]) ) {
                call_user_func_array(array($cond->where, 'add'), $args);

            // when array condition.
            } else {
                $cond->import($first);
            }
        }
        
        return $cond;
    }
1248000
function isKeyword(id) {
		switch (id.length) {
			case 2:
				return 'do' == id || 'if' == id || 'in' == id || 'or' == id;
			case 3:
				return 'and' == id || 'end' == id || 'for' == id || 'nil' == id ||
					'not' == id;
			case 4:
				return 'else' == id || 'goto' == id || 'then' == id || 'true' == id;
			case 5:
				return 'break' == id || 'false' == id || 'local' == id ||
					'until' == id || 'while' == id;
			case 6:
				return 'elseif' == id || 'repeat' == id || 'return' == id;
			case 8:
				return 'function' == id;
		}
		return false;
	}
912970
function _condition()
	{
		$result = $this->_expression();
		if ($this->_current_token == "<") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgLT', $result, $result2);
		} elseif ($this->_current_token == ">") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgGT', $result, $result2);
		} elseif ($this->_current_token == "<=") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgLE', $result, $result2);
		} elseif ($this->_current_token == ">=") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgGE', $result, $result2);
		} elseif ($this->_current_token == "=") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgEQ', $result, $result2);
		} elseif ($this->_current_token == "<>") {
			$this->_advance();
			$result2 = $this->_expression();
			$result = $this->_createTree('ptgNE', $result, $result2);
		} elseif ($this->_current_token == "&") {
		    $this->_advance();
		    $result2 = $this->_expression();
		    $result = $this->_createTree('ptgConcat', $result, $result2);
		}
		return $result;
	}
896801
function rules () {
        var pub = {};
        pub.maxLength = function (val, max) {

            if (!Array.isArray(val) && typeof val !== 'string' || typeof max !== 'number') {
                return getResult(new Error('rules.maxLength(fail): value must be a string or array, max must be a number'));
            }

            if (val.length > max) {
                return getResult(getError('maxLength', max, val));
            }

            return getResult(null);
        };
        pub.minLength = function (val, min) {

            if (!Array.isArray(val) && typeof val !== 'string' || typeof min !== 'number') {
                return getResult(new Error('rules.minLength(fail): value must be a string or array, min must be a number'));
            }

            if (val.length < min) {
                return getResult(getError('minLength', min, val));
            }

            return getResult(null);
        };
        pub.minimum = function (val, min) {

            if (typeof val !== 'number' || typeof min !== 'number') {
                return getResult(new Error('rules.minimum(fail): value must be a number, min must be a number'));
            }

            if (val < min) {
                return getResult(getError('minimum', min, val));
            }

            return getResult(null);
        };
        pub.maximum = function (val, max) {

            if (typeof val !== 'number' || typeof max !== 'number') {
                return getResult(new Error('rules.maximum(fail): value must be a number, max must be a number'));
            }

            if (val > max) {
                return getResult(getError('maximum', max, val));
            }

            return getResult(null);
        };
        pub.exclusiveMinimum = function (val, min) {

            if (typeof val !== 'number' || typeof min !== 'number') {
                return getResult(new Error('rules.exclusiveMinimum(fail): value must be a number, min must be a number'));
            }

            if (val <= min) {
                return getResult(getError('exclusiveMinimum', min, val));
            }

            return getResult(null);
        };
        pub.exclusiveMaximum = function (val, max) {

            if (typeof val !== 'number' || typeof max !== 'number') {
                return getResult(new Error('rules.exclusiveMaximum(fail): value must be a number, max must be a number'));
            }

            if (val >= max) {
                return getResult(getError('exclusiveMinimum', max, val));
            }

            return getResult(null);
        };
        pub.divisibleBy = function (val, div) {

            if (typeof val !== 'number' || typeof div !== 'number') {
                return getResult(new Error('rules.divisibleBy(fail): value must be a number, div must be a number'));
            }

            var multiplier = Math.max((val - Math.floor(val)).toString().length - 2,
                (div - Math.floor(div)).toString().length - 2);
            multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;

            if ((val * multiplier) % (div * multiplier) !== 0) {
                return getResult(getError('divisibleBy', div, val));
            }

            return getResult(null);
        };
        pub.minItems = function (val, min) {

            if (!Array.isArray(val) || typeof min !== 'number') {
                return getResult(new Error('rules.minItems(fail): value must be a array, min must be a number'));
            }

            if (val.length < min) {
                return getResult(getError('minItems', min, val.length));
            }

            return getResult(null);
        };
        pub.maxItems = function (val, max) {

            if (!Array.isArray(val) || typeof max !== 'number') {
                return getResult(new Error('rules.maxItems(fail): value must be a array, max must be a number'));
            }

            if (val.length > max) {
                return getResult(getError('maxItems', max, val.length));
            }

            return getResult(null);
        };
        pub.uniqueItems = function (val) {

            if (!Array.isArray(val)) {
                return getResult(new Error('rules.uniqueItems(fail): value must be a array'));
            }

            if (!(uniqueArrayHelper(val))) {
                return getResult(getError('uniqueItems', val, true));
            }

            return getResult(null);
        };
        pub['enum'] = function (val, en) {

            if (typeof val === 'undefined' || !Array.isArray(en)) {
                return getResult(new Error('rules.enum(fail): value must be a defined and enum mus be a array'));
            }

            if (en.indexOf(val) === -1) {
                return getResult(getError('enum', en, val));
            }

            return getResult(null);
        };

        return pub;
    }
497828
function (elements, rule, type) {
            var foundElements = [];
            // The length is a special case, where the placeholders
            // of the search pattern (X,Y) first must be replaced by
            // the value(s) specified in the attribute.
            if (type === "length") {
                for (var i = 0; i < elements.length; i++) {
                    // Length attribute is not a substitute for the
                    // required attribute. Length just states what
                    // min/max-length an element should have, if it
                    // is filled in.
                    if (elements[i].value === "")
                        continue;
                    var length = elements[i].getAttribute("data-length");
                    var format = elements[i].getAttribute("data-format");
                    // Format can be either max or min. The length
                    // attribute combined with the format attribute
                    // must only contain one digit for it to be
                    // considered valid.
                    if (format === "max") {
                        if (/^([0-9]$)/.test(length))
                            var string = new RegExp(rule.replace("X,Y", "0," + length));
                        else
                            continue;
                    } else if (format === "min") {
                        if (/^([0-9]$)/.test(length))
                            var string = new RegExp(rule.replace("X,Y", length + ","));
                        else
                            continue
                    } else {
                        // Even if a format attribute is not set, the validation
                        // of the element should differ, depending on how the
                        // length attribute is set up.
                        if (/^([0-9]\,[0-9]$)/.test(length))
                            // Normal case, a max and min is specified ("1,5").
                            var string = new RegExp(rule.replace("X,Y", length));
                        else if (/^([0-9]\,$)/.test(length))
                            // A single digit with a comma at the end is to be
                            // considered minimum length ("1,")
                            var string = new RegExp(rule.replace("X,Y", length));
                        else if (/^([0-9]$)/.test(length))
                            // A single digit without a comma should be treated
                            // as max length, but for the regex to work a zero
                            // needs to be added at the beginning. ("5") => ("0,5")
                            var string = new RegExp(rule.replace("X,Y", "0," + length));
                        else
                            // If none of the above checks out it is not a valid
                            // value, skip this one and move to the next.
                            continue;
                    }
                    if (string.test(elements[i].value) === false)
                        foundElements.push(elements[i]);
                }
            } else if (type === "date") {
                // Date is also a special case, where the regex pattern
                // needs to be build depending on the format specified.
                // The date delimiter can be almost any non-word
                // character, therefore the regex pattern \W.
                var delimiterPattern = new RegExp(/([\W])/), delimiterMatches;
                for (var i = 0; i < elements.length; i++) {
                    var elementValue = elements[i].value;
                    if (elementValue.length < 1)
                        continue;
                    // Retrieve the date format from the element
                    var format = elements[i].getAttribute("data-format");
                    if (format === null)
                        format = this.settings.dateFormat;
                    if ((delimiterMatches = delimiterPattern.exec(format)) !== null) {
                        var dateComponents = format.split(delimiterMatches[0]);
                        var dateBrokenDown = elementValue.split(delimiterMatches[0]);
                        var date = [];
                        // Begin building the date pattern
                        var validDatePattern = "^(";
                        for (var x = 0; x < dateComponents.length; x++) {
                            // Create an array out of the components and inputed date
                            // for later use, to make sure that it is an actual date.
                            var key = dateComponents[x][0].toUpperCase();
                            date[key] = dateBrokenDown[x];
                            // Dates and months should have an interval-length,
                            // so that if they are set to max 2 digits (MM) the
                            // user should not have to write a leading zero, as
                            // this often isn't how date parsers read a date.
                            if (key !== "Y")
                                var length = "1," + dateComponents[x].length;
                            else
                                var length = dateComponents[x].length;
                            validDatePattern += "\\d{" + length + "}";
                            // Add the delimiter, but not to the last digit.
                            if (dateComponents.length > x+1)
                                validDatePattern += "\\" + delimiterMatches[0];
                        }
                        // Close the date pattern.
                        validDatePattern += ")$";
                        var validDate = new RegExp(validDatePattern);
                        if (validDate.test(elementValue) === false) {
                            foundElements.push(elements[i]);
                        } else {
                            // Even if the date has the right format, it may not be an
                            // actual date. This will make sure that the date exists.
                            // The year must be four digits, so add the first two digits
                            // if they are missing.
                            if (date["Y"].length == 2)
                                date["Y"] = new Date().getFullYear().toString().substr(0,2) + date["Y"];
                            // Also, remove 0 if month and date begins with one.
                            date["M"] = date["M"].replace(/^0/, '');
                            date["D"] = date["D"].replace(/^0/, '');
                            // Create the date object, and retrieve the individual
                            // components to compare it to the inputed date. If the
                            // date is wrong, the parsed date will not be the same
                            // as the user inputed one (JS will parse for example
                            // 31st of february as a valid date).
                            var dateObject = new Date(date["Y"], (date["M"]-1), date["D"]);
                            var dateParsed = dateObject.getFullYear() +''+ (dateObject.getMonth()+1) +''+ dateObject.getDate();
                            var dateString = date["Y"] +''+ date["M"] +''+ date["D"];
                            if (dateParsed !== dateString)
                                foundElements.push(elements[i]);
                        }
                    }
                }
            } else {
                var string = new RegExp(rule);
                for (var i = 0; i < elements.length; i++) {
                    if (string.test(elements[i].value) === false) {
                        if (type === "required" ||
                            type !== "required" && elements[i].value.length > 0)
                            foundElements.push(elements[i]);
                    }

                }

            }
            return foundElements;
        }