<% if @site_request.type == "existing" %>
	<div class="line-content">
		<span class="header-line">Site Title :</span>
		<span class="content-line"><%= @site_request.get_site.title %></span>
	</div>
	<div class="line-content">
		<span class="header-line">Site Domain :</span>
		<span class="content-line">
			<a href="<%= @site_request.get_site.site_domain %>" target="_blank"><%= @site_request.get_site.site_domain %></a>
		</span>
	</div>
<% else %>
	<div class="line-content">
		<span class="header-line"><%= f.label :new_site_cost, "New Site Cost :"%></span>
	  <span class="content-line"><%= f.number_field :new_site_cost, :min => "0" %></span>
	</div>
	<% if @site_request.host_with_rulingdigital %>
	  <div class="line-content">
			<span class="header-line"><%= f.label :hosting_with_rulingdigital_cost, "Host with RulingDigital:" %></span>
	   	<span class="content-line"><%= f.number_field :hosting_with_rulingdigital_cost, :min => "0" %></span>
	  </div>
	<% end %>
<% end %>
<% if @site_request.type == "existing" && @site_request.maintenance %>
	<div class="line-content">
		<span class="header-line"><%= f.label :service_cost, "Maintenance Cost for #{@site_request.maintenance_years} year(s):" %></span>
		<span class="content-line"><%= f.number_field :service_cost, :min => "0" %></span>
	</div>
<% elsif @site_request.type == "newsite" %>
	<div class="line-content">
		<span class="header-line"><%= f.label :service_cost, "Maintainance Cost:" %></span>
		<span class="content-line"><%= f.number_field :service_cost, :min => "0" %></span>
	</div>
<% end %>

<% if !@site_request.optional_modules.blank? %>
	<div class="line-content">
		<span class="header-line"><%= f.label :option_module_cost, "Optional Modules Cost:" %></span>
		<% rsm = RegisteredModule.find(@site_request.optional_modules) %>
  		<span class="content-line">
  			<ul class="selected-module">
  				<% rsm.each do |mod| %>
				<li><span class="label label-info"><%= mod.name %></span></li>
				<% end %>
			</ul>
			<%= f.number_field :option_module_cost, :min => "0" %>	
  		</span>
	</div>
<% end %>

<% if @site_request.custom_module %>
	<div class="line-content">
		<span class="header-line">
			<%= f.label :customized_module_cost, "Optional Module Cost:" %>
		</span>
  		<span class="content-line">
			<%= f.number_field :customized_module_cost, :min => "0" %>	
  		</span>
	</div>
<% end %>

<% if !@site_request.template_number.empty? %>
	<div class="line-content">
		<span class="header-line">
			<%= f.label :template_cost, "Template Cost:" %>
		</span>
		<span class="content-line">
			<%= f.number_field :template_cost, :min => "0" %>	
		</span>
	</div>
<% end %>
<% if @site_request.custom_template %>
	<div class="line-content">
		<span class="header-line">
			<%= f.label :customized_template_cost, "Customized Template Cost:" %>
		</span>
		<span class="content-line">
			<%= f.number_field :customized_template_cost, :min => "0" %>	
		</span>
	</div>
<% end %>
<% if @site_request.rwd %>
	<div class="line-content">
		<span class="header-line">
			<%= f.label :rwd_cost, "RWD Cost:" %>
		</span>
  		<span class="content-line">
			<%= f.number_field :rwd_cost, :min => "0" %>	
  		</span>
	</div>
<% end %>
	<div class="line-content">
		<span class="header-line">
			<%= f.label :other, "Other Requirements:" %>
  		<%= f.text_area :other, :class => "text_require" %>
		</span>
  	<span class="content-line">
			<%= f.number_field :other_cost, :min => "0" %>	
  	</span>
	</div>
<% if !@contract.contract_file.url.nil? %>
	<div class="line-content">
		<span class="header-line">Contract File :</span>
		<span class="content-line"><a href="<%= @contract.contract_file.url %>" target="_blank" class="btn btn-primary flat">Download Contract</a></span>
	</div>
<% end %>
<div class="line-content">
	<span class="header-line"><%= f.label :contract_file, "Upload Contract File :" %></span>
	<span class="content-line"><%= f.file_field :contract_file %></span>
</div>

<div class="line-content">
	<span class="header-line">Total Amount :</span>
	<span class="content-line"><span id="total-amount"><%= @contract.new_record? ? 0 : @contract.total_amount %></span> NTD.</span>
</div>
<% if @contract.new_record? %>
	<%= f.hidden_field :site_request, :value => @site_request.id.to_s %>
<% end %>
<div class="line-content button">
	<span class="header-line"></span>
	<span class="content-line">
		<%= f.submit "Submit", :class => "btn btn-primary" %>
		<a href="<%= see_contract_admin_client_management_path(@contract.id) %>" class="btn">Back</a>
		<script type="text/javascript">
			var costFields = $("form.contract-form input[type=number]"),
					totalAmountDom = $("#total-amount");
			costFields.on("change",function(){
				var totalAmount = 0;
				$.each(costFields,function(){
					var amt = ($(this).val() == "" ? 0 : $(this).val());
					totalAmount += parseInt(amt);
				})
				totalAmountDom.text(totalAmount);
			})
		</script>
	</span>
</div>