// --------------------------------------------------
// check_st()
// --------------------------------------------------
function check_st(which,ckcnt) {
	for (var i=0;i<ckcnt;i++) {
		if (i==which) document.mssearch._searchtype[i].checked=true
		else document.mssearch._searchtype[i].checked=false
	}
} // check_st()

// --------------------------------------------------
// switch_ck()
// --------------------------------------------------
function switch_ck(ckname) {	
	with (document.mssearch) {
		var inp = eval("document.mssearch."+ckname);
		inp.checked=!inp.checked
	}
}

// --------------------------------------------------
// _markall()
// --------------------------------------------------
function _markall(act) {
	len = document.mssearch.length
	for (var i=0;i<len;i++) {
		var inp = document.mssearch[i];
		if (inp.type=="checkbox" && inp.name.substr(0,3)=="use") {
			inp.checked = act
		}
	}
} // _markall()

// --------------------------------------------------
// nothing_checked()
// --------------------------------------------------
function nothing_checked(theForm) {
	var len = theForm.length
	for (var i=0;i<len;i++) {
		var obj = document.mssearch[i]
		if (obj.type=="checkbox" && obj.name.substr(0,3)=="use" && obj.checked) return false;
	}
	return true;
} // nothing_checked()

// --------------------------------------------------
// validate_mss_search()
// --------------------------------------------------
function validate_mss_search(q) {
// "String." below must be Uppercase!
var char34 = String.fromCharCode(34)
var char39 = String.fromCharCode(39)

wronglen			= "введите строку для поиска (не менее 2 символов)";
illegalchars 	= 'в строке поиска недопустимы символы:\n          / \\ + - * [ ] ( ) '+char34+" "+char39;
nosites				= 'не отмечено ни одного сайта для поиска';

	theForm=document.mssearch

	if (!theForm) {
		if (q) return
		else return false
	}
	
	if (nothing_checked(theForm)) {
		alert(nosites)
		if (q) return
		else return false
	}

	qval = theForm.ss.value.trim()

	// check for min/max length
	if (qval.length < 2) {
		alert(wronglen)
		theForm.ss.focus()
		if (q) return
		else return false
	}

	if (qval.length > 100) {
		alert(wronglen)
		theForm.ss.focus()
		if (q) return
		else return false
	}

	if (q) theForm.submit()
	else return true
} // validate_mss_search()

