<%@ Page Language="C#" AutoEventWireup="true" Codebehind="ChooseShool.aspx.cs" Inherits="JuSNS.Web.user.Space.ChooseShool" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>

    <script language="javascript" type="text/javascript" src="../../js/ajax.js"></script>

    <script language="javascript" type="text/javascript" src="../../js/public.js"></script>

    <link href="../../template/<% Response.Write(JuSNS.Config.UiConfig.SkinStyle); %>/css/base.css" id="skinpath" type="text/css" rel="stylesheet" />

</head>
<body>
        <div class="boxtitle chengse">
            <div class="nl bold">
                选择学校</div>
            <div class="nr">
                <a href="javascript:;" onclick="setnone();">关闭</a>&nbsp;&nbsp;</div>
        </div>
        <div class="c"></div>
        <input type="hidden" id="txtDegreeID" runat="server" />
        <input type="hidden" id="txtFlag" runat="server" />
        <input type="hidden" id="txtArea" runat="server" />
        <div id="choose_box">
                <div class="choosetop" id="divPr">
                    <span id="title1"></span>
                    <select name="selPr" id="selPr" runat="server" onchange="LoadCity(this.value,'true')">
                    </select>
                    <select name="selCity" id="selCity" runat="server" style="display: none;" onchange="LoadCity(this.value,'false')">
                    </select>
                </div>
                <div class="font14 bold" id="divArea"> 选择地区</div>
                <div id="spanContent" class="prochoose" runat="server"></div>
           <div class="c"></div> 
            <div class="choosecontent" id="divChoose">
                <div class="choosesearch" id="title2" style="display: none;">
                </div>
                <div class="choosesearchbox" id="divSearch" style="display: none;">
                    <input type="text" class="f-text" runat="server" id="txtSearch" onkeyup="getSearchShool(this.value);openerimg();" />
                    <div class="chooseclose" id="choosehidden" style="display: none;cursor:pointer;" onclick="closerimg();" title="清除">x</div>
                </div>
                <ul id="spanShool"></ul>
            </div>
        </div>
</body>
</html>

<script type="text/javascript" language="javascript">
//function $(o){return document.getElementById(o);}
//指定其显示方式为不可见
function closerimg(){
   document.getElementById('choosehidden').style.display="none";
   LoadShool($("txtArea").value);
   $("txtSearch").value="";
}
function openerimg(){
   document.getElementById('choosehidden').style.display="";
}
//取坐标
function setsee()
{
    var I=$("txtDegreeID").value;
    if(I==1)
    {
        $("title1").innerHTML="请选择初中所在的省份";
        $("title2").innerHTML="选择初中";
        $("divArea").style.display="";
        $("selPr").style.display="";
    }
    else if(I==2)
    {
        $("title1").innerHTML="请选择高中所在的省份";
        $("title2").innerHTML="选择高中";
        $("divArea").style.display="";
        $("selPr").style.display="";
    }
     else if(I==3 || I==4 || I==5)
    {
        $("title1").innerHTML="请选择大学所在的省份";
        $("title2").innerHTML="选择大学";
        $("divArea").style.display="none";
        $("selPr").style.display="none";
        $("selCity").style.display="none";
    }
    $('choose_box').style.display="block";
}setsee();
//指定其为块级元素

function setnone(){
 window.frameElement.document.getElementById('Zindextop').style.display="none";
}

//根据区域编号加载学校

function LoadShool(AreaID)
{
    var DegreeID=$("txtDegreeID").value;
   $("title2").style.display="";
   $("divSearch").style.display="";
   $("txtArea").value=AreaID;
    var  options={  
				   method:'post',  
				   parameters:"AreaID="+AreaID+"&DegreeID="+DegreeID+"&Type=Shool",  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText;
					    if (v.indexOf("??")>-1)
					    {
                           $('spanShool').innerHTML="没有学校信息";
                        }
					    else
					    {
                           $('spanShool').innerHTML=v;
                        }
					}  
				  }; 
    new Ajax.Request('ChooseShool.aspx',options);
}

//根据一级一级省市显示二级省市
function LoadCity(ID,bl)
{
    var DegreeID=$("txtDegreeID").value;
    $('spanShool').innerHTML="";
    
    var  options={  
				   method:'post',  
				   parameters:"AreaID="+ID+"&DegreeID="+DegreeID+"&Type=City&bl="+bl,  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText;
					    if (v.indexOf("??")>-1)
					    { 
					        if(bl=="true")
					        {
					            $("spanContent").innerHTML="";
					            $('spanShool').innerHTML="";
					            $("selCity").style.display="none";
					        }
                        }
					    else
					    {
                           var array=v.split('|');
                           var len=array.length;
                          
                           if(len>1)
                           {  
                               $("spanContent").innerHTML="<ul class=\"chooselist2\">"+array[len-1]+"</ul>";
                                $("selCity").length=0;
                               for(var i=0;i<array.length-1;i++)
                               { 
                                  var s=array[i].split(',');
                                  if(s.length>0)
                                  {
                                    $("selCity").style.display="";
                                    $("selCity").options.add(new Option(s[1],s[0]));
                                  }
                               }
                           }
                           else
                           {
                                if(bl=="true")
                                {
                                    $("selCity").style.display="none";
                                }
                                $("spanContent").innerHTML="<ul>"+v+"</ul>";
                           }
                        }
					}  
				  }; 
    new Ajax.Request('ChooseShool.aspx',options);
}

//返回学校名称、编号、
function getShool(Name,ShoolID)
{
    var flag=$("txtFlag").value;
    var  options={  
				   method:'post',  
				   parameters:"ShoolID="+ShoolID+"&Type=Shool",  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText;
					    if (v.indexOf("??")>-1)
					    {
                          alert('传递参数错误！');
                        }
					    else
					    {
					        parent.document.getElementById("txtSchoolName_"+flag).value=Name;
					        parent.document.getElementById("txtShoolID_"+flag).value=ShoolID;
					        var array=v.split('|');
					        
					        if(array.length>0)
					        {
					            parent.document.getElementById("selAcademy_"+flag).length=0;
					            parent.document.getElementById("selAcademy_"+flag).style.display="";
                               for(var i=0;i<array.length-1;i++)
                               { 
                                  var s=array[i].split(',');
                                  if(s.length>0)
                                  {
                                    parent.document.getElementById("selAcademy_"+flag).options.add(new Option(s[1],s[0]));
                                    parent.document.getElementById("selAcademy_"+flag).selectedindex=0;
                                  }
                               }
					        }
					        setnone();
                        }
					}  
				  }; 
    new Ajax.Request('edit-edu.aspx',options);

}

//搜索学校
function getSearchShool(Name)
{
    var DegreeID=$("txtDegreeID").value;//受教育程度
    var AreaID=$("txtArea").value;//地区编号
    var  options={  
				   method:'post',  
				   parameters:"DegreeID="+DegreeID+"&AreaID="+AreaID+"&Name="+Name+"&Type=Search",  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText;
					     if (v.indexOf("??")>-1)
					    {
                           $('spanShool').innerHTML="没有学校信息";
                        }
					    else
					    {
                           $('spanShool').innerHTML=v;
                        }
					}  
				  }; 
    new Ajax.Request('ChooseShool.aspx',options);
}
</script>

