<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html>
	<head>
		<%@include file="/WEB-INF/navigation/JsAndCss.jsp" %>
		<script type="text/javascript" charset="utf-8" src="/js/data.js"></script>
		<script type="text/javascript" charset="utf-8" src="/js/datajs.js"></script>
		<script type="text/javascript">
		function isNull(obj){
			if(obj.value!=null&&obj.value!=""&&obj.value!=undefined){
				return true;
			}else{
				return false;
			}
		}
		function checkNull(){
			var flag = true;
			if(!isNull($('#companyName')[0])){
				alert("公司名不能为空");
				flag=false;
			}else if(!isNull($('#shorterName')[0])){
				alert("公司简称不能为空");
				flag=false;
			}else if(!isNull($('#contactName')[0])){
				alert("公司联系人不能为空");
				flag=false;
			}else if(!isNull($('#contactPhoneNumber')[0])){
				alert("公司联系电话不能为空");
				flag=false;
			}else if(!isNull($('#contactAddress')[0])){
				alert("公司地址不能为空");
				flag=false;
			}
			if(flag){
		$('#new-project')[0].submit();
			}
		}
			function getCitys(){
				var id=$("#province").val();
				
				$.post("findCityByProvinceId.do",{"provinceId":id},function(data){
					var obj = document.form.city;
					obj.length=1;
					if(data != null){
						for(i=0;i<data.length;i++){
							obj[i+1]=new Option(data[i].name, data[i].id);
						}
					}
				});
				
			}
			
			function ajaxFileUpload() {  
	            $.ajaxFileUpload  
	        (  
	            {  
	                url: '/imageUp.jsp',  
	                secureuri: false,  
	                fileElementId: 'businesslisenseUriFile',  
	                dataType: 'json',  
	                beforeSend: function() {  
	                    $("#loading").show();  
	                },  
	                complete: function() {  
	                    $("#loading").hide();  
	                },  
	                success: function(data, status) {  
	                	//alert(data.url);
	                    $('#businesslisenseUri').val(data.url);
	                    $('#label1').html("\(已上传图片\)");
	                },  
	                error: function(data, status, e) {  
	                    alert(e);  
	                }  
	            }  
	        )  
	            return false;  
	        }  
		</script>
		<style>
		div.fee_type input, div.fee_type label
{
    border-width: 0px;
    display: block;
    height: 30px;
    line-height: 27px;
    float: left;
    margin-left: 5px;
}
div.fee_type label
{
    margin-left: 3px;
    margin-right: 5px;
}
div.input_info
{
    width: 580px;
    text-align: left;
    margin-left: 10px;
    float: left;
    height: 40px;
}
div.input_info span.info
{
    display:inline-block;
    width:50px;
}
		</style>
		
	</head>
	<body>
		
		<div class="container">
			<div class="navbar">
				<div class="navbar-inner">
					<%@include file="../navigation/menu.jsp" %>
				</div>
			</div>
			<div class="row">
				<%@include file="../navigation/navigation.jsp" %>
				<div class="span9">
					<h1>
						添加合作公司
					</h1>
					
					<form id="new-project" class="form-horizontal" action="addCompany.do" method="post" name="form">
						<fieldset>
						<legend></legend>
							<div class="control-group">
								<label class="control-label" for="companyName">公司名称</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="companyName" name="companyName" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="shorterName">公司简称</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="shorterName" name="shorterName" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="select01">国家</label>
								<div class="controls">
									<select id="select01" name="country">
									<option value="1">中国</option>										
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="province">省市</label>
								<div class="controls">
									<select id="province" class="zzjg_sel1"  name="province" onchange="getCitys()" >
										<option value="0">--请选择城市--</option>
										<c:forEach items="${province }" var="province">
											<option value="${province.id }">${province.name }</option>
										</c:forEach>
										
									</select>
									<select id="city" class="zzjg_sel1" name="city"  >
										<option value="0">--请选择城市--</option>
									</select>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="contactName">联系人</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactName" name="contactName" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="contactPhoneNumber">联系电话</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactPhoneNumber" name="contactPhoneNumber" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="contactAddress">公司地址</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactAddress" name="contactAddress" />
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="input01">邮箱</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="contactEmail" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">传真</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="contactFox" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">官方网站</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="website" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">法律顾问</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="lawAdviser" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">审计事务所</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="auditFirm" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="uploadPreview">添加营业执照</label>
								<div class="controls">
									<input id="businesslisenseUriFile" type="file" name="businesslisenseUriFile" class="fimg1"/>
									<input id="businesslisenseUri" type="hidden" name="businesslisenseUri"/>
									<button type="button" class="btn btn-primary" onclick="return ajaxFileUpload();">上传图片</button>
									<label id="label1"></label>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="yes">是否为合作方</label>
								<div class="input_info fee_type">
									<input type="radio" name="isPartner" id="yes" value="1"/>
                        			<label for="yes">是</label>
                        			<input type="radio" name="isPartner" id="no" checked="checked" value="0"/>
                       		 		<label for="no">否</label>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="textarea">公司简介</label>
								<div class="controls">
									<textarea class="input-xlarge" id="textarea" rows="3" name="companyIntroduction"></textarea>
								</div>
							</div>
							
							<div class="control-group">
							<label class="control-label" for="showStatus">前台显示</label>
								<div class="controls">
									<input type="checkbox"  id="showStatus" name="showStatus" 
										name="showStatus" 
										<c:if test="${product.showStatus==1}">checked</c:if>  value="1"/>
							</div>
						</div>
							<div class="form-actions">
								<button type="button"  class="btn btn-primary" onclick="checkNull()">确定</button>
								 <button class="btn" type="reset" onclick="history.back()">取消</button>
							</div>
						</fieldset>
					</form>
				</div>
			</div>
		</div>
	</body>
</html>
