$(document).ready(function () {
    content_resize();
    $(window).resize(content_resize);
    $(document).resize(content_resize);
    $('#mainbanner').cycle({
        fx: 'scrollUp',
        speed: 800,
        timeout: 5000,
        easing: 'easeOutQuad'
    });
    $(".menuserif a").hover(function () {
        $(this).addClass('hover')
    }, function () {
        $(this).removeClass('hover')
    });
    if (document.getElementById('news-page')) {
        var newsItems;
        var rowCnt;
        var colCnt = 4;
        var gridH = $(".newscol").height();
        $(".newscol").hide();
        newsItems = new Array();
        $(".newscol").each(function () {
            newsItems.push($(this))
        });
        rowCnt = Math.ceil((newsItems.length) / colCnt);
        $('#pg-content').css({
            'height': ((gridH * rowCnt) + (rowCnt * 30)) + 'px'
        });
        doAnimation(newsItems.shift())
    }
    function doAnimation(item) {
        item.fadeIn("fast", function () {
            if (newsItems.length > 0) doAnimation(newsItems.shift())
        })
    }
    
    if (document.getElementById('portfolio-page')) {
        $(".thumbnails").hover(function () {
            $(this).css({
                'cursor': 'pointer'
            });
            $(this).find('img').fadeTo(150, 0.5);
            $(this).find('h2').stop().animate({
                'color': 'rgb(83,59,39)'
            }, 300)
        }, function () {
            $(this).find('img').fadeTo(150, 1.0);
            $(this).find('h2').stop().animate({
                'color': 'rgb(178,85,56)'
            }, 300)
        });
        $(".thumbnails").click(function () {
            var link = $(this).find('a').attr('href');
            window.location.href = link
        })
    }
    if (document.getElementById('pg-content')) {
        $(".newscol").hover(function () {
            $(this).css({
                'cursor': 'pointer'
            });
            $(this).find('img').fadeTo(150, 0.5);
            $(this).find('h2, h2 a').stop().animate({
                'color': 'rgb(83,59,39)'
            }, 300)
        }, function () {
            $(this).find('img').fadeTo(150, 1.0);
            $(this).find('h2, h2 a').stop().animate({
                'color': 'rgb(178,85,56)'
            }, 300)
        })
    }
    if (document.getElementById('blog-sidebar')) {
        $(".togglebox ul").hide();
        $(".togglebox h4").hover(function () {
            $(this).css({
                'cursor': 'pointer'
            })
        }, function () {});
        $(".togglebox h4").click(function () {
            $(".togglebox ul").toggle()
        })
    }
    if (document.getElementById('comments')) {
        $("#commentform").validate()
    }
    function content_resize() {
        var w = $(window);
        var H = w.height();
        var W = w.width();
        var hdrHeight = $('#header').height();
        var pgHeight = $('#content').height();
        var ftrHeight = $('#footer').height();
        var fPos;
    }
});
