﻿function CallBackForRecipeHTML(x)
{
document.getElementById('RecipeViewArea').innerHTML = ""
WebForm_DoCallback('__Page',x,RVCallBack,"",MyErrCallBack,true)
}
function DummyCallBack()
{
WebForm_DoCallback('__Page',"",DumCallBack,"",MyErrCallBack,true)
}
function ChangeServings(x)
{
x='chgsvgsiz' + document.getElementById('servings').value;
WebForm_DoCallback('__Page',x,CSCallBack,"",MyErrCallBack,true)
}
function ChangeUnits(x)
{
x='chgunits0' + document.getElementById('units').value
WebForm_DoCallback('__Page',x,CSCallBack,"",MyErrCallBack,true)
}
function ReturnHTMLStr(x)
{
document.getElementById('RecipeViewArea').innerHTML = x
window.scroll(0,0)
}
function ReturnDummyCallBack(x)
{
}
function Print_Recipe_Window(tblname)
{
RecipePrintView = window.open("PrintRecipehtml.aspx", "RecipePrintView", "resizable=1,scrollbars=1,width=700,height=600");
RecipePrintView.moveTo(0,0);
}
function PrintRecipe ()
{
document.getElementById("butHtmlRecipePrint").visble = false
window.print()
window.close()
}

//Functions for editing Keys in input boxes
//var keybYN = new keybEdit('yn','Valid values are \'Y\' or \'N\'.');
//var keybNumeric = new keybEdit('01234567890','Numeric input only.');
//var keybAlpha = new keybEdit('abcdefghijklmnopqurstuvwxy ','Alpha input only.');
//var keybAlphaNumeric = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890 ','Alpha-numeric input only.');
//var keybDecimal = new keybEdit('01234567890.','Decimal input only.');
//var keybDate =  new keybEdit('01234567890/','Date input only');;
//var keybYNNM = new keybEdit('yn');
//var keybNumericNM = new keybEdit('01234567890');
//var keybAlphaNM = new keybEdit('abcdefghijklmnopqurstuvwxy');
//var keybAlphaNumericNM = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890');
//var keybDecimalNM = new keybEdit('01234567890.');
//var keybDateNM = new keybEdit('01234567890/');;
//Usage: editKeyBoard(this,keybAlpha) called for the onkeypress event
function getkeypress(e) {
 e = window.event;
 if( typeof( e.keyCode ) == 'number'  ) {
    //DOM
    e = e.keyCode;
 } else if( typeof( e.which ) == 'number' ) {
    //NS 4 compatible
    e = e.which;
 } else if( typeof( e.charCode ) == 'number'  ) {
    //also NS 6+, Mozilla 0.9+
    e = e.charCode;
 } else {
    //total failure, we have no way of obtaining the key code
    return;
 }
 return e;
//  window.alert('The key pressed has keycode ' + e + ' and is key ' + String.fromCharCode( e ) );
}

function KeyPressSort(typeinput, errmsg) {
//		Purpose:	The purpose of this function is to edit edit keyboard input to determine if the keystrokes are valid.
	var e = getkeypress()
	invalidchar = false;	// Valid character flag
	if (e == 13) {
	document.getElementById("units").focus();
//	document.form.testinput.focus();
	window.event.returnvalue=false;
	return;
	} else	if (typeinput == "numeric") {
		validstr="0123456789";
	} else if (typeinput == "decimal") {
		validstr="0123456789."
	} else if (typeinput == "alpha") {
		validstr = "abcdefghijklmnopq"
	}
	for (i=0;i<validstr.length;i++){
		if (e == validstr.charCodeAt(i)){
			invalidchar = true;
			break;
		}
	}
	if (!invalidchar) {
		window.event.returnValue = false;
	}
}

function confirmSubmit() {
var doc = document.forms[0];
var msg = "Are you sure you want to submit this data?";
if (confirm(msg)) {
doc.submit();
} else {
// do nothing
} }

function dopostback() {
	myform.submit()
//	window.opener.document.forms[0].submit(); 
	//self.close()
}
