/*
##########################################
# JavaScript Document จาวาสคริป
##########################################
# Title : functions.global.js
# Author : Mr. Anuluck Nantajan
# Email : anuluck@minddezign.com
# URL : www.minddezign.com
# Description : All Script for JavaScript
# Created : 2010-07-23
# Last modified : 2010-07-23
# Copyright : MindDezign 2009.
##########################################
*/

/* Check all and Uncheck all for check box */
function check_uncheck_all(checkname, field)
{
	for (i = 0; i < checkname.length; i++) {
		checkname[i].checked = field.checked? true:false
	}
}

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

function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	} else {
		return true;
	}
}

function decision(message, url)
{
	if(confirm(message)) location.href = url;
}

function open_thickbox(title, url) // ใช้สำหรับเปิด thickbox
{
	$(document).ready(function(){ tb_show(title, url, null); });
	// วิธีใช้งาน
	// onclick="open_thickbox('Title For ThickBox', 'modules/stockin/stoin_add.php?TB_iframe=true&height=450&width=700&modal=true'); return false;"
}
/* Start: Disable the Enter key on HTML form */
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  //if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
  if ((evt.keyCode == 13) && ((node.type=="text") || (node.type=="password") || (node.type=="checkbox") || (node.type=="radio") || (node.type=="file") || (node.type=="hidden"))) {return false;}
}
document.onkeypress = stopRKey;
/* End: Disable the Enter key on HTML form */

function is_numeric(value) { // ระบุเป็นตัวเลขเท่านั้น
	if (value == '' || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
	return true;
}

function is_email(value) {       
	var strMail = value;
	var regMail =  /^\w+([-.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (regMail.test(strMail)) {
		return true;
	} else {
		return false;
	}
}
