
var SchoolSelector={inited:false,type:"university",bind:"",id:"",loadFaculty:false,init:function(id,bind){if(SchoolSelector.inited==true)
{}
SchoolSelector.bind=bind;SchoolSelector.loadProvince();SchoolSelector.id=id;SchoolSelector.show();SchoolSelector.adjustPosition();SchoolSelector.inited=true;if($("main")){$("main").style.overflow="visible";}},clearEvents:function(){if(SchoolSelector.id)
{$(SchoolSelector.id).stopObserving("schoolselector:changetype");$(SchoolSelector.id).stopObserving("schoolselector:selectschool");$(SchoolSelector.id).stopObserving("schoolselector:department");}},adjustPosition:function()
{var offset=$(SchoolSelector.bind).cumulativeOffset();var left=offset.left-10;var top=offset.top+20;$(SchoolSelector.id).setStyle({top:top+"px",left:left+"px"});},reset:function(){h("location_county_box");h("location_city_box");h("location_school_box");},onlyEnableTypes:function(types){for(var i=0;i<4;i++)
{if(types.indexOf(i)==-1)
{var li=$$("#"+SchoolSelector.id+" .cs_nav li")[i];li.update(li.down('a').innerHTML).setStyle({color:"#ccc",cursor:"default"});}}},getTypeStr:function(intType)
{var maps=["university","highschool","vocationalschool","juniorschool","elementary"];return maps[intType];},getTypeVal:function(type)
{var maps={"university":0,"highschool":1,"vocationalschool":2,"juniorschool":3,"elementary":4};return maps[type];},buildTypes:function(){var html="";var klass="cs_off";var type="university";var typename="大学";if(type==SchoolSelector.type)
{klass="cs_on";}
html+='<li class="'+klass+'"><a onclick="javascript:SchoolSelector.changeType('+"'"+type+"'"+', this);" class="s12">'+typename+'</a></li>';var type="highschool";var typename="高中";var klass="cs_off";if(type==SchoolSelector.type)
{klass="cs_on";}
html+='<li class="'+klass+'"><a onclick="javascript:SchoolSelector.changeType('+"'"+type+"'"+', this);" class="s12">'+typename+'</a></li>';var type="vocationalschool";var typename="技校";var klass="cs_off";if(type==SchoolSelector.type)
{klass="cs_on";}
html+='<li class="'+klass+'"><a onclick="javascript:SchoolSelector.changeType('+"'"+type+"'"+', this);" class="s12">'+typename+'</a></li>';var type="juniorschool";var typename="初中";var klass="cs_off";if(type==SchoolSelector.type)
{klass="cs_on";}
html+='<li class="'+klass+'"><a onclick="javascript:SchoolSelector.changeType('+"'"+type+"'"+', this);" class="s12">'+typename+'</a></li>';$("cs_nav").innerHTML=html;},changeType:function(type,obj){if($(obj).parentNode.className=="cs_on")
{return;}
SchoolSelector.type=type;var nodes=$(SchoolSelector.id).getElementsBySelector(".cs_on");nodes.each(function(node){$(node).className="cs_off";});$(obj).parentNode.className="cs_on";SchoolSelector.clearData();SchoolSelector.loadProvince();if(typeof(SchoolTypeChange)=="function"){SchoolTypeChange(type);}
$(SchoolSelector.id).fire("schoolselector:changetype",type);},clearData:function(){$("location_city_box").innerHTML="";$("location_county_box").innerHTML="";$("location_school_box").innerHTML="";h("location_city_box");h("location_county_box");h("location_school_box");},show:function()
{SchoolSelector.reset();SchoolSelector.buildTypes();$(SchoolSelector.id).style.display="block";$(SchoolSelector.id).fire("schoolselector:changetype",SchoolSelector.type);},hide:function()
{if($(SchoolSelector.id))h(SchoolSelector.id);},loadProvince:function()
{SchoolSelector.showLoading("location_province_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=0",{method:"get",onComplete:SchoolSelector.showProvince});},showLoading:function(id){$(id).style.display="block";$(id).innerHTML='<div class="tac p20"><img src="http://img1.kaixin001.com.cn/i2/diary/loading.gif"/></div>';},showProvince:function(trans)
{var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{if(SchoolSelector.type=="university"){if(data[i].name=="海外"){continue;}}
else{if(data[i].name=="海外"||data[i].name=="香港"||data[i].name=="澳门"){continue;}}
html+='<span><a class="sl2" onclick="SchoolSelector.selectProvince('+data[i].id+','+data[i].type+",'"+data[i].name+"'"+', this);">'+data[i].name+'</a></span>';}
$("location_province_box").innerHTML=html;},selectProvince:function(id,type,name,obj){SchoolSelector.clearData();if(SchoolSelector.type=="university")
{SchoolSelector.loadUniversity(id);}
else
{if(type==-1)
{SchoolSelector.loadCounty(0,id);}
else
{SchoolSelector.loadCity(id);}}
var nodes=$(SchoolSelector.id).getElementsBySelector(".curr");nodes.each(function(node){if($(node).parentNode.id=="location_province_box"){$(node).className="";}});$(obj).parentNode.className="curr";},loadCity:function(pid){SchoolSelector.showLoading("location_city_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=1&id="+pid,{method:"get",onComplete:SchoolSelector.showCity});},showCity:function(trans){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<span><a class="sl2" onclick="SchoolSelector.selectCity('+data[i].id+','+data[i].type+",'"+data[i].name+"'"+', this);">'+data[i].name+'</a></span>';}
$("location_city_box").innerHTML=html;},selectCity:function(id,type,name,obj){$("location_county_box").innerHTML="";h("location_county_box");$("location_school_box").innerHTML="";h("location_school_box");SchoolSelector.loadCounty(id,0);var nodes=$(SchoolSelector.id).getElementsBySelector(".curr");nodes.each(function(node){if($(node).parentNode.id=="location_city_box"){$(node).className="";}});$(obj).parentNode.className="curr";},loadUniversity:function(pid){SchoolSelector.showLoading("location_school_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=4&id="+pid,{method:"get",onComplete:SchoolSelector.showUniversity});},showUniversity:function(trans){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<p><a class="sl" onclick="SchoolSelector.selectSchool('+data[i].id+",'"+data[i].name+"'"+');">'+data[i].name+'</a></p>';}
html+='<div class="c"></div>';html+='<div class="c6" style="padding:5px 0 5px 10px;">其他：';html+='<input type="text" style="width:160px; height:12px;"/>';html+='<input type="button" value="" class="com_but" onclick="javascript:SchoolSelector.selectSchool(0, this.previousSibling.value);" />';html+='</div>';$("location_school_box").innerHTML=html;},loadCounty:function(pid,ppid){var type=2;var id=pid;if(pid==0){type=3;id=ppid;}
SchoolSelector.showLoading("location_county_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type="+type+"&id="+id,{method:"get",onComplete:SchoolSelector.showCounty});},showCounty:function(trans){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<span><a class="sl2" onclick="SchoolSelector.selectCounty('+data[i].id+",'"+data[i].name+"'"+', this);">'+data[i].name+'</a></span>';}
if(data.length==0)
{html="";html+='<div class="c"></div>';html+='<div class="c6" style="padding:5px 0 5px 10px;">其他：';html+='<input type="text" style="width:160px; height:12px;"/>';html+='<input type="button" value="" class="com_but" onclick="javascript:SchoolSelector.selectSchool(0, this.previousSibling.value);" />';html+='</div>';}
$("location_county_box").innerHTML=html;},selectCounty:function(id,name,obj){$("location_school_box").innerHTML="";h("location_school_box");if(SchoolSelector.type=="highschool"){SchoolSelector.loadHighschool(id);}
else if(SchoolSelector.type=="vocationalschool"){SchoolSelector.loadVocationalschool(id);}
else if(SchoolSelector.type=="juniorschool"){SchoolSelector.loadJuniorschool(id);}
var nodes=$(SchoolSelector.id).getElementsBySelector(".curr");nodes.each(function(node){if($(node).parentNode.id=="location_county_box"){$(node).className="";}});$(obj).parentNode.className="curr";},selectSchool:function(id,name){$(SchoolSelector.bind).value=name;$(SchoolSelector.id).fire("schoolselector:selectschool",name);SchoolSelector.hide();if(SchoolSelector.type=="university"&&id>0&&(typeof(showDepartment)=="function"||SchoolSelector.loadFaculty)){SchoolSelector.loadDepartment(id);}
else if(SchoolSelector.type=="university"&&id==0&&typeof(emptyDepartment)=="function"){emptyDepartment();}},loadDepartment:function(id){var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=8&id="+id,{method:"get",onComplete:function(trans){if(typeof(showDepartment)=="function")showDepartment(trans);$(SchoolSelector.id).fire("schoolselector:department",trans);}});},loadHighschool:function(id){SchoolSelector.showLoading("location_school_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=5&id="+id,{method:"get",onComplete:SchoolSelector.showHighschool});},showHighschool:function(trans){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<p><a class="sl" onclick="SchoolSelector.selectSchool('+data[i].id+",'"+data[i].name+"'"+');">'+data[i].name+'</a></p>';}
html+='<div class="c"></div>';html+='<div class="c6" style="padding:5px 0 5px 10px;">其他：';html+='<input type="text" style="width:160px; height:12px;"/>';html+='<input type="button" value="" class="com_but" onclick="javascript:SchoolSelector.selectSchool(0, this.previousSibling.value);" />';html+='</div>';$("location_school_box").innerHTML=html;},loadVocationalschool:function(id){SchoolSelector.showLoading("location_school_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=7&id="+id,{method:"get",onComplete:SchoolSelector.showVocationalschool});},showVocationalschool:function(trans){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<p><a class="sl" onclick="SchoolSelector.selectSchool('+data[i].id+",'"+data[i].name+"'"+', this);">'+data[i].name+'</a></p>';}
html+='<div class="c"></div>';html+='<div class="c6" style="padding:5px 0 5px 10px;">其他：';html+='<input type="text" style="width:160px; height:12px;"/>';html+='<input type="button" value="" class="com_but" onclick="javascript:SchoolSelector.selectSchool(0, this.previousSibling.value);" />';html+='</div>';$("location_school_box").innerHTML=html;},loadJuniorschool:function(id){SchoolSelector.showLoading("location_school_box");var myAjax=new Ajax.Request("/interface/suggestlocation.php?type=6&id="+id,{method:"get",onComplete:SchoolSelector.showVocationalschool});},showJuniorschool:function(id){var data=eval('('+trans.responseText+')');var html="";for(var i=0;i<data.length;i++)
{html+='<p><a class="sl" onclick="SchoolSelector.showJuniorschool('+data[i].id+",'"+data[i].name+"'"+');">'+data[i].name+'</a></p>';}
html+='<div class="c"></div>';html+='<div class="c6" style="padding:5px 0 5px 10px;">其他：';html+='<input type="text" style="width:160px; height:12px;"/>';html+='<input type="button" value="" class="com_but" onclick="javascript:SchoolSelector.selectSchool(0, this.previousSibling.value);" />';html+='</div>';$("location_school_box").innerHTML=html;}};