﻿// JScript File
  function setStatus(grid,clsNm, action)
	{ 
	       
	        if(document.getElementById("gvContacts_ctl05_ddStatus"))
	        {	        
	         if(document.getElementById("gvContacts_ctl05_ddStatus").selectedIndex < 1)
	         {
	          document.getElementById("divValidationMsg").innerHTML = "Please select the supplier type and supplier to change the status";
	           //alert("Please select the supplier type")
	           return	
	         }		 
	        }
	  		var status,count, str="";
	  		//loop for checking all the records coming in the html-table format 
	  	
			
				//if Click on OK, then call the hdn button click event
				var resp = confirm("Do you want to change the Supplier type?");
				if (resp == true)
					{
						document.getElementById("hdnSelectedSupp").value=str
					   if(action == "Approve")
			           { 
						document.getElementById("btnApprove").click();
					   }
					   if(action == "Suspend")	
					   { 
					    document.getElementById("btnSuspend").click();
					   }
					   if(action == "New")	
					   { 
					    document.getElementById("btnNew").click();
					   }						
					}	
				else
				    document.getElementById("hdnSelectedIds").value = "";				    		
		}
		
		                                                                    
function showHideElement(chkId,controlId)
{
    
	if(document.getElementById(controlId) != null)
	{  
		if( document.getElementById(chkId).checked == true )
		{ 
			document.getElementById(controlId).style.visibility = "visible";
			document.getElementById(controlId).style.position = "relative";
			document.getElementById(controlId).style.height = "100%";
			document.getElementById(controlId).style.width = "100%";
			document.getElementById(controlId).style.overflow = "visible";
		}
		else
		{      
				document.getElementById(controlId).style.visibility = "hidden";
				document.getElementById(controlId).style.position = "absolute";
				document.getElementById(controlId).style.overflow = "hidden";
				document.getElementById(controlId).style.width = "0px";
	    		document.getElementById(controlId).style.height = "0px";		 
		}
	}
}


/* Function to calculet the cancellation amount on WO cancel page */
/*The function is updated to handle the german format of currency i.e. 1,10 instead of 1.10*/
function CalculateVAT(source, dest)
{	
    
    var txtSource, txtDest, txtFees, txtWOFees, txtValue, txtWOValue, txtFeesVAT, txtVATPerc;
    var txtValueVAT, txtValueTotal, txtFeesTotal, txtRefundTotal, txtWOCommission;
    var txtSuppValue, txtSuppValueVAT, txtSuppValueTotal, txtSupplierComm, txtSupplierCommVAT;
    var txtSupplierCommTotal, txtSupplierTotal;

    if (country == "DE")	 
    {   //If the country variable has value DE then replace the commma with the decimal
        txtSource = replaceCommaFormValue(source);
        txtDest = replaceCommaFormValue(dest);
        txtFees = replaceCommaFormValue('txtFees');
        txtWOFees = replaceCommaFormValue('txtWOFees');
        txtValue = replaceCommaFormValue('txtValue');
        txtWOValue = replaceCommaFormValue('txtWOValue');
        txtFeesVAT = replaceCommaFormValue('txtFeesVAT');
        txtVATPerc = replaceCommaFormValue('txtVATPerc');
        txtValueVAT = replaceCommaFormValue('txtValueVAT');
        txtValueTotal = replaceCommaFormValue('txtValueTotal');
        txtFeesTotal = replaceCommaFormValue('txtFeesTotal');
        txtRefundTotal = replaceCommaFormValue('txtRefundTotal');
        txtSuppValue = replaceCommaFormValue('txtSuppValue');
        txtSuppValueVAT = replaceCommaFormValue('txtSuppValueVAT');
        txtSuppValueTotal = replaceCommaFormValue('txtSuppValueTotal');
        txtSupplierComm = replaceCommaFormValue('txtSupplierComm');
        txtSupplierCommVAT = replaceCommaFormValue('txtSupplierCommVAT');
        txtSupplierCommTotal = replaceCommaFormValue('txtSupplierCommTotal');
        txtSupplierTotal = replaceCommaFormValue('txtSupplierTotal');
        txtWOCommission = replaceCommaFormValue('txtWOCommission');
    }
    else
    { //else if country is not DE - take the value as it is.
        txtSource = document.getElementById(source).value;
        txtDest = document.getElementById(dest).value;
        txtFees = document.getElementById('txtFees').value;
        txtWOFees = document.getElementById('txtWOFees').value;
        txtValue = document.getElementById('txtValue').value;
        txtWOValue = document.getElementById('txtWOValue').value;
        txtFeesVAT = document.getElementById('txtFeesVAT').value;
        txtVATPerc = document.getElementById('txtVATPerc').value;
        txtValueVAT = document.getElementById('txtValueVAT').value;
        txtValueTotal = document.getElementById('txtValueTotal').value;
        txtFeesTotal = document.getElementById('txtFeesTotal').value;
        txtRefundTotal = document.getElementById('txtRefundTotal').value;
        txtSuppValue = document.getElementById('txtSuppValue').value;
        txtSuppValueVAT = document.getElementById('txtSuppValueVAT').value;
        txtSuppValueTotal = document.getElementById('txtSuppValueTotal').value;
        txtSupplierComm = document.getElementById('txtSupplierComm').value;
        txtSupplierCommVAT = document.getElementById('txtSupplierCommVAT').value;
        txtSupplierCommTotal = document.getElementById('txtSupplierCommTotal').value;
        txtSupplierTotal = document.getElementById('txtSupplierTotal').value;
        txtWOCommission = document.getElementById('txtWOCommission').value;
    }
    
    
       
	document.getElementById('lblError').innerHTML = "";
    //document.getElementById('divValidationMain').visible = false;
	if (!isNaN(txtSource) && !(txtSource < 0)) {
		if(source == 'txtFees') {
			if(eval(txtSource) > eval(txtWOFees)) {
			   	document.getElementById('lblError').innerText = "WO Fees refunded cannot be greater than " + document.getElementById('txtWOFees').value
				document.getElementById(source).value = document.getElementById('txtWOFees').value
				return false;
			}	
		}
		if(source == 'txtValue') {
			if(eval(txtSource) > eval(txtWOValue)) {
			   	document.getElementById('lblError').innerText = "WO Value refunded cannot be greater than " + document.getElementById('txtWOValue').value
				document.getElementById(source).value = document.getElementById('txtWOValue').value
				return false;
			}	
		}
		
		if(document.getElementById('rdoYes').checked == true) {
			txtFees = eval(txtWOFees).toFixed(2);
			txtFeesVAT = (eval(txtFees) * txtVATPerc / 100)
			txtFeesVAT = eval(txtFeesVAT).toFixed(2)
		} else {
			txtFees = 0
			txtFeesVAT = 0
		}		
			
		if(document.getElementById('txtSuppVATReg').value == 'Yes') {
			txtDest = (txtSource * txtVATPerc / 100)
			txtDest = eval(txtDest).toFixed(2);
		} else {
			txtDest = 0;
			txtDest = eval(txtDest).toFixed(2);
		}
		
		if(txtValue == "")
			txtValue = 0
		if(txtFees == "")
			txtFees = 0
		if(txtValueVAT == "")
			txtValueVAT = 0		    
		if(txtFeesVAT == "")
			txtFeesVAT = 0
			
		txtValueTotal = eval(txtValue) + eval(txtValueVAT)
		txtValueTotal = eval(txtValueTotal).toFixed(2)
		txtFeesTotal = eval(txtFees) + eval(txtFeesVAT)
		txtFeesTotal = eval(txtFeesTotal).toFixed(2)
		
		txtRefundTotal = eval(txtValueTotal) + eval(txtFeesTotal)
		txtRefundTotal = eval(txtRefundTotal).toFixed(2)
		var SuppComm;
		var SuppCommVAT;
		if(document.getElementById('rdoYesComm')) {
			if(document.getElementById('rdoYesComm')) {
				if(document.getElementById('rdoYesComm').checked == true) {
					SuppComm = (eval(txtWOValue) - eval(txtValue))* eval(txtWOCommission) / 100;
					SuppCommVAT = (SuppComm * txtVATPerc / 100)
				} else {
					SuppComm = 0;
					SuppCommVAT = 0;
				}
			} else {
					SuppComm = 0;
					SuppCommVAT = 0;
			}
			txtSuppValue = eval(txtWOValue) - eval(txtValue);
			txtSuppValue = eval(txtSuppValue).toFixed(2)
			if(document.getElementById('txtSuppVATReg').value == 'Yes') {
				txtSuppValueVAT = (txtSuppValue * txtVATPerc / 100)
				txtSuppValueVAT = eval(txtSuppValueVAT).toFixed(2)
			} else {
				txtSuppValueVAT = 0;
				txtSuppValueVAT = eval(txtSuppValueVAT).toFixed(2)
			}		
			txtSuppValueTotal = eval(txtSuppValue) + eval(txtSuppValueVAT)
			txtSuppValueTotal = eval(txtSuppValueTotal).toFixed(2)
			txtSupplierComm = eval(SuppComm).toFixed(2);
			//alert(document.getElementById('txtSupplierComm').value)
			txtSupplierCommVAT = eval(SuppCommVAT).toFixed(2);
			txtSupplierCommTotal = eval(txtSupplierComm) + eval(txtSupplierCommVAT)
			txtSupplierCommTotal = eval(txtSupplierCommTotal).toFixed(2)
			txtSupplierTotal = eval(txtSuppValueTotal) - eval(txtSupplierCommTotal)
			txtSupplierTotal = eval(txtSupplierTotal).toFixed(2)
		}
		document.getElementById('lblError').innerText = ""	
				
	} else
		{
		       document.getElementById('lblError').innerText = "Please enter positive whole numbers only"
		}	
		
		if (document.getElementById('txtValue'))
		    document.getElementById('CalculatedWOValue').value = document.getElementById('txtValue').value;
		if (document.getElementById('txtSuppValue'))
	        document.getElementById('CalculatedSuppWoValue').value = document.getElementById('txtSuppValue').value;   
	        
    if (country == "DE")	 
    {   // after the calculations are done for DE admin - replace decimal with comma.
        if (document.getElementById(source))
            document.getElementById(source).value = replaceDecimalFormValue(txtSource + "");
        if (document.getElementById('txtFees'))
            document.getElementById('txtFees').value = replaceDecimalFormValue(txtFees + "");
        if (document.getElementById('txtWOFees'))
            document.getElementById('txtWOFees').value = replaceDecimalFormValue(txtWOFees + "");
        if (document.getElementById('txtValue'))
            document.getElementById('txtValue').value = replaceDecimalFormValue(txtValue + "");
        if (document.getElementById('txtWOValue'))
            document.getElementById('txtWOValue').value = replaceDecimalFormValue(txtWOValue + "");
        if (document.getElementById('txtFeesVAT'))
            document.getElementById('txtFeesVAT').value = replaceDecimalFormValue(txtFeesVAT + "");
        if (document.getElementById('txtVATPerc'))
            document.getElementById('txtVATPerc').value = replaceDecimalFormValue(txtVATPerc + "");
        if (document.getElementById('txtValueVAT'))
            document.getElementById('txtValueVAT').value = replaceDecimalFormValue(txtValueVAT + "");
        if (document.getElementById('txtValueTotal'))
            document.getElementById('txtValueTotal').value = replaceDecimalFormValue(txtValueTotal + "");
        if (document.getElementById('txtRefundTotal'))document.getElementById('txtFeesTotal').value = replaceDecimalFormValue(txtFeesTotal + "");
            document.getElementById('txtRefundTotal').value = replaceDecimalFormValue(txtRefundTotal + "");
        if (document.getElementById('txtSuppValue'))
            document.getElementById('txtSuppValue').value  = replaceDecimalFormValue(txtSuppValue + "");
        if (document.getElementById('txtSuppValueVAT'))
            document.getElementById('txtSuppValueVAT').value = replaceDecimalFormValue(txtSuppValueVAT + "");
        if (document.getElementById('txtSuppValueTotal'))
            document.getElementById('txtSuppValueTotal').value = replaceDecimalFormValue(txtSuppValueTotal + "");
        if (document.getElementById('txtSupplierComm'))
            document.getElementById('txtSupplierComm').value = replaceDecimalFormValue(txtSupplierComm + "");
        if (document.getElementById('txtSupplierCommVAT'))
            document.getElementById('txtSupplierCommVAT').value = replaceDecimalFormValue(txtSupplierCommVAT + "");
        if (document.getElementById('txtSupplierCommTotal'))
            document.getElementById('txtSupplierCommTotal').value = replaceDecimalFormValue(txtSupplierCommTotal + "");
        if (document.getElementById('txtSupplierTotal'))
            document.getElementById('txtSupplierTotal').value = replaceDecimalFormValue(txtSupplierTotal + ""); 
        if (document.getElementById('txtWOCommission'))
            document.getElementById('txtWOCommission').value = replaceDecimalFormValue(txtWOCommission + "");
        if (document.getElementById(dest))
            document.getElementById(dest).value = replaceDecimalFormValue(txtDest + "");
        
    }    
    else
    {   // for other admin - take the values as it is.
        if (document.getElementById(source))
            document.getElementById(source).value = (txtSource);
        if (document.getElementById('txtFees'))
            document.getElementById('txtFees').value = (txtFees);
        if (document.getElementById('txtWOFees'))
            document.getElementById('txtWOFees').value = (txtWOFees );
        if (document.getElementById('txtValue'))
            document.getElementById('txtValue').value = (txtValue);
        if (document.getElementById('txtWOValue'))
            document.getElementById('txtWOValue').value = (txtWOValue);
        if (document.getElementById('txtFeesVAT'))
            document.getElementById('txtFeesVAT').value = (txtFeesVAT);
        if (document.getElementById('txtVATPerc'))
            document.getElementById('txtVATPerc').value = (txtVATPerc);
        if (document.getElementById('txtValueVAT'))
            document.getElementById('txtValueVAT').value = (txtValueVAT);
        if (document.getElementById('txtValueTotal'))
            document.getElementById('txtValueTotal').value = (txtValueTotal);
        if (document.getElementById('txtFeesTotal'))
            document.getElementById('txtFeesTotal').value = (txtFeesTotal);
        if (document.getElementById('txtRefundTotal'))
            document.getElementById('txtRefundTotal').value = (txtRefundTotal);
        if (document.getElementById('txtSuppValue'))
            document.getElementById('txtSuppValue').value  = (txtSuppValue);
        if (document.getElementById('txtSuppValueVAT'))
            document.getElementById('txtSuppValueVAT').value = (txtSuppValueVAT);
        if (document.getElementById('txtSuppValueTotal'))
            document.getElementById('txtSuppValueTotal').value = (txtSuppValueTotal);
        if (document.getElementById('txtSupplierComm'))
            document.getElementById('txtSupplierComm').value = (txtSupplierComm);
        if (document.getElementById('txtSupplierCommVAT'))
            document.getElementById('txtSupplierCommVAT').value = (txtSupplierCommVAT);
        if (document.getElementById('txtSupplierCommTotal'))
            document.getElementById('txtSupplierCommTotal').value = (txtSupplierCommTotal);
        if (document.getElementById('txtSupplierTotal'))
            document.getElementById('txtSupplierTotal').value = (txtSupplierTotal); 
        if (document.getElementById('txtWOCommission'))
            document.getElementById('txtWOCommission').value = (txtWOCommission);        
        if (document.getElementById(dest))
            document.getElementById(dest).value = (txtDest);
    }
}


/*Function to calculate the refund value for refund value funds*/
/*Function updated to handle the german format of curreny*/
function CalculateRefund(source)
{	
    var txtVATPerc, txtWOFees, txtFees, txtFeesVAT, txtFeesTotal, txtWOValue, txtSource;
    var txtSupplierComm, txtPercComm, txtSupplierCommVAT, txtSupplierCommTotal, txtWOCommission;

    if (country == "DE")	 
    {//If the country variable has value DE then replace the commma with the decimal
        txtVATPerc = replaceCommaFormValue('txtVATPerc');
        txtWOFees = replaceCommaFormValue('txtWOFees');
        txtFees = replaceCommaFormValue('txtFees');
        txtFeesVAT = replaceCommaFormValue('txtFeesVAT');
        txtFeesTotal = replaceCommaFormValue('txtFeesTotal');
        txtWOValue = replaceCommaFormValue('txtWOValue');
        txtSource = replaceCommaFormValue(source);
        
        txtSupplierComm = replaceCommaFormValue('txtSupplierComm');
        txtPercComm = replaceCommaFormValue('txtPercComm');
        txtSupplierCommVAT = replaceCommaFormValue('txtSupplierCommVAT');
        txtSupplierCommTotal = replaceCommaFormValue('txtSupplierCommTotal');
        txtWOCommission = replaceCommaFormValue('txtWOCommission');
    }
    else
    {//else if country is not DE - take the value as it is.
        txtVATPerc = document.getElementById('txtVATPerc').value;
        txtWOFees = document.getElementById('txtWOFees').value;
        txtFees = document.getElementById('txtFees').value;
        txtFeesVAT = document.getElementById('txtFeesVAT').value;
        txtFeesTotal = document.getElementById('txtFeesTotal').value;
        txtWOValue = document.getElementById('txtWOValue').value;
        txtSource = document.getElementById(source).value;
        
        txtSupplierComm = document.getElementById('txtSupplierComm').value;
        txtPercComm = document.getElementById('txtPercComm').value;
        txtSupplierCommVAT = document.getElementById('txtSupplierCommVAT').value;
        txtSupplierCommTotal = document.getElementById('txtSupplierCommTotal').value;
        txtWOCommission = document.getElementById('txtWOCommission').value;
    }
    
	document.getElementById('lblError').innerHTML = "";
	//check if not invalid number - AP
	if (!isNaN(txtSource) && !(txtSource < 0)) {		
		document.getElementById('lblError').innerHTML = ""
		//if fees not already refunded - AP
		if(document.getElementById('tblBuyer')) {
			//if no fee refund option not chekced, allow going further - AP
			if(document.getElementById('rdoNoFee')) {
				if(document.getElementById('rdoNoFee').checked != true) {
					//if full fee to be refunded. disallow edit of fee textbox - AP
					if(document.getElementById('rdoFullFee')) {
						if(document.getElementById('rdoFullFee').checked == true) {
							txtFees = eval(txtWOFees).toFixed(2);
							document.getElementById('txtFees').readOnly = true;
						} else { // check if refund amount is not greater than allowable.
							if(eval(txtFees) > eval(txtWOFees)) {
								if(document.getElementById('lblError').innerHTML != "")
									document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "<br>"
								document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "WO Fees refunded cannot be greater than &pound;" + document.getElementById('txtWOFees').value
								txtFees = txtWOFees
							}	
							document.getElementById('txtFees').readOnly = false;
						}
						//calculate VAT - AP
						txtFeesVAT = (eval(txtFees) * txtVATPerc / 100)
						txtFeesVAT = eval(txtFeesVAT).toFixed(2)
						
						if(txtFees == "")
							txtFees = 0
						if(txtFeesVAT == "")
							txtFeesVAT = 0
						//Calculate Total for fees - AP
						txtFees = eval(txtFees).toFixed(2)
						txtFeesVAT = eval(txtFeesVAT).toFixed(2)
						txtFeesTotal = eval(txtFees) + eval(txtFeesVAT)
						txtFeesTotal = eval(txtFeesTotal).toFixed(2)
					}
				} else {//refund no fee, set to 0 and readonly - AP
					document.getElementById('txtFees').readOnly = true;
					txtFees = 0;
					txtFeesVAT = 0;
					txtFeesTotal = 0;
				}
			}
		}
		if(document.getElementById('tblSupplier')) {
			var SuppComm;
			var SuppCommVAT;
			SuppComm = eval(txtWOValue) * eval(txtWOCommission) / 100;
			if(document.getElementById('rdoNoComm')) {
				if(document.getElementById('rdoNoComm').checked != true) {
					if(document.getElementById('rdoFullComm').checked == true) {
						txtSupplierComm = eval(SuppComm).toFixed(2);
						document.getElementById('txtSupplierComm').readOnly = true;
						document.getElementById('rdoPerc').disabled = true;
						document.getElementById('rdoFlat').disabled = true;
						document.getElementById('tdPerc').style.visibility = "hidden"
					} else {
						document.getElementById('rdoPerc').disabled = false;
						document.getElementById('rdoFlat').disabled = false;
						
						if(document.getElementById('rdoFlat').checked == true) {
							document.getElementById('tdPerc').style.visibility = "hidden"
							if(eval(txtSupplierComm) > eval(SuppComm)) {
							if(document.getElementById('lblError').innerHTML != "")
									document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "<br>"
								document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "Supplier Commission refunded cannot be greater than &pound;" + SuppComm
								txtSupplierComm = SuppComm
							}	
						} else {
							document.getElementById('tdPerc').style.visibility = "visible"
							if(eval(txtPercComm) > eval(txtWOCommission)) {
								if(document.getElementById('lblError').innerHTML != "")
									document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "<br>"
								document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "Supplier Commission refunded cannot be greater than " + document.getElementById('txtWOCommission').value + "%."
								txtPercComm = txtWOCommission;
							}	
							SuppComm = eval(txtWOValue) * eval(txtPercComm) / 100;
							txtSupplierComm = SuppComm
						}
						document.getElementById('txtSupplierComm').readOnly = false;
					}

					txtSupplierCommVAT = (txtSupplierComm * txtVATPerc / 100)
					txtSupplierCommVAT = eval(txtSupplierCommVAT).toFixed(2);

					if(txtSupplierComm == "")
						txtSupplierComm = 0
					if(txtSupplierCommVAT == "")
						txtSupplierCommVAT = 0

					txtSupplierComm = eval(txtSupplierComm).toFixed(2);
					txtSupplierCommVAT = eval(txtSupplierCommVAT).toFixed(2);
					txtSupplierCommTotal = eval(txtSupplierComm) + eval(txtSupplierCommVAT)
					txtSupplierCommTotal = eval(txtSupplierCommTotal).toFixed(2)
				} else {//refund no fee, set to 0 and readonly - AP
					document.getElementById('txtSupplierComm').readOnly = true;
					txtSupplierComm = 0;
					txtSupplierCommVAT = 0;
					txtSupplierCommTotal = 0;
					document.getElementById('rdoPerc').disabled = true;
					document.getElementById('rdoFlat').disabled = true;
					document.getElementById('tdPerc').style.visibility = "hidden"
				}
			} 
		}
	} else {
		document.getElementById('lblError').innerHTML = "Please enter positive whole numbers only";
		document.getElementById(source).value = 0;
		document.getElementById(source+'VAT').value = 0;
		document.getElementById(source+'Total').value = 0;
	}
	if (document.getElementById('txtFees'))
	    document.getElementById('CalculatedFees').value = document.getElementById('txtFees').value;
	if (document.getElementById('txtSupplierComm'))
        document.getElementById('CalculatedComm').value = document.getElementById('txtSupplierComm').value;
	if (document.getElementById('txtPercComm'))
        document.getElementById('CalculatedCommPerc').value = document.getElementById('txtPercComm').value;
        
    if (country == "DE")	 
    {// after the calculations are done for DE admin - replace decimal with comma.
        
        if (document.getElementById(source))
            document.getElementById(source).value = replaceDecimalFormValue(txtSource + "");
        if (document.getElementById('txtVATPerc'))
            document.getElementById('txtVATPerc').value = replaceDecimalFormValue(txtVATPerc + "");
        if (document.getElementById('txtWOFees'))
            document.getElementById('txtWOFees').value = replaceDecimalFormValue(txtWOFees + "");
        if (document.getElementById('txtFees'))
            document.getElementById('txtFees').value = replaceDecimalFormValue(txtFees + "");
        if (document.getElementById('txtFeesVAT'))
            document.getElementById('txtFeesVAT').value = replaceDecimalFormValue(txtFeesVAT + "");
        if (document.getElementById('txtFeesTotal'))
            document.getElementById('txtFeesTotal').value = replaceDecimalFormValue(txtFeesTotal + "");
        if (document.getElementById('txtWOValue'))
            document.getElementById('txtWOValue').value = replaceDecimalFormValue(txtWOValue + "");
        if (document.getElementById('txtSupplierComm'))
            document.getElementById('txtSupplierComm').value = replaceDecimalFormValue(txtSupplierComm + "");
        if (document.getElementById('txtPercComm'))
            document.getElementById('txtPercComm').value = replaceDecimalFormValue(txtPercComm + "");
        if (document.getElementById('txtSupplierCommVAT'))
            document.getElementById('txtSupplierCommVAT').value = replaceDecimalFormValue(txtSupplierCommVAT + "");
        if (document.getElementById('txtSupplierCommTotal'))
            document.getElementById('txtSupplierCommTotal').value = replaceDecimalFormValue(txtSupplierCommTotal + "");
        if (document.getElementById('txtWOCommission'))
            document.getElementById('txtWOCommission').value = replaceDecimalFormValue(txtWOCommission + "");                
    } 
    else
    {   // for other admin - take the values as it is.
    
        if (document.getElementById(source))
            document.getElementById(source).value = (txtSource);
        if (document.getElementById('txtVATPerc'))
            document.getElementById('txtVATPerc').value = (txtVATPerc);
        if (document.getElementById('txtWOFees'))
            document.getElementById('txtWOFees').value = (txtWOFees);
        if (document.getElementById('txtFees'))
            document.getElementById('txtFees').value = (txtFees);
        if (document.getElementById('txtFeesVAT'))
            document.getElementById('txtFeesVAT').value = (txtFeesVAT);
        if (document.getElementById('txtFeesTotal'))
            document.getElementById('txtFeesTotal').value = (txtFeesTotal);
        if (document.getElementById('txtWOValue'))
            document.getElementById('txtWOValue').value = (txtWOValue);
        if (document.getElementById('txtSupplierComm'))
            document.getElementById('txtSupplierComm').value = (txtSupplierComm);
        if (document.getElementById('txtPercComm'))
            document.getElementById('txtPercComm').value = (txtPercComm);
        if (document.getElementById('txtSupplierCommVAT'))
            document.getElementById('txtSupplierCommVAT').value = (txtSupplierCommVAT);
        if (document.getElementById('txtSupplierCommTotal'))
            document.getElementById('txtSupplierCommTotal').value = (txtSupplierCommTotal);
        if (document.getElementById('txtWOCommission'))
            document.getElementById('txtWOCommission').value = (txtWOCommission);                
    }   
}
	
/*Function to replace comman with decimal in the given string*/	
function replaceCommaFormValue(strField)
{
    var strFieldValue 
    if (document.getElementById(strField))
    {
        strFieldValue = document.getElementById(strField).value
        if(strFieldValue.indexOf(",") != -1 )
        {
            strFieldValue = strFieldValue.replace(",", ".")
        } 
     }
     else
        strFieldValue = ""
    return strFieldValue
}
/*Function to replace decimal with comma in the given string*/	
function replaceDecimalFormValue(strField)
{
    var strFieldValue = strField
    if  (strFieldValue.indexOf(".") != -1 )
    {
        strFieldValue = strFieldValue.replace(".", ",")
    }
    return strFieldValue
}


function setValuesRefund()
{
	if(document.getElementById('tblSupplier')) {
		document.getElementById('rdoFlat').checked = true;
		document.getElementById('rdoPerc').disabled = true;
		document.getElementById('rdoFlat').disabled = true;
	}
}

function sumbitRefund()
{
    var txtFees;
    var txtSupplierComm;
    
    if (country = "DE")	 
    {
        txtFees = replaceCommaFormValue('txtFees');
        txtSupplierComm = replaceCommaFormValue('txtSupplierComm');        
    }
   
	var RefundValid = false
	if(document.getElementById('rdoNoComm'))
		if(document.getElementById('rdoNoComm').checked != true && (!isNaN(txtSupplierComm) && !(txtSupplierComm < 0)))
			RefundValid = true
	if(document.getElementById('rdoNoFee'))
		if(document.getElementById('rdoNoFee').checked != true && (!isNaN(txtFees) && !(txtFees < 0)))
			RefundValid = true
	if(RefundValid == false) {
		if(document.getElementById('lblError').innerHTML == "")
			document.getElementById('lblError').innerHTML = document.getElementById('lblError').innerHTML + "Please select an option to refund."
	}
	if(document.getElementById('lblError').innerHTML == "")
		document.getElementById('btnSubmit').click();
}

function handleSPOutstandingEtoE()
{
 window.open(document.getElementById('hdnEtoE').value);
 document.getElementById('btnUpdateStatus').click();
}

