String.prototype.Trim = function() { 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() { 
	return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() { 
	return this.replace(/(\s*$)/g, ""); 
} 

function isNotNull(fieldname,formObj){
	formObj.value = formObj.value.Trim();
	if (formObj.value == "") {
		alert(char_input + fieldname);
		formObj.focus();
		return false;
	}else{
		return true;
	}
}

function isNotSelect(fieldname,formObj){
	formObj.value = formObj.value.Trim();
	if (formObj.value == "") {
		alert(char_select + fieldname);
		formObj.focus();
		return false;
	}else{
		return true;
	}
}

function isNotSelectR(fieldname,formObj){
	var selectedIndex = -1;
	for (var i = 0; i<formObj.length; i++){
		if (formObj[i].checked){
			selectedIndex = i;
			break;
		}
	}
	if (selectedIndex < 0){
		alert(char_select + fieldname);
		return false;
	}else{
		return true;
	}
}

function $(id){
	return document.getElementById(id);
}

function breakWord(dEl){
	if(!dEl || dEl.nodeType !== 1){
		return false;
	} else if(dEl.currentStyle && typeof dEl.currentStyle.wordBreak === 'string'){
		breakWord = function(dEl){
			//For Internet Explorer
			//dEl.runtimeStyle.wordBreak = 'break-all';
			return true;
		}
		return breakWord(dEl);
	}else if(document.createTreeWalker){
		var trim = function  (str) {
			var	str = str.replace(/^\s\s*/, ''),
			ws = /\s/,
			i = str.length;
			while (ws.test(str.charAt(--i)));
			return str.slice(0, i + 1);
		}
		breakWord = function(dEl){
			//For Opera, Safari, and Firefox
			var dWalker = document.createTreeWalker(dEl, NodeFilter.SHOW_TEXT, null, false);
			var node,s,c = String.fromCharCode('8203');
			while (dWalker.nextNode())
			{
				node = dWalker.currentNode;
				//we need to trim String otherwise Firefox will display
				//incorect text-indent with space characters
				s = trim( node.nodeValue ) .split('').join(c);
				node.nodeValue = s;
			}
			return true;
		}
		return breakWord(dEl);
	}else{
		return false;
	}
}

function reinitIframe(){
	var iframe = document.getElementById("frame_content");
	try{
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height =  height;
	}catch (ex){}
}
