<?

function compile($files, $filename=false) {
$tempFileName = $filename?$filename:$files;

$split = split(",", $files);
$js = "";

foreach ($split as $file) {
	if (!strstr(".", $file)) {
	$js .= file_get_contents("_src/".$file);
	$js .= "\r\n\r\n";
	}
}
$js = ereg_replace(" {2,}", " ", $js);
$js = str_replace("\t", "", $js);
$js = str_replace(" = ", "=", $js);
$js = str_replace("; ", ";", $js);
$js = str_replace(" != ", "!=", $js);
$js = str_replace(" == ", "==", $js);
$js = str_replace(") {", "){", $js);
$js = str_replace("if (", "if(", $js);
$js = str_replace("} else {", "}else{", $js);
$js = str_replace(" . ", ".", $js);
$js = ereg_replace("(\r\n){2,}", "\r\n", $js);
/* sterge enterurile de dupa ; numai cand dupa urmeaza litera nu semn, gen paranteza*/
$js = preg_replace("/;\r\n(\w+)/", ";\\1", $js);

$fp = fopen("compiled/".$tempFileName, "w");
fwrite($fp, $js);
fclose($fp);

echo "Compiled: /js/_src/".$filename;
echo "<br>";

}



compile('misc.js,interface.js,afian.js,build_icon.js,build_list.js,build_thumb.js,myfiles.js,trash.js,search.js,tree.js,dom-drag.js,hidelements.js,myshares.js,browseshare.js,admin_groups.js,admin_users.js,browsezip.js', "all.js");
compile('misc.js,interface.js,tree.js,dom-drag.js,hidelements.js', "for_tree_browser.js");
compile('misc.js,interface.js,dom-drag.js,hidelements.js', "for_popups.js");
compile('misc.js');
?>