// Jquery Function Calls - Two Four Digital - CJH - Work that Jquery
$(function() {
    // text replace
    Cufon.replace("h1", "Megaphone");
    Cufon.replace("h2", "Megaphone");
    Cufon.replace("h2.cyan", "Megaphone");
    Cufon.replace("h2.black", "Megaphone");
    Cufon.replace("h2.darkBlue", "Megaphone");
    Cufon.replace("p.markets", "Megaphone");
    Cufon.replace("h3.title_heading", "Megaphone")


    // show div's - cleaner looking when page is loading
    $(".news").show();


    //Buttons Hompage
    $('.fadeThisCorporate,.fadeThisPublicSector,.fadeThisMediaEntertainment,.fadeThis,.fadeThisBroadcastTechnology,.fadeThisMapHoverUSA, .fadeThisMapHoverUK, .fadeThisMapHoverPoland, .fadeThisMapHoverPune, .fadeThisMapHoverHyderabad, .fadeThisMapHoverDubai,.fadeThisMediaThin, .fadeThisPublicSectorThin, .fadeThisbroadcastTechnologyThin, .fadeThisCorporateThin').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(500, 1);
        }, function() {
            $span.stop().fadeTo(500, 0);
        });
    });

  

    // News Slideshow
    $('#slideshow_news').cycle({
        fx: 'scrollLeft',
        timeout: 0,
        prev: '#prev',
        next: '#next',
        pager: '#newsPager',
        pagerAnchorBuilder: pagerFactory2
    });


    function pagerFactory2(idx2, slide2) {
        var s2 = idx2 > 7 ? ' style="display:none"' : '';
        return '<li' + s2 + '><a href="#" class="img' + (+idx2 + 1) + '"><span class="floatLeft">' + (idx2 + 1) + '</span></a></li>';
    };




    //Toggle panels
    $(".action").click(function() {
        $(this).parent().next().fadeSliderToggle()
        return false;
    })

    // possible fix for small images appearing
    setTimeout("CustomersImageCycleHome();", 1700);
    setTimeout("CustomersImageCylce();", 400);
});


function CustomersImageCycleHome() {
    $(".customers").show();

    //Image Cycle Homepage
    $('#slideshow').cycle({
        fx: 'fade',
        timeout: 5000,
        prev: '#prev',
        next: '#next',
        pager: '#rightNavIndex',
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 7 ? ' style="display:none"' : '';
        return '<li' + s + '><a href="#" class="img' + (+idx + 1) + '"><span class="floatLeft">' + (idx + 1) + '</span></a></li>';
    };
}

function CustomersImageCylce()
{
    $(".custImageCycle").show();
    
    // button fades
    $('#contact_web').cycle({
        timeout: 0,
        speed: 1000,
        fx: 'fade',
        startingSlide: 0
    });
    $('.fadeThisMediaThin').hover(function()
    {
        $('#contact_web').cycle(0);
        return false;
    });
    $('.fadeThisPublicSectorThin').hover(function()
    {
        $('#contact_web').cycle(1);
        return false;
    });
    $('.fadeThisbroadcastTechnologyThin').hover(function()
    {
        $('#contact_web').cycle(2);
        return false;
    });
    $('.fadeThisCorporateThin').hover(function()
    {
        $('#contact_web').cycle(3);
        return false;
    });
}



//$(document).ready(function() {
//    $(document).pngFix();
//});




