$(document).ready(function() {
	$('.dev_calendar').each(function(){
		var elid = $(this).attr('id');
		CalendarInit(elid);
	});
});

jQuery.getXmlDom = function(string){
	var browserName = navigator.appName;
	var doc;
	if (browserName == 'Microsoft Internet Explorer'){
		doc = new ActiveXObject('Microsoft.XMLDOM');
		doc.async = 'false'
		doc.loadXML(string);
	} else {
		doc = (new DOMParser()).parseFromString(string, 'text/xml');
	}
	if(isvalidate(doc)) return doc;
	return '';
}

$(document).ready(function() {
	$('textarea[maxlength]').keyup(function(){
		//get the limit from maxlength attribute
		var limit = parseInt($(this).attr('maxlength'));
		//get the current text inside the textarea
		var text = $(this).val();
		//count the number of characters in the text
		var chars = text.length;

		//check if there are more characters then allowed
		if(chars > limit){
			//and if there are use substr to get the text before the limit
			var new_text = text.substr(0, limit);

			//and change the current text with the new text
			$(this).val(new_text);
		}
	});
});

jQuery.checknorm = function(target, cmt, astr, lmax,lshort){
	var t = $.trim(target.val());
	if (t.length == 0 )	{
		alert(cmt + '(을)를 정확히 기재해 주십시오.');
		target.focus();
		return true ;
	}
	if (lshort != 0 && t.length < lshort){
		alert(cmt + '는 ' + lshort + '자 이상만 가능합니다.');
		target.focus()
		return true;
	}
	if (lmax != 0 && t.length > lmax){
		alert(cmt + '는 ' + lmax + '자 이내만 가능합니다.');
		target.focus()
		return true;
	}
	if (astr.length >= 1){
		for (var i=0; i<t.length; i++){
			if(astr.indexOf(t.substring(i,i+1))<0){
				alert(cmt + '에 정확히 입력해 주십시오.');
				try{
					target.focus();
				}catch ( ex ){
				}
				return true;
			}
		}
	}
	return false;
}
