﻿// JScript File

//var is_appname = navigator.appName;
//var is_appcodename = navigator.appCodeName;
var is_Safari = navigator.userAgent.indexOf('Safari');
var is_Firefox = navigator.userAgent.indexOf('Firefox');
function SetFoodDescId(FoodDescId)
{   
    //alert(is_Firefox);
    //alert(is_Safari);
	var temp = document.getElementById("hidFoodDescId");
	if(temp != null && temp!= "")
	{
		temp.value = FoodDescId;
	}
   
	
	var btnObj=document.getElementById("btnHidden");
	if (document.all)
	{	   
		// IE
		btnObj.click();
		
	}
	else
    if(is_Firefox > 0)
    {   
        //For Firefox
	     var e = document.createEvent("MouseEvents");
		 e.initEvent("click", true, true);
    	 btnObj.dispatchEvent(e);         
	}
    else
    if(is_Safari > 0)
	{ 
	    //For Safari
	     btnObj.click();
	}	
	else
	{   //For Other Browser
	    btnObj.click();
	}	

	return true;
 
}


function CalculateValidate()
{
   if(ValidateCalculateForm()==false)
	{
		return(false);
	}
	else
	{
	   // alert("Validation successful");
		return(true);
	}

}

function ValidateCalculateForm()
{
	
	errors = "<ul>";
	
	var status = true;
	mandatoryFieldsErrorFlag=false;
	
	// validating Title field
	var varTemp = document.getElementById("txtAmount");
   
	var alertName = " Serving ";
	var isMandatory = 'True';
	
	var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
	registrationErrorsDiv.innerHTML = "";
	registrationErrorsDiv.style.display = "none";
	document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
	
   if(bValidate(varTemp, "Float" ,isMandatory , alertName) != true)
	{	status = false;  
	   
	}
		
   //if validation of any field comes out to be invalid then display error message 
   if(status == false)
   {
	   
		var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");

		registrationErrorsDiv.style.display = "block";
		errors +='</ul>';
		registrationErrorsDiv.innerHTML = "";
        document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
		registrationErrorsDiv.innerHTML = errors; 
	   
		return false;   
	}
	else 
	{
		return true;
	}   
}
function btnBackClick()
{
    var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
	registrationErrorsDiv.innerHTML = "";
	registrationErrorsDiv.style.display = "none";
	document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
	return true;
}
 function HandleException()
 {
      if (!document.all)
       {
            window.onbeforeunload = function()
             {
               Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
              }
      }
  }

  function endRequest(sender, e)
  {
       var err = e.get_error();
        if (err)
        {
              if (err.name == "Sys.WebForms.PageRequestManagerServerErrorException") 
              {
                e.set_errorHandled(true);
              }
              if (err.name == "Sys.WebForms.PageRequestManagerParserErrorException") 
              {
                e.set_errorHandled(true);
              }
        }
  }
