function view_image(img,width,height,prop) {
	var scroll = "no"
	var w = width;
	var h = height;
	if (width>=800) { w=800; scroll = "yes"; }
	if (height>=800) { h=800; scroll = "yes"; }
	view_image_win=window.open("",'','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars='+scroll+',resizable=yes,width='+w+',height='+h);
	view_image_win.focus();
	view_image_win.document.write("<html>\n");
	view_image_win.document.write("<title>"+img+" : "+width+"x"+height+" pixel</title>\n");
/*
	view_image_win.document.write( "<SCRIPT type='text/Javascript'>\n");
	view_image_win.document.write( "<!--\nif ((parseInt(navigator.appVersion)>3)) {top.resizeTo("+width+","+height+")}\;\n");
	view_image_win.document.write( "//-->\n</SCRIPT>");
*/
	view_image_win.document.write("<body bgcolor=white topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>\n");
	view_image_win.document.write("<center><img src='"+img+"' ><center>");
	view_image_win.document.write("</body>\n");
	view_image_win.document.write("</html>\n");
	view_image_win.document.close();
}

function CheckAll(FormName, CheckAllBox) {
  for (var i=0; i<FormName.elements.length; i++) {
    var e = FormName.elements[i];
    if ((e.name != CheckAllBox.name) && (e.type=='checkbox')) {
      e.checked = CheckAllBox.checked;
    }
  }
}

function checkedVolumn(colId,usedVolumn) {
	usedVolumnList=usedVolumn.split(';')
	usedVolumn=false
	if (colId != "") {
		for (i=0;i<usedVolumnList.length;i++) {
			if (colId == usedVolumnList[i]) {
				usedVolumn=true
				break
			}
		}
	}
	if (usedVolumn) {
		document.all.volumnList.style.visibility='visible'
	} else {
		document.all.volumnList.style.visibility='hidden'
	}
}

function ConfirmDelete(PromptMessage,DeleteCommand) {
//	alert("คำสั่งคือ "+DeleteCommand);
	if ( PromptMessage == '' ) PromptMessage="ต้องการลบรายการนี้ออกจากฐานข้อมูลจริงหรือไม่?";
	if (confirm(PromptMessage)) {
		window.location = DeleteCommand;
		return true;
	}
}

function ConfirmWindow(PromptMessage,Command) {
//	alert("คำสั่งคือ "+DeleteCommand);
	if (confirm(PromptMessage)) {
		window.location = Command;
		return true;
	}
}

function AjaxLink(id,url) {
	new Ajax.Updater(id,url);
}
	
function newImage(arg) {
	if (document.images) {
		var rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
	return true;
}
function changeImages() {
	if (document.images && (preloadFlag == true)) 
		for (var i=0; i<arguments.length; i+=2) document[arguments[i]].src = arguments[i+1];
}

function open_window(url,width,height) {
	cusuwinpopup=window.open(url,'','toolbar=no,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,resizable=no,width='+width+',height='+height);
	return false;
}

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
	for (i = selectCtrl.options.length; i >= 0; i--) {
		selectCtrl.options[i] = null;
	}
	prompt = (itemArray != null) ? goodPrompt : badPrompt;
	if (prompt == null) {
		j = 0;
	} else {
		selectCtrl.options[0] = new Option(prompt);
		j = 1;
	}
	if (itemArray != null) {
// add new items
		for (i = 0; i < itemArray.length; i++) {
			selectCtrl.options[j] = new Option(itemArray[i][0]);
			if (itemArray[i][1] != null) {
				selectCtrl.options[j].value = itemArray[i][1];
			}
			j++;
		}
// select first item (prompt) for sub list
		selectCtrl.options[0].selected = true;
	}
}

function fillSelect(id, fillList, selectValue , clearCtrl) {
var i,j;
	// clear old option
	if ( typeof(clearCtrl) != 'undefined' ) {
		debug_str=''
		for ( i=0; i<clearCtrl.length; i++ ) {
			for (j = getElement(clearCtrl[i]).options.length; j > 0; j--) getElement(clearCtrl[i]).options[j] = null;
			getElement(clearCtrl[i]).options[0].selected = true;
		}
	}
	// add new items
	for ( i=2; i < fillList.length; i++ ) {
		if (typeof(fillList[i]) != 'undefined') {
			getElement(id).options[i-1] = new Option(fillList[i][1])
			getElement(id).options[i-1].value = fillList[i][0]
			if ( fillList[i][0] == selectValue ) getElement(id).options[i-1].selected = true;
		}
	}
}

function showImage(id,str) {
	myImage = new Image()
	myImage.src = "file:///"+str

	getElement(id).src = "file:///"+str
}

function sb(txt) { window.status = txt; return true; }
