window.onload = function()
{
    Symptoms.loadSymptoms();
    Utilities.setColumnHeight();
//    CSSColumns.equalise('main','content','news');
    Utilities.setPageTab();
    Utilities.loadEvents();
}
var Utilities = {
    setColumnHeight : function() {
        var col = new Array('content','news');
        var max = 0;
        for (var i=0,l=col.length;i<l;i++) {
            var height = $(col[i]).offsetHeight;
            if (height > max) max = height;
        }
        max += 'px';
        for (var i=0,l=col.length;i<l;i++) {
            $(col[i]).style.height = max;
        }
    },
    setPageTab : function() {
        var sPage = 'menu' + Utilities.getPageName();
        var oElement = $(sPage);
        oElement.id = 'current';
    },
    getPageName : function() {
        var sPage = window.location.pathname;
        sPage = sPage.substring(sPage.lastIndexOf('/') + 1);
        sPage = (sPage != '') ? sPage.replace(/\.aspx/i,'') : 'Default';
        return sPage
    },
    loadEvents : function() {
        if (Utilities.getPageName() == 'Classes') {
            var oElements = $$('.toggleClass');
            for (var i=0,l=oElements.length;i<l;i++) {
                $(oElements[i]).onclick = ClassSchedule.toggleClass;
                $(oElements[i]).value = 'Show';
            }
        }
    }
};
var Symptoms = {
    loadSymptoms : function() {
        var s = 'Stop Smoking,Achieve Success,Overcome Exam Anxiety,Improve Sports Performance,Create Well-Being,Eliminate Fears & Phobias,Reduce Stress,Build Self Confidence,Control Weight,Enhance Relationships,Relieve Anxiety,Reach Your Goals,Increase Motivation,Mold Self-Image,Eliminate Anger,Decrease Frustration,Eradicate Worry,Reduce Guilt,Encourage Forgiveness,Do Away With Nail Biting,Release Anxiety,Foster Assertiveness,Improve Public Speaking,Increase Memory,Improve Concentration,Lower Blood Pressure,Quit Smoking,Abolish Stage Fright,Remove Procrastination,Change Habits,Improve Sales,Adjust Attitude,Drive Career Success,Conquer Exam Anxiety,Eliminate Hair Twisting,Dispose of Helplessness,Ease Nausea,Enhance Surgical Recovery,Eliminate Tardiness,Reduce Performance Anxiety,Get Rid of Perfectionism,Build Initiative,Improve Self-Expression,Eliminate Hopelessness,Remove Overly Critical Tendancies,Take Away Negativism,Resolve Death or Loss Issues,Decrease Panic Attacks,Reduce Temptation,Become Self-Aware,Reduce Aggression,Increase Self-Esteem,Eliminate Self-Blame,Overcome Hostility,Reduce Moodiness,Eliminate Overeating,Discover Age Regression,Experience Past Life Regression,Remove Irrational thoughts,Increase Enthusiasm,Find Direction,Reduce Ulcers,Overcome Writers Block,Stop Tics,Overcome Fear of School,Reduce Chronic Pain,Improve Problem Solving,Reduce Hypertension,Overcome Resistance,Take on Responsibility,Encourage Self-Forgiveness,Eliminate Thumb Sucking';
        Symptoms.hold = new Array();
        Symptoms.list = new Array();
        Symptoms.list = s.split(',');
        Symptoms.resetSymptom();
        var oTimer = window.setInterval('Symptoms.resetSymptom()',3000);
    },
    resetSymptom : function() {
        var i = Math.round(Math.random()*(Symptoms.list.length - 1));
        $("symptom").update(Symptoms.list[i]);
        $("symptom").innerHTML;
        Symptoms.hold.push(Symptoms.list[i]);
        Symptoms.list.splice(i,1);
        if (Symptoms.list.length == 0) {
            Symptoms.list = Symptoms.hold.join().split(',');
            Symptoms.hold.length = 0;
        }
    }
};
var ClassSchedule = {
    toggleClass : function() {
        var sValue = this.id.substring(3);
        var oButton = $('btn'+sValue);
        var oTable = $('div'+sValue);
        var oContent = $("content");
        var oNews = $("news");
        var iOldContent = oContent.offsetHeight;
        var iOldHeight = oTable.offsetHeight;
        oButton.value = (oButton.value != 'Show' ? 'Show' : 'Hide' );
        oTable.className = (oTable.className != 'hidden' ? 'hidden' : 'unhidden' );
    //    CSSColumns.equalise('main','content','news');
        var iNewHeight = oTable.offsetHeight;
        var max = iOldContent + (iNewHeight - iOldHeight);
        oContent.style.height = max + 'px';
        oNews.style.height = max + 'px';
    }
};
/* http://blogs.chayachronicles.com/sonofnun/archive/2007/08/04/270.aspx */
var CSSColumns = {
    maxHeight : 0,
    els : new Array(),
    equalise : function(){
        for (var i=0,l=arguments.length;i<l;i++) if(!$(arguments[i])) return;
        for (var i=0,l=arguments.length;i<l;i++) {
            this.els.push($(arguments[i]));
        }
        this.maxHeight = this.calcMaxHeight();
        for (var i=0,l=this.els.length;i<l;i++){
            this.els[i].style.height = this.maxHeight + 'px';
        }
    },
    calcMaxHeight : function() {
        var h = 0;
        for (var i=0,l=this.els.length;i<l;i++) {
            if (this.els[i].getHeight()>h) {
                h = this.els[i].getHeight();
            }
        }
        return h;
    }
};