    function getimageremove(n)
    {
        var obj = document.getElementById('id_'+n);

        if(obj == 'undefined')
            return "Can not find image block!";

        obj.value = '';

        var obj = document.getElementById('id_'+n+'_image');

        if(obj == 'undefined')
            return "Can not find image block!";

        obj.src = '';
    }
	function goTab(tid)
	{
		/*
		var s = window.location.toString();
		if(s.indexOf('is_subformedit=1')!=-1)
		{
			alert('Can not change tab while editing.');
			return;

		}
		*/
		var elements = document.getElementsByTagName('div');
		var tabclass = 'tabbox';
		tid = 'tab_'+tid;

		for(var i = 0; i < elements.length; i++)
		{
			var e = elements[i];

			if(e.className.match(new RegExp("(^|\\s+)" + tabclass + "(\\s+|$)")))
			{

				if(e.id == tid)
				{

					addCSSClass('nav'+e.id,'active');
					swapDisplay(e.id,true);
				}
				else
				{
					removeCSSClass('nav'+e.id,'active');
					swapDisplay(e.id,false);
				}
			}

		}
	}
		function addCSSClass(id, c, b) {
		// b true for add before
		if(typeof(id)=='object')
		    var e = id;
		else
    		var e = document.getElementById(id);
		var o = removeCSSClass(id, c);
		return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
	};

	// removing class gtom existed object by id
	function removeCSSClass(id, c) {

		if(typeof(id)=='object')
		    var e = id;
		else
    		var e = document.getElementById(id);

		c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
		return e.className = c != ' ' ? c : '';
	};

    function haveCSSClass(id,c)
    {
        if(typeof(id)=='object')
		    var e = id;
		else
    		var e = document.getElementById(id);
       return e.className.match(new RegExp("(^|\\s+)" + c + "(\\s+|$)"));

    }


	function removeCommas( strValue ) {

	  var objRegExp = /,/g; //search for commas globally

	  //replace all matches with empty strings
	  return String(strValue).replace(objRegExp,'');
	}

       function addCommas(someNum){
            // from Shawn -> http://lists.evolt.org/pipermail/javascript/2004-June/007409.html
            while (someNum.match(/^\d\d{3}/)){
               someNum = someNum.replace(/(\d)(\d{3}(\.|,|$))/, '$1,$2');
            }
            return someNum;
         }
	function setReadonly(ids)
	{
		var id = ids.split(',');
		var obj=null;
		for(var i=0;i<id.length;i++)
		{
			addCSSClass(id[i],'readonly');
			obj=document.getElementById(id[i]);

			if(obj)
				obj.readOnly=true;
		}
	}

	function swapDisplay(o)
	{
		var obj=document.getElementById(o);

		if(arguments.length==1)
		{
			//var regex = arguments[3]
			if(obj.style.display=='none' )
			{
				obj.style.display='';
				return true;
			}
			else
			{
				obj.style.display='none';
				return false;
			}
		}
		else
		{
			if(arguments[1])
				obj.style.display = '';
			else
				obj.style.display = 'none';

			return arguments[1];
		}
	}
	function doFocus(id)
	{
		setTimeout('document.getElementById(\''+id+'\').focus()', 100);
	}
	function doSelect(id)
	{
		setTimeout('document.getElementById(\''+id+'\').focus();document.getElementById(\''+id+'\').select(); ', 100);
	}
	function doSelectNext(evt,id,select,req,obj)
	{
		if(evt==null)
			evt=window.event;
		if(evt.keyCode==13)
		{
			if(req)
			{
				if(obj.value=='')
					return;
			}
			if(select)
				doSelect(id);
			else
				doFocus(id);
		}
	}

// check box
    function checkAll(cclass,val)
	{
		var elements = document.getElementsByTagName('input');

		for(var i = 0; i < elements.length; i++)
		{
			var e = elements[i];

			if(e.className.match(new RegExp("(^|\\s+)" + cclass + "(\\s+|$)")))
			{
	           e.checked = val;

			}

		}
	}
	function isCheckedAll(cclass,val)
	{
		var elements = document.getElementsByTagName('input');
		var same = true;
		for(var i = 0; (i < elements.length) && same; i++)
		{
			var e = elements[i];

			if(e.className.match(new RegExp("(^|\\s+)" + cclass + "(\\s+|$)")))
			{
	           if(e.checked != val)
	           	 same = false;
			}

		}
		return same;
	}
    function anyChecked(n)
	{
		var elements = document.getElementsByName(n);
		var testcheck = false;
		for(var i = 0; (i < elements.length) && (!testcheck); i++)
		{
			var e = elements[i];

			testcheck =e.checked;
		}

		return testcheck;
	}


//******************************
// string part
//******************************
	function trim(s)
	{
		return String(s).replace(/(^\ +|\ +$)/, "");
	}

	function is_array(obj) {
	   if (obj.constructor.toString().indexOf("Array") == -1)
	      return false;
	   else
	      return true;
	}

	function in_array(the_needle, the_haystack){
	        var the_hay = the_haystack.toString();
	        if(the_hay == ''){
	            return false;
	        }
	        var the_pattern = new RegExp(the_needle, 'g');
	        var matched = the_pattern.test(the_haystack);
	        return matched;
	}
	function utils_copyvalue(f,t)
	{
	    var fs = document.getElementById(f);
	    var ts = document.getElementById(t);
	    if(ts.value!='')
	    {
	        if(confirm('Do you want to replace exsiting value?'))
        	    ts.value = fs.value;
        }
        else
            ts.value = fs.value;
	}
//******************************
// datetime part
//******************************


	function is_validDate(day,month,year,t){
	var dteDate;
	//set up a Date object based on the day, month and year arguments
	//javascript months start at 0 (0-11 instead of 1-12)
	month=month-1;
	dteDate=new Date(year,month,day);
	/*
	Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
	*/

	if (!((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear())))
	{
		if(t)
			alert('Invalid date or Format Invalid!\r\n  dd/mm/yyyy hh:mm ');
		else
			alert('Invalid date or Format Invalid!\r\n  dd/mm/yyyy ');
		return false;
	}
	else
		return true;
	}
	function convertDate(o,f)
	{

		if(o=='')
			return '';
		if(!f)
		{
			var d=o.split('-');
			if (d[0] > 2500)
			{
				d[0]-=543;
			}
			if(is_validDate(d[2],d[1],d[0],false))
				return d[2]+'/'+d[1]+'/'+d[0];
			else
				return '';

		}
		else
		{
			var d=o.split('/');
			if (d[2] > 2500)
			{
				d[2]-=543;
			}

			if(is_validDate(d[0],d[1],d[2],false))
				return d[2]+'-'+d[1]+'-'+d[0];
			else
				return '';
		}
	}

	function convertDateTime(o,f)
	{
		if(o=='')
			return '';
		var item=o.split(' ');

		if(!f)
		{
			var d=item[0].split('-');
			if (d[0] > 2500)
			{
				d[0]-=543;
			}
			if(item.length==1)
				item[1]='00:00';
			var t=item[1].split(':');
			if(t[0] < 0 || t[0]> 23 || t[0]=='undefined' || t[0]=='')
				t[0]='00';
			if(t[1] < 0 || t[1]> 59 || t[1]=='undefined' || t[1]=='')
				t[1]='00';

			if(is_validDate(d[2],d[1],d[0],true))
				return d[2]+'/'+d[1]+'/'+d[0]+' '+t[0]+':'+t[1];
			else
				return '';

		}
		else
		{
			var d=item[0].split('/');
			if (d[2] > 2500)
			{
				d[2]-=543;
			}

			if(item.length==1)
				item[1]='00:00';
			var t=item[1].split(':');
			if(t[0] < 0 || t[0]> 23 )
				t[0]=0;
			if(t[1] < 0 || t[1]> 59 )
				t[1]=0;

			if(is_validDate(d[0],d[1],d[2],true))
				return d[2]+'-'+d[1]+'-'+d[0]+' '+t[0]+':'+t[1];
			else
				return '';
		}

	}
	function HTML_removeChild(element,targetE,parentE)
    {
        var itarget = null;
        var iparent = null;
        var iloop   = element;

        if(iloop.tagName==targetE)
            itarget = iloop;

        while((iloop = iloop.parentNode) && (iparent == null))
        {
             if(iloop.tagName==targetE)
                itarget = iloop

             if(iloop.tagName==parentE)
                iparent = iloop

        }
        if(iparent.removeChild)
            return iparent.removeChild(itarget);
        else
            return false;
    }

    function init()
    {
        for(f in _INIT)
        {
           var func = eval(_INIT[f]);
           if(typeof(func)=='function')
           {
                func();
           }
        }
    }

    var _INIT = Array();



