﻿var Site = {
    init: function() {
        Site.TextSize.init({ selector: '.textSize a', cookieName: 'textsize'});		
    },
    
    TextSize: {
            cName: null,
            opts: { duration: 60 },
            scale: ['0.6em', '0.7em', '0.8em', '0.9em'],
            myScale: null,
            els: null,
            curr: 0,
            init: function(obj) {
                this.els = $$(obj.selector)
                if (this.els.length == 0) return

                this.cName = obj.cookieName
                if (!$chk(Cookie.read(this.cName))) Cookie.write(this.cName, 0, this.opts) //if doesnt exist, set cookie to 0					
                this.myScale = parseInt(Cookie.read(this.cName)) || 0 //in case cookies are disabled use 0								

                this.els.each(function(el, i) {
                    el.set('href', 'javascript:void(0);')
                    el.addEvent('click', function() {
                        this.processScale(el, i)
                    } .bind(this))
                }, this)
                this.targetEl = $(obj.targeted) || $(document.body)
                this.targetEl.setStyles({ 'font-size': this.scale[this.myScale] })
                
            },
            setCookie: function() {
                Cookie.write(this.cName, this.myScale, this.opts)
            },
            processScale: function(el, index) {                            
                switch (index) {
                    case 0:
                        this.myScale = (this.myScale - 1 < 0) ? 0 : this.myScale - 1
                        break;
                    case 1:
                        this.myScale = (this.myScale + 1 > this.scale.length - 1) ? this.scale.length - 1 : this.myScale + 1
                        break;
                    case 2:
                        this.myScale = (this.myScale - 1 < 0) ? 0 : this.myScale - 1
                        break;
                    case 3:
                        this.myScale = (this.myScale + 1 > this.scale.length - 1) ? this.scale.length - 1 : this.myScale + 1
                        break;             
                }
                this.setCookie();
                this.targetEl.setStyle('font-size', this.scale[this.myScale]);
            }
        }
    }

window.addEvent("domready", function() {
    Site.init();
});

function validateWhom(source, args) {
    if ((document.getElementById('ctl00_ContentPlaceHolder1_c_3_1').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_3_2').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_3_3').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_3_4').checked == true)) {
        args.IsValid = true;
        return;
    }
    else {
        args.IsValid = false;
        return;
    }        
}

    function validateConcerns(source, args) {
        if ((document.getElementById('ctl00_ContentPlaceHolder1_c_5_1').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_5_2').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_5_3').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_5_4').checked == true) ||
        (document.getElementById('ctl00_ContentPlaceHolder1_c_5_5').checked == true)) {
            args.IsValid = true;
            return;
        }
        else {
            args.IsValid = false;
            return;
        }        
    }

    function validateHear(source, args) {
        if ((document.getElementById('ctl00_ContentPlaceHolder1_User_HearList').selectedIndex != 0)) {
            args.IsValid = true;
            return;
        }
        else {
            args.IsValid = false;
            return;
        }   
    }
        
    function validateAgeGroup(source, args) {
        if ((document.getElementById('ctl00_ContentPlaceHolder1_User_Agegroup').selectedIndex != 0)) {
        args.IsValid = true;
        return;
        }
        else {
            args.IsValid = false;
            return;        
        }       
    }
