<!--
function remove_all_item(obj){
		while(obj.length != 1){
			obj.remove(1);
		}
		return true;	
	}
	function extract_number_on_string(str){
		for(var i=0; i<str.length; i++){
			var ch = str.charAt(i);
			if((ch>=0)&&(ch<=9))
				return str.substr(i,(str.length-i));
		}
		return 0;
	}
function windowupload_ext(revalto, folder){
	var pathlink = 'imageup.php?revalto='+revalto+'&folder='+folder;
	window_open(pathlink,300,300,'no','normal');
}	
function windowupload(revalto, folder){
	var pathlink = 'admin/includes/imageup.php?revalto='+revalto+'&folder='+folder;
	window_open(pathlink,300,300,'no','normal');
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
var priority_value=0;
function all_selection(textid){
	var obj_arr = document.getElementById("report").getElementsByTagName("input");
	for (var i=0; i < obj_arr.length; i++){
		if(obj_arr[i].name == textid){
			obj_arr[i].checked = true;
		}
	}
}
function is_selected(textid){
	var ok=false;
	var obj_arr = document.getElementById("report").getElementsByTagName("input");
	for (var i=0; i < obj_arr.length; i++){
		if((obj_arr[i].name == textid)&&(obj_arr[i].checked == true))
			return true;
	}
	return false;
}
function reset_priority_values(){
	document.frm.reset();
	priority_value = 0;
	var obj_arr = document.getElementById("report").getElementsByTagName("input");
	for (var i=0; i < obj_arr.length; i++){
		if((obj_arr[i].name == "PRID[]")){
			var id = obj_arr[i].value;
			var obj = document.getElementById("PRVAL"+id);
			if(obj.disabled == false)
				obj.disabled = true;
		}
	}
}
function default_priority_values(){
	priority_value = 0;
	var obj_arr = document.getElementById("report").getElementsByTagName("input"); //DynamicDrive.com change
	for (var i=0; i < obj_arr.length; i++){
		if(obj_arr[i].name == "PRID[]"){
			var id =obj_arr[i].value; 
			document.getElementById("PRVAL"+id).value = document.frm.total.value;
		}

		if(obj_arr[i].name == "PRID[]")
			obj_arr[i].checked= false;
	}
}
function priority_selection(obj){
	var id = obj.value;
	if(obj.checked == true){
		priority_value++;
		priority_value_old = document.getElementById("PRVAL"+id).value;
		document.getElementById("PRVAL"+id).value = priority_value;
		document.getElementById("PRVAL"+id).disabled = false;
	}
	else{
		if(priority_value > 0)
			priority_value--;
		document.getElementById("PRVAL"+id).value = document.frm.total.value;		
		document.getElementById("PRVAL"+id).disabled = true;
	}	
}

function value_priority_exits(obj){
	var pos=0;
	var msg = '';
	var dup = false;
	var obj_arr = document.getElementById("report").getElementsByTagName("input"); //DynamicDrive.com change
	for (var i=0; i < obj_arr.length; i++){
		if(obj_arr[i].name.substr(0,5) == "PRVAL"){
			pos++;
			if((obj.name != obj_arr[i].name)&&(parseInt(obj.value)== parseInt(obj_arr[i].value))){
				msg += pos + ', ';
				dup=true;
			}
		}		
	}
	if(dup==true)
		alert(msg.substr(0,msg.length-2));
	return msg;	
}
var last_click;             // zuletzt angeklickter Button
var windows = new Array();  // Array mit Win-Objekten
function button_mouse_overme(obj){
	obj.className='mybutton_over';
}
function button_mouse_outme(obj){
	obj.className='mybutton';
}
function set_over(obj) {
   document.getElementById(obj).style.borderTopColor = "white";
   document.getElementById(obj).style.borderLeftColor = "white";
   document.getElementById(obj).style.borderBottomColor = "black";
   document.getElementById(obj).style.borderRightColor = "black";
}

function set_out(obj) {
   document.getElementById(obj).style.borderColor = "black";
}
function set_outh(obj) {
   document.getElementById(obj).style.borderColor = "ButtonFace";
}

function set_click(obj)
{
   document.getElementById(obj).style.borderTopColor = "black";
   document.getElementById(obj).style.borderLeftColor = "black";
   document.getElementById(obj).style.borderBottomColor = "white";
   document.getElementById(obj).style.borderRightColor = "white";
   elem1 = document.getElementById(last_click);
   if (elem1) elem1.style.fontWeight = "normal";
   last_click = obj;
   document.getElementById(obj).style.fontWeight = "bold";
}

function Win(ref, posx, posy) {
   this.ref  = ref;
   this.posx = posx;
   this.posy = posy;
}

function check_windows() {
   var windows_new = new Array();
   var i;
   for (i=0; i<windows.length; i++)
   {
    var found = false;
    try{
        if(!windows[i].ref.closed)
            found = true;
    }
    catch(e){
        found = false;
    }
    if (found && windows[i] && windows[i].ref && !windows[i].ref.closed) {
         windows_new.push(windows[i]);
         windows[i].ref.focus();
      }
   }
   windows = windows_new;
}

function window_open(url, w_width, w_height, scroll, type) {
   var proper;
   var posx;
   var posy;
   check_windows();
   var ind = windows.length - 1;
   if (windows[ind]) {
      posx = windows[ind].posx + 20;
      posy = windows[ind].posy + 20;
   }
   else {
      posx = (screen.width - w_width) / 2;
      posy = (screen.height - w_height) / 2 - 30;
   }
   if (type == 'resizeable')  proper = 'titlebar=no,toolbar=yes,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'normal')      proper = 'titlebar=no,toolbar=no,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'menu')        proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'mresizeable') proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'minimized')   proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+screen.width+',top='+screen.height+',screenX='+screen.width+',screenY='+screen.height;
   
   var win_ref;
   win_ref = window.open(url, '', proper);
   if (win_ref) {
      var tmp;
	  tmp = new Win(win_ref, posx, posy);
      windows.push(tmp);
      win_ref.focus();
   }
   return win_ref;
}

function modal_open(url, w_width, w_height, scroll, type) {
	var proper;	
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   window.showModalDialog(url, window, proper);
}

function modless_open(url, w_width, w_height, scroll, type) {
	var proper;
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   window.showModalDialog(url, window, proper);
}


function vntext(st)
{
var Rex = ["&#224;","&#7843;","&#227;","&#225;","&#7841;","&#259;","&#7857;","&#7859;","&#7861;","&#7855;","&#7863;","&#226;","&#7847;","&#7849;","&#7851;","&#7845;","&#7853;","&#273;","&#232;","&#7867;","&#7869;","&#233;","&#7865;","&#234;","&#7873;","&#7875;","&#7877;","&#7871;","&#7879;","&#236;","&#7881;","&#297;","&#237;","&#7883;","&#242;","&#7887;","&#245;","&#243;","&#7885;","&#244;","&#7891;","&#7893;","&#7895;","&#7889;","&#7897;","&#417;","&#7901;","&#7903;","&#7905;","&#7899;","&#7907;","&#249;","&#7911;","&#361;","&#250;","&#7909;","&#432;","&#7915;","&#7917;","&#7919;","&#7913;","&#7921;","&#7923;","&#7927;","&#7929;","&#253;","&#7925;","&#192;","&#7842;","&#195;","&#193;","&#7840;","&#258;","&#7856;","&#7858;","&#7860;","&#7854;","&#7862;","&#194;","&#7846;","&#7848;","&#7850;","&#7844;","&#7852;","&#272;","&#200;","&#7866;","&#7868;","&#201;","&#7864;","&#202;","&#7872;","&#7874;","&#7876;","&#7870;","&#7878;","&#204;","&#7880;","&#296;","&#205;","&#7882;","&#210;","&#7886;","&#213;","&#211;","&#7884;","&#212;","&#7890;","&#7892;","&#7894;","&#7888;","&#7896;","&#416;","&#7900;","&#7902;","&#7904;","&#7898;","&#7906;","&#217;","&#7910;","&#360;","&#218;","&#7908;","&#431;","&#7914;","&#7916;","&#431&#7918;","&#7920;","&#7922;","&#7926;","&#7928;","&#221;","&#7924;"]
var Req = ["224","7843","227","225","7841","259","7857","7859","7861","7855","7863","226","7847","7849","7851","7845","7853","273","232","7867","7869","233","7865","234","7873","7875","7877","7871","7879","236","7881","297","237","7883","242","7887","245","243","7885","244","7891","7893","7895","7889","7897","417","7901","7903","7905","7899","7907","249","7911","361","250","7909","432","7915","7917","7919","7913","7921","7923","7927","7929","253","7925","192","7842","195","193","7840","258","7856","7858","7860","7854","7862","194","7846","7848","7850","7844","7852","272","200","7866","7868","201","7864","202","7872","7874","7876","7870","7878","204","7880","296","205","7882","210","7886","213","211","7884","212","7890","7892","7894","7888","7896","416","7900","7902","7904","7898","7906","217","7910","360","218","7908","431","7914","7916","4317918","7920","7922","7926","7928","221","7924"]

     function replaceString(szString,szFind,szReplace){
    var iMatched, fSubstring, sSubstring;
    iMatched=0;
        while(iMatched>=0){
        iMatched=szString.indexOf(szFind);
        if(iMatched<0)
        return szString;
        fSubstring=szString.substring(0,iMatched);
        sSubstring=szString.substring(iMatched+szFind.length,szString.length);
        szString=fSubstring + szReplace + sSubstring;
    }
    // Next line for Netscape compatibility 
    //     only - no effects
    return(0);
}

var s = st
for (i=0;i<133;i++)
{

	s = replaceString(s,Rex[i],String.fromCharCode(Req[i]))
}
return s
}	
// Ham kiem tra chuoi nhap so dau cho cac Mang 

function ValidString(sText,sodau,socuoi)
{
	var ValidChars = "0123456789,";
	var IsNumber=true;
	var Char;
	// Kiem tra tinh hop le cua cac Ky tu trong chuoi
	for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i); 
			if (i == 0 && Char=="," ) // Kiem tra dau o dau chuoi
				{
					return false;
				}
					//continue;
			if (ValidChars.indexOf(Char) == -1) 
				{
					return false;
				}
       }		
// kiem tra tinh hop le cua vi tri dau cham (,) trong chuoi so, khong the co <> 3-4  chu so giua 2 dau ,
//var mang=new Array();
    var luu=sText;
	var mang=luu.split(",");
	if (mang.length>0)	
		for(i=0;i<mang.length;i++)
			{
			    if(mang[i].length>socuoi || mang[i].length <sodau)
				    return false;				
			}			

	return true;

}
//--> 
function isNumeric(str)
{	var iLen;
	iLen=str.length;
	var c ;
	for(var i=0; i<iLen; i++)
	{	c = str.charAt(i);
		if ((c<'0') || (c>'9'))
			return false;
	}
	return true;
}

