////document.onkeydown = subM;
var CTRL = false

function checkInput(act,n) {
	var frm = document.forms[1];	
	if (checkCode() && checkDesc() && checkGroup()) {
		//if (frm.tActMits.value == 'edit') {frm.tActMits.value = 'OK'}
		//frm.action = frm.action + '&b=OK'     //+ frm.tActMits.value
		frm.submit();
	}	
}

function checkGroup() {
	var frm = document.forms[1];
	if (frm.sM0.selectedIndex < 2) {
		//alert('You must select a group for the item...');
		frm.sM0.selectedIndex = 0;
		frm.sM0.focus();
		return false;
	}else{
		//alert(frm.sM0.selectedIndex)	
		//if (frm.sM1 == '[object]') {
		//	if (frm.sM1.selectedIndex < 1) {
		//		//alert('You must select a sub-group for the item...');
		//		frm.sM1.selectedIndex = 0;
		//		frm.sM1.focus();
		//		return false;
		//	//}else{
		//	//	alert(frm.sM1.selectedIndex)	
		//	}
		//}	
		//if (frm.sM2 == '[object]') {
		//	if (frm.sM2.selectedIndex < 1) {			
		//		//alert('You must select a sub-level for the item...');				
		//		frm.sM2.selectedIndex = 0;
		//		frm.sM2.focus();
		//		return false;
		//	//}else{
		//	//	alert(frm.sM2.selectedIndex)	
		//	}
		//}
		return true;
	}
}
function checkCode() {
	var frm = document.forms[1];
	if (frm.txtEdit.value == '') {
		//alert('You must provide a code for the item...');
		frm.txtEdit.focus();
		return false;
	}else{
		return true;
	}
}
function checkDesc() {
	var frm = document.forms[1];
	if (frm.txtDesc.value == '') {
		//alert('You must provide a description for the item...');
		frm.txtDesc.focus();
		return false;
	}else{
		return true;
	}
}

function subM(e) {
	if (bSearch || document.forms[0].txtSearch.value == '') {
		var frm = document.forms[1]		
		var qsVal = frm.txtBkQS.value
		var bCode = typeof(frm.txtCode) == 'object'
		if (window.Event){
			uKey = e.which;
		}else{
			uKey = event.keyCode;
		}
		//window.status = uKey + ' ' + CTRL
		if (!CTRL && uKey == 17) {CTRL = true}
		if (CTRL && uKey != 17 && uKey != 83 && uKey != 75 && uKey != 77 && uKey != 85) {CTRL = false}
		if (CTRL && uKey == 85) {				
			document.location.href = 'main.asp?t=setup' + qsVal.substr(8,qsVal.length-8)
		}		
		if (uKey == 118) {
			document.location.href = 'main.asp?b=newgrp&t=group' + qsVal.substr(8,qsVal.length-8)
		}		
		if (uKey == 119) {
			document.location.href = 'main.asp?t=group' + qsVal.substr(8,qsVal.length-8)
		}		
		if ((!frm.tActMits || (typeof(frm.tActMits) == 'object' && frm.tActMits.value == 'edit')) && uKey == 120) {
			document.location.href = 'main.asp?b=new&t=edit' + qsVal.substr(8,qsVal.length-8)
		}
		if (bCode) {
			if (CTRL && uKey == 83) {		
				setPrice(1);
				setPrice(2);			
				checkInput()
			}		
			if (CTRL && uKey == 75) {				
				document.location.href = 'main.asp?' + qsVal
			}		
			if (frm.tActMits.value == 'edit' && CTRL && uKey == 77) {
				document.location.href = 'main.asp?b=upload&t=upload&c=' + frm.txtCode.value + qsVal.substr(8,qsVal.length-8)
			}
			if (frm.tActMits.value == 'edit' && uKey == 123 && confirm('Are you sure you want to delete this item?...')) {
				document.location.href = 'main.asp?b=delete&t=thumbs&c=' + frm.txtCode.value + qsVal.substr(8,qsVal.length-8)
			}
		}
		if (frm.name == 'accsForm') {
			if (CTRL && uKey == 83) {				
				//alert(frm.name)				
				//checkIt()
			}
		}			
		if (uKey == 13) {}
	}	
}
