$(document).ready(function () {

    $('.mainBlurb, .post, .sponsor, .section .head, .blogBlurb, .searchPost').hover(function () {
        if ($(this).find('a').attr('href') != null) {
            $(this).addClass('hover');
        }
    }, function () {
        $(this).removeClass('hover');
    });

    $('.mainBlurb, .post, .sponsor, .section .head, .blogBlurb, .searchPost').click(function () {
        var url = $(this).find('a').attr('href');
        var target = $(this).find('a').attr('target')

        if (url != null) {
            if (target != null && target == "_blank")
                window.open(url, "external");
            else {
                window.location = url;
            }
        } else {
            return false;
        }

    });

    $('input.formfield, textarea.formbox').focus(function () {
        if ($(this).val() == $(this).attr('title')) {
            $(this).val('').addClass('active');
        }
    });

    $('input.formfield, textarea.formbox').blur(function () {
        if ($(this).val() == '') {
            $(this).val($(this).attr('title')).removeClass('active');
        }

    });

    function setCookie(c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toUTCString());
    }

    function getCookie(c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    }

    var textSize = getCookie("textsize");
    if (textSize == 'normal') {
        $('body').css({ 'fontSize': '13px' });
    }
    else if (textSize == 'large') {
        $('body').css({ 'fontSize': '15px' });
    }
    else if (textSize == 'xlarge') {
        $('body').css({ 'fontSize': '17px' });
    }

    if (textSize != "") {
        $('ul.fontSize li').removeClass('current');
        $('ul.fontSize a.' + textSize).parent().addClass('current');
    }

    $('ul.fontSize a').click(function () {

        setCookie("textsize", $(this).attr('class'), 7);

        $('ul.fontSize li').removeClass('current');
        if ($(this).attr('class') == 'normal') {
            $('body').css({ 'fontSize': '13px' });
        }
        else if ($(this).attr('class') == 'large') {
            $('body').css({ 'fontSize': '15px' });
        }
        else {
            $('body').css({ 'fontSize': '17px' });
        }
        $(this).parent().addClass('current');
        return false;

    });

    $('.calPost a.showLess').hide();
    $('.calPost a.showMore').click(function () {
        $(this).parent().children('a.showMore').hide();
        $(this).parent().children('.text').addClass('show');
        $(this).parent().children('a.showLess').show();
        return false;
    });
    $('.calPost a.showLess').click(function () {
        $(this).parent().children('a.showLess').hide();
        $(this).parent().children('.text').removeClass('show');
        $(this).parent().children('a.showMore').show();
        return false;
    });

});
	
			
	

	
