// iStudy Enterprise Server common utilitys
// Copyright 2005-2010 System technology-i Co.,Ltd.


//---------------------------------
// Validate Check
//---------------------------------
function numbersonly(myfield, e, dec){
   var key;
   var keychar;

   if (window.event)
	key = window.event.keyCode;
   else if (e)
	key = e.which;
   else
	return true;
   keychar = String.fromCharCode(key);

// control keys
   if ((key==null) || (key==0) || (key==8) ||
       (key==9) || (key==13) || (key==27) )
	return true;

// numbers
   else if ((("0123456789").indexOf(keychar) > -1))
	return true;

// decimal point jump
   else if (dec && (keychar == "."))
	{
	myfield.form.elements[dec].focus();
	return false;
	}
   else
	return false;
}

function numbersonly2(myfield, e, dec){
   var key;
   var keychar;

   if (window.event)
	key = window.event.keyCode;
   else if (e)
	key = e.which;
   else
	return true;
   keychar = String.fromCharCode(key);

// control keys
   if ((key==null) || (key==0) || (key==8) ||
       (key==9) || (key==13) || (key==27) )
	return true;

// numbers
   else if ((("0123456789.").indexOf(keychar) > -1))
	return true;

// decimal point jump
   else if (dec && (keychar == "."))
	{
	myfield.form.elements[dec].focus();
	return false;
	}
   else
	return false;
}
function checkRange(num, min, max) {
	if (isNumeric(num) && isNumeric(min) && isNumeric(max)) {
		if ((num < min) || (num > max)) {
			return false;
		}
		return true;
	}
	return false;
}

// flg 0:1byte,1:2byte
function isExistsOneOrDoubleByte(str,flg) { 
    for (var i = 0; i < str.length; i++) { 
        var c = str.charCodeAt(i); 
        // Shift_JIS: 0x0 - 0x80, 0xa0 , 0xa1 - 0xdf , 0xfd - 0xff 
        // Unicode : 0x0 - 0x80, 0xf8f0, 0xff61 - 0xff9f, 0xf8f1 - 0xf8f3 
        if ( (c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) { 
            if(!flg) return true; 
        } else { 
            if(flg) return true; 
        }
    } 
    return false; 
}
function isOneByteAlphanumeric(str){
    okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

    err = 0;
    for (i=0;i<str.length;i++){
      if (okstr.indexOf(str.charAt(i)) == -1) err++;
    }
    if (err!=0) {return false;};
    return true;
}
function isOneByteAlphanumericPlus(str){
    okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_';

    err = 0;
    for (i=0;i<str.length;i++){
      if (okstr.indexOf(str.charAt(i)) == -1) err++;
    }
    if (err!=0) {return false;};
    return true;
}
function isOneByteAlphanumericUnderscoreHash(str){
    okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_#';

    err = 0;
    for (i=0;i<str.length;i++){
      if (okstr.indexOf(str.charAt(i)) == -1) err++;
    }
    if (err!=0) {return false;};
    return true;
}
function isOneByteAlphanumericForDeptCd(str){
    okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-().';

    err = 0;
    for (i=0;i<str.length;i++){
      if (okstr.indexOf(str.charAt(i)) == -1) err++;
    }
    if (err!=0) {return false;};
    return true;
}
function isEmail(str){
    data = str.match(/^\S+@\S+\.\S+$/);
	if (!data) return false;
	
	return true;
}
function isNumeric(num){ 
	var numeric="0123456789"; 

	if(num.length == 0){ 
		return true; 
	} 

	for(i = 0;i < num.length;i++){ 
		if(numeric.indexOf(num.charAt(i)) < 0){ 
			return false; 
		} 
	}
	return true; 
}

/*
 * version 3.0.0.8
 */
function checkNumeric(text,msg){
	if(!isNumeric(text.value)){
		alert(msg);
		text.focus();
		return false;
	}
	return true;
}

/*
 * Must check 
 * version 3.0.0.8
 */
function checkMustInput(text,msg){

	if(text.value==''){
		alert(msg);
		text.focus();
		return false;
	}
	return true;
}

function checkZenkaku(elm,msg){
	var txt=elm.value
	for(i=0;i<txt.length;i++){
		if(escape(txt.charAt(i)).length>=4){
			alert(msg);
			
			return false;
		}
	}
	
	return true;
}

function checkByteCount(str,bytes) {
	count=0;
	var i;
	for(i=0;i<str.length;i++) {
		(escape(str.charAt(i)).length< 4)?count++:count+=2;
	}
	if (count>bytes) {
		return false;
	} else {
		return true;
	}
}

/*
 * version 3.0.0.8 limit text lines
 */
function limitLines(target,lines){

	var text=target.value;
	
	var cnt = stringCounter(text,"\n");
	
	if(cnt>=lines ){
		
		text = text.split(/\r|\n/);
		var retStr="";
		for(var i=0; i<lines;i++){
				if(text[i]== undefined )
					text[i]="";
				retStr+=text[i];
			if(i!=lines-2 || i!=lines-1){
				retStr+="\r\n";
			}
		}
			
		target.value=retStr.slice(0,-2);
		return false;		
		
	}else{
		return true;
	}
}
function trim(value) {
	var output = "";
	for (var i = 0; i < value.length; i++) {
		if (value.substring(i, i+1) != ' ') {
			output += value.substring(i, i+1);
		}
	}
	return output;
}

/*
 * version 3.0.0.8
 * count string length
 */
function stringCounter(str1,str2){
  var strlength=str2.length;
  var ans=0;
  var i=0;
  while((i=str1.indexOf(str2,i)) != -1){
    i+=strlength; 
    ans++;
  }
  return ans;
}

 /*
 * ok character check
 */
function ckeckOkCharacter(str, okstr) {
   var err = 0;
   for (i=0;i<str.length;i++){
     if (okstr.indexOf(str.charAt(i)) == -1) err++;
   }
   if (err!=0) {return false;};
   return true;
}

 /*
  * ng character check
  */
function ckeckNgCharacter(str, ngstr) {
    var err = 0;
    for (i=0;i<str.length;i++){
      if (ngstr.indexOf(str.charAt(i)) != -1) err++;
    }
    if (err!=0) {return false;};
    return true;
 }

// Date Exist Check
//  inputFlg: boolean must input ( true:must false: not must )
//  str:input String
//  datefmt:date format
function CheckCalendarDate(inputFlg, str, datefmt){

	var chkdate=str;
	var chktime;

	if (str.length==0) {
		if (inputFlg == true) {
			return false;
		}
		return true;
	}
		
	if (str.length!=datefmt.length) {
		return false;
	}

	var dateFormat = new DateFormat(datefmt);
	var dateex = dateFormat.parse(str);
	if (dateex == null) {
		return false;
	}

	strs = str.match(/\d+/g);

	var years = 0;
	var months = 0;
	var days = 0;
	if (datefmt.search(/^yyyy\/mm\/dd/i) != -1) {
		years = parseInt(strs[0],10);
		months = parseInt(strs[1],10) - 1;
		days = parseInt(strs[2],10);
	} else {
		years = parseInt(strs[2],10);
		months = parseInt(strs[0],10) - 1;
		days = parseInt(strs[1],10);
	}
	var dates = new Date(years,months,days);
	if (dates.getYear() < 1900) {
		if (years != dates.getYear() + 1900) { return false; }
	} else {
		if (years != dates.getYear()) { return false; }
	}
	if (months != dates.getMonth()) { return false; }
	if (days != dates.getDate()) { return false; }

	return true;
}

/*
 * compare date 
 * version 3.0.0.8
 */
function compareDate(date1,date2){

	dateData1=date1.split('/');
	dateData2=date2.split('/');
	
	dateObj1=new Date(dateData1[0],dateData1[1]-1,dateData1[2]);
	dateObj2=new Date(dateData2[0],dateData2[1]-1,dateData2[2]);
	
	if(dateObj1.getTime() >dateObj2.getTime()){
		return 1;
	}else if(dateObj1.getTime()==dateObj2.getTime()){
		return 0;
	}else{
		return -1;
	}
	
}
 
 
 /*
  * search elements by className
  * version 3.0.0.11
  */
function getElementsByClass(document,searchClassName,tagName){
		
		var retElements = new Array();
		
		var elements=document.getElementsByTagName(tagName);
		for(var i=0,j=0;i<elements.length;i++){
			if(elements[i].className==searchClassName){
				retElements[j]=elements[i];
				j++;
			}
		}

		return retElements;
}


//---------------------------------
// Sub Window Open
//---------------------------------
function help(sURL) {
   xhelp = window.open(sURL,"helpwindow","top=5,left=5,toolbars=no,maximize=yes,resize=yes,width=600,height=530,location=no,directories=no,scrollbars=yes")
   xhelp.focus();
}
var helpType = "";

function helpOpen() {
   if (helpType.substring(0,1) == '/') {
      helpFile = helpType;
   }else{
      helpFile = "help.do?TYPE="+helpType;
   }
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=800,height=600";
   xwin = window.open(helpFile, "_blank", sArg);
   xwin.focus();
}

function openWindow(sURL,sName) {
   var sArg = "toolbar=no,scrollbars=no,resizable=yes,width=500,height=500";
   xwin = window.open(sURL, sName, sArg);
   xwin.focus();
}

function openDeptWindow(cust,dept) {
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/deptTree.do?TYPE=2&CUST_CD=" + cust+"&OLD_DEPT_CD="+dept, "dept", sArg);
   xwin.focus();
}

function openDeptWindowNotNeedPriv(cust,dept) {
   
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/deptTree.do?TYPE=2&CUST_CD=" + cust+"&OLD_DEPT_CD="+dept+"&NOT_NEED_PRIV=true", "dept", sArg);
   xwin.focus();
}

function openDeptWindowRoot(cust,dept,rootDept) {
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/deptTree.do?TYPE=2&CUST_CD=" + cust+"&OLD_DEPT_CD="+dept+"&ROOT_DEPT_CD="+rootDept, "dept", sArg);
   xwin.focus();
}

function searchDept(frm, mode, rootDeptCd, custCd) {
	var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";

	if (mode == 'TREE') {
		if (rootDeptCd == '') {
			xwin = window.open("/ies/deptTree.do?FORM=" + frm + "&CUST_CD=" + custCd, "dept", sArg);
		} else {
			xwin = window.open("/ies/deptTree.do?FORM=" + frm + "&DEPTCD=" + rootDeptCd + "&CUST_CD=" + custCd, "dept", sArg);
		}
	} else {
		if (rootDeptCd == '') {
			xwin = window.open("/ies/deptList.do?FORM=" + frm + "&CUST_CD=" + custCd, "dept", sArg);
		} else {
			xwin = window.open("/ies/deptList.do?FORM=" + frm + "&DEPTCD=" + rootDeptCd + "&CUST_CD=" + custCd, "dept", sArg);
		}
	}
	xwin.focus();
	   
}

function searchCust(frm) {
	var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
	xwin = window.open("/ies/selectCust.do?FORM=" + frm, "cust", sArg);
	xwin.focus();
}

function searchUser(frm) {
	var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
	xwin = window.open("/ies/selectUser.do?FORM=" + frm, "user", sArg);
	xwin.focus();
}

function searchGroup(frm) {
	var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
	xwin = window.open("/ies/selectGroup.do?FORM=" + frm, "group", sArg);
	xwin.focus();
}

function searchContents(frm) {
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/selectContents.do?FORM=" + frm, "course", sArg);
   xwin.focus();
}

function searchContentsSch(frm) {
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/selectContents.do?FORM=" + frm+"&SCHID=1", "course", sArg);
   xwin.focus();
}

//ENROLLED COURSE SEARCH
function searchContents(frm, uid) {
   var sArg = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
   xwin = window.open("/ies/selectContents.do?FORM=" + frm + "&USER_ID=" + uid, "course", sArg);
   xwin.focus();
}

function changeCust(form) {
	if (form.DEPT_CD != null) {
		var index = form.CUST_CD.selectedIndex;
	    var value = form.CUST_CD.options[index].value;
	
		if (value == '-1') {
		    form.DEPT_CD.value = '-1';		
		} else {
		    form.DEPT_CD.value = '0';				
		}
	}
}
function clearCust(form) {
    form.CUST_CD.value = '-1';

	if (form.DEPT_CD != null) {
	    form.DEPT_CD.value = '-1';
	}
}

function clearDept(form) {
    form.DEPT_CD.value = '-1';
}

//---------------------------------
// menu
//---------------------------------
var add_confirm = false;
var add_message = '';
function add(s, n) {

	if(add_confirm == true) {
       sWk = confirm(add_message);
	   if (sWk == true) {
	      document.userForm.OPERATION.value = s;
	      document.userForm.SUB_TYPE.value = n;
	
	      document.userForm.submit();
	   }
	} else {
      document.userForm.OPERATION.value = s;
      document.userForm.SUB_TYPE.value = n;
	
      document.userForm.submit();
	}
	
}
function add(s, n, next) {
	
	if (next!=null && next!='null' && next.length>0) {
		document.userForm.action=next;
	}
	if(add_confirm == true) {
       sWk = confirm(add_message);
	   if (sWk == true) {
	      document.userForm.OPERATION.value = s;
	      document.userForm.SUB_TYPE.value = n;
	
	      document.userForm.submit();
	   }
	} else {
      document.userForm.OPERATION.value = s;
      document.userForm.SUB_TYPE.value = n;
	
      document.userForm.submit();
	}
	
}

function commonBack(obj) {

	if(confirm(add_message)==true) {
		if (typeof(obj) == "string") {
			if (obj.indexOf("history.back") != -1) {
				history.back();
			} else if (obj.indexOf("javascript:") != -1) {
				backTo();
			} else {
				location.href = obj;
			}
		}
		if (typeof(obj) == "object"){
			obj.submit();
		}
	}
}

function commonBackEx(obj) {

	if(add_message && add_message!='') {
		// confirm first
		if(!confirm(add_message)) return;
	}
	
	
	if (typeof(obj) == "string") {
		if (obj.indexOf("history.back") != -1) {
			history.back();
		} else if (obj.indexOf("javascript:") != -1) {
			backTo();
		} else {
			location.href = obj;
		}
	}
	
	if (typeof(obj) == "object"){
		obj.submit();
	}
	
}

//---------------------------------
// Table List
//---------------------------------
function selectRow(line,stat,class1,field_max,field_name) {
   if (stat == 1) {
      for (i = 1; i <= field_max; i++) {
         document.getElementById(field_name+i+"_"+line).className ="TableSelect";
      }
   } else {
      for (i = 1; i <= field_max; i++) {
         document.getElementById(field_name+i+"_"+line).className =class1;
      }
   }
}

function chg_lines(line) {
	var maxline = parseInt(document.searchForm.MAXLINES.value);
	maxline = maxline + line;
	if (maxline < 10) {
	   maxline = 10;
	}
	document.searchForm.MAXLINES.value = maxline;
	
	// DEPT SELECTBOX
	if (document.searchForm.DEPT!=undefined) {
		for (i = 0; i < document.searchForm.DEPT.length; i++) {
		   document.searchForm.DEPT[i].selected=true;
		}
	}
	document.searchForm.PAGE_COUNT.value = 0;
	document.searchForm.submit();
	
}
function movePage(page) {
	document.searchForm.PAGE_COUNT.value = page;
	document.searchForm.submit();
}

//---------------------------------
// Other
//---------------------------------
function body_init(){
	var ie  = document.all;
	if (ie) {
		var hh = document.body.clientHeight;
		if (document.getElementById("basessm") != null){
		   var y = document.getElementById("basessm").offsetTop;
		   var h = document.getElementById("thessm").clientHeight;
	   	   var hhx = y + h + 85; 
		   if (hhx > hh){
		      hh = hhx;
		   }
		}
		document.getElementById("contents").style.height = (hh-85)+"px";
	}else{
		var hh = window.innerHeight;
		if (document.getElementById("basessm") != null){
		   var y = document.getElementById("basessm").offsetTop;
	   	   var h = document.getElementById("thessm").clientHeight;
		   var hhx = y + h + 85; 
		   if (hhx > hh){
		      hh = hhx;
		   }
		}
		document.getElementById("contents").style.minHeight = (hh-85)+"px";
	}
}

function encodeURL(str){
    var s0, i, s, u;
    s0 = "";                

    for (i = 0; i < str.length; i++){  
        s = str.charAt(i);
        u = str.charCodeAt(i);         
        if (s == " "){
           s0 += "+";
        } else {
            if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){ 
                s0 = s0 + s;           
            } else {            

                if ((u >= 0x0) && (u <= 0x7f)){    
                    s = "0"+u.toString(16);
                    s0 += "%"+ s.substr(s.length-2);
                } else if (u > 0x1fffff){    
                    s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                } else if (u > 0x7ff){       
                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                } else {                     
                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);

                }

            }

        }

    }

    return s0;
}

function exportData(id,format){
	document.exportForm.id.value = id;
	document.exportForm.format.value = format;
	document.exportForm.submit();
}
function inputNumeric(e){ 
	var key = false;
    if(document.all) {
		if (event.keyCode == 45) {
			key = true;
		}
		if (event.keyCode == 46) {
			key = true;
		}
		if (event.keyCode >= 48 && event.keyCode <= 57) {
			key = true;
		}

    	return  key;
	}
	if(document.getElementById) { 
		if (event.keyCode == 45) {
			key = true;
		}
		if (event.keyCode == 46) {
			key = true;
		}
		if (event.keyCode >= 48 && event.keyCode <= 57) {
			key = true;
		}
       	return key;
	}
	if(document.layers) {
		if (e.which == 45) {
			key = true;
		}
		if (e.which == 46) {
			key = true;
		}
		if (e.which >= 48 && e.which <= 57) {
			key = true;
		}
	  	return  key;
	}
}

function messageReplace(str,arg0,arg1,arg2,arg3){
   var ret = str;
   if (arg0 != null){
      ret = ret.replace("{0}",arg0);
   }
   if (arg1 != null){
      ret = ret.replace("{1}",arg1);
   }
   if (arg2 != null){
      ret = ret.replace("{2}",arg2);
   }
   if (arg3 != null){
      ret = ret.replace("{3}",arg3);
   }
   return ret;
}
function getCookie(item) {
    var i, index, arr;
    arr = document.cookie.split(";");
    for(i = 0; i < arr.length; i++) {
        index = arr[i].indexOf("=");
        if(arr[i].substring(0, index) == item || 
                arr[i].substring(0, index) == " " + item)
            return arr[i].substring(index + 1);
    }
    return "";
}
function setPeriod(obj,fld_from,fld_to,fmt) {
	var dateFormat1 = new DateFormat(fmt);
	var dateFormat2 = new DateFormat("yyyy-MM-dd");
	var idx = obj.selectedIndex;
	var sel = obj[idx].value;
	if (sel != '' && sel != '-1') {
		var sel_fld = sel.split(",");
		dijit.byId(fld_from).setDisplayedValue(sel_fld[0]);
		dijit.byId(fld_to).setDisplayedValue(sel_fld[1]);
	} else {
		dijit.byId(fld_from).setValue('');
		dijit.byId(fld_to).setValue('');
	}	
}

function checkLength(str) {
	var count = 0;
    for(var i=0;i<str.length;i++){
        if( escape( str.charAt(i) ).length >= 4 ){
            count += 2 ;
        }else{
            count++ ;
        }
    }
    return count;
}

function autoskip(org,dest){ 

	if (org.getAttribute && org.value.length == org.getAttribute("maxlength")){ 
		dest.focus() 
	}

} 
function calcTimezone(d, offset) {
//	alert("day="+d.toLocaleString());
	var utc = d.getTime() + ((offset*60) * 60000);
	var nd = new Date(utc);
//	alert("day="+nd.toLocaleString());
	return nd;
}
function setTimeNow(d, offset) {
    var today = new Date();
	var utc = today.getTime() + (today.getTimezoneOffset() * 60000);
	var now = new Date(utc + (3600000*offset));
	d.setHours(now.getHours());
	d.setMinutes(now.getMinutes());
	d.setSeconds(now.getSeconds());
}
function isEnableFileName(str){
    okstr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.';

	if ((n = str.lastIndexOf("\\")) != -1) {
    	str = str.substring(n+1);
	}
	if ((n = str.lastIndexOf("/")) != -1) {
    	str = str.substring(n+1);
	}

    err = 0;
    for (i=0;i<str.length;i++){
      if (okstr.indexOf(str.charAt(i)) == -1) err++;
    }
    if (err!=0) {return false;};
    return true;
}

function addEvent(elem, event, func) {
	if(elem.addEventListener) {   // not IE
		elem.addEventListener(event, func, false);
	} else {  // IE
		elem.attachEvent('on' + event, func);
	}
}

function fireEvent(elem, event) {
	
	if(elem.fireEvent) {  // IE
		elem.fireEvent('on' + event);
		//var e = document.createEventObject();
		//e.srcElement = elem;
		//elem.fireEvent('on' + event, e);
	} else {
		var e = document.createEvent('MouseEvents');
		//e.target = elem;
		e.initEvent(event, false, true);
		elem.dispatchEvent(e);
	}
}

function selectColumnHeader(fld,flg) {
	if (flg) {
		fld.className = "TableColumnHeaderSelect";
	}else{
		fld.className = "TableColumnHeader";
	}
}
function sortColumnHeader(fld,scope) {
	 for (i=0;i<fld.childNodes.length;i++){
		 if (fld.childNodes.item(i).nodeType == 1){
			 if (fld.childNodes.item(i).nodeName == 'IMG'){
				var fldx = fld.childNodes.item(i);
				 if (fldx.src.indexOf('sort_none.gif') > 0){
						sort_item(scope,'ASC');
				 }
				 if (fldx.src.indexOf('sort_down.gif') > 0){
						sort_item(scope,'ASC');
				 }
				 if (fldx.src.indexOf('sort_up.gif') > 0){
						sort_item(scope,'DESC');
				 }
				 break;
			 }
		 }
	}
}
function showCalendar(id){
	dojo.byId(id).focus();
	dojo.byId(id).onclick();
}
function clearCalendar(id){
	dijit.byId(id).setValue('');
}
function setPramsDate(obj_fid,obj_y,obj_m,obj_d,fmt) {

	var n_day = obj_fid.value;
	var dateFormat = new DateFormat(fmt);
	
	if (n_day.length == 0) {
		return;
	}
	
	var date_x = dateFormat.parse(n_day);
	var dateFormat_yy = new DateFormat("yyyy");
	var date_yy = dateFormat_yy.format(date_x);
	if (date_yy != null) {
		obj_y.value = date_yy;
	}
	var dateFormat_mm = new DateFormat("MM");
	var date_mm = dateFormat_mm.format(date_x);
	if (date_mm != null) {
		obj_m.value = date_mm;
	}
	var dateFormat_dd = new DateFormat("dd");
	var date_dd = dateFormat_dd.format(date_x);
	if (date_dd != null) {
		obj_d.value = date_dd;
	}
	
}
/*
 * this method called by
 *     simpleCheckPhoneNumber("any pattern") or simpleCheckPhoneNumber("any pattern", true)
 */ 
function simpleCheckPhoneNumber(str, rapid) {
	var result = false;

	if (!rapid) {
		switch (str.length) {
		case 12: // fixed-line phone 
			result = /^\d{2,5}\-\d{1,4}\-\d{4}$/.test(str);
			break;
		case 13: // mobile phone
			result = /^\d{3}\-\d{4}\-\d{4}$/.test(str);
			break;
		default:
			break;
		}
	} else {
		result = /^\d+\-\d+\-\d+$/.test(str);
	}

	return result;
}

/*
 * check domain name. but muitibyte maby not supported.
 *
 */ 
function isDomainName(str) {
	var re=new RegExp("^"+dojox.validate.regexp.host({allowIP:false,allowPort:false,allowNamed:true})+"$","i");
	return re.test(str.value);
}
 
/*
 * Open all folders
 *
 */
function expandTree(folderObj) {
	var childObj;
	var i;

	//Open folder
	if (!folderObj.isOpen) {
		clickOnNodeObj(folderObj);
	}
	
	//Call this function for all folder children
	for (i=0 ; i < folderObj.nChildren; i++)  {
		childObj = folderObj.children[i];
		if (typeof childObj.setState != "undefined") {
			//is folder
			expandTree(childObj)
		}
	}
}
