var Tools = 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 Tools = new Tools(); 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) { Tools.display(cd,1); return false }); } if ($(c)) { $(c).addEvent('click', function(e) { Tools.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'; Tools.fade(1); }; if ($(o)) { $(o).addEvent('click', function(e) { $('faded_bg_container').insertBefore(cd,null); Tools.center(cd); Tools.display(cd,1); Tools.fade(0,cf); return false }); } if ($(c)) { $(c).addEvent('click', function(e) { Tools.fade(1); Tools.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'; Tools.fade(1); }; $('faded_bg_container').insertBefore(cd,null); Tools.center(cd); Tools.display(cd,1); Tools.fade(0,cf); if ($(c)) { $(c).addEvent('click', function(e) { Tools.fade(1); Tools.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(); /* =========================================== */ /* function $(id) { return document.getElementById(id); } */ function Foundation() { this.load = $('loaded'); this.loaded = 0; this.root = ""; this.layout_w = 1090; this.screen = []; this.items = []; this.calendar_data = new Array("",0,0,-1); // field to return value too, sub-window, open (1)/closed (0), sub-window (1)/primary (0) } function foundation_initialize() { with (this) { load = $('loaded'); if (load) { loaded = 1; root = "http://www.gmf.ca/"; Site.Align(null,0,0,'',''); } else { window.setTimeout('Site.Initialize()',10); } } } function foundation_screensize() { with (this) { if (loaded == 1) { if (document.body) { screen['width'] = document.body.clientWidth; screen['height'] = document.body.clientHeight; } else { window.setTimeout('Site.Initialize()',10); } } } } function foundation_align(d,y,x,v,h) { with (this) { if (loaded == 1) { Site.ScreenSize(); if (d) { if (!items[d.id]) { items[d.id] = new Array(y,x,v,h); } d.style.top = 0; d.style.left = 0; d.style.top = (v == "bottom" ? (screen['height']-y) : (v == "middle" ? ((screen['height']/2)+y) : y)); d.style.left = (h == "right" ? (screen['width']-x) : (h == "center" ? ((screen['width']/2)+x) : (h == "layout" ? (((screen['width']/2)-(layout_w/2))+x) : x))); if (h == "layout" && screen['width'] <= layout_w) { d.style.left = x; } } else { for (i in items) { if ($(i)) { $(i).style.top = 0; $(i).style.left = 0; $(i).style.top = (items[i][2] == "bottom" ? (screen['height']-items[i][0]) : (items[i][2] == "middle" ? ((screen['height']/2)+items[i][0]) : items[i][0])); $(i).style.left = (items[i][3] == "right" ? (screen['width']-items[i][1]) : (items[i][3] == "center" ? ((screen['width']/2)+items[i][1]) : (items[i][3] == "layout" ? (((screen['width']/2)-(layout_w/2))+items[i][1]) : items[i][1]))); if (items[i][3] == "layout" && screen['width'] <= layout_w) { $(i).style.left = items[i][1]; } } } } } } } function foundation_bubble(d,item,s,top,left) { var z = new Array("hidden","none"); with (this) { if (loaded == 1) { if (d && $('layout_bubble') && $('layout_bubble_'+item)) { if (s == 1) { d.style.cursor = "pointer"; z = new Array("visible","inline"); } $('layout_bubble').style.visibility = z[0]; $('layout_bubble').style.display = z[1]; $('layout_bubble_'+item).style.visibility = z[0]; $('layout_bubble_'+item).style.display = z[1]; Align($('layout_bubble'),top,left,'top','layout'); } } } } function foundation_display(item) { var z = new Array("hidden","none"); with (this) { if (loaded == 1) { if ($(item)) { if (!$(item).style.visibility || $(item).style.visibility == "hidden") { z = new Array("visible","inline"); } $(item).style.visibility = z[0]; $(item).style.display = z[1]; } } } } function foundation_darkwindow(url,title,w,h,r,s) { with (this) { if (loaded == 1) { $('layout_window_type').value = "dark"; Site.LightWin(url,title,w,h,r,s); } } } function foundation_lightwindow(url,title,w,h,r,s) { var bg; var win; var winsubs; var sub; var opening = "layout_lightwin"; var z; var temp; var nf = 0; // not found var x = 1; var wtype = "lightwin"; with (this) { if (loaded == 1) { wtype = ($('layout_window_type').value == "dark" ? "darkwin" : "lightwin"); opening = (wtype == "darkwin" ? "layout_darkwin" : "layout_lightwin"); bg = $('layout_lightwin_bg'); win = $('layout_'+wtype); winsubs = $('layout_'+wtype+'_subs'); sub = $('layout_'+wtype+'_sub_'+s); opening += (s > 0 ? "_sub_"+s : ""); if (win && winsubs && bg) { if (s > 1) { if (!$('layout_'+wtype+'_sub_'+s)) { temp = document.createElement('DIV'); temp.id = "layout_"+wtype+"_sub_"+s; temp.style.position = "absolute"; temp.style.zIndex = (1000002+(s-1)); temp.style.visibility = "hidden"; temp.style.display = "none"; temp.style.top = 0; temp.style.left = 0; temp.style.width = "100%"; temp.style.height = "100%"; winsubs.insertBefore(temp,null); sub = $('layout_'+wtype+'_sub_'+s); } } if ((s > 0 && sub) || s == 0) { if (s > 0) { if (title != "") { winsubs.style.visibility = "visible"; winsubs.style.display = "inline"; } else if (r == 0 && s < 2) { winsubs.style.visibility = "hidden"; winsubs.style.display = "none"; } } if (s > 0 && sub.innerHTML == "") { if (wtype == "darkwin") { sub.innerHTML = win.innerHTML.replace(/layout_darkwin/gi,"layout_darkwin_sub_"+s); sub.innerHTML = sub.innerHTML.replace(/Site.DarkWin\('','',0,0,1,0\)/gi,"Site.DarkWin('','',0,0,1,"+s+")"); sub.innerHTML = sub.innerHTML.replace(/Site.DarkWin\('','',0,0,0,0\)/gi,"Site.DarkWin('','',0,0,0,"+s+")"); } else { sub.innerHTML = win.innerHTML.replace(/layout_lightwin/gi,"layout_lightwin_sub_"+s); sub.innerHTML = sub.innerHTML.replace(/Site.LightWin\('','',0,0,1,0\)/gi,"Site.LightWin('','',0,0,1,"+s+")"); sub.innerHTML = sub.innerHTML.replace(/Site.LightWin\('','',0,0,0,0\)/gi,"Site.LightWin('','',0,0,0,"+s+")"); } } z = (s > 0 ? sub : win); if (r == 1) { $(opening+'_page').src = $(opening+'_page').src; } else if (url != "") { if (s == 0) { bg.style.visibility = "visible"; bg.style.display = "inline"; bg.style.height = document.body.scrollHeight; } $(opening+'_title').innerHTML = (title == "" ? " " : title); $(opening+'_title').style.width = (w < 100 ? 80 : (w-20)); $(opening+'_body').style.width = (w < 100 ? 100 : w); $(opening+'_body').style.height = (h < 100 ? 100 : h); $(opening+'_page').src = url; z.style.visibility = "visible"; z.style.display = "inline"; if (s == 0) { while (nf == 0) { if (!$('layout_'+wtype+'_sub_'+x)) { nf = 1; } else { if (wtype == "darkwin") { DarkWin('','',0,0,0,x); } else { LightWin('','',0,0,0,x); } } x++; } } else { x = (s+1); while (nf == 0) { if (!$('layout_'+wtype+'_sub_'+x)) { nf = 1; } else { if (wtype == "darkwin") { DarkWin('','',0,0,0,x); } else { LightWin('','',0,0,0,x); } } x++; } } } else { if (s == 0) { bg.style.visibility = "hidden"; bg.style.display = "none"; } z.style.visibility = "hidden"; z.style.display = "none"; $(opening+'_title').innerHTML = ""; $(opening+'_page').src = ""; if (s == 0) { while (nf == 0) { if (!$('layout_'+wtype+'_sub_'+x)) { nf = 1; } else { if (wtype == "darkwin") { DarkWin('','',0,0,0,x); } else { LightWin('','',0,0,0,x); } } x++; } winsubs.style.visibility = "hidden"; winsubs.style.display = "none"; } else { if (wtype == "darkwin") { DarkWin('','',0,0,1,(s-1)); } else { LightWin('','',0,0,1,(s-1)); } x = (s+1); while (nf == 0) { if (!$('layout_'+wtype+'_sub_'+x)) { nf = 1; } else { if (wtype == "darkwin") { DarkWin('','',0,0,0,x); } else { LightWin('','',0,0,0,x); } } x++; } } } } } $('layout_window_type').value = "light"; } } } function foundation_calendar(field,opt,sec,v) { var onoff = new Array("hidden","none","",0); var cal; var frame; var result; var f; var r; with (this) { if (loaded == 1) { switch (sec) { case "sub": if (opt == "open") { parent.$('layout_calendar').style.top = 20; parent.$('layout_calendar').style.left = (parent.document.body.scrollWidth - (182+30)); parent.$('layout_calendar').style.visibility = "visible"; parent.$('layout_calendar').style.display = "inline"; parent.$('layout_calendar_frame').src = "http://www.gmf.ca/x/utility/calendar.php"; parent.Site.calendar_data[0] = field; parent.Site.calendar_data[2] = 1; parent.Site.calendar_data[3] = 1; window.setTimeout('Site.CalendarResult()',50); } break; case "cal": switch (opt) { case "selected": parent.Site.Calendar(parent.Site.calendar_data[0],'selected','',v); CalendarResult(); break; case "blank": parent.Site.Calendar(parent.Site.calendar_data[0],'blank','',''); CalendarResult(); break; case "close": parent.Site.Calendar(parent.Site.calendar_data[0],'close','',''); break; } break; default: switch (opt) { case "open": $('layout_calendar').style.top = 20; $('layout_calendar').style.left = (document.body.scrollWidth - (182+30)); $('layout_calendar').style.visibility = "visible"; $('layout_calendar').style.display = "inline"; $('layout_calendar_frame').src = "http://www.gmf.ca/x/utility/calendar.php"; calendar_data[0] = field; calendar_data[2] = 1; calendar_data[3] = 0; window.setTimeout('Site.CalendarResult()',50); break; case "selected": $('layout_calendar_value').value = v; $('layout_calendar').style.visibility = "hidden"; $('layout_calendar').style.display = "none"; $('layout_calendar_frame').src = ""; calendar_data[2] = 0; break; case "blank": $('layout_calendar_value').value = ""; $('layout_calendar').style.visibility = "hidden"; $('layout_calendar').style.display = "none"; $('layout_calendar_frame').src = ""; calendar_data[2] = 0; break; case "close": $('layout_calendar').style.top = 0; $('layout_calendar').style.left = 0; $('layout_calendar').style.visibility = "hidden"; $('layout_calendar').style.display = "none"; $('layout_calendar_frame').src = ""; calendar_data[2] = 0; break; } } } } } function foundation_calendarresult() { with (this) { if (loaded == 1) { switch (calendar_data[3]) { case -1: if (parent.Site.calendar_data[0].id && parent.$('layout_calendar_value')) { parent.Site.calendar_data[0].value = parent.$('layout_calendar_value').value; } break; case 0: if (calendar_data[0].id && $('layout_calendar_value')) { calendar_data[0].value = $('layout_calendar_value').value; } break; } if (calendar_data[2] == 1) { window.setTimeout('Site.CalendarResult()',50); } } } } function foundation_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.gmf.ca/z.php?id="+id; } else if (countries && provinces && towns) { UpdateAreas("country",c,s[0]); UpdateAreas("province",p,s[1]); UpdateAreas("town",t,""); } } } } function foundation_updateareas(l,e,s) { var list; var total = 0; var new_entry; with (this) { if (loaded == 1) { list = $(l+'_list'); if (list && e) { 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; } } } } } } } } function foundation_verifyunique(p,t,v,e) { var field; var error; with (this) { if (loaded == 1) { field = $(t); error = $(t+"_error"); if (p == 1 && (t == "name" || t == "email")) { $('data_loader').src = "http://www.gmf.ca/zv.php?"+t+"="+v; } else if (p == 0 && field && error && (t == "name" || t == "email")) { error.innerHTML = e; error.style.visibility = "visible"; error.style.display = "inline"; } } } } function foundation_number(v) { return (isFinite(v) && parseFloat(v) == v ? (v >= 0 ? 1 : 0) : 0); } Foundation.prototype.Initialize = foundation_initialize; Foundation.prototype.ScreenSize = foundation_screensize; Foundation.prototype.Align = foundation_align; Foundation.prototype.Bubble = foundation_bubble; Foundation.prototype.Display = foundation_display; Foundation.prototype.DarkWin = foundation_darkwindow; Foundation.prototype.LightWin = foundation_lightwindow; Foundation.prototype.Calendar = foundation_calendar; Foundation.prototype.CalendarResult = foundation_calendarresult; Foundation.prototype.LoadAreas = foundation_loadareas; Foundation.prototype.UpdateAreas = foundation_updateareas; Foundation.prototype.VerifyUnique = foundation_verifyunique; Foundation.prototype.Number = foundation_number; var Site = new Foundation(); Site.Initialize();