// -----------------------------------------------------------------------------
// $Overflow fix
// -----------------------------------------------------------------------------

@mixin overflow_fix() {
	$png_fix: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC";
	-webkit-mask-image: url( #{$png_fix} );
}

// -----------------------------------------------------------------------------
// $Transitions with prefix support
// -----------------------------------------------------------------------------

@function prefix($property, $prefixes: (webkit moz o ms)) {
	$vendor-prefixed-properties: transform background-clip background-size;
	$result: ();
	@each $prefix in $prefixes {
	   @if index($vendor-prefixed-properties, $property) {
		 $property: -#{$prefix}-#{$property}
	   }
	   $result: append($result, $property);
	}
	@return $result;
}

@function trans-prefix($transition, $prefix: moz) {
	$prefixed: ();
	@each $trans in $transition {
		$prop-name: nth($trans, 1);
		$vendor-prop-name: prefix($prop-name, $prefix);
		$prop-vals: nth($trans, 2);
		$prefixed: append($prefixed, ($vendor-prop-name $prop-vals), comma);
	}

	@return $prefixed;
}

@mixin ev-transition($values...) {
	$transitions: ();
	@each $declaration in $values {
		$prop: nth($declaration, 1);
		$prop-opts: ();
		$length: length($declaration);
		@for $i from 2 through $length {
			$prop-opts: append($prop-opts, nth($declaration, $i));
		}
		$trans: ($prop, $prop-opts);
		$transitions: append($transitions, $trans, comma);
	}

	-webkit-transition: trans-prefix($transitions, webkit);
	-moz-transition: trans-prefix($transitions, moz);
	-o-transition: trans-prefix($transitions, o);
	transition: $values;
}

// -----------------------------------------------------------------------------
// $FLUID GRID SYSTEM
// -----------------------------------------------------------------------------
// Return the column size value
// -----------------------------------------------------------------------------
// Specify only the column ratio i.e. 1/3
@function _ev_col( $size ) {
	 @return $size*100%;
}

// -----------------------------------------------------------------------------
// $FIXED GRID SYSTEM
// -----------------------------------------------------------------------------
// Return the dimension of the column without gutter
// -----------------------------------------------------------------------------
@function _ev_fixed_col( $size ) {
   @return $size * $container;
}

// -----------------------------------------------------------------------------
// $Check if a variable is a map
// -----------------------------------------------------------------------------
@function ev-is-map( $var ) {
	@return type-of( $var ) == 'map';
}

// -----------------------------------------------------------------------------
// $Replace a character in a string
// -----------------------------------------------------------------------------
@function ev-str-replace($string, $search, $replace: '') {
  $index: str-index($string, $search);

  @if $index {
	@return str-slice($string, 1, $index - 1) + $replace + ev-str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
  }

  @return $string;
}

// -----------------------------------------------------------------------------
// $Split a string
// @return list
// -----------------------------------------------------------------------------
@function ev-str-split($string, $separator) {
	// empty array/list
	$split-arr: ();
	// first index of separator in string
	$index : str-index($string, $separator);
	// loop through string
	@while $index != null {
		// get the substring from the first character to the separator
		$item: str-slice($string, 1, $index - 1);
		// push item to array
		$split-arr: append($split-arr, $item);
		// remove item and separator from string
		$string: str-slice($string, $index + 1);
		// find new index of separator
		$index : str-index($string, $separator);
	}
	// add the remaining string to list (the last item)
	$split-arr: append($split-arr, $string);

	@return $split-arr;
}
