
function focusfield(obj) {
	obj.style.borderColor = "#e1e1e1";
}
function markfield(fldid) {
	document.getElementById(fldid).style.borderColor = "red";
}
function check_ly(fldid) {
	ytun = document.getElementById(fldid).value;
	ytun = ytun.replace(" ", "");
	ytun = ytun.replace("-", "");
	if (isNaN(ytun)) {
		return false;
	} else {
		return true;
	}
}

function check_sposti(fldid) {
	sposti = document.getElementById(fldid).value
	AtPos = sposti.indexOf("@")
	StopPos = sposti.lastIndexOf(".")

	if (AtPos == -1 || StopPos == -1) {
		return false;
	} else {
	
	} return true;

}

function noenter() {
  return !(window.event && window.event.keyCode == 13); 
}

function check_saldo(real,formfield,koko,override) {
	if (override == 1) {
		ret = true;	
	} else {
		addval = Number(document.getElementById(formfield).value);
		if (addval % koko != 0) {
			alert('Määrä ei ole pakkauskoon mukainen.');
			ret = false;
		} else if (real < addval) {
			if (confirm('Saldo on ' + real + '. Hyväksytäänkö jälkitoimitus?')) {
				// document.getElementById(formfield).value = real; 
				ret = true;
			} else {
				ret = false;
			}

		} else {
			ret = true;
		}	
	}
	return ret; 
}
/*function change_maara(a) {
	alert(a);
}*/
function change_maara(oldfield,change_by,resultfield) {
	newmaara = Number(document.getElementById(oldfield).value) + Number(change_by);
	if (newmaara >= 0) {
		document.getElementById(resultfield).value = change_by;
		document.getElementById(oldfield).value = Number(document.getElementById(oldfield).value) + Number(change_by);
		document.getElementById(oldfield).style.color = 'blue';
	}
}

var opentuotetiedot = null;
function tuotetieto(koodi) {
	tuoteurl = "/site/tuotetieto.cfm?tuotekoodi=" + koodi; 
	if (!opentuotetiedot || opentuotetiedot.closed) {
		opentuotetiedot = window.open(tuoteurl, "", "width=400,height=520,scrollbars=yes,resizable=yes,toolbar=no,status=no");
	} else {
		opentuotetiedot.location = tuoteurl;
		opentuotetiedot.focus();
	}
}

function printview(querystring) {
	printurl = "/print.cfm?" + querystring;
	window.open(printurl, "", "width=600,height=600,scrollbars=1,resizable=1,toolbar=0,status=0,menubar=1,location=0");
}

function nav_mouseover(nav_id, over_filename) {
	document.getElementById(nav_id).src = over_filename;
}
function nav_mouseout(nav_id, normal_filename) {
	document.getElementById(nav_id).src = normal_filename;
}

function required_fileformat(fmt) {
	
	str = document.getElementById('wimg').value;
	ext = str.substr(-3,fmt.length);
	if (fmt.toLowerCase() !== ext.toLowerCase()) {
		alert("Sallittu tiedostomuoto on '" + fmt + "'");
		document.getElementById('wimg').value = "";
	}
	
}

/*function test() {
	document.getElementById('testspan').innerHTML = document.getElementById('maintd').clientHeight;
}*/
/*function submitform(form_id) {
	document.getElementById(form_id).submit();
}*/
