
function isFireFox() {
	return (navigator.userAgent.indexOf("Firefox")!=-1);
}

function isOpera() {
	return (navigator.userAgent.indexOf("Opera")!=-1);
}

/*
function IEVersion() {
	var version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
			version=parseFloat(temp[1])
	}
	
	return version;
}
*/
function isNum(passedVal)
{
	// Is this a number ?
	if (passedVal == "") 
	{
		return false;
	}

	for (i=0; i<passedVal.length; i++) 
	{
		if ((passedVal.charAt(i) < "0" || passedVal.charAt(i) > "9") && passedVal.charAt(i) != "." && passedVal.charAt(i) != "-") 
			return false;
	}

	return true;
}

function GotoURL(sURL)
{
	window.open(sURL,"_self");
}

function GotoURLSelf(sURL)
{
	window.open(sURL,"_self");
}

function GotoURLTop(sURL)
{
	window.open(sURL,"_top");
}

function validEmail(email)
{
  invalidChars = " /:,;";
  if (email == "") {
    return false;
  }

  for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i);
    if (email.indexOf(badChar,0) != -1) {
      return false;
    }
  }
  
  atPos = email.indexOf("@",1);
  if (atPos == -1) {
    return false;
  }
  
  if (email.indexOf("@",atPos+1) != -1) {
    return false;
  }
  
  periodPos = email.indexOf(".",atPos);
  if (periodPos == -1) {
    return false;
  }
  
  if (periodPos+3 > email.length) {
    return false;
  }
  
  return true;
}

function strrev(str)
{
	str = str.toString();
	len = str.length;

	if (!len)
		return "";

    var s = "";

	for (i=len-1; i >= 0; i--)
	{
		ch = str.charAt(i);
		s = s + ch;
	}
	return s;   
}

function isNumeric(str)
{
	if (str.length == null || str.length == 0)
		return false;
		
	for (var i=0; i < str.length; i++)
	{
	    var ch = str.substring(i, i+1)
	    if ((ch < "0" || ch > "9") && ch != "." && ch != "-")
		{
	      return false
	    }
	}
	return true
}	

function FormatMoney(Value)
{
	if (Value == "")
		return "0.00";

	Value = parseFloat(Value) + 0.0005;
	Value = Value.toString();
		
	if (!isNumeric(Value))
	{
//		alert("value is not numeric '" + Value + "'");
		Value = 0.0;
	}	

	strR = Value;
	// strR is in the format 56.24321
	
	strR = strrev(strR);
	// strR is in the format 12342.65

	periodPos = strR.indexOf(".",1);

	// no decimal place
	if (periodPos == -1) 
		strR = strR + ".00";

	// too many decimal places
	if (periodPos > 2)
		strR = strR.slice(periodPos-2);
		
	if (periodPos == 0)			// starts with a period
		strR = "00" + strR;
		
	else if (periodPos == 1)	// only one decimal place
		strR = "0" + strR;
	
	strR = strrev(strR);
	
	return (strR);
}

function doMouseOver(img, newURL){	if (!newURL || newURL == "")	{		if (img.src.length < 5) return;		var _ext = img.src.substring(img.src.length-4)		var _src = img.src.substring(0, img.src.length-4);				newURL = _src + '_over' + _ext;	}	if (!img.oSrc)		img.oSrc = img.src;			img.src = newURL;}function doMouseOut(img){	if (img.oSrc)		img.src = img.oSrc;}function Search()
{
	document.form1.submit();
}

// MenuItem Function
function mI(menuItem)
{
	var sURL = "module.aspx?mod=menuitem_detail&action=item&menus=0&MenuItemid=" + menuItem + "&r=" + Math.random();

	window.open(sURL, "main")
}

function qI(menuItem, qtyfield)
{
	var sURL = "module.aspx?mod=menuitem_detail&quick=1&action=item&menus=0&MenuItemid=" + menuItem + "&r=" + Math.random();
	
	if (qtyfield)
	{
		sURL = sURL + "&qty=" + document.Form1[qtyfield].value;
		document.Form1[qtyfield].value = 1;
	}

	window.open(sURL, "main")
}

function mOI(orderItem)
{
	var sURL = "module.aspx?mod=menuitem_detail&action=item&menus=0&MyOrderItem=" + orderItem + "&r=" + Math.random();
	
	window.open(sURL, "main")
}

function mC(catID) 
{
	if (!document.all) return;
	
	var txtObj = document.all(catID + "items");
	var imgObj = document.all(catID + "img");

	if (txtObj == null || imgObj == null)
		return;

	//alert(catID + "items");

	if (txtObj.style.display == 'none') 
	{
		txtObj.style.display = '';
		imgObj.src = '/images/minus.gif';
	}
	else 
	{
		txtObj.style.display = 'none';
		imgObj.src = '/images/plus.gif';
	}
}

function setDisplay(e, display)
{
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(e).style.display = display;
	}
	else {
		if (document.layers) { // Netscape 4
			document.e.display = display;
		}
		else { // IE 4
			document.all.e.style.display = display;
		}
	}
}

function setVisibility(eid, visibility)
{
	if (document.getElementById) { // DOM3 = IE5, NS6
		var e = document.getElementById(eid);
		
		if (!e) return;
		
		e.style.visibility = visibility;
	}
	else {
		if (document.layers) { // Netscape 4
			document.eid.visibility = visibility;
		}
		else { // IE 4
			alert("IE4");
			document.all.eid.style.visibility = visibility;
		}
	}
}

function setOptionVisibility(id)
{
	parent.frames["main"].promoteOption(id,1);
}

function showOptions(id)
{
	window.open("module.aspx?mod=toppings&grp=2&menuitemid=" + id, 'toppings');
}

function placeFocus() 
{
	if (document.forms.length > 0) 
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) 
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) 
			{
				document.forms[0].elements[i].focus();
			break;
			}
		}
	}
}
