﻿$(document).ready(function() {

    //Get the selected menu item
    if ($('h3#ClientName').length > 0) {
        var menuArray = $('input.ClientLink');
        var h3tag = $('h3#ClientName')[0].innerHTML;
        for (var i = 0; i < menuArray.length; i++) {
            if (menuArray[i].value == h3tag) {
                $(menuArray[i]).parent('form').parent('li').attr('class', 'Selected');
            }
        }
    }

    //Hover styles for input.NavigationSubmit
    $('.input.NavigationSubmit').hover(function() {
        $(this).css('text-decoration', 'underline');
        $(this).css('color', '#aaa');
    }, function() {
        $(this).css('text-decoration', 'none');
        $(this).css('color', '#fff');
    });

    //About menu
    $('.Clientlist a').click(function() {
        //debugger;
        var Section = $(this).attr('id');
        var SectionName = $(this).text();
        $(this).parent('li').addClass('Selected');
        $(this).parent('li').siblings('li').removeClass('Selected');
        $('.AboutTitle').empty();
        $('.AboutTitle').append(SectionName);
        $('#' + Section + 'Text').siblings('div').addClass('Hidden');
        $('#' + Section + 'Text').removeClass('Hidden');
    });

    //Hover effect for inputs
    $('input.ClientLink').hover(function() {
        $(this).css('color', '#bbb');
        $(this).css('text-decoration', 'underline');
        if ($(this).parent('form').parent('li')[0].className == 'Selected') {
            //dont change background color
        } else {
            $(this).parent('form').parent('li').css('background', '#0c0c0c');
        };
        $(this).parent('form').parent('li').animate({
            'width': 180,
            'marginLeft': 10
        }, 'fast');
    }, function() {
        $(this).css('color', '#fff');
        $(this).css('text-decoration', 'none');
        if ($(this).parent('form').parent('li')[0].className == 'Selected') {
            //dont change background color
        } else {
            $(this).parent('form').parent('li').css('background', '#111111');
        };
        $(this).parent('form').parent('li').animate({
            'width': 200,
            'marginLeft': 0
        }, 'fast');
    });
    //Click effect for inputs parent li element
    $('input.ClientLink').click(function() {
        $(this).parent('form').parent('li').css('background', 'transparent');
    });

    //Animations for the portfolio viewer
    $('.PortfolioViewer dd img').hover(function() {
        $(this).animate({
            'width': 110,
            'height': 74,
            'marginLeft': -5
        }, 'fast');
        $(this).parent('dd').animate({
            'paddingTop': 4
        }, 'fast');
        $(this).parent('dd').siblings('dd').fadeTo('fast', 0.5);
    }, function() {
        $(this).animate({
            'width': 100,
            'height': 68,
            'marginLeft': 0
        }, 'fast');
        $(this).parent('dd').animate({
            'paddingTop': 7
        }, 'fast');
        $(this).parent('dd').siblings('dd').fadeTo('fast', 1);
    });

    //Image swapping for the portfolio viewer
    $('.PortfolioViewer dd img').click(function() {
        var getThumbSrc = $(this).attr('src');
        var getLargeSrc = $(this).parent('dd').parent('dl').children('dt').children('img').attr('src');
        $(this).fadeOut('slow');
        $(this).attr('src', getLargeSrc);
        $('.PortfolioViewer dt img').fadeOut('slow', function() {
            $('.PortfolioViewer dt img').attr('src', getThumbSrc);
            $(this).fadeIn('fast');
        });
    });

    //Admin form validation - yes i have to validate my own forms for my own website
    //    if ($('.required').length > 0) {
    //        $('.required').onFocus
    //    }

    //Admin blog/project viewer
    $('.ShowProjects').click(function() {
        $('.AdminBlogs').hide();
        $('.AdminNews').hide();
        $('.AdminProjects').show();
    });
    $('.ShowArticles').click(function() {
        $('.AdminProjects').hide();
        $('.AdminNews').hide();
        $('.AdminBlogs').show();
    });
    $('.ShowNews').click(function() {
        $('.AdminProjects').hide();
        $('.AdminBlogs').hide();
        $('.AdminNews').show();
    });

});