public static function prepareVariableForJavascript($string, $asObject) {
		if ($asObject) {
			$string = str_replace(array(
				'"', '/', '<', "\n", "\r"
			), array(
				'\"', '\/', '\<', '<br />', ''
			), $string);
		} else {
			$string = str_replace(array(
				'"', '/', '<', "\n", "\r"
		  ), array(
				'\"', '\/', '\<', '', ''
			), $string);
		}

		return $string;
	}
public static function prepareVariableForJavascript($string, $asObject) {
		if ($asObject) {
			$string = str_replace(array(
				'"', '/', '<', "\n", "\r"
			), array(
				'\"', '\/', '\<', '<br />', ''
			), $string);
		} else {
			$string = str_replace(array(
				'"', '/', '<', "\n", "\r"
		  ), array(
				'\"', '\/', '\<', '', ''
			), $string);
		}

		return $string;
	}
public static function prepareVariableForJavascript ( $ string , $ asObject ) { if ( $ asObject ) { $ string = str_replace ( array ( '"' , '/' , '<' , "\n" , "\r" ) , array ( '\"' , '\/' , '\<' , '<br />' , '' ) , $ string ) ; } else { $ string = str_replace ( array ( '"' , '/' , '<' , "\n" , "\r" ) , array ( '\"' , '\/' , '\<' , '' , '' ) , $ string ) ; } return $ string ; }
Replaces special characters for the usage inside javascript

@param string $string
@param boolean $asObject
@return string
Replaces special characters for the usage inside javascript