// JS trim function
function trim(txt) {
	var ch ;
	var str = "";

	if (txt.length == 0) {return str;}

	for (i = 0; i <= txt.length-1;i++)   {
		  ch = txt.charAt(i);
		  if (ch != " ")  {
			  str = txt.substr(i);
			  break;
		  } 
	}
		
	for (i = str.length-1 ; i >= 0;i--)   {
		  ch = str.charAt(i);
		  if (ch != " ")  {
			  str = str.substr(0,i+1);
			  break;
		  } 
	}
	
	return str;
}

// JS for check email format
function chkEmail(str){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(str)) {
		return true;
	} else {
		return false;
	}
}

// JS for check Http format
function chkHttp(str){
	var filter  = /^(http:\/\/www.)/;
	if (filter.test(str)) {
		return true;
	} else {
		return false;
	}
}

// JS for check UserName
function chkUsername(str) {
	var inword = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	//inword = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."
	inword += "ðñòóôõö÷øù¡¢¤£¥¦§¨©ª«¬­¯®°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÐ-ÑÒ-Ó-í-Ô-Õ-Ö-×-Ø-Ùàáâãä-è-é-ê-ë-ç-ì";
	inword += "_!@#$%^*=+-().:;[]{}|<>";

	var t = str ;

	if (t.length < 5 || t.length > 32) {
		return false;
	} 

	for ( var i=0; i<t.length; i++ ) {
		if( inword.indexOf(t.charAt(i)) < 0){
			return false;
		}
	}

	return true; 
}

// JS for check chkPassword
function chkPassword(txt) {
	var inword = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var t = txt ;

	if (t.length < 8 || t.length > 32) {
		return false;
	} 

	for ( var i=0; i<t.length; i++ ) {
		if( inword.indexOf(t.charAt(i)) < 0){
			return false;
		}
	}

	return true; 
}

// JS for check domain
function chkDomainName(txt) {
	var inword = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
	var t = txt ;

	if (t.length < 2) {
		return false;
	} 

	if (t.charAt(0) == '-') {
		return false;
	}

	if (t.charAt(t.length -1) == '-') {
		return false;
	}

	if( inword.indexOf('--') > 0){
		return false;
	}

	for ( var i=0; i<t.length; i++ ) {
		if( inword.indexOf(t.charAt(i)) < 0){
			return false;
		}
	}

	return true; 
}

// JS for check digit
function chkDigit(obj) {
	if (!isFinite(obj.value)) {
		//alert('¡ÃØ³ÒÃÐºØµÑÇàÅ¢à·èÒ¹Ñé¹¤èÐ');
		obj.focus();
		obj.select();
	}
}

// JS for check data of Textfield
function chkTextData(obj) {
	if (obj.value == "") {
		return false;
	}

	return true;
}

// JS for check data of Combo Box
function chkCmbData(obj) {
	if (obj.selectedIndex == 0) {
		return false;
	}

	return true;
}

// Remove Enter Key For Submit  When Type Data Into TextField
function enterNonSubmit(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	} else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if character code is equal to ascii 13 (if enter key)
		return false //return false to the event handler
	} else{
		return true //return true to the event handler
	} 
}

// JS Confirm Message
function confirmMsg(msg) {
	if (confirm(msg) == true) {
		return true;
	} else {
		return false;
	}
}