function Employment_Jobs() { this.loaded = 0; this.queryitems = []; this.auto = 0; } function employment_jobs_initialize() { with (this) { if (Site.loaded == 1) { loaded = 1; root = "http://www.mns-firstnet.ca/"; CompileQuery(); } else { window.setTimeout('Jobs.Initialize()',10); } } } function employment_jobs_compilequery() { var fields; with (this) { if (loaded == 1) { fields = document.body.getElementsByTagName("INPUT"); for (i = 0; i < fields.length; i++) { if (fields[i].id != "" && fields[i].name != "") { if (fields[i].id.search(/s-/gi) != -1) { queryitems[fields[i].id] = new Array(fields[i].name,fields[i].value); } } } if (queryitems['s-auto']) { auto = queryitems['s-auto'][1]; auto = (auto == "1" || auto == "-1" ? auto : "-1"); } } } } function employment_jobs_addtoquery(item,value,s) { with (this) { if (loaded == 1) { if (item) { if (item.id.search(/s-/gi) != -1) { item.value = value; CompileQuery(); if (s == 1 && auto == "1") { SubmitQuery(); } } } } } } function employment_jobs_submitquery() { var query = "http://www.mns-firstnet.ca/employment/?x=1&"; with (this) { if (loaded == 1) { for (i in queryitems) { if (queryitems[i][1] != "") { query += queryitems[i][0]+"="+queryitems[i][1]+"&"; } } query = query.substr(0,query.length-1); location.href = query; } } } function employment_jobs_keypress(e) { var evt = e || window.event; var key = evt.which || evt.keyCode; with (this) { if (key == 13) { SubmitQuery(); } } } function employment_jobs_loadareas(z,id,s,c,p,t) { // z - type (country,province) // id - selected entry from a list (country or province) // s - list of selected entries from each list (as per results of loading) // c - list of country entries // p - list of province entries (based on country selection) // t - list of towns entries (based on province selection) var countries; var provinces; var towns; with (this) { if (loaded == 1) { countries = $('country_list'); provinces = $('province_list'); towns = $('town_list'); if (z == "country" || z == "province") { $('data_loader').src = "http://www.mns-firstnet.ca/employment/x.php?id="+id; } else if (countries && provinces && towns) { UpdateAreas("country",c,s[0]); UpdateAreas("province",p,s[1]); UpdateAreas("town",t,""); } } } } function employment_jobs_updateareas(l,e,s) { var list; var total = 0; var new_entry; with (this) { if (loaded == 1) { list = $(l+'_list'); if (list) { if (list.options.length > 0) { total = list.options.length; for (i = total; i > -1; i--) { list.remove(i); } } if (e.length > 0) { if (l == "country") { new_entry = document.createElement('OPTION'); new_entry.text = "Select.."; new_entry.value = ""; new_entry.label = ""; list.options.add(new_entry); } for (i = 0; i < e.length; i++) { new_entry = document.createElement('OPTION'); new_entry.text = e[i][0]; new_entry.value = e[i][0]; new_entry.label = e[i][1]; list.options.add(new_entry); } } if (list.options.length == 1) { list.selectedIndex = 0; $(l).value = list.options[list.selectedIndex].value; } else { if (list.options.length > 0 && s != "") { total = list.options.length; for (i = (total-1); i > -1; i--) { if (list.options[i].value == s) { list.selectedIndex = i; $(l).value = list.options[list.selectedIndex].value; } } } } } } } } Employment_Jobs.prototype.Initialize = employment_jobs_initialize; Employment_Jobs.prototype.CompileQuery = employment_jobs_compilequery; Employment_Jobs.prototype.AddToQuery = employment_jobs_addtoquery; Employment_Jobs.prototype.SubmitQuery = employment_jobs_submitquery; Employment_Jobs.prototype.KeyPress = employment_jobs_keypress; Employment_Jobs.prototype.LoadAreas = employment_jobs_loadareas; Employment_Jobs.prototype.UpdateAreas = employment_jobs_updateareas; var Jobs = new Employment_Jobs(); Jobs.Initialize();