function $(id) { return document.getElementById(id); } // Stay put (don't jump back to the top of the page // ----------------------------------------- function $$() { } function Site_Layout() { this.load = $('loaded'); this.loaded = 0; this.root = ""; this.page = ""; this.scripts = document.getElementsByTagName('script'); this.screen = []; this.items = []; this.highlight = []; this.layout_width = 978; this.blanket = 0; this.election = []; this.election['num'] = 0; this.election['days'] = 0; this.election['hours'] = 0; this.election['mins'] = 0; this.election['secs'] = 0; this.options = []; this.options['donations'] = new Array("misc/donate.php",450,450); this.options['requestsign'] = new Array("misc/sign.php",280,400); this.options['volunteer'] = new Array("misc/volunteer.php",280,340); this.options['cycletowalk'] = new Array("misc/letter.php",580,400); this.options['thanksgiving'] = new Array("misc/thanksgiving.php",580,400); // Video clips this.options['clip1'] = new Array("videos/clip.php?z=1",580,400); this.options['clip2'] = new Array("videos/clip.php?z=2",580,400); this.options['clip3'] = new Array("videos/clip.php?z=3",580,400); this.options['clip4'] = new Array("videos/clip.php?z=4",580,400); this.options['clip5'] = new Array("videos/clip.php?z=5",580,400); this.options['ad1'] = new Array("videos/clip.php?z=6",580,400); this.options['ad2'] = new Array("videos/clip.php?z=7",580,400); this.options['ad3'] = new Array("videos/clip.php?z=8",580,400); this.options['ad4'] = new Array("videos/clip.php?z=9",580,400); this.opt_selected = ""; this.agent = navigator.userAgent; this.agent = this.agent.toLowerCase(); this.safari = 0; } function site_layout_scriptquery(item) { var selected = ""; var start = -1; var query = ""; var list = new Array(); var temp; var name = ""; var v = []; with (this) { scripts = document.getElementsByTagName('script'); for (i = 0; i < scripts.length; i++) { if (!selected) { selected = (scripts[i].id == "site_jscript_"+item ? scripts[i] : ""); } } if (selected.id != "") { name = item+".js"; start = selected.src.indexOf(name); query = (selected.src.length > (start+(name.length+1)) ? selected.src.substring((start+(name.length+1)),selected.src.length) : ""); if (query != "") { list = query.split(";"); for (i = 0; i < list.length; i++) { temp = list[i].split("="); v[temp[0]] = (temp[1] ? temp[1] : ""); } } } } return v; } function site_layout_initialize() { with (this) { load = $('loaded'); if (load) { loaded = 1; Site.SetRoot(); Site.Align(null,0,0,'','',0); Site.CountDown(); } else { window.setTimeout('Site.Initialize()',10); } } } function site_layout_set_root() { var query_list = Site.ScriptQuery("main"); with (this) { if (loaded == 1) { if (root == "") { root = "http://www.votepetermackay.ca/";//(query_list['root'] ? query_list['root'] : ""); page = "x/script/thankyou.php";//(query_list['page'] ? query_list['page'] : ""); safari = "0";//(query_list['safari'] ? query_list['safari'] : ""); election['num'] = -24451582-((60*60*1));//1*(query_list['countdown'] ? (query_list['countdown']-((60*60*2)+(60*8))) : "0"); } if (root != "") { loaded = 2; } else { window.setTimeout('Site.SetRoot()',10); } } } } function site_layout_screensize() { with (this) { if (loaded == 2) { if (document.body) { screen['width'] = document.body.clientWidth; screen['height'] = document.body.clientHeight; } else { window.setTimeout('Site.Initialize()',10); } } } } function site_layout_align(d,y,x,v,h,reset) { Site.ScreenSize(); var temp = new Array(0,0); // y,x var thankyou = 0; //90; with (this) { if (loaded == 2) { items['site_layout_thankyou'] = new Array(0,layout_width-60,"top","center"); items['site_layout_leaf'] = new Array(0+thankyou,layout_width,"top","center"); items['site_layout_header'] = new Array(0+thankyou,layout_width,"top","center"); items['site_layout_navigation'] = new Array(73+thankyou,layout_width,"top","center"); items['site_layout_body'] = new Array(103+thankyou,layout_width,"top","center"); items['homepage_details_photo_frame'] = new Array(103+thankyou,layout_width-(37*2),"top","center"); items['homepage_details_splash'] = new Array(103+thankyou,layout_width-(37*2),"top","center"); items['homepage_details_signature'] = new Array(250+thankyou,layout_width-(846*2),"top","center"); items['homepage_details_body'] = new Array(333+thankyou,layout_width,"top","center"); items['staff_login_lock'] = new Array(3+thankyou,layout_width-(956*2),"top","center"); items['staff_login_box'] = new Array(8+thankyou,layout_width-(646*2),"top","center"); if (d) { if (!items[d.id] || reset == 1) { 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) : x)); } else { for (i in items) { if ($(i)) { temp[0] = (items[i][2] != "middle" ? items[i][0] : (items[i][0] >= screen['height'] ? 0 : ((screen['height']-items[i][0])/2))); temp[1] = (items[i][3] != "center" ? items[i][1] : (items[i][1] >= screen['width'] ? 0 : ((screen['width']-items[i][1])/2))); $(i).style.top = 0; $(i).style.left = 0; $(i).style.top = (items[i][2] == "bottom" ? (screen['height']-items[i][0]) : (items[i][2] == "middle" ? temp[0] : items[i][0])); $(i).style.left = (items[i][3] == "right" ? (screen['width']-items[i][1]) : (items[i][3] == "center" ? temp[1] : items[i][1])); } } } if (blanket == 1) { blanket = 0; Overlay(); } } } } function site_layout_highlight(item) { var name = ""; var strip = ""; var temp = ""; var x = this.root+"x/img/layout/n/"; with (this) { if (loaded == 2) { if (item && root != "") { name = item.src.substring(x.length,item.src.length); name = name.substring(0,name.indexOf('.png')); strip = name.substring(0,(name.length-1)); if (highlight["pmnav_"+strip]) { temp = "pmnav_"+strip; highlight[temp] = (highlight[temp] == "1" ? "" : "1"); item.src = x+strip+highlight[temp]+".png"; } else { temp = "pmnav_"+name; if (!highlight["pmnav_"+name]) { item.id = temp; highlight[temp] = 1; } else { highlight[temp] = (highlight[temp] == "1" ? "" : "1"); } item.src = x+name+highlight[temp]+".png"; } } } } } function site_layout_hover(type,item,content,onoff) { var box; var text; var image; var image_src; var _xy = new Array(); var coords = new Array(); with (this) { if (loaded == 2) { box = $('site_hover_box'); text = $('site_hover_box_text'); image = $('site_hover_box_image'); image_src = $('site_hover_box_image_src'); if (box) { box.style.left = 0; box.style.top = 0; switch (onoff) { case 1: if (item) { _xy = XY(item,''); coords = item.coords.split(","); box.style.left = (_xy[0] + (coords[2]*1) - 50); box.style.top = (_xy[1] + (coords[3]*1) - 50); switch (type) { case "text": text.innerHTML = content; text.style.visibility = "visible"; text.style.display = "inline"; box.style.visibility = "visible"; box.style.display = "inline"; break; } } break; default: if (text) { text.innerHTML = ""; text.style.visibility = "hidden"; text.style.display = "none"; } box.style.visibility = "hidden"; box.style.display = "none"; } } } } } function site_layout_xy(id,opt) { var pE; var x; var y; with (this) { if (agent.lastIndexOf("msie") == -1) { pE = id.offsetParent; x = id.offsetLeft; y = id.offsetTop; while(pE != document.body) { x += pE.offsetLeft; y += pE.offsetTop; pE = pE.offsetParent; } } else { x = ((screen['width']-id.offsetLeft)/2); y = ((screen['height']-id.offsetTop)/2); } } return (opt == "x" ? x : (opt == "y" ? y : new Array(x,y))); } function site_layout_overlay() { var over; with (this) { if (loaded == 2) { over = $('site_overlay'); if (over) { switch (blanket) { case 0: over.style.height = (document.body.scrollHeight >= screen['height'] ? document.body.scrollHeight : screen['height']); over.style.width = (document.body.scrollWidth >= screen['width'] ? document.body.scrollWidth : screen['width']); over.style.visibility = "visible"; over.style.display = "inline"; break; case 1: over.style.visibility = "hidden"; over.style.display = "none"; over.style.height = 1; over.style.width = 1; break; } blanket = (blanket == 0 ? 1 : 0); } } } } function site_layout_photo(item,img,t) { var dir; var frame; var title; var image; var _xy = new Array(); var coords = new Array(); var imgLeft = 0; with (this) { if (loaded == 2) { dir = root+"photos/"; frame = $('site_overlay_image'); title = $('site_overlay_image_title'); image = $('site_overlay_image_src'); if (img != "") { if (frame) { if (item) { _xy = XY(item,''); title.innerHTML = t; image.src = dir+img; Align(frame,document.body.scrollTop+20,0,"top","left",1); frame.style.visibility = "visible"; frame.style.display = "inline"; if (blanket == 0) { Overlay(); } } } } else { if (blanket == 1) { Overlay(); } if (frame) { frame.style.visibility = "hidden"; frame.style.display = "none"; frame.style.top = 0; frame.style.left = 0; title.innerHTML = ""; image.src = ""; } } } } } function site_layout_countdown() { var calc = []; calc['days'] = 60*60*24; calc['hours'] = 60*60; calc['mins'] = 60; var temp = 0; with (this) { if (loaded == 2) { election['num'] = (election['num'] > 0 ? 1*(election['num']-1) : 0); if (election['num'] > 0) { temp = election['num']; election['days'] = (temp == calc['days'] ? 1 : (temp > calc['days'] ? ((temp-(temp % calc['days']))/calc['days']) : 0)); temp -= (election['days'] * calc['days']); election['hours'] = (temp == calc['hours'] ? 1 : (temp > calc['hours'] ? ((temp-(temp % calc['hours']))/calc['hours']) : 0)); temp -= (election['hours'] * calc['hours']); election['mins'] = (temp == calc['mins'] ? 1 : (temp > calc['mins'] ? ((temp-(temp % calc['mins']))/calc['mins']) : 0)); temp -= (election['mins'] * calc['mins']); election['secs'] = temp; } else { election['days'] = 0; election['hours'] = 0; election['mins'] = 0; election['secs'] = 0; } if ($('site_countdown_days')) { $('site_countdown_days').innerHTML = ""+election['days']+" Day"+(election['days'] > 1 ? "s": "")+""; } if ($('site_countdown_hours')) { $('site_countdown_hours').innerHTML = ""+election['hours']+" hour"+(election['hours'] > 1 ? "s": "")+""; } if ($('site_countdown_mins')) { $('site_countdown_mins').innerHTML = ""+election['mins']+" min"+(election['mins'] > 1 ? "s": "")+""; } if ($('site_countdown_secs')) { $('site_countdown_secs').innerHTML = ""+election['secs']+" sec"+(election['secs'] > 1 ? "s": "")+""; } if (election['num'] > 0) { window.setTimeout('Site.CountDown()',1000); } } } } function site_layout_misc(opt,overlay) { var box; var frame; with (this) { if (loaded == 2) { box = $('site_misc_box'); frame = $('site_misc_frame'); if (opt == "" || opt == opt_selected) { if (box) { box.style.visibility = "hidden"; box.style.display = "none"; box.style.top = 0; box.style.left = 0; frame.src = ""; frame.width = 1; frame.height = 1; if (overlay == 1) { parent.Site.blanket = 0; parent.Site.Overlay(); } opt_selected = ""; } } else if (options[opt]) { if (box) { opt_selected = opt; frame.width = options[opt][1]; frame.height = options[opt][2]; frame.src = root+options[opt][0]; if (opt.indexOf("clip") != -1 || opt.indexOf("ad") != -1) { Align(box,125,-315,"top","center",1); } else if (opt == "cycletowalk" || opt == "thanksgiving") { Align(box,(page == "index.php" ? 260 : 125),-315,"top","center",1); } else if (opt == "donations") { Align(box,125,0,"top","center",1); } else { Align(box,(page == "index.php" ? 360 : 125),0,"top","center",1); } box.style.visibility = "visible"; box.style.display = "inline"; if (overlay == 1) { parent.Site.blanket = 0; parent.Site.Overlay(); } } } } } } function site_layout_videoads(num) { with (this) { if (loaded == 2) { $('video_ads_param').value = root+"videos/ads-"+num+".swf?autoplay=1"; $('video_ads_embed').src = root+"videos/ads-"+num+".swf?autoplay=1"; } } } Site_Layout.prototype.ScriptQuery = site_layout_scriptquery; Site_Layout.prototype.Initialize = site_layout_initialize; Site_Layout.prototype.SetRoot = site_layout_set_root; Site_Layout.prototype.ScreenSize = site_layout_screensize; Site_Layout.prototype.Align = site_layout_align; Site_Layout.prototype.Highlight = site_layout_highlight; Site_Layout.prototype.Hover = site_layout_hover; Site_Layout.prototype.XY = site_layout_xy; Site_Layout.prototype.Overlay = site_layout_overlay; Site_Layout.prototype.Photo = site_layout_photo; Site_Layout.prototype.CountDown = site_layout_countdown; Site_Layout.prototype.Misc = site_layout_misc; Site_Layout.prototype.VideoAds = site_layout_videoads; var Site = new Site_Layout(); Site.Initialize();