var thum_id="tdthum0";




/**
Purpose : Filter key input
**/
function validKey(e,key){ //Filter key input
		if (e.keyCode){
				code = e.keyCode;
		}else if (e.which){
				code = e.which;
		}
		switch(key){
				case 'INTEGER' :
						return (48 <= code) && (code <= 57); //Filter 0-9
						break;
				case 'FLOAT' :
						return ( (48 <= code) && (code <= 57) ) || (code==46); //Filter 0-9 and (.)
						break;
				case 'ENTER' :
						return (13==code);
						break;
				case 'TAB' :
						return (9==code);
						break;
				case 'OTHER' :
						break;
		}//end switch
}


/**
Purpose : หาตำแหน่ง cursor ปัจจุบัน
**/
function getCursorPos(ObjTextBox){
	var i = ObjTextBox.value.length;
	if (ObjTextBox.createTextRange){
		var Range = document.selection.createRange().duplicate();
		while (Range.parentElement()== ObjTextBox && Range.move("character",1)==1)
				--i;
		return i;
	}
	else return -1;
}


function el(id){
		return document.getElementById(id);
}

function $$(frm,id){
		if(typeof(frm)=='object')
			return frm.elements[id];
		else
			return document.forms[frm].elements[id];
}


// RegExp trim function

function str_trim(str, chars){
      return str_ltrim(str_rtrim(str, chars), chars);
  }
  function str_ltrim(str, chars){
      chars = chars || "\\s";
      return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
  }
  function str_rtrim(str, chars){
      chars = chars || "\\s";
      return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
  }


function cboGetValue(cbo){
  var res=null;
  if(el(cbo)){
         if(el(cbo).options[el(cbo).selectedIndex].value !=null){
			 res=el(cbo).options[el(cbo).selectedIndex].value;
		 }
  }
		 return res;
}

function cboGetText(cbo){
	var res=null;
     if(el(cbo)){
	  if(el(cbo).options[el(cbo).selectedIndex].text!=null) {
          res=el(cbo).options[el(cbo).selectedIndex].text;
	  }
	 }
return res;
}

function nextpage(){
}



function popup(purl, pw, ph) {
	pww = pw + 30;
   	pwh = ph + 30;
	winpops = window.open('', 'imgWindow', 'width=' + pww + ',height=' + pwh);
   	winpops.document.write('<html><head><title></title></head><body style=\'cursor:pointer;\' onload=\'this.focus();\' onclick=\'window.close();\' onblur=\'window.close();\'><img alt=\'\' src=\'' + purl + '\' width=\'' + pw + '\' height=\'' + ph + '\'></body></html>');
	winpops.document.close();
}

function popupTerms(msg) {
	winpops = window.open('','imgWindowPricing','width=500,height=400,resizable=1,scrollbars=yes')
	winpops.document.write('<html><head><title></title></head><body onload=\'this.focus();\' onclick=\'window.close();\' onblur=\'window.close();\' style=\'cursor:pointer;\'><span class=\'aom_pdr\'>' + msg + '</span></body></html>')
	winpops.document.close();
}

function thum_hover(obj,url_img){
		var objimg=el('imglarge');
		objimg.src=url_img;
		el(thum_id).style.borderColor="#FBB3DA";
		obj.style.borderColor="#FF0000";
		thum_id=obj.id;
}


function setDefault(){
		// run onload
		if(el(thum_id)!=null){
				el(thum_id).style.borderColor="#FF0000";
		}
}
