function ConfirmActivate() {
  if (confirm("Are you sure you want to Activate this?") == true)
    return true;
  else
    return false;
}
function ConfirmAccount() {
  if (confirm("Are you sure you want to Account this invoice?") == true)
    return true;
  else
    return false;
}
function ConfirmAccountEvt(csMsg) {
  if (confirm("Are you sure you want to " + csMsg + " this Account?") == true)
    return true;
  else
    return false;
}
function ConfirmGlobal() {
  if (confirm("Are you sure you want to make global this Plan?") == true)
    return true;
  else
    return false;
}
function ConfirmComplete() {
  if (confirm("Are you sure you want to Completed this?") == true)
    return true;
  else
    return false;
}
function ConfirmDeleteNew(csMsg) {
  if (confirm("Are you sure you want to delete this " + csMsg + "?") == true)
    return true;
  else
    return false;
}
function ConfirmDelete() 
{ 
	if (confirm("Are you sure you want to delete this record?")==true) 
		return true; 
	else 
		return false; 
}
function ConfirmApprove() 
{ 
	if (confirm("Are you sure you wish to approve this Quotation?")==true) 
		return true; 
	else 
		return false;
}
function ConfirmCancelPO() {
  if (confirm("Do you want to cancel this PO?") == true)
    return true;
  else
    return false;
}
function ConfirmApprovePO() {
  if (confirm("Are you sure you wish to approve this PO?") == true)
    return true;
  else
    return false;
}
function ConfirmCancel() 
{ 
	if (confirm("Do you want to CANCEL your order?")==true) 
		return true; 
	else 
		return false; 
}
function ConfirmFavStoreDelete() 
{ 
	if (confirm("Are you sure you want to delete this restaurant from your list?")==true) 
		return true; 
	else 
		return false; 
}
function ConfirmRemove() 
{ 
	if (confirm("Are you sure you want to delete these items from your Usual/Confirm Order" + "\n"+ "and"  + " find a new restaurant?")==true) 
		return true; 
	else 
		return false; 
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function OpenNewWindow(Page){
	var objWindow=window.open(Page,"awindow","toolbar=no,scrollbars=yes,top=100,left=100,width=560,height=340");
}

function OpenNewWindow1(Page){
	var objWindow=window.open(Page,"awindow","toolbar=no,scrollbars=yes,top=100,left=100,width=740,height=540");
}
function openViewWindow(pgName)
{
	var myPage = window.open(pgName, 'ViewItemForm', 'Scrollbars=yes,Toolbar=yes,resizable=no,left=230,top=150,width=460,height=560');
}
function open_Attribute_Style_Window(pgName)
{
	var myPage = window.open(pgName, 'View_Attribute_Style', 'Scrollbars=yes,Toolbar=no,resizable=no,left=230,top=150,width=520,height=460');
}
function setSubmit(x)
{
	alert(x);
	if (x==1)
	{
		toSubmit = 'btnLogin';
	}
	else if (x==2)
	{
		toSubmit = 'btnSubmit';
	}
	else
	{
		toSubmit = 'none';
	}
}
function goSubmit(){
	
	if (toSubmit == 'btnLogin')
	{
		window.document.all("btnLogin").click();
	}
	if (toSubmit == 'btnSubmit')
	{
		window.document.all("btnSubmit").click();
	}
}
function clickButton(e, buttonid)
{ 
			var bt = document.getElementById(buttonid); 
			if (typeof bt == 'object')
			{ 
						if(navigator.appName.indexOf("Netscape")>(-1)){ 
									if (e.keyCode == 13){ 
												bt.click(); 
												return false; 
									} 
						} 
						if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
									if (event.keyCode == 13){ 
												bt.click(); 
												return false; 
									} 
						} 
			} 
} 
function SetFocus(fieldID)
{
			var bt = document.getElementById(fieldID); 
			if (bt != null)
			{
				if (typeof bt == 'object')
				{
					bt.focus();
				}
			}
			return true;
}
function SetFocusViaTextBox(txtFocusID)
{
	var fieldTag = document.getElementById(txtFocusID);
	if (fieldTag != null)
	{
		if (typeof fieldTag == 'object')
		{
			SetFocus(fieldTag.value);	
		}
	}
}
function SetFocusBack(fieldTag)
{
	var fieldID = document.getElementById(fieldTag);
	if (fieldID != null)
	{
		var bt = document.getElementById(fieldID.value); 
		if (bt != null)
		{
			if (typeof bt == 'object')
			{
				bt.focus();
			}
		}
	}
}


		/* -- Checkbox List / Radio Button List on the button */
function chkList_Max_OnBtn(csListID, inTotCount, inMaxSelected)
{
	var inCtr;
	var inCheckMaxCtr = 0;
	if (inTotCount > 0)
	{
		for (inCtr=0; inCtr <= inTotCount - 1; inCtr++)
			{ 
				var csCreatedID = csListID + "_" + inCtr;
				if(window.document.getElementById(csCreatedID).checked==true)
				{
					inCheckMaxCtr	= inCheckMaxCtr + 1;
				}
			}
			if(inCheckMaxCtr < inMaxSelected) return false;
	} 
	return true;
}
			
		/////////////////////////////////////////////////////////////////////////
//		function ShowCaption(csEventID)
	//	{
		//	switch(csEventID)
			//{
				//case 'Category_Default':  window.document.getElementById('lblMsg').value = "Manage your restaurant categories." ;		break; 
			//	case 'Category_Edit':  window.document.getElementById('lblMsg').value = "Edit your restaurant categories." ;		break; 
			//	case 'Category_Add':  window.document.getElementById('lblMsg').value = "Add new restaurant categories." ;		break; 
		//	} 
	//	}
	  /////////////////////////////////////////////////////////////////////////


function movefocus(txtToValidate, txtToFocus, maxlimit)
{
	var txtToValidate = document.getElementById(txtToValidate);
	
	if (txtToValidate.value.length + 1 > maxlimit)
	{
		var txtSetfocus = document.getElementById(txtToFocus);
		txtSetfocus.focus();
	}
}


//////////////////////////////////////////////////////////////////
//Loading Duration Function
/////////////////////////////////////////////////////////////////
function showImage()
{                        
    document.getElementById('image').style.display = "block";                                                
    document.getElementById('data').style.display = "none";                        
}
function hideImage()
{
    document.getElementById('image').style.display = "none";
    document.getElementById('data').style.display = "block";                        
}


		//---RadioBution event with one Textbox ENABLED OR DISABLED WITH COLOR CHANGE and Validator Enabled or disabled
function setRdTxtOneEnabledValidator(rdID,txtID,validatorID)
	{
	var rdbutton = document.getElementById(rdID);
	var txtbox = document.getElementById(txtID);
	var validtor = document.getElementById(validatorID);
	
		if (typeof rdbutton == 'object')
		{
			if (rdbutton.checked == true) 
			{
				txtbox.disabled = false;  
				validtor.enabled = true;
				txtbox.style.backgroundColor="#ffffff";
			}
			else
			{
				txtbox.value=""
				txtbox.disabled = true;
				validtor.enabled = false;
				txtbox.style.backgroundColor="#d3d3d3";
			}
		}
	}

//---RadioBution event with one Textbox ENABLED OR DISABLED WITH COLOR CHANGE and Validator Enabled or disabled
function comboEffect(cmbID,rowID,datavalue)
	{
		var comboID = document.getElementById(cmbID);
		var TRID = document.getElementById(rowID);
		
			if (typeof comboID == 'object')
			{
					if (datavalue == 'O') 
					{
							if (typeof TRID == 'object')
							{
								TRID.visibility='visible';
							}
					}
					else
					{
							if (typeof TRID == 'object')
							{
								TRID.visibility='hiddien';
							}
					}
			}
	}

//alert('done global');
////////////////////////////////////
  var form_submitted = false;
  function submit_form()
  {
   if (form_submitted)
   {
    alert( "Your form has already been submitted. Please wait for some time and click OK to continue!" );
    form_submitted = false;
    return false;
   }
   else
   {
    form_submitted = true;
    return true;
   }
  }


/////////////////////////////////////////////////////////////////////////
// Text Character Counter and Limit set to Destination textbox

		function LimittextCounter(field,cntfield,maxLimit)
		{
			var Srcfield = document.getElementById(field);
			var Destfield = document.getElementById(cntfield);
				if (Srcfield != null)
				{
					if (Srcfield.value.length > maxLimit) 
					{
						Srcfield.value = Srcfield.value.substring(0, maxLimit);
						return false; 
					}
					Destfield.value = (Srcfield.value.length);
					return true; 
				}
		}

		// Text Character Counter and Limit without set to Destination textbox

		function LimittextCounterWithoutDestination(field,maxLimit)
		{
			var Srcfield = document.getElementById(field);
				if (Srcfield != null)
				{
					if (Srcfield.value.length >= maxLimit) 
					{
						Srcfield.value = Srcfield.value.substring(0, maxLimit-1);
						return false; 
					}
					return true; 
				}
		}
		
		
	function ConfirmCashPurchase() 
  { 
	  if (confirm("Your Payment method is Cash. Make sure that your phone/mobile is registered with MHungry? If your phone is registered then it will ring soon to confirm the order!")==true) 
		  return true; 
	  else 
		  return false; 
  }

function ConfirmJump() 
{ 
	if (confirm("Are you sure to qit this Page?")==true) 
		return true; 
	else 
		return false; 
}

function ConfirmStoreChange() 
{ 
if (confirm("If you change the restaurant then all the Shop Cart Items will be lost. Are you sure?")==true) 
return true; 
else 
return false; 
}

function ConfirmDecline() 
{ 
if (confirm("You really want to decline your Group order?")==true) 
return true; 
else 
return false; 
}

/////////////////////
function fn_blankfield(txtField, msg)
{
	var field_ID = document.getElementById(txtField);
	if (field_ID != null)
	{
		if (field_ID.value == "")
		{
			alert(msg + " cannot be blank!");
			field_ID.focus();
			return false;
		}
	return true;
	}
}


/////////////////////
function fn_checkedPPC(chkField1, chkField2)
{
	var field_ID1 = document.getElementById(chkField1);
	var field_ID2 = document.getElementById(chkField2);
	
	if (field_ID1 != null)
	{
		if (field_ID1.checked == 0)
		{
			alert("Please check the user agreement checkbox!");
			field_ID1.checked = 1
			return false;
		}
	}
	if (field_ID2 != null)
	{
		if (field_ID2.checked == 0)
		{
			alert("Please check the user privacy policy checkbox!");
			field_ID2.checked = 1
			return false;
		}
	}
//	return true;
}

///////////////////////////
function chkBlank(txtToCheck, csmsg)
{
	var txtBox = document.getElementById(txtToCheck);
	
	if (txtBox.value == "")
	{
		alert("Please enter " + csmsg);
		txtBox.focus();
	}
}
/*  Radio Button section   */
	function chk_Required(csID, csDispName)
	{ 
		var bt = document.getElementById(csID);
		if (bt != null)
		{
			if (typeof bt == 'object')
			{
				if (bt.value != "") return true;
			}
		}
		alert(csDispName + " is required!");
		return false;
	}
///////////////////////////////////////
	
function fn_Calc_Markup_OnSell(dlCost, dlMarkUp, txtSellPrice, txtMargin)
{
	var txtSellBox = document.getElementById(txtSellPrice);
	var txtMarginBox = document.getElementById(txtMargin);
	
	if (dlCost == 0)
	{
	  txtSellBox.value = round(0,2);
	  txtMarginBox.value = round(0,2);
	}
	else
	{
	  txtSellBox.value = dlCost + ((dlCost * dlMarkUp)/100);
	  txtMarginBox.value = ((dlCost * dlMarkUp)/100);
	}  
}


