<?php
	if (!function_exists('debug')) {
		
		function debug($structure=null, $html=true) {
			
			global $config;
			
			if ($config['settings']['debug']) {
			
				$nl = !$html ? "\n" : "<br>";
				
				if (is_array($structure) || is_object($structure)) {
					
					if (!$html) {
						print "\n"; print_r($structure);
					} else {
						print '<pre>'; print_r($structure); print '</pre>';
					}
					
					return;
				}
				
				if (is_bool($structure)) {
					echo $structure === true ? "\n".'Bool: true'.$nl : "\n".'Bool: false'.$nl;
					return;
				}
				
				if (is_numeric($structure)) {
					echo "\n".'Numeric: ', $structure.$nl;
					return;
				}
				
				if (is_string($structure)) {
					echo "\n".'String: ', $structure.$nl;
					return;
				}
				
				if (is_null($structure)) {
					echo "null\n";
					return;
				}
				
				echo "\n".$structure;
			
			} else {
				return null;
			}
			
		} //function
	} //if
	
	function _t($textId) {
		//return utf8_encode(_($textId));
	}
	
	function leadingZeros($number) {
		return (int)$number<10 ? "0$number" : $number;
	}
	
	function optionSelected($value) {
		if ($value === true) return 'selected="selected"';
		return null;
	}