"use strict";
YUI.add("ksu-major-search",function(a){var c=a.one,b,g,k,h,j="/admissions/guides/",f="neverloaded";
var i={AA:"Associate of Arts",AS:"Associate of Science",AT:"Associate of Technology",BA:"Bachelor of Arts",BME:"Bachelor of Music Education",BS:"Bachelor of Science",C:"Certificate",CBM:"Concurrent Bachelor and Master's",DVM:"Doctor of Veterinary Medicine",M:"Minor",MARCH:"Master of Architecture",MIAPD:"Master of Interior Architecture and Product Design",MLA:"Master of Landscape Architecture",MRCP:"Master of Regional and Community Planning",MS:"Master's",PHD:"Doctor of Philosophy"};
var d=function(l){if(!l){return false
}if(l.substr(0,1)==="/"||l.indexOf(":")!==-1){return true
}return false
};
var e=function(l){e.superclass.constructor.apply(this,arguments)
};
e.NAME="MajorSearch";
e.NS="majorSearch";
e.ATTRS={source:{value:null,setter:"_setSource"},resultContainer:{value:null},history:{value:null},historyName:{value:null},processNullQuery:{value:false},initialQuery:{value:null},insertFn:{value:null}};
a.extend(e,a.Plugin.Base,{getCollegeNameFromCode:function(m){var l={AG:"Agriculture",AR:"Architecture, Planning and Design",AS:"Arts and Sciences",BA:"Business Administration",ED:"Education",EN:"Engineering",HE:"Human Ecology",SA:"Technology and Aviation",VM:"Veterinary Medicine"};
if(!m){return""
}return l[m]||m
},getDeptNameFromCode:function(m){var n,l={PHPP:{name:"Pre-Health Professions Program",url:"/artsci/phpp/"},ASB:{name:"Department of Arts, Sciences, and Business",url:"http://www.sal.k-state.edu/academics/asb/"},HN:{name:"Department of Human Nutrition",url:"http://www.humec.k-state.edu/hn/"},IAS:{name:"International and Area Studies",url:"http://www.k-state.edu/ias/"},MKTG:{name:"Department of Marketing",url:"http://www.cba.ksu.edu/marketing"},ACCTG:{name:"Department of Accounting",url:"http://www.cba.ksu.edu/accounting"},AERO:{name:"Department of Aerospace Studies (Air Force ROTC)",url:"http://www.k-state.edu/usaf/"},AGCOM:{name:"Department of Communications",url:"http://www.communications.k-state.edu/"},AGEC:{name:"Department of Agricultural Economics",url:"http://www.ageconomics.ksu.edu/DesktopDefault.aspx"},AGRON:{name:"Department of Agronomy",url:"http://www.agronomy.k-state.edu/DesktopDefault.aspx"},AMETH:{name:"American Ethnic Studies",url:"http://www.k-state.edu/ameth/"},AP:{name:"Department of Anatomy and Physiology",url:"http://www.vet.k-state.edu/depts/ap/"},ARCH:{name:"Department of Architecture",url:"http://capd.ksu.edu/arch/"},ARE:{name:"Department of Architectural Engineering and Construction Science",url:"http://www.k-state.edu/are-cns/"},ART:{name:"Department of Art",url:"http://art.ksu.edu/"},ASI:{name:"Department of Animal Sciences and Industry",url:"http://www.asi.k-state.edu/DesktopDefault.aspx"},ATM:{name:"Department of Agricultural Technology Management",url:"http://www.ag.ksu.edu/p.aspx?tabid=874"},AT:{name:"Department of Apparel, Textiles, and Interior Design",url:"http://www.humec.k-state.edu/atid/"},AV:{name:"Department of Aviation Technology",url:"http://www.salina.k-state.edu/aviation/"},BAE:{name:"Department of Biological and Agricultural Engineering",url:"http://www.bae.ksu.edu/"},BIOCH:{name:"Department of Biochemistry",url:"http://www.k-state.edu/bchem/"},BIOL:{name:"Division of Biology",url:"http://www.k-state.edu/biology/"},CE:{name:"Department of Civil Engineering",url:"http://www.ce.ksu.edu/"},ET:{name:"Department of Engineering Technology",url:"http://www.salina.k-state.edu/engtech/"},CHE:{name:"Department of Chemical Engineering",url:"http://www.che.ksu.edu/"},CHM:{name:"Department of Chemistry",url:"http://www.k-state.edu/chem/"},CIS:{name:"Department of Computing and Information Sciences",url:"http://www.cis.ksu.edu/"},CS:{name:"Department of Clinical Sciences",url:"http://www.vet.k-state.edu/depts/ClinicalSciences/"},CSTD:{name:"Department of Communication Studies, Theatre, and Dance",url:"http://cstd.k-state.edu/"},CURRI:{name:"Department of Curriculum and Instruction",url:"http://coe.ksu.edu/departments/currin/"},DMP:{name:"Department of Diagnostic Medicine/Pathobiology",url:"http://www.vet.k-state.edu/depts/dmp/"},ECON:{name:"Department of Economics",url:"http://www.k-state.edu/economics/"},EDLDR:{name:"Department of Educational Leadership",url:"http://coe.k-state.edu/departments/edlea/index.htm"},EDSP:{name:"Special Education, Counseling and Student Affairs",url:"http://coe.k-state.edu/departments/secsa/index.htm"},EECE:{name:"Department of Electrical and Computer Engineering",url:"http://www.ece.ksu.edu/"},ENGL:{name:"Department of English",url:"http://www.k-state.edu/english/"},ENTOM:{name:"Department of Entomology",url:"http://www.entomology.ksu.edu/DesktopDefault.aspx"},FDSCI:{name:"Food Science Institute",url:"http://foodsci.k-state.edu/DesktopDefault.aspx"},FINAN:{name:"Department of Finance",url:"http://www.cba.ksu.edu/finance"},FSHS:{name:"School of Family Studies and Human Services",url:"http://www.humec.k-state.edu/fshs/"},GEOG:{name:"Department of Geography",url:"http://www.k-state.edu/geography/"},GEOL:{name:"Department of Geology",url:"http://www.k-state.edu/geology/"},GERON:{name:"Gerontology",url:"http://www.humec.k-state.edu/aging/"},GRSC:{name:"Department of Grain Science and Industry",url:"http://www.grains.k-state.edu/DesktopDefault.aspx"},HIST:{name:"Department of History",url:"http://www.k-state.edu/history/"},HMD:{name:"Department of Hospitality Management and Dietetics",url:"http://www.humec.k-state.edu/hmd/"},HORT:{name:"Department of Horticulture, Forestry, and Recreation Resources",url:"http://www.hfrr.k-state.edu/DesktopDefault.aspx"},IAPD:{name:"Department of Interior Architecture and Product Design",url:"http://www.capd.ksu.edu/iapd/"},IMSE:{name:"Department of Industrial and Manufacturing Systems Engineering",url:"http://cheetah.imse.ksu.edu/"},KIN:{name:"Department of Kinesiology",url:"http://kinesiologyksu.weebly.com/"},LAR:{name:"Department of Landscape Architecture/Regional and Community Planning",url:"http://capd.ksu.edu/larcp/"},MANGT:{name:"Department of Management",url:"http://www.cba.ksu.edu/management"},MATH:{name:"Department of Mathematics",url:"http://www.math.ksu.edu/main/"},MC:{name:"A.Q. Miller School of Journalism and Mass Communications",url:"http://jmc.ksu.edu/"},MLANG:{name:"Department of Modern Languages",url:"http://www.k-state.edu/mlangs/"},MNE:{name:"Department of Mechanical and Nuclear Engineering",url:"http://www.mne.ksu.edu/"},MSCI:{name:"Department of Military Science (Army ROTC)",url:"http://armyrotc.k-state.edu/"},MUSIC:{name:"Department of Music",url:"http://www.k-state.edu/music/"},PHILO:{name:"Department of Philosophy",url:"http://www.k-state.edu/philos/"},PHYS:{name:"Department of Physics",url:"http://www.phys.ksu.edu/"},PLPTH:{name:"Department of Plant Pathology",url:"http://www.plantpath.k-state.edu/DesktopDefault.aspx"},POLSC:{name:"Department of Political Science",url:"http://www.k-state.edu/polsci/"},PSYCH:{name:"Department of Psychology",url:"http://www.k-state.edu/psych/"},SASW:{name:"Department of Sociology, Anthropology, and Social Work",url:"http://www.k-state.edu/sasw/"},STAT:{name:"Department of Statistics",url:"http://www.k-state.edu/stats/"},WOMST:{name:"Women's Studies",url:"http://www.k-state.edu/womst/"}};
if(!m){return""
}n=l[m]||{};
return n.name||m
},getGuideLink:function(l){var m=l;
if(!m){return""
}if(!d(m)){m=j+m
}return"<a href='"+m+"' target='_blank'>Guide for this major</a> <img width='16' height='12' alt='opens in new window' src='/admissions/images/new-win-icon.gif'>"
},getCareerLink:function(l){if(!l){return""
}return"<p><a href='/acic/majorin/"+l+"'>What can I do with this major?</a></p>"
},getSpanishGuideLink:function(l){if(l==="HE"){return" / <a href='"+j+"EcologiaHumana.pdf'>Gu&iacute;a en Espa&ntilde;ol</a>"
}return""
},getDegreeList:function(o){var m,n,l,p=[];
if(!o||!o.length){return""
}for(m=0;
m<o.length;
m++){n=o[m];
l=i[n]||n;
if(l){p.push(l)
}}return p.join(", ")
},hilight:function(m,n){var l=n;
if(m){l=n.replace(new RegExp("\\b"+a.Escape.regex(a.Lang.trim(m)),"gi"),"<b>$&</b>")
}return l
},subsetCareers:function(n,o){var l=[],m=new RegExp("\\b"+a.Escape.regex(a.Lang.trim(n)),"i");
o.forEach(function(p){if(m.test(p)){l.push(p)
}});
return l
},majorCareerFormatter:function(o,l){var n=this,q,p,m;
if(!o){m=g;
q=""
}if(!l){return""
}return a.Array.map(l,function(s){var t,r;
if(o){r=n.subsetCareers(o,s.careers);
if(r.length){m=k;
q=n.hilight(o,r.join(", "))
}else{m=h;
q=""
}}p=s.careers.join(", ");
t=a.Lang.sub(m,{name:n.hilight(o,s.name),desc:n.hilight(o,s.desc),matchingcareers:q,collegename:n.getCollegeNameFromCode(s.college),deptname:n.getDeptNameFromCode(s.dept),degreelist:n.getDegreeList(s.type),guidelink:n.getGuideLink(s.guide),spanishguidelink:n.getSpanishGuideLink(s.college),careerlink:n.getCareerLink(s.careerurl),careers:p});
return t
})
},_compareMajor:function(n,m){var l=n.major.name,o=m.major.name;
if(l<o){return -1
}if(l>o){return 1
}if(n.keytype==="major"){return -1
}if(m.keytype==="major"){return 1
}if(n.keytype==="desc"){return -1
}if(m.keytype==="desc"){return 1
}l=n.keyword;
o=m.keyword;
if(l<o){return -1
}if(l>o){return 1
}return 0
},_deduplicateMajors:function(o){var n,p,l,m=[];
if(!o||!o.length){return m
}p=o[0].major;
for(n=1;
n<o.length;
n++){l=o[n].major;
if(p.name!==l.name){m.push(p);
p=l
}}m.push(p);
return m
},_setSource:function(n){var m,l;
for(m=0;
m<n.length;
m++){l=n[m];
if(l.type&&l.type.length===1&&l.type[0]==="M"&&!(/\(minor\)/.test(l.name))){l.name=l.name+" (minor)"
}l.desc=l.desc||"";
l.type=l.type||[];
l.careers=l.careers||[]
}this.source=n
},majorsource:function(r){var l,n,m,s,o=[],q,p,t;
console.log("majorsource",r,this);
l=this.get("source");
if(r){q=new RegExp("\\b"+a.Escape.regex(a.Lang.trim(r)),"i")
}else{q=new RegExp(".")
}for(n=0;
n<l.length;
n++){s=l[n];
if(s.name.search(q)!==-1){o.push({keyword:s.name,keytype:"major",major:s})
}if(s.desc.search(q)!==-1){o.push({keyword:s.desc,keytype:"desc",major:s})
}if(r){p=s.careers;
for(m=0;
m<p.length;
m++){t=p[m];
if(t.search(q)!==-1){o.push({keyword:t,keytype:"career",major:s})
}}}}return this._deduplicateMajors(o.sort(this._compareMajor))
},formatMajor:function(l){return a.Lang.sub(b,{desc:l.desc,name:l.name,deptname:this.getDeptNameFromCode(l.dept),degreelist:this.getDegreeList(l.type),guidelink:this.getGuideLink(l.guide),spanishguidelink:this.getSpanishGuideLink(l.college),careerlink:this.getCareerLink(l.careerurl),careers:l.careers})
},selectByCollege:function(r){var t=this,p,n,m,s,l,o=[],q;
if(!r){return""
}p="";
this.get("source").forEach(function(u){if(u.college===r){p=p+t.formatMajor(u)
}});
return p
},insertMajorsByCollege:function(o){var n=this.get("host"),l,m;
l=n.get("value"),m=this.get("resultContainer");
if(!b){b=c("#major-by-college-template").getContent()
}m.setContent(this.selectByCollege(l));
a.Disclosures.prepare(m)
},handleCollegeSelection:function(l){var p,n,o,m;
p=l.currentTarget;
n=p.get("value");
o=this.get("history");
if(o){m=this.get("historyName");
if(m){o.replaceValue(m,n)
}}else{this.insertMajorsByCollege(n)
}},insertMajors:function(o){var n,l,m;
l=this.get("resultContainer");
if(!o&&!this.get("processNullQuery")){l.setContent("")
}else{if(o!==f){n=this.majorsource(o);
if(n){m=this.majorCareerFormatter(o,n)
}else{m=["No majors match your search."]
}l.setContent(m.join(""));
a.Disclosures.prepare(l)
}}f=o
},handleHistoryChange:function(o){var n,l,m;
console.log("queryChange",arguments);
n=this.get("history");
l=this.get("historyName");
m=n.get(l);
this.get("insertFn").call(this,m)
},handleKey:function(q,l){var p,o,m,n;
console.log("key",arguments);
p=q.currentTarget;
n=p.get("value");
o=this.get("history");
if(o){m=this.get("historyName");
if(m){o.replaceValue(m,n)
}}else{this.insertMajors(n)
}},initializer:function(){var n=this.get("host"),p,q,l,o,m,r;
k=c("#major-result-with-career-template").getContent();
h=c("#major-result-without-career-template").getContent();
g=c("#major-result-no-query-template").getContent();
console.log("host",n);
p=n.get("tagName");
if(p==="INPUT"){n.on("keyup",this.handleKey,this);
this.set("insertFn",this.insertMajors)
}else{n.on("change",this.handleCollegeSelection,this);
this.set("insertFn",this.insertMajorsByCollege)
}q=this.get("history");
o=null;
if(q){l=this.get("historyName");
if(l){q.on(l+"Change",this.handleHistoryChange,this);
o=q.get(l);
if(o){n.set("value",o);
this.insertMajors(o)
}}}if(!o){o=this.get("initialQuery");
if(o!==null){this.get("insertFn").call(this,o)
}}}});
a.namespace("Plugin").MajorSearch=e
},"2.0.0",{requires:["node","plugin"]});
if(!Array.prototype.forEach){Array.prototype.forEach=function(b){if(this===void 0||this===null){throw new TypeError()
}var e=Object(this);
var a=e.length>>>0;
if(typeof b!=="function"){throw new TypeError()
}var d=arguments[1];
for(var c=0;
c<a;
c++){if(c in e){b.call(d,e[c],c,e)
}}}
};
