function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/* poll */
function submitData(f, choice_num) {
	var xChoice = null;
	for (i = 0;i < choice_num;i++) {
		if (f.choice[i].checked) {
			xChoice = f.choice[i].value;		
			break;
		}
	}
	if (xChoice == null) {
		alert("กรุณาเลือกหัวข้อ.");
		return false;
	}

	var url = "pollresult.php?poll_id=" + f.poll_id.value + "&votes=" + xChoice;
	MM_openBrWindow(url,'result','width=650,height=480');
}

/* end poll */


function detail() {}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function view() {}

function ltrim (s){
return s.replace( /^\s*/, "" );
}

function rtrim (s){
return s.replace( /\s*$/, "" );
}

function trim (s){
return rtrim(ltrim(s));
}

function isValid(Obj, isInteger){// isInteger : true - Integer, false - Double Precision.
var allowed;
if (isInteger == true)
  allowed = '0123456789';
else
  allowed = '0123456789.';

var string = Obj.value;
for (var i=0; i< string.length; i++) {
  if (allowed.indexOf(string.charAt(i)) == -1) {
if (isInteger == true)
alert('Invalid Interger Format');
else
alert('Invalid Double Precision Format');
Obj.select();
return false;
  }
}
return true;
}

function ValidForm(f) {
if (trim(f.quantity.value) == "") {
alert("Please enter quantity.");
f.quantity.select();
return false;
}
if (!isValid(f.quantity, true)) {
return false;
}
if (f.hprice.value <= 0) {
alert("Not available.");
return false;
}
return true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var messages = new Array();
VAR_TOOLTIP_MESSAGES

