<br/>
<script language="javascript">
<!--        
	var billingTypeArray = new Array();
	<!-- BEGIN DYNAMIC BLOCK: jspopulatebillingarray -->
	billingTypeArray[{BILLINGARRAYINDEX}] = [{BILLINGARRAYID},"{BILLINGARRAYDETAIL}","{BILLINGARRAYDESCRIPTION}"];
	<!-- END DYNAMIC BLOCK: jspopulatebillingarray -->
	
	function toggleCreateInvoiceOption(option){
		if($('createinvoice') != null){		
			if(option.value == 1){
				$('idcreateinvoice').style.display="none";				
				$('createinvoice').checked = false;
			}else{
				$('idcreateinvoice').style.display="";
			}
		}
	}
	
    function isNumber(inputStr) {
        for (var i = 0; i < inputStr.length; i++) {
            var oneChar = inputStr.substring(i, i + 1)
            if ((oneChar < "0" || oneChar > "9") && (oneChar!=".")) {
                return false;
            }
        }
        return true;
    }
             
    function submitNewEntryForm(myform){
        strAlertMessage="[l]You have not filled out all required fields.  Please do so, then try again.[/l]";
        bolSubmit=true;
    
        if ((myform.date.value == "")||(myform.description.value == "")||(myform.detail.value == "")||(myform.price.value == "")) bolSubmit=false;
    
        if (bolSubmit){
            if (myform.billingtypeid.value==-5){
                strAlertMessage="[l]Please select the billing type before submitting this new entry[/l]";
                bolSubmit=false;
            }
        }
    
        if (bolSubmit){
            if (!isNumber(myform.price.value)){
                strAlertMessage="[l]You have entered an invalid price, please try again.[/l]";
                bolSubmit=false;
                myform.price.value = {INVOICEENTRYPRICE};
            }
        }
    
        if (bolSubmit){ submitonce(myform); myform.submit();}
        else alert(strAlertMessage);
    }         
    
    <!-- should put here begin block for newentry1 -->      
    function SetValuesOnSelectedDomain(){
        if (($('appliestoid')!=null) && ($('appliestoid').selectedIndex != 0)){
             if (document.forms['InvoiceEntry'].recurring[0].checked==1) EnableIncludeNextPayment();
        }else{
             DisableIncludeNextPayment();
        }
    }
    function DisableIncludeNextPayment(){        
        if(document.forms['InvoiceEntry'].includenextpayment != null){
	        document.forms['InvoiceEntry'].includenextpayment[0].checked = 1;
	        document.forms['InvoiceEntry'].includenextpayment[0].disabled = true;
	        document.forms['InvoiceEntry'].includenextpayment[1].disabled = true;
        }
    }
    function EnableIncludeNextPayment(){    
    	if(($('appliestoid')!=null) && (document.forms['InvoiceEntry'].includenextpayment != null)){
	        if (document.forms['InvoiceEntry'].appliestoid.selectedIndex != 0){
	            document.forms['InvoiceEntry'].includenextpayment[0].disabled = false;
	            document.forms['InvoiceEntry'].includenextpayment[1].disabled = false;            
	        }
        }
    }     
	<!-- BEGIN DYNAMIC BLOCK: newentry1 -->     
    onLoadFunctions.push(function() {DisableIncludeNextPayment();});        
	<!-- END DYNAMIC BLOCK: newentry1 -->      
	
	<!-- BEGIN DYNAMIC BLOCK: editrecurring1 -->     
    onLoadFunctions.push(function() {togglerecurringfields(true);});            
	<!-- END DYNAMIC BLOCK: editrecurring1 -->      
    
    function changeDescription(myform){        
        if ((myform.description.value != '')&&(myform.billingtypeid.value > 0)){
			var answer=confirm("[l]Click OK if you want to replace with the default settings for this selection[/l]");
        	if (!answer) return false;
        }

		for (var i = 0; i < billingTypeArray.length; i++) {		
			if(myform.billingtypeid.value==billingTypeArray[i][0]){
        		myform.description.value = billingTypeArray[i][1];
        		myform.detail.value = billingTypeArray[i][2];
        	}         		
		}        
    }
    
    function togglerecurringfields(forceshow){    
        if ((forceshow) || (document.forms['InvoiceEntry'].recurring[0].checked==0)){
             if ($('idcreateinvoice')!=null) $('idcreateinvoice').style.display = "none";
             $('billingcycle').style.display="";        
        }else{
             $('billingcycle').style.display="none";
             if ($('idcreateinvoice')!=null) $('idcreateinvoice').style.display = "";
        }
	}    
    
//-->
</script>
<form name="InvoiceEntry" method="Post" action="index.php?fuse=clients&action={ENTRYFORMSUBMITACTION}" onKeyUp="highlight(event)" onClick="highlight(event)">
{ENTRYHIDDENIDVALUEPAIRS}
<div id="wrap_main">
<h2>{SCREENTITLE}</h2>
 {BILLINGTYPERETURNURL}
<div id="wrap_form">                        
<ul>
<li>
<div class="left">
<label>[l]Billing type[/l] : {CREATENEWBILLINGTYPEURL}</label>
<select class="sele_c2" name="billingtypeid"  onChange="changeDescription(form);">
<option value="-5">Please select ...</option>
<!-- BEGIN DYNAMIC BLOCK: billingtypeoption -->
<option value="{BILLINGTYPEVALUE}" {BILLINGTYPESELECTED}>{BILLINGTYPENAME}</option>
<!-- END DYNAMIC BLOCK: billingtypeoption -->
</select>

</div>
<div class="right">
	<label>[l]Due date[/l] :
		<img id="calButton" src="images/dynCalendar.gif" style="cursor:pointer" />
	</label>
    <input type="text" class="inpl small_2" id="date" name="date"  value="{INVOICEENTRYDATE}" />
    <script type="text/javascript">		
        Calendar.setup(
            {inputField: 'date', ifFormat: '{DATEFORMAT}', showsTime: false, button: 'calButton', weekNumbers: false, step: 1}
        );
    </script>
</div>
</li>
<li>
<label>[l]Description[/l] :</label>
<input name="description" type="text" class="inpl" value="{INVOICEENTRYDESCRIPTION}" />
</li>
<li>
<label>[l]Entry detail[/l] :</label>
<textarea name="detail" rows="10" cols="70" class="texta">{INVOICEENTRYDETAIL}</textarea>
</li>
<li>
<div style="height:40px;">
	<!-- BEGIN DYNAMIC BLOCK: appliesto -->  
	<div class="left">
		<label>[l]Applies to[/l] :</label>
		<select id="appliestoid" name="appliestoid" class="appliestoid" <!-- BEGIN DYNAMIC BLOCK: newentry2 -->onChange='SetValuesOnSelectedDomain();'<!-- END DYNAMIC BLOCK: newentry2 -->>
		<option value=0>[l]not applicable[/l]</option>
		<!-- BEGIN DYNAMIC BLOCK: appliestooption -->
		<option value="{APPLIESTOVALUE}" {APPLIESTOSELECTED}>{APPLIESTONAME}</option>
		<!-- END DYNAMIC BLOCK: appliestooption -->
		</select>
	</div>
	<!-- END DYNAMIC BLOCK: appliesto -->
	<div class="right">
		<label>[l]Price[/l]: {INVOICEENTRYPRICESYMBOL}</label>
		<input type="text" name="price" id="price" class="inpl small_2" value="{INVOICEENTRYPRICE}" />
	</div>
</div>
</li>
<!-- BEGIN DYNAMIC BLOCK: advancedoptions -->   
<li><h3>[l]Advanced Options[/l]</h3></li>

    <!-- BEGIN DYNAMIC BLOCK: advancedoptions_tax -->
    <li>
        <label class="inpc_lv">[l]Do you want to charge tax on this invoice entry?[/l]</label>
        <label class="inpc_h"><input type="radio" name="taxable" value="0" class="rv" {TAXABLE_NO} /> [l]No[/l]</label>
        <label class="inpc_h"><input type="radio" name="taxable" value="1" class="rv" {TAXABLE_YES} /> [l]Yes[/l]</label>
    </li>
    <!-- END DYNAMIC BLOCK: advancedoptions_tax -->
	<!-- BEGIN DYNAMIC BLOCK: advancedoptions_part1 -->
	<li>
		<label class="inpc_lv">[l]Do you want this entry included in the next recurring payment of the selected "applies to" account?[/l]</label>
		<label class="inpc_h"><input type="radio" name="includenextpayment" value="0" class="rv" onclick="toggleCreateInvoiceOption(this)" checked="checked" /> [l]No[/l]</label>
		<label class="inpc_h"><input type="radio" name="includenextpayment" value="1" class="rv" onclick="toggleCreateInvoiceOption(this)" /> [l]Yes[/l]</label>
	</li>
	<!-- END DYNAMIC BLOCK: advancedoptions_part1 -->
	<!-- BEGIN DYNAMIC BLOCK: advancedoptions_part2 -->		
	<li>
		<label class="inpc_lv">[l]Is this a reccuring payment?[/l]</label>
		<label class="inpc_h"><input type="radio" name="recurring" value="0" class="rv" checked="checked" onclick='EnableIncludeNextPayment();togglerecurringfields(false);' /> [l]No[/l]</label>
		<label class="inpc_h"><input type="radio" name="recurring" value="1" class="rv" onclick='DisableIncludeNextPayment();togglerecurringfields(false);' /> [l]Yes[/l]</label>
	</li>
	<!-- END DYNAMIC BLOCK: advancedoptions_part2 -->
<li>
	<div id="billingcycle" style="display:none">
			<label>[l]Billing cycle[/l] :</label>
			<!-- BEGIN DYNAMIC BLOCK: billingcycleselect -->
				<select name="paymentterm" class="appliestoid">
				<!-- BEGIN DYNAMIC BLOCK: billingcycleoption -->
					<option value="{BILLINGCYCLEVALUE}" {BILLINGCYCLESELECTED}>{BILLINGCYCLENAME}</option>
				<!-- END DYNAMIC BLOCK: billingcycleoption -->
				</select>
			<!-- END DYNAMIC BLOCK: billingcycleselect -->
			&nbsp;&nbsp;&nbsp;
			[l]Duration[/l]
			<input class="body" type="text" size=2 id="recurringmonths" name="recurringmonths" value="{BILLINGCYCLEDURATION}" />
			<input type="hidden" id="usedmonths" name="usedmonths" value="{BILLINGCYCLEDURATIONUSEDMONTHS}" />
			[l]month(s)[/l] 
	</div>
</li>
<!-- END DYNAMIC BLOCK: advancedoptions -->   
</ul>
</div>
</div>

<div style="margin-top:5px;">
	<input type='button' class='button_xlarge' name='submitbutton' onclick="submitNewEntryForm(form);" value='{SUBMITBUTTONTEXT}' />
	<!-- BEGIN DYNAMIC BLOCK: createinvoice --> 
	<label id="idcreateinvoice" class="inpc_v bb"><input type='checkbox' id='createinvoice' name='createinvoice' class="rv" />[l]Create Invoice[/l]</label>
	<!-- END DYNAMIC BLOCK: createinvoice -->
</div> 
</form>
