﻿// JScript File

             function selectPartialRadio(radPar)
             {
                document.getElementById(radPar).checked = true;
             }
            function validateAdjustment(val1,val2,radPar,chkUnk)
            {
                //alert(parseFloat(document.getElementById("lblPartialTotal").innerHTML));
                CompulsoryTxtFlds = Array(val1,val2);
                FriendlyNames = Array("Amount","Adjustment Date");

                for(i=0;i<CompulsoryTxtFlds.length;i++)
                {
            		
	                myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))

	                if(myfld.value.split(" ").join("") == "")
	                {
		                alert(FriendlyNames[i]+" can not be blank.");
		                myfld.select();
		                myfld.focus();
		                return false;
	                }
                }
                if(document.getElementById(radPar).checked && !document.getElementById(chkUnk).checked)
                {
                    if(!isNaN(document.getElementById(val1).value))
                    {
                        if(parseFloat(document.getElementById(val1).value) != parseFloat(document.getElementById("lblPartialTotal").innerHTML))
                        {
                            alert("Selected Partial Payment and Amount must be same");
                            return false;
                        }
                     }
                }
               
                return true;
            }
            
            
            function validateCPD(val1,val2,val3,val4)
            {
                               
                CompulsoryTxtFlds = Array(val1,val2,val3);
                FriendlyNames = Array("Program","Date","Hours");

                for(i=0;i<CompulsoryTxtFlds.length;i++)
                {
            		
	                myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
	                	                
	                if(myfld.value.split(" ").join("") == "")
	                {
		                alert(FriendlyNames[i]+" can not be blank.");
		                myfld.select();
		                myfld.focus();
		                return false;
	                }
                }

                return true;
            }
            
            
            function validateOrganisation(val1,val2)
            {
                                
                CompulsoryTxtFlds = Array(val1,val2);
                FriendlyNames = Array("Start Date","End Date");

                for(i=0;i<CompulsoryTxtFlds.length;i++)
                {
            		
	                myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))

	                if(myfld.value.split(" ").join("") == "")
	                {
		                alert(FriendlyNames[i]+" can not be blank.");
		                myfld.select();
		                myfld.focus();
		                return false;
	                }
                }

                return true;
            }
            
           
        function addalltotal()
        {
            
            var price1 = 0
            
            price1 = parseInt(price1) + parseInt(document.getElementById("lbltotal11").value);
            
            price1 = parseInt(price1) + parseInt(document.getElementById("lbltotalmain").innerHTML);
            
            price1 = parseInt(price1) + parseInt(document.getElementById("lbltotal12").innerHTML);
            
            document.getElementById("lbltotalall").innerHTML = price1;
            document.getElementById("lbltotalall1").innerHTML = price1;
            
            var paid = document.getElementById("lbltotalpaid").innerHTML;
            
            document.getElementById("lblbalance").innerHTML = parseInt(price1) - parseInt(paid);
        }
        
        function setpractisetotal(lblTotal,chkbox)
        {
            var ddval = document.getElementById(lblTotal).innerHTML;
            
            document.getElementById("lbltotalmain").innerHTML = ddval;
            addalltotal();            
        }
        
         function setattribute(lbldefaultfee,ddattribute,lbldefaultfee0,lbldefaultfee2,lbldefaultfee3,lbldefaultfee4,lbldefaultfee5,lbldefaultfee6,lblTotal,chkbox)
            {
                             
                    Total = 0;
                    Total += parseInt(document.getElementById(lbldefaultfee).value);
                                    
                    selectedval=document.getElementById(ddattribute).value;
                                    
                    if(selectedval == '0')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee0).value);
                    }
                    else if(selectedval == '2')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee2).value);
                    }
                    else if(selectedval == '3')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee3).value);
                    }
                    else if(selectedval == '4')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee4).value);
                    }
                    else if(selectedval == '5')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee5).value);
                    }
                    else if(selectedval == '6')
                    {
                        Total+=parseInt(document.getElementById(lbldefaultfee6).value);
                    }
              
                    document.getElementById(lblTotal).innerHTML=Total;
                    if(document.getElementById(chkbox).checked)
                    {
                        setpractisetotal(lblTotal,chkbox);
                    }
            }
            function setnonpractisetotal(lblNonPractise,chkbox)
            {
                var ddval = document.getElementById(lblNonPractise).innerHTML;
                
                document.getElementById("lbltotalmain").innerHTML = ddval;
                addalltotal();            
            }
            function setattributenon(lbldefaultfeenon,ddattributenon,lbldefaultfeenon0,lbldefaultfeenon33,lblNonPractise,chkbox)
            {
                             
                Total = 0;
                Total = parseInt(document.getElementById(lbldefaultfeenon).value);
                                
                selectedval=document.getElementById(ddattributenon).value;
                     
                /*if(selectedval == '0')
                {
                    Total =parseInt(document.getElementById(lbldefaultfeenon0).value);
                }
                else */
                if(selectedval == '33')
                {
                    Total=parseInt(document.getElementById(lbldefaultfeenon33).value);
                }
                document.getElementById(lblNonPractise).innerHTML=Total;
                if(document.getElementById(chkbox).checked)
                {
                    setnonpractisetotal(lblNonPractise,chkbox);
                }
            }
        
        function addattr(price,chkbox)
        {
            var price1 = document.getElementById("lbltotal11").value;
            
            if(chkbox.checked)
            {
                price1 = parseInt(price1) + parseInt(price);
            }
            else
            {
                price1 = parseInt(price1) - parseInt(price);
            }
            
            document.getElementById("lbltotal11").value = price1;
            addalltotal();                                
        }
        
        function addattr1(ctrl,chkbox)
        {
            if(chkbox.checked)
            {
                var price = document.getElementById(ctrl).innerHTML;
                document.getElementById("lbltotalmain").innerHTML = price;                                
            }
            addalltotal(); 
        }
        
        function addattr2(ctrl,chkbox)
        {
            var price = document.getElementById(ctrl).innerHTML;
            var price1 = document.getElementById("lbltotal12").innerHTML;
            
            if(chkbox.checked)
            {
                price1 = parseInt(price1) + parseInt(price);
            }
            else
            {
                price1 = parseInt(price1) - parseInt(price);
            }
            
            document.getElementById("lbltotal12").innerHTML = price1; 
            addalltotal(); 
        }
        
        function addattr3(ctrl,chkbox)
        {
            var price = document.getElementById(ctrl).value;
            var price1 = document.getElementById("lbltotal12").innerHTML;
            
            if(chkbox.checked)
            {
                price1 = parseInt(price1) + parseInt(price);
            }
            else
            {
                price1 = parseInt(price1) - parseInt(price);
            }
            
            document.getElementById("lbltotal12").innerHTML = price1; 
            addalltotal(); 
        }
        function addPartialPrice(price,chkbox)
        {
            var price1 = document.getElementById("lblPartialTotal").innerHTML;
            if(chkbox.checked)
            {
                price1 = parseInt(price1) + parseInt(price);
            }
            else
            {
                price1 = parseInt(price1) - parseInt(price);
            }
            
            document.getElementById("lblPartialTotal").innerHTML = price1;
        }
        function editCPD(a)
        {
            //window.showModalDialog("editcpd.aspx?id=" + a + "&no=" + Math.random(),"","dialogWidth:850px;dialogHeight:600px;center:1"); 
            window.open("editcpd.aspx?id=" + a + "&no=" + Math.random(),"","width=850,height=600,scrollbars=yes"); 
        }
    
    
    function checkOtherForAddress(txt,chk,ddl)
    {
        var str = document.getElementById(txt).value;
        if(str.length > 0)
        {
            document.getElementById(chk).checked=true;
            document.getElementById(ddl).selectedIndex=0;
        }
        else
        {
            document.getElementById(chk).checked=false;
            document.getElementById(ddl).selectedIndex=0;
        }
    }
    
    function validatePlanned(val1,val2)
    {
                       
        CompulsoryTxtFlds = Array(val1,val2);
        FriendlyNames = Array("Need Identified","Date");

        for(i=0;i<CompulsoryTxtFlds.length;i++)
        {
    		
            myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
            	                
            if(myfld.value.split(" ").join("") == "")
            {
                alert(FriendlyNames[i]+" can not be blank.");
                myfld.select();
                myfld.focus();
                return false;
            }
        }

        return true;
    }
    
    function validateUnPlanned(val1,val2)
    {
                       
        CompulsoryTxtFlds = Array(val1,val2);
        FriendlyNames = Array("Experience","Date");

        for(i=0;i<CompulsoryTxtFlds.length;i++)
        {
    		
            myfld = eval(document.getElementById(CompulsoryTxtFlds[i]))
            	                
            if(myfld.value.split(" ").join("") == "")
            {
                alert(FriendlyNames[i]+" can not be blank.");
                myfld.select();
                myfld.focus();
                return false;
            }
        }

        return true;
    }
    
    
    function createGoogleURL(txtCounty,chkCounty,ddlCounty,ddlCountry,txtStreet,txtGoogle)
    {
        var Google = 'http://maps.google.com/maps?f=q&hl=en&geocode=&q=' + document.getElementById(txtStreet).value;
        var chk = document.getElementById(chkCounty).value;
        if(document.getElementById(chkCounty).checked)
        {
            Google = Google + ' ' + document.getElementById(txtCounty).value;
        }
        else
        {
            Google = Google + ' ' + document.getElementById(ddlCounty).value;
        }
        Google = Google + ' ' + document.getElementById(ddlCountry).value;
        document.getElementById(txtGoogle).value = Google;
    }
