function xssReplace(a){
	var limit_char = /[~!\#$^&%*\=+|:;?"<,.>']/;
	var tmp_str="";
	for(var i=0; i<a.length; i++) {
		var data1=a.charAt(i);
		tmp_str+=data1.replace(limit_char,"");
	}
	return tmp_str;
}

$( function() {

	$( "#btnLand" ).click( function () {
		window.location.href = "info0501.do";		
	}).css( "cursor", "pointer" );	
	
	$( "#btnMesure" ).click( function () {
		window.location.href = "info0502.do";		
	}).css( "cursor", "pointer" );	
	
	$( "#btnSearch" ).click( function () {
		window.document.forms[ "frmDictionaryList" ].method.value = "getDictionarySearch";
		window.document.forms[ "frmDictionaryList" ].prmKeyword.value = xssReplace(window.document.getElementById( "txtSearch" ).value);
		window.document.forms[ "frmDictionaryList" ].submit();
		
	}).css( "cursor", "pointer" );	
	
	$( "#txtSearch" ).keydown( function( evt ) {
		if( evt.keyCode == 13 ) {
			window.document.forms[ "frmDictionaryList" ].method.value = "getDictionarySearch";
			window.document.forms[ "frmDictionaryList" ].prmKeyword.value = xssReplace(window.document.getElementById( "txtSearch" ).value);
			window.document.forms[ "frmDictionaryList" ].submit();
		}
	});
	
});

function goPage( pageNum ) {
	var strSpell = window.document.getElementById( "strSpell" ).value;
	if( strSpell == "" || strSpell == undefined ) {
		window.document.forms[ "frmDictionaryList" ].method.value = "getDictionaryList";
		window.document.forms[ "frmDictionaryList" ].prmPagingNum.value = pageNum;
		window.document.forms[ "frmDictionaryList" ].submit();
	} else {
		getListForSpell( strSpell, pageNum );
	}
}

function viewContent( contentNo ) {
	window.document.forms[ "frmDictionaryList" ].method.value = "getDictionaryView";
	window.document.forms[ "frmDictionaryList" ].prmContentNo.value = contentNo;
	window.document.forms[ "frmDictionaryList" ].target = "DictionaryView";
	window.open( "", "DictionaryView", "toolbar=no,location=no,status=no,menubar=no,width=536, height=325" );
	window.document.forms[ "frmDictionaryList" ].submit();
}

function getListForSpell( spell, pageNum ) {	
	if( pageNum == "" || pageNum == undefined ) {
		pageNum = 1;
	}
	window.document.forms[ "frmDictionaryList" ].method.value = "getDictionaryListForSpell";
	window.document.forms[ "frmDictionaryList" ].prmPagingNum.value = pageNum;
	window.document.forms[ "frmDictionaryList" ].prmSpell.value = spell;
	window.document.forms[ "frmDictionaryList" ].submit();
}

function goList(pg){
	document.all.method.value = 'landList';
	document.all.page.value = pg;
	document.all.dictionary.submit();
}
function goSearch(){
	var str = document.all.search_w.value;
	var exp = '\"\'\<\>\@\.\/\-\_\+\*\%\&\\" "';
	if(!str){
		return;
	}
	for(i=0;i<str.length;++i){
		for(j=0;j<exp.length;++j){
			if(str.charAt(i) == exp.charAt(j)){
				alert('특수문자 또는 공백을 입력할 수 없습니다.');
				return;
			}
		}
	}
	document.all.method.value = 'landList';
	document.all.search_word.value = document.all.search_w.value;
	document.all.dictionary.target = '';
	document.all.dictionary.submit();
}
function goSearch2(chr){
	document.all.method.value = 'landList';
	document.all.dictionary.target = '';
	document.all.search_word.value = chr;
	document.all.dictionary.submit();
}
function goContent(seq){
	document.all.no.value = seq;
	document.all.method.value = 'dicContents';
	chk = window.open('about:blank','dicCon','width=550,height=330,scrollbars=yes');
	document.all.dictionary.target = 'dicCon';
	document.all.dictionary.submit();
}
function enterCheck(dist){
	if(dist == 3 && event.keyCode ==13){
		goSearch();
	}
}
function goDictionary(table){
	document.all.table_name.value = table;
	document.all.page.value = '1';
	document.all.search_word.value = '';
	document.all.dictionary.method.value = 'landList';
	document.all.dictionary.target = '';
	document.all.dictionary.submit();
}
