﻿// JScript File

function CheckForModifications()
{
    var intLoop;
    var intCount = 0;
    var rowCount= 0;
    rowCount= document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails").rows.length;
    document.getElementById("ctl00_ContentPlaceHolder1_lblErr").Text = "";
	
   for (intLoop = 0;intLoop < rowCount; intLoop++)
   {    
       var hdnQtyInStock = 0;
       var hidQuantity = 0;
       var txtQty = 0;
       if(intLoop<10)
	    {      
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_txtQty_txtQty") != null)
	        {
	    	    txtQty = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_txtQty_txtQty").value;
	        }
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_hdnQtyInStock") != null)
	        {
	            hdnQtyInStock = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_hdnQtyInStock").value;
	        }
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_hidQuantity") != null)
	        {
	            hidQuantity = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl0"+intLoop+"_hidQuantity").value;
	        }
	        
	        if (txtQty != hidQuantity)
	        {
	            alert("You have changed the Quantity for one of the products. Please Recalculate before checked out.");
	            return false;
	        }
	    }
	    else
	    {
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_txtQty_txtQty") != null)
	        {
	    	    txtQty = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_txtQty_txtQty").value;
	        }
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_hdnQtyInStock") != null)
	        {
	            hdnQtyInStock = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_hdnQtyInStock").value;
	        }
	        if(document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_hidQuantity") != null)
	        {
	            hidQuantity = document.getElementById("ctl00_ContentPlaceHolder1_dlTempOrderDetails_ctl"+intLoop+"_hidQuantity").value;
	        }
	        
	        if (txtQty != hidQuantity)
	        {
	            alert("You have changed the Quantity for one of the products. Please Recalculate before checked out.");
	            return false;
	        }
	    }			
	}
	return true;
}