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); } }); 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.width = "100%"; 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 CosmoSalon = new Class({ Implements: [Options, Events], options: { sections: ['hair','esthetics','waxing','inside','contact'], page: '', hl: [], nav: [], pwin: 0 }, initialize: function (options) { }, Light: function (n,o) { var base = (o == 1 ? 'menu' : 'nav')+'_'; if ($(base+n)) { if (this.options.nav[n]) { this.options.nav[n] = (this.options.nav[n] == '1' ? '' : '1'); } else { this.options.nav[n] = 1; } $(base+n).src = 'http://x.cosmosalon.ca/'+(o == 1 ? 'nav' : 'splash')+'/'+n+this.options.nav[n]+'.png'; } }, Open: function (pg) { if ($('pageframe') && $('page') && $('pagetitle')) { this.options.page = pg; $('page').src = 'http://www.cosmosalon.ca/'+pg+'.php'; $('pagetitle').src = 'http://x.cosmosalon.ca/titles/'+pg+'.png'; $('pageframe').style.visibility = "visible"; $('pageframe').style.display = "inline"; } }, Close: function () { if ($('pageframe') && $('page') && $('pagetitle')) { this.options.page = ''; $('pageframe').style.visibility = "hidden"; $('pageframe').style.display = "none"; $('page').src = 'about:blank'; } }, Photo: function (p,w,h) { if ($('photoframe') && $('photo')) { $('photo').src = 'http://x.cosmosalon.ca/photos/'+p+'.jpg'; $('photo').style.width = w; $('photo').style.height = h; $('photoframe').style.width = w; PageX.FadeDisplay('photoframe','photo'); } } }); var Cosmo = new CosmoSalon();