﻿$(document).ready(function()
{
    $('.HomeZone #subnav_home .subnav_make_homepage a').each(function()
    {
        $(this).mouseover(function()
        {
            var hover_id = $(this).attr('title');

            if (hover_id != null && hover_id != undefined && hover_id != '')
            {
                if ($('.HomeZone #subnav_home .subnav_make_homepage .' + hover_id).is(':animated'))
                {
                    $('.HomeZone #subnav_home .subnav_make_homepage .' + hover_id).stop();
                    $('.HomeZone #subnav_home .subnav_make_homepage .' + hover_id).css({ opacity: '100' });
                }
                else
                {
                    $('.HomeZone #subnav_home .subnav_make_homepage .' + hover_id).attr('style', 'display: block');
                }
            }
        });

        $(this).mouseout(function()
        {
            var hover_id = $(this).attr('title');

            if (hover_id != null && hover_id != undefined && hover_id != '')
            {
                $('.HomeZone #subnav_home .subnav_make_homepage .' + hover_id).fadeOut(250);
            }
        });
    });

    $('.HomeZone #subnav_home .subnav_make_homepage .hover_box').mouseover(function()
    {
        if ($(this).is(':animated'))
        {
            $(this).stop();
            $(this).css({ opacity: '100' });
        }
    });

    $('.HomeZone #subnav_home .subnav_make_homepage .hover_box').mouseout(function()
    {
        $(this).fadeOut(250);
    });

    // twitter follwer count
    $.ajax(
    {
        type: "POST",
        url: "http://api.twitter.com/1/users/show.json",
        dataType: "json",
        data: "{\"screen_name\": \"OKmagAustralia\"}",
        contentType: "application/json; charset=utf-8",
        success: function(data)
        {
            var container = $(".HomeZone #subnav_home .subnav_make_homepage .twitter_hover_box");
            
            if (container.length > 0 && data.d != null)
            {
                $(container).find(".inner_box .image_box a").html('<img alt="follow" src="' + data.d.profile_image_url + '" class="icon" />');
                $(container).find(".inner_box .text_box span.followers").text(data.d.followers_count + " followers");
            }
        },
        error: function(xhr, ajaxOptions, thrownError)
        {
            // alert(xhr.responseText);
        }
    });
});

