$(document).ready(function() {

    /* text replacement */
    Cufon.replace('.replace');


    /* accordion FAQs */
    jQuery('dl.faqList').accordion({ autoheight: false, active: false, alwaysOpen: false, animated: false, header: "dt" });
    /* accordion +/- */
    jQuery('dl.accordList').accordion({ autoheight: false, active: false, alwaysOpen: false, animated: false, header: "dt" });
    /* accordion compatablities */
    jQuery('#compList').accordion({ autoheight: false, active: false, alwaysOpen: false, animated: false, header: "div.title" });

    /* featured handset carousel */

    function mycarousel_initCallback(carousel) {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };


    jQuery('#featuredSets').jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });

    //Hide (Collapse) the toggle containers on load
    $("div.tsandcs_copy").hide();
    $("div.tsandcs_copy.q1").hide();


    //Switch the "Open" and "Close" state per click & show / hide Ts and Cs div
    $("h4.tsandcsH4").toggle(function() {
        $(this).removeClass("tsandcs_link_on");
        $(this).addClass("tsandcs_link_off");
        $(this).next().slideDown('slow');
    }, function() {
        $(this).removeClass("tsandcs_link_off");
        $(this).addClass("tsandcs_link_on");
        $(this).next().slideUp('slow');
    });

    //List Ts and Cs quick links each need a list "id" and a class adding to the relevant TsandCs_div
    $("li#q1").click(function() {
        $("div.tsandcs_copy").slideUp('slow');
        $("h4.tsandcsH4").removeClass("tsandcs_link_off");
        $("h4.tsandcsH4").addClass("tsandcs_link_on");
        $("h4.q1").removeClass("tsandcs_link_on");
        $("h4.q1").addClass("tsandcs_link_off");
        $("div.q1").slideDown('slow');
    });
    $("li#q2").click(function() {
        $("div.tsandcs_copy").slideUp('slow');
        $("h4.tsandcsH4").removeClass("tsandcs_link_off");
        $("h4.tsandcsH4").addClass("tsandcs_link_on");
        $("h4.q2").removeClass("tsandcs_link_on");
        $("h4.q2").addClass("tsandcs_link_off");
        $("div.q2").slideDown('slow');
    });
    $("li#q3").click(function() {
        $("div.tsandcs_copy").slideUp('slow');
        $("h4.tsandcsH4").removeClass("tsandcs_link_off");
        $("h4.tsandcsH4").addClass("tsandcs_link_on");
        $("h4.q3").removeClass("tsandcs_link_on");
        $("h4.q3").addClass("tsandcs_link_off");
        $("div.q3").slideDown('slow');
    });

    //Hide (Collapse) the toggle containers on load
    $("div.faq_copy").hide();
    $("div.q1").show();

    //Switch the "Open" and "Close" state per click & show / hide faq div
    $("h4.faqsH4").toggle(function() {
        $(this).removeClass("faq_link_on");
        $(this).addClass("faq_link_off");
        $(this).next().slideDown('slow');
    }, function() {
        $(this).removeClass("faq_link_off");
        $(this).addClass("faq_link_on");
        $(this).next().slideUp('slow');
    });

    //List FAQ quick links each need a list "id" and a class adding to the relevant faq_div
    $("li#q1").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q1").removeClass("faq_link_on");
        $("h4.q1").addClass("faq_link_off");
        $("div.q1").slideDown('slow');
    });
    $("li#q2").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q2").removeClass("faq_link_on");
        $("h4.q2").addClass("faq_link_off");
        $("div.q2").slideDown('slow');
    });
    $("li#q3").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q3").removeClass("faq_link_on");
        $("h4.q3").addClass("faq_link_off");
        $("div.q3").slideDown('slow');
    });
    $("li#q4").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q4").removeClass("faq_link_on");
        $("h4.q4").addClass("faq_link_off");
        $("div.q4").slideDown('slow');
    });
    $("li#q5").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q5").removeClass("faq_link_on");
        $("h4.q5").addClass("faq_link_off");
        $("div.q5").slideDown('slow');
    });
    $("li#q6").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q6").removeClass("faq_link_on");
        $("h4.q6").addClass("faq_link_off");
        $("div.q6").slideDown('slow');
    });
    $("li#q7").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q7").removeClass("faq_link_on");
        $("h4.q7").addClass("faq_link_off");
        $("div.q7").slideDown('slow');
    });
    $("li#q8").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q8").removeClass("faq_link_on");
        $("h4.q8").addClass("faq_link_off");
        $("div.q8").slideDown('slow');
    });
    $("li#q9").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q9").removeClass("faq_link_on");
        $("h4.q9").addClass("faq_link_off");
        $("div.q9").slideDown('slow');
    });
    $("li#q10").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q10").removeClass("faq_link_on");
        $("h4.q10").addClass("faq_link_off");
        $("div.q10").slideDown('slow');
    });
    $("li#q11").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q11").removeClass("faq_link_on");
        $("h4.q11").addClass("faq_link_off");
        $("div.q11").slideDown('slow');
    });
    $("li#q12").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q12").removeClass("faq_link_on");
        $("h4.q12").addClass("faq_link_off");
        $("div.q12").slideDown('slow');
    });
    $("li#q13").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q13").removeClass("faq_link_on");
        $("h4.q13").addClass("faq_link_off");
        $("div.q13").slideDown('slow');
    });
    $("li#q14").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q14").removeClass("faq_link_on");
        $("h4.q14").addClass("faq_link_off");
        $("div.q14").slideDown('slow');
    });
    $("li#q15").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q15").removeClass("faq_link_on");
        $("h4.q15").addClass("faq_link_off");
        $("div.q15").slideDown('slow');
    });
    $("li#q16").click(function() {
        $("div.faq_copy").slideUp('slow');
        $("h4.faqsH4").removeClass("faq_link_off");
        $("h4.faqsH4").addClass("faq_link_on");
        $("h4.q16").removeClass("faq_link_on");
        $("h4.q16").addClass("faq_link_off");
        $("div.q16").slideDown('slow');
    });

    $('a.iframe').fancybox({
        'overlayShow': true,
        "centerOnScroll": false,
        'overlayOpacity': 0.5,
        'frameWidth': 600,
        'frameHeight': 560,
        'zoomSpeedIn': 600,
        'zoomSpeedOut': 500,
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'

    });

    $('a.imagePop').fancybox({
        'overlayShow': true,
        "centerOnScroll": false,
        'overlayOpacity': 0.5,
        'frameWidth': 600,
        'frameHeight': 550,
        'zoomSpeedIn': 600,
        'zoomSpeedOut': 500,
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'

    });

    // hides the div //
    $('div.tariffShow').hide();
    // toggles the slickbox on clicking the noted link
    $('p.more_link a').click(function() {
        $('p.more_link a').toggleClass("tariffLinkOn");
        $('div.tariffShow').slideToggle("600");
        return false;

        $('.myselectbox').selectbox();

    });

    // hides the div //
    $('div#TopUpCard').hide();
    // toggles the slickbox on clicking the noted link
    $('a#toggle').click(function() {
        $('div#TopUpCard').slideToggle("600");
        return false;
    });

    // hides the div //
    $('div#tellAFriend').hide();
    // toggles the slickbox on clicking the noted link
    $('a#toggle').click(function() {
        $('div#tellAFriend').slideToggle("600");
        return false;
    });

});


function changeclass1() {
var NAME = document.getElementById("itemDescHeader")
NAME.className="selected"
}

function clickButton(e)
{
    var intKey = (window.Event) ? e.which : e.keyCode;

    if (intKey == 13)
    {
        document.getElementById('searchBar_searchButton').click();
        return false;
    }

    return true;
}

function clickButton(e, button)
{
    var intKey = (window.Event) ? e.which : e.keyCode;

    if (intKey == 13)
    {
        document.getElementById(button).click();
        return false;
    }

    return true;
}

function changeImage(e, imageUrl)
{
    if (document.images)
    {
        document.getElementById(e).src = imageUrl;
    }
}

function changeHRef(e, url)
{
    document.getElementById(e).href = url;
}
