// Standard functions copied from Dreamweaver
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { nm="\""+args[i+1]+"\""; test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

///////////////////////////////////////////////////////////////////////////////////////////////
function njaru_get_microtime(){
	var d = new Date();
	return (((d.getHours() * 60 + d.getMinutes()) * 60 + d.getSeconds()) * 1000 + d.getMilliseconds());
}
var iDebugTimeStartAt = 0;
var sDebugTimeString = "";
function njaru_debugtime_start(){
	iDebugTimeStartAt = njaru_get_microtime();
	sDebugTimeString = "**START: " + iDebugTimeStartAt.toString() + "\r\n";;
}
function njaru_debugtime_point(pointid){
	var t = njaru_get_microtime();
	sDebugTimeString = sDebugTimeString + pointid.toString() + ": " + t.toString() + " - " + (t - iDebugTimeStartAt).toString() + "ms\r\n";
}
function njaru_debugtime_end(){
	njaru_debugtime_point("**END");
	alert(sDebugTimeString);
	sDebugTimeString = "";
}
function njaru_str_valid(str,charset){
	var result = true;
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0){ result = false; break; }
	return result;
}
function njaru_str_filter(str, fltr, remove_keep){ // remove_keep=0: Keep, remove_keep = 1: Remove
	var i, l, chr, fnd, result;
	l = str.length;
	result = "";
	for (i = 0; i < l; i++){
		chr = str.substr(i, 1);
		fnd = fltr.indexOf(chr);
		if (remove_keep == 1){ // remove if found
			if (fnd < 0) result = result + chr;
		}else{ // keep if found
			if (fnd >= 0) result = result + chr;
		}
	}
	return result;
}
function njaru_url_decode(val){ return unescape(val); }
function njaru_url_encode(val){
	var len; if (val == undefined || val == null){ len = 0; }else{ len = val.toString().length; }
	var i = 0;
	var t, ret = "";
	for (i=0; i<len; i++) {
		t = val.substring(i, i+1);
		if (njaru_url_is_valid_char(t)){ ret = ret + t; }
		else if (t == " "){ ret = ret + "+"; }
		else{ ret = ret + "%" + njaru_dec_2_hex(t.charCodeAt(0), 16); }
	}
	return ret;
}
function njaru_url_is_valid_char(chr_compare){
	var str_unsafe = "-_.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	return (str_unsafe.indexOf(chr_compare) != -1);
}
function njaru_dec_2_hex(num, radix){
	var array_hex_vals = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
	var loc, ret = "";
	while (num >= radix){
		loc = num % radix;
		num = Math.floor(num / radix);
		ret += array_hex_vals[loc];
	}
	ret += array_hex_vals[num];
	return njaru_string_reverse(ret);
}
function njaru_string_reverse(s){
	var len = s.length;
	var ret = "";
	for (i=0; i<len; i++){ ret = ret + s.substring(len-i-1, len-i); }
	return ret;
}
function njaru_array_to_string(arr){
	var ret = "", i, l = arr.length;
	for (i = 0; i < l; i++){
		if (ret != "") ret = ret + ", ";
		ret = ret + "" + arr[i];
	}
	return ret;
}
function njaru_format_currency(fPrice){
	var ret,i,j,k,s;
	ret="";
	i=Math.floor(fPrice);
	j=Math.round((fPrice-i)*100)/100;
	s=""+i;
	for(k=s.length-1;k>-3;k-=3){
		ret=s.substring(k-2,k+1)+","+ret;
	}
	while(ret.substring(0,1)==","){ ret=ret.substring(1,ret.length-1); }
	while(ret.substring(ret.length-1,ret.length)==","){ ret=ret.substring(0,ret.length-1); }
	if(j>0){
		s=""+j+"0000";
		ret="$"+ret+"."+s.substring(2,4);
	}else{
		ret="$"+ret+".00";
	}
	return ret;
}
// validate the credit card number
// parameter:
//     1: string, card number to be validated, required
//     2: string, card type
//     3: boolean, if alert the error message
function njaru_check_credit_card(){
	var argv = njaru_check_credit_card.arguments;
	var argc = njaru_check_credit_card.arguments.length;
	var validation_rules = new Array();
	validation_rules[0] = {name: "Visa", length: "13,16", prefixes: "4", checkdigit: true};
	validation_rules[1] = {name: "MasterCard", length: "16", prefixes: "51,52,53,54,55", checkdigit: true};
	validation_rules[2] = {name: "DinersClub", length: "14,", prefixes: "300,301,302,303,304,305,36,38", checkdigit: true};
	validation_rules[3] = {name: "CarteBlanche", length: "14", prefixes: "300,301,302,303,304,305,36,38", checkdigit: true};
	validation_rules[4] = {name: "AmEx", length: "15", prefixes: "34,37", checkdigit: true};
	validation_rules[5] = {name: "Discover", length: "16", prefixes: "6011", checkdigit: true};
	validation_rules[6] = {name: "JCB", length: "16", prefixes: "3", checkdigit: true};
	validation_rules[7] = {name: "JCB", length: "15", prefixes: "1800,2131", checkdigit: true};
	validation_rules[8] = {name: "Enroute", length: "15", prefixes: "2014,2149", checkdigit: false};

	this.CardNumber = (argc > 0) ? argv[0] : "";
	this.CardType = (argc > 1) ? argv[1] : "";

	this._checkprefix = function (sprefixes, cm){
		var arr_prefix = sprefixes.split(","), ret = false;
		for (var i = 0; i < arr_prefix.length; i++){
			var exp = new RegExp ("^" + arr_prefix[i]);
			if (exp.test(cm)) ret = true;
		}
		return ret;
	}
	this._checklength = function (slength, cm){
		var arr_length = slength.split(","), l = cm.length, ret = false;
		for (var i = 0; i < arr_length.length; i++){
			if (parseInt(arr_length[i], 10) == l) ret = true;
		}
		return ret;
	}
	this._checkluhn = function (cm){
		var checksum = 0;	// running checksum total
		var j = 1;			// takes value of 1 or 2
		var calc;
		for (i = cm.length - 1; i >= 0; i--) {
			calc = Number(cm.charAt(i)) * j;
			if (calc > 9) {
				checksum = checksum + 1;
				calc = calc - 10;
			}
			checksum = checksum + calc;
			if (j == 1) {j = 2} else {j = 1};
		} 
		return (checksum % 10 == 0);
	}
	this.Validate = function (){
		var argv = arguments;
		var argc = arguments.length;
		this.CardNumber = (argc > 0) ? argv[0] : "";
		this.CardType = (argc > 1) ? argv[1] : "";
		var i, bOK = true;
		if (this.CardNumber.length == 0) bOK = false;
		if (bOK && !njaru_str_valid(this.CardNumber, "0123456789 ")) bOK = false;
		if (bOK){
			this.CardNumber = this.CardNumber.replace(/ /g, "");
			bOK = false;
			for (i = 0; i < validation_rules.length && !bOK; i++){
				if ((this.CardType == "") || (this.CardType.toLowerCase() == validation_rules[i].name.toLowerCase())){
				if (this._checklength(validation_rules[i].length, this.CardNumber)){
				if (this._checkprefix(validation_rules[i].prefixes, this.CardNumber)){
				if (validation_rules[i].checkdigit){
					if (this._checkluhn(this.CardNumber)){
						bOK = true;
						if (this.CardType == "") this.CardType = validation_rules[i].name;
					}
				}else{
					bOK = true;
					if (this.CardType == "") this.CardType = validation_rules[i].name;
				} } } }
			}
		}
		return bOK;
	}
}
// insert a character at the specific location
// parameter:
//     sText (string): the base string
//     iLoc (integer): the location to insert
//     sChar (string): the string to insert
// return: string
function njaru_text_insertat(sText, iLoc, sChar){
	var l = sText.length;
	if (iLoc > l + 1) iLoc = 0;
	var s1 = sText.substr(0, l - iLoc);
	var s2 = sText.substr(l - iLoc);
	return (s1+sChar+s2);
}
function njaru_get_keycode(evnt){
	if (typeof(evnt.which) != 'undefined') return evnt.which;
	else return evnt.keyCode;
}
function njaru_get_parent_object(obj, parentTag){
	var x = obj, i = 0;
	while(x.tagName != parentTag && i < 100){ x = x.parentElement; i++; }
	return x;
}
function njaru_get_object_left(e){
	var l=e.offsetLeft;
	while(e=e.offsetParent) l+=e.offsetLeft;
	return l;
}
function njaru_get_object_top(e){
	var t=e.offsetTop;
	while(e=e.offsetParent) t+=e.offsetTop;
	return t;
}
function njaru_get_cursor_location(){
	var r = document.selection.createRange();
	var x = r.moveStart("character", 999);
	return x;
}
function njaru_resize_image(objImage, iWidth, iHeight){
	var r1, r2, w, h;
	if (''+objImage.readyState=="complete" || (''+objImage.readyState=="undefined" && objImage.complete)){
		w = objImage.width;
		h = objImage.height;
		if (w > 0 && h > 0){
			//alert(objImage.id + ' = ' + w + ':' + h);
			if (w > iWidth || h > iHeight){
				r1 = w / iWidth;
				r2 = h / iHeight;
				if (r1 > r2){
					objImage.width = iWidth;
					//objImage.height = h / r1;
				}else{
					//objImage.width = w / r2;
					objImage.height = iHeight;
				}
			}
			objImage.id=objImage.id.replace("__njaru_auto", "__njaru_done");
		}
	}
}
var njaru_auto_resize_image_timeout_id;
njaru_auto_resize_image_timeout_id = 0;
function njaru_auto_resize_image(){
	var i, iIdCount, imgid, sz, asz;
	iIdCount = 0;
	for(i=0; i<document.images.length; i++){
		imgid = document.images[i].id;
		if(imgid.substr(0, 26) == "__njaru_auto_resize_image_"){
			sz = imgid.substr(26);
			asz = sz.split("_");
			if (asz.length >= 2){
				njaru_resize_image(document.images[i], parseInt("0"+asz[0], 10), parseInt("0"+asz[1], 10));
				iIdCount++;
			}
		}
	}
	if (iIdCount > 0){
		njaru_auto_resize_image_timeout_id = window.setTimeout("njaru_auto_resize_image()", 1000);
	}else{
		if (njaru_auto_resize_image_timeout_id != 0) window.clearTimeout(njaru_auto_resize_image_timeout_id);
	}
}
// open a dhtml popup window
// parameter:
//     u: (string) url string
//     t: (string) window title
//     w: (integer) window width
//     h: (integer) window height
//     xdp: (string) extra window property except width/height
// return: array of form object matched
var njaru_popup_window;
function njaru_open_popup_window(u, t, w, h, xdp){
	var dp = ",center=1,resize=1,scrolling=0";
	if (xdp != undefined) dp = xdp;

	if (njaru_popup_window){
		njaru_popup_window.load("iframe", u, t);
		njaru_popup_window.show();
		njaru_popup_window.setSize(w, h);
		njaru_popup_window.moveTo('middle', 'middle');
	}else{
		njaru_popup_window = dhtmlmodal.open("njaru_popup_window_name", "iframe", u, t, "width="+w+"px,height="+h+"px"+dp);
	}
}
// get the form object array from a form
// parameter:
//     f: the form object
//     n: (string) the name of object want to find
// return: array of form object matched
function njaru_get_form_object(f, n){
	var fo;
	if (typeof(f) == "string") fo = MM_findObj(f);
	else fo = f;
	var i, objlist = new Array();
	if (fo){ for (i = 0; i < fo.length; i++){
		if (fo[i].name == n || fo[i].name == n+'[]') objlist.push(fo[i]);
	}}
	return objlist;
}
// get the form object value from the array got
// parameter:
//     objlist: the form object list returned by njaru_get_form_object
// return: the value list (if more than one selected, maybe return a value sperated by comma)
function njaru_get_form_object_value(objlist){
	var i, j, l = objlist.length, ret = null;
	for (i = 0; i < l; i++){
		switch(objlist[i].type){
			case "radio": case "checkbox":
				if (objlist[i].checked){
					if (ret == null) ret = objlist[i].value.toString();
					else ret += "," + objlist[i].value.toString();
				}
				break;
			case "select-one":
			case "select-multiple":
				for (j = 0; j < objlist[i].options.length; j++){
					if (objlist[i].options[j].selected){
						if (ret == null) ret = objlist[i].options[j].value.toString();
						else ret += "," + objlist[i].options[j].value.toString();
					}
				}
				break;
			case "text": case "hidden": case "textarea": case "password":
				if (ret == null) ret = objlist[i].value.toString();
				else ret += "," + objlist[i].value.toString();
				break;
		}
	}
	return ret;
}
// set the form object from the array got to a new value
// parameter:
//     objlist: the form object list returned by njaru_get_form_object
//     v: the new value
function njaru_set_form_object_value(objlist, v){
	var i, j, l = objlist.length;
	for (i = 0; i < l; i++){
		switch(objlist[i].type){
			case "radio": case "checkbox":
				objlist[i].checked = (objlist[i].value.toString() == v);
				break;
			case "select-one":
			case "select-multiple":
				for (j = 0; j < objlist[i].options.length; j++){
					objlist[i].options[j].selected = (objlist[i].options[j].value.toString() == v);
				}
				break;
			case "text": case "hidden": case "textarea": case "password":
				objlist[i].value = v;
				break;
		}
	}
}
// the below 2 functions are combine the action of get object and their value
function njaru_fastget_form_object_value(f, n){
	var o = njaru_get_form_object(f, n);
	return njaru_get_form_object_value(o);
}
function njaru_fastset_form_object_value(f, n, v){
	var o = njaru_get_form_object(f, n);
	njaru_set_form_object_value(o, v)
}
// get the value from a form object
//     potential problem, if obj name is duplicated in the document, it will return un-predicted value
// parameter:
//     obj: the form object
// return: string of value
function njaru_get_object_value(obj){
	if(obj != undefined){
		var otype,  val = "", val_count = 0;
		if (obj.length != undefined) otype = obj[0].type;
		if (otype == null) otype = obj.type;
		switch(otype){
			case 'radio': case 'checkbox':
				if (obj.length != undefined){
					for (var i=0;i<obj.length;i++) {
						if (obj[i].checked){
							if (val != "") val += ",";
							val += obj[i].value;
							val_count++;
						}
					}
					return (val_count==0)?null:val;
				}
				return ((obj.checked)?obj.value:null);
			case 'text': case 'hidden': case 'textarea': case 'password':
				if (obj.length != undefined){
					for (var i=0;i<obj.length;i++) {
						if (val != "") val += ",";
						val += obj[i].value;
						val_count++;
					}
					return (val_count==0)?null:val;
				}
				return obj.value;
			case 'select-one':
				if (obj.options==null) { return null; }
				if (obj.selectedIndex<0){ return null; }
				return (obj.options.length>0)?obj.options[obj.selectedIndex].value:null;
			case 'select-multiple': 
				if (obj.options==null) { return null; }
				for(var i=0;i<obj.options.length;i++) {
					if(obj.options[i].selected){
						if (val != "") val += ",";
						val += obj.options[i].value;
						val_count++;
					}
				}
				return (val_count==0)?null:val;
		}
	}
	return null;
}

function njaru_set_rowcolor(theRow, thePointerColor){
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') return false;
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }else {
        return false;
    }
    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }
    return true;
}

// --- display a tree based on an array
// 
function njaru_tree_node(){
	this.id = 0;
	this.title = "";
	this.pid = 0;
	this.level = 0;
	this.hasson = false;
}
function njaru_tree(){
	this.variable = "";			// the name of the object njaru_tree instance
	this.name = "";				// the name of the tree
	this.value = "";			// the initial value of the tree
	this.exception = "";		// id list seperated by ",", all nodes under these id will not be displayed
	this.data = new Array();	// the node array: njaru_tree_node
	// template, which will be displayed before the title
	// available template variabls: {{id}}, {{title}}, {{name}}, {{checked}}
	this.default_template_normal = "&nbsp;{{title}}";
	this.default_template_checkbox = "<input type=\"checkbox\" name=\"{{name}}\" value=\"{{id}}\"{{checked}}>&nbsp;{{title}}";
	this.default_template_radio = "<input type=\"radio\" name=\"{{name}}\" value=\"{{id}}\"{{checked}}>&nbsp;{{title}}";
	this.template_normal = this.default_template_normal;
	this.template_lastlevel = this.default_template_normal;
	
	this.expandall = false;
	this.image_minus = "libs/core/common/tree_minus.gif";
	this.image_plus = "libs/core/common/tree_plus.gif";
	this.image_bullet = "libs/core/common/tree_bullet.gif";
	this.style_table = "border='0' cellspacing='1' cellpadding='0'";
	this.style_text = "style='font-family: Tahoma; font-size: 8pt;' nowrap";
	this.style_indent = "<img src='libs/core/common/e.gif' height=1 width='10'>";
	
	this._create_name = function (){
		this.name = "__njaru_tree_" + Math.round(Math.random() * 100000000);
	}
	// add a new node
	this.add = function (_id, _title, _pid){
		var _obj_new_node;
		_obj_new_node = new njaru_tree_node;
		_obj_new_node.id = _id;
		_obj_new_node.title = _title;
		_obj_new_node.pid = _pid;
		this.data.push(_obj_new_node);
	}
	// calculate level/hasson/childs properties
	this.rebuild = function (_pid, _level){
		var obj_node, i, l, i_son_count = 0, ret = 0;
		if (this.name == "") this._create_name();
		if (_pid == undefined || _level == undefined){ _pid = 0; _level = 0; }
		l = this.data.length;
		for (i = 0; i < l; i++){
			if (this.data[i].pid == _pid){
				i_son_count = this.rebuild(this.data[i].id, _level + 1);
				this.data[i].level = _level;
				this.data[i].hasson = (i_son_count > 0);
				ret ++;
			}
		}
		return ret;
	}
	this.show = function (_pid, _hidetable){
		if (_pid == undefined) _pid = 0;
		if (_hidetable == undefined) _hidetable = false;
		var i, j, l, ret = "", stext;
		l = this.data.length;
		ret = "<table id='__" + this.name + "_table_" + _pid + "' " + (_hidetable?" style='position: absolute; visibility: hidden'":"") + this.style_table + ">";
		for (i = 0; i < l; i++){
			if (this.data[i].pid == _pid){ if ((","+this.exception+",").indexOf(","+this.data[i].id+",") == -1){
				ret = ret + "<tr><td>";
				ret = ret + "<table border='0' cellspacing='0' cellpadding='0'>\r\n";
				ret = ret + "\t<tr>\r\n";
				for (j = 0; j < this.data[i].level; j++){
					ret = ret + "\t\t<td>" + this.style_indent + "</td>\r\n";
				}
				ret = ret + "\t\t<td>";
				if (this.data[i].hasson){
					if (this.expandall) ret = ret + "<img src='" + this.image_minus + "' width='9' height='9' style='cursor: pointer;' onclick='" + this.variable + ".expand(this, " + this.data[i].id + ");'>";
					else ret = ret + "<img src='" + this.image_plus + "' width='9' height='9' style='cursor: pointer;' onclick='" + this.variable + ".expand(this, " + this.data[i].id + ");'>";
				}else ret = ret + "<img src='" + this.image_bullet + "' width='9' height='9'>";
				ret = ret + "</td>\r\n\t\t<td " + this.style_text + ">";
				if (this.data[i].hasson) stext = this.template_normal;
				else stext = this.template_lastlevel;
				stext = stext.replace(/\{\{id\}\}/, this.data[i].id);
				stext = stext.replace(/\{\{title\}\}/, this.data[i].title);
				stext = stext.replace(/\{\{name\}\}/, this.name);
				stext = stext.replace(/\{\{checked\}\}/, (((","+this.value+",").indexOf(","+this.data[i].id+",") != -1)?" checked":""));
				ret = ret + stext + "</td>\r\n\t</tr>\r\n";
				ret = ret + "</table>\r\n";
				if (this.data[i].hasson) ret = ret + this.show(this.data[i].id, !this.expandall);
				ret = ret + "</td></tr>";
			} }
		}
		ret = ret + "</table>";
		//if (_pid == 0) alert(ret);
		return ret;
	}
	this.expand = function (_obj_img, _id){
		var oTable;
		oTable = MM_findObj("__" + this.name + "_table_" + _id);
		if (_obj_img.src.indexOf(this.image_minus) == -1){ // not minus image, means not expanded
			oTable.style.position = "static";
			oTable.style.visibility = "inherit";
			_obj_img.src = this.image_minus;
		}else{ // is minus image, means expanded
			oTable.style.position = "absolute";
			oTable.style.visibility = "hidden";
			_obj_img.src = this.image_plus;
		}
	}
	this.checkall = function (v){
		var i, l, o;
		l = document.all || document.getElementsByTagName('*');
		for (i = 0, o; o = l[i++]; ){
			if (o.name == this.name) o.checked = v;
		}
	}
	this.debug = function (){
		var i, l, ret = "";
		ret = ret + "name=" + this.name + "\r\n"
		ret = ret + "variable=" + this.variable + "\r\n"
		ret = ret + "template_normal=" + this.template_normal + "\r\n"
		ret = ret + "template_lastlevel=" + this.template_lastlevel + "\r\n"
		ret = ret + "expandall=" + this.expandall + "\r\n"
		l = this.data.length;
		for (i = 0; i < l; i++){
			ret = ret + "" + i + ".";
			ret = ret + " id=" + this.data[i].id;
			ret = ret + " title=" + this.data[i].title;
			ret = ret + " pid=" + this.data[i].pid;
			ret = ret + " level=" + this.data[i].level;
			ret = ret + " hasson=" + this.data[i].hasson;
			ret = ret + "\r\n";
		}
		alert(ret);
	}
}


// ------------------------------------------------------------------
// Function to convert date format
//   php  mattkruse               php  mattkruse
//    a => a                       i => mm
//    A => a                       j => d
//    d => dd                      l => EE
//    D => E                       m => MM
//    F => MMM                     M => NNN
//    g => h                       n => M
//    G => H                       s => ss
//    h => hh                      Y => yyyy
//    H => HH                      y => yy
// Last Edit: 06/24/2005
// ------------------------------------------------------------------
function njaru_convert_php_date_format_2_mattkruse(old_format){
	var ret = old_format;
	ret = ret.replace(/A/g, "a");
	ret = ret.replace(/d/g, "dd");
	ret = ret.replace(/D/g, "E");
	ret = ret.replace(/h/g, "hh");
	ret = ret.replace(/H/g, "HH");
	ret = ret.replace(/g/g, "h");
	ret = ret.replace(/G/g, "H");
	ret = ret.replace(/j/g, "d");
	ret = ret.replace(/l/g, "EE");
	ret = ret.replace(/M/g, "NNN");
	ret = ret.replace(/F/g, "MMM");
	ret = ret.replace(/m/g, "MM");
	ret = ret.replace(/i/g, "mm");
	ret = ret.replace(/n/g, "M");
	ret = ret.replace(/s/g, "ss");
	ret = ret.replace(/y/g, "yy");
	ret = ret.replace(/Y/g, "yyyy");
	return ret;
}
