var Utility = new Class({ Implements: [Options, Events], options: { fade_opacity: 0, clock_items: [] }, initialize: function (options) { }, display: function (i,o) { if (i) { if (i.style.visibility) { i.style.visibility = (o == 0 ? 'hidden' : 'visible'); } if (i.style.display) { i.style.display = (o == 0 ? 'none' : 'inline'); } } }, rez: function () { var xS,yS,wW,wH,pW,pH; if (window.innerHeight && window.scrollMaxY) { xS = window.innerWidth + window.scrollMaxX; yS = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ xS = document.body.scrollWidth; yS = document.body.scrollHeight; } else { xS = document.body.offsetWidth; yS = document.body.offsetHeight; } if (self.innerHeight) { if(document.documentElement.clientWidth){ wW = document.documentElement.clientWidth; } else { wW = self.innerWidth; } wH = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { wW = document.documentElement.clientWidth; wH = document.documentElement.clientHeight; } else if (document.body) { wW = document.body.clientWidth; wH = document.body.clientHeight; } if(yS < wH){ pH = wH; } else { pH = yS; } if(xS < wW){ pW = xS; } else { pW = wW; } return [pW,pH]; }, center: function (i) { var r = this.rez(); if (i) { var sw = i.style.width; w = sw.replace("px",""); if (r[0] <= w) { i.style.left = "0px"; } else { w = Math.round((r[0]-w)/2); i.style.left = w+"px"; } } }, opacity: function (i,v) { if (i) { if (i.style.opacity) { i.style.opacity = (v/100); } if (i.filters) { i.filters.alpha.opacity = v; } } }, fade: function () { var a = arguments; var f = 0; if (a[0]) { f = (a[0] ? a[0] : 0); f = (f === 1 ? 1 : 0); } var c = function () { Utility.fade(1); }; if (a[1]) { if (typeof a[1] == "function") { c = a[1]; } } var container = $('faded_bg_container'); var fade = $('faded_bg'); if (f == 1) { this.display(container,0); this.display(fade,0); this.options.fade_opacity = 0; this.opacity(fade,this.options.fade_opacity); } else { if (fade.style.visibility == "hidden") { var xy = this.rez(); this.display(container,1); this.display(fade,1); fade.style.width = xy[0]+"px"; fade.style.height = xy[1]+"px"; fade.onclick = c; } if (this.options.fade_opacity < 80) { this.options.fade_opacity += 16; this.opacity(fade,this.options.fade_opacity); if (this.options.fade_opacity < 80) { window.setTimeout('Utility.fade()',140); } } } }, int: function (v) { return (v.toString().search(/^[0-9]+$/) != -1); }, clock: function() { var n = (arguments[0] ? arguments[0] : ""); var item = $(n); if (item) { this.options.clock_items[n] = n; } var d = Date(); var h = d.getHours(); var m = d.getMinutes(); var s = d.getSeconds(); var am = "AM"; if (h > 12) { am = "PM"; h = h - 12; } if (h == 0) { h = 12; } if (m <= 9) { m = "0"+m; } if (s <= 9) { s = "0"+s; } if (this.options.clock_items.length > 0) { for (i in this.options.clock_items) { if ($(i)) { $(i).innerHTML = h+":"+m+":"+s+" "+am; } } window.setTimeout('Utility.clock()',1000); } else { return h+":"+m+":"+s+" "+am; } } }); var Utility = new Utility(); var PageX = new Class({ Implements: [Options, Events], options: { }, initialize: function (options) { }, Item: function (t,a,p,r) { var el = new Element(t,a); p.insertBefore(el,null); if (r == 1) { return el; } }, SelectOpt: function (a,p) { var el = new Element('option',a); p.options.add(el); }, Radio: function (t,n,v,p,f) { var el = PageX.Item('input',{ 'type': 'radio', 'name': n, 'value': v, 'click': function() { $(f.id).value = v; } },p,1); var span = PageX.Item('span',{ 'html': t },p,0); }, Switch: function (p,o,c) { window.addEvent('domready', function() { if ($(p)) { var cd = $(p); if ($(o)) { $(o).addEvent('click', function(e) { Utility.display(cd,1); return false }); } if ($(c)) { $(c).addEvent('click', function(e) { Utility.display(cd,0); return false }); } } }); }, FadeSwitch: function (p,o,c) { window.addEvent('domready', function() { var fc = PageX.Item('div',{ 'id': 'faded_bg_container' },document.body,1); fc.style.visibility = "hidden"; fc.style.display = "none"; fc.style.position = "absolute"; fc.style.top = "0px"; fc.style.left = "0px"; fc.style.zIndex = "4000"; var fade = PageX.Item('div',{ 'id': 'faded_bg' },fc,1); fade.style.visibility = "hidden"; fade.style.display = "none"; fade.style.position = "fixed"; fade.style.top = "0px"; fade.style.left = "0px"; fade.style.backgroundColor = "#000000"; fade.style.opacity = "0"; if ($(p)) { var cd = $(p); var cf = function () { $(p).style.visibility = 'hidden'; $(p).style.display = 'none'; Utility.fade(1); }; if ($(o)) { $(o).addEvent('click', function(e) { $('faded_bg_container').insertBefore(cd,null); Utility.center(cd); Utility.display(cd,1); Utility.fade(0,cf); return false }); } if ($(c)) { $(c).addEvent('click', function(e) { Utility.fade(1); Utility.display(cd,0); return false }); } } }); }, FadeDisplay: function (p,c) { window.addEvent('domready', function() { var fc = PageX.Item('div',{ 'id': 'faded_bg_container' },document.body,1); fc.style.visibility = "hidden"; fc.style.display = "none"; fc.style.position = "absolute"; fc.style.top = "0px"; fc.style.left = "0px"; fc.style.zIndex = "4000"; var fade = PageX.Item('div',{ 'id': 'faded_bg' },fc,1); fade.style.visibility = "hidden"; fade.style.display = "none"; fade.style.position = "fixed"; fade.style.top = "0px"; fade.style.left = "0px"; fade.style.backgroundColor = "#000000"; fade.style.opacity = "0"; if ($(p)) { var cd = $(p); var cf = function () { $(p).style.visibility = 'hidden'; $(p).style.display = 'none'; Utility.fade(1); }; $('faded_bg_container').insertBefore(cd,null); Utility.center(cd); Utility.display(cd,1); Utility.fade(0,cf); if ($(c)) { $(c).addEvent('click', function(e) { Utility.fade(1); Utility.display(cd,0); return false }); } } }); }, ResultDiv: function (n) { if (!$(n+'_form_result')) { PageX.Item('br','',$(n+'_form'),0); var result = PageX.Item('div',{'id': n+'_form_result', 'styles': { 'display': 'none', 'visibility': 'hidden', 'font-size': '7pt' } },$(n+'_form'),1); } else { var result = $(n+'_form_result'); } return result; } }); var PageX = new PageX(); var Axe = new Object(); Axe.pageLoaded = 0; Axe.IE = ""; Axe.root = "http://www.pictoucounty.ca/"; Axe.img = "http://x.pictoucounty.ca/"; Axe.body_width = 0; Axe.body_height = 0; Axe.wingroups = []; Axe.listings = []; Axe.select_total = []; Axe.Dashboard = 1; // 0 - no dashboard Axe.dashlinks = new Array(); Axe.redirect_url = ""; Axe.redirect_cd = 16; Axe.fade_opacity = 0; Axe.Load = function () { if ($('loaded')) { this.pageLoaded = 1; this.Initiate(); } else { window.setTimeout('Axe.Load()',5); } } Axe.Resolution = function () { var x = 0, y = 0; if (this.pageLoaded == 1) { if (window.innerHeight && window.scrollMaxY) { x = window.innerWidth + window.scrollMaxX; y = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { x = document.body.scrollWidth; y = document.body.scrollHeight; } else { x = document.body.offsetWidth; y = document.body.offsetHeight; } } this.body_width = x; this.body_height = y; } Axe.BodyPixels = function () { if (this.pageLoaded == 1) { Axe.Resolution(); } } Axe.Initiate = function () { this.BodyPixels(); // Load site specific elements // -------------------- } Axe.MouseCoords = function (e) { var posx = 0; var posy = 0; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } var result = new Array(posx,posy); return result; } Axe.Display = function (item) { var z = new Array("hidden","none"); if (this.pageLoaded == 1 && item) { if (!item.style.visibility || item.style.visibility == "hidden") { z = new Array("visible","inline"); } item.style.visibility = z[0]; item.style.display = z[1]; } } Axe.GroupDisplay = function (group,item) { var x = 0; var found = false; if (this.pageLoaded == 1 && item) { if (this.wingroups[group]) { if (this.wingroups[group].length == 0) { this.wingroups[group] = new Array(item.id); } else { for (var i = 0; i < this.wingroups[group].length; i++) { if (this.wingroups[group][i] == item.id) { found = true; } } if (found === false) { x = this.wingroups[group].length; this.wingroups[group][x] = item.id; } } if (item.style.visibility == "hidden") { for (var i = 0; i < this.wingroups[group].length; i++) { $(this.wingroups[group][i]).style.visibility = "hidden"; $(this.wingroups[group][i]).style.display = "none"; } } Axe.Display(item); } else { this.wingroups[group] = new Array(item.id); if (item.style.visibility == "hidden") { for (var i = 0; i < this.wingroups[group].length; i++) { $(this.wingroups[group][i]).style.visibility = "hidden"; $(this.wingroups[group][i]).style.display = "none"; } } Axe.Display(item); } } } Axe.MenuItem = function (i,s) { i.style.cursor = (s == 1 ? "pointer" : ""); i.style.color = (s == 1 ? "#FFFFFF" : "#3A4C6C"); i.style.backgroundColor = (s == 1 ? "#19447E" : "#EDEDED"); } Axe.isArray = function(x) { return (typeof(x) == 'object' && (x instanceof Array)); } Axe.Trim = function (v) { return v.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); } // d - delimiter, a - array, t - trim (0/1) Axe.Implode = function (d,a,t) { d = (d.length != 1 ? " " : d); var r = ""; for (var i = 0; i < a.length; i++) { if (a[i] != "") { r += (t == 1 ? this.Trim(a[i]) : a[i])+d; } } return this.Trim(r); } Axe.WhiteSpace = function (v) { var w = 0; v = this.Trim(v); while (w > -1) { w = v.indexOf(' '); if (w > -1) { v = v.split(' ').join(' '); } } return v; } Axe.Strip = function (a,v) { var r = ""; v = this.WhiteSpace(v); if (a.length > 0 && v.length > 0) { for (var i = 0; i < v.length; i++) { if (a.indexOf(v[i]) > -1) { r += v[i]; } } } return r; } Axe.SKU = function (v) { v = v.toUpperCase(); v = this.Strip("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_",v); return v; } Axe.Keywords = function (v,n) { var t; var t2 = []; var x = 0; var e = false; //v = this.Strip("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -()&@#$+!',.",v); if (v.length > 0) { if (v.indexOf(',') > -1) { t = v.split(','); for (var i = 0; i < t.length; i++) { t[i] = this.WhiteSpace(t[i]); } for (var i = 0; i < t.length; i++) { if (x == 0) { t2[x] = t[i]; x++; } else { e = false; for (var j = 0; j < t2.length; j++) { if (t[i].toUpperCase() == t2[j].toUpperCase()) { e = true; } } if (e === false) { t2[x] = t[i]; x++ } } } if (n > 0) { if (t2.length > n) { alert("You have entered more than "+n+" keywords!"); } } v = t2.join(','); } } return v; } Axe.SelectTotal = function(name,opt,max,item,start) { if (!(this.select_total[name])) { this.select_total[name] = start; } switch (opt) { case "+": if (this.select_total[name]) { if (this.select_total[name] < max) { this.select_total[name]++; } else { item.checked = false; alert("You have reached the maximum allowed of -"+max+"- items!"); } } else { this.select_total[name] = 1; } break; case "-": if (this.select_total[name]) { if (this.select_total[name] > 0) { this.select_total[name]--; } } else { this.select_total[name] = 0; } break; } } Axe.Currency = function (v) { v = this.Strip("0123456789.",v); if (v.length == 0) { v = 0; } else { v = parseFloat(v); v = v.toFixed(2); } return v; } Axe.Postal = function (v) { v = v.toUpperCase(); v = this.Strip("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",v); return v; } // t - type (1 - menu,2 - submenu) // m - menu name // s - submenu name Axe.DashMenu = function (t,m,s,a) { var menu, submenu; var sg = ""; var temp; var found = false; var a_go = 0; if (this.pageLoaded == 1) { menu = $('member_menu_'+m); if (menu) { if (a) { if (this.dashlinks.length == 0) { if (a.tagName == "A") { this.dashlinks[0] = a; } } else { for (var i = 0; i < this.dashlinks.length; i++) { if (this.dashlinks[i] == a) { found = true; } this.dashlinks[i].style.color = "#333333"; } if (found === false && a.tagName == "A") { this.dashlinks[this.dashlinks.length] = a; } } if (a.tagName == "A") { a.blur(); a_go = 1; } } switch (t) { case "menu": sg = "dash_"+m; Axe.GroupDisplay('dash',menu); if (menu.style.visibility == "visible" && a_go == 1) { a.style.color = "#287614"; } // hide all submenus // ------------------ for (var i = 0; i < this.wingroups['dash'].length; i++) { temp = "dash_"+this.wingroups['dash'][i].replace("member_menu_",""); if (this.wingroups[temp]) { for (var j = 0; j < this.wingroups[temp].length; j++) { $(this.wingroups[temp][j]).style.visibility = "hidden"; $(this.wingroups[temp][j]).style.display = "none"; } } } break; case "sub": submenu = $('member_menu_'+m+'_'+s); if (menu.style.visibility == "visible" && submenu) { Axe.GroupDisplay('dash_'+m,submenu); if (submenu.style.visibility == "visible" && a_go == 1) { a.style.color = "#287614"; } } break; } } } } Axe.Lists = function (opt,name) { var num = ""; var exist = false; var add = ""; var new_entry; if (this.pageLoaded == 1 && $(name+'_insert') && $(name+'_field') && $(name+'_previous')) { switch (opt) { case "insert": if (this.listings[name]) { if ($(name+'_insert').value != "") { if (this.listings[name].length > 0) { for (var i = 0; i < this.listings[name].length; i++) { if ($(name+'_insert').value == this.listings[name][i]) { exist = true; } } if (exist === false) { num = this.listings[name].length; this.listings[name][num] = $(name+'_insert').value; add = this.listings[name][num]; } } else { this.listings[name] = new Array($(name+'_insert').value); add = this.listings[name][0]; } } } else { if ($(name+'_insert').value != "") { this.listings[name] = new Array($(name+'_insert').value); add = this.listings[name][0]; } } if (add != "") { $(name+'_field').value = $(name+'_field').value+add+", "; new_entry = document.createElement('OPTION'); new_entry.text = add; new_entry.value = add; $(name+'_previous').options.add(new_entry); } $(name+'_insert').value = ""; break; case "add": if (this.listings[name] && $(name+'_previous').options.length > 0) { num = $(name+'_previous').selectedIndex; if ($(name+'_previous').options[num].value != "") { } } break; case "remove": break; case "clear": $(name+'_field').value = ""; this.listings[name] = new Array(); break; } } } // id - containing div // f - to return result to, if any // t - title, if any // s - page src (short) // q - query string // d - display or hide // ------------------------------- Axe.Validate = function (id,f,t,s,q,d) { div = (id.length > 0 ? $(id) : $('-')); d = (d == 0 || d == 1 ? d : 0); var title, page; if (this.pageLoaded == 1 && div && $(id+"_page_url")) { title = $(id+"_title"); switch (d) { case 1: if (s.length > 0) { if (title && t.length > 0) { title.innerHTML = t; } $(id+"_page_url").src = "http://www.pictoucounty.ca/x/validate/"+s+".php"+(f.length > 0 || q.length > 0 ? "?" : "")+(f.length > 0 ? "f="+f+(q.length > 0 ? "&" : "") : "")+(q.length > 0 ? q : ""); div.style.visibility = "visible"; div.style.display = "inline"; } else { alert("Opps. Unable to retrieve the selected validation page!"); } break; default: div.style.visibility = "hidden"; div.style.display = "none"; $(id+"_page_url").src = ""; if (title) { title.innerHTML = ""; } } } } Axe.Redirect = function () { var cd = $('redirect_cd'); if (this.pageLoaded == 1) { if (cd && this.redirect_cd > 0) { cd.innerHTML = (this.redirect_cd-1); } if (this.redirect_cd < 1) { window.open(this.redirect_url,'_self'); } else { this.redirect_cd = (this.redirect_cd-1); window.setTimeout('Axe.Redirect()',975); } } } Axe.Fade = function () { var fclose = 0; if (arguments[0]) { fclose = (arguments[0] ? arguments[0] : 0); fclose = (fclose === 1 ? 1 : 0); } var cclick = function () { Axe.Fade(1); }; if (arguments[1]) { if (typeof arguments[1] == "function") { cclick = arguments[1]; } } if (this.pageLoaded == 1 && $('faded_bg')) { if (fclose == 1) { $('faded_bg').style.visibility = "hidden"; $('faded_bg').style.display = "none"; Axe.fade_opacity = 0; Axe.Opacity($('faded_bg'),Axe.fade_opacity); } else { if ($('faded_bg').style.visibility == "hidden") { this.Resolution(); $('faded_bg').style.visibility = "visible"; $('faded_bg').style.display = "inline"; $('faded_bg').style.width = this.body_width+"px"; $('faded_bg').style.height = this.body_height+"px"; $('faded_bg').onclick = cclick; //function () { Axe.Fade(1); }; } if (this.fade_opacity < 80) { this.fade_opacity += 16; this.Opacity($('faded_bg'),this.fade_opacity); if (this.fade_opacity < 80) { window.setTimeout('Axe.Fade()',140); } } } } } Axe.Opacity = function (item,v) { if (item) { if (item.style.opacity) { item.style.opacity = (v/100); } if (item.filters) { item.filters.alpha.opacity = v; } } } // "Pockets" (windows) // ------------------------------- // dp -> 'depth' of the pocket // - if none open, will be '0' (open 'base') // - '1' - down one, '2' - up one // - determines the 'z-index' based on a preset -or- indicated // w -> width (of the actual window) // h -> height // u -> url of the page to open // r -> return ID of the new pocket // ------------------------------- Axe.pocket_z = new Array(0,1001,0); // z-index > lowest, base, highest (max. of -10/+10) Axe.pocket_bn = "axe_pocket_"; Axe.Pocket = function (dp,w,h,u,r) { dp = (this.isArray(dp) ? 1 : dp); u = (this.isArray(u) ? "" : u); if (this.pageLoaded == 1) { // return ID of the new pocket //----------------------------- if (r == 1) { } } } // Initiate // ---------------------- Axe.Load();