﻿

function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title"><p>' + (title && title.length ? '<span>' + title + '</span>' : '') + '</p></div>';
}

jQuery.extend(jQuery.ui.accordion.animations, {
    fastslide: function (options) {
        jQuery.ui.accordion.animations.slide(options, { duration: 680 });
    }
});







jQuery(document).ready(function () {

    jQuery('#ptkSubscribe #txtEmailAddress').watermark('Your Email Address');


    function HighlightFormField() {
        jQuery(this).addClass('highlightFormField');
    }

    function UnhighlightFormField() {
        jQuery(this).removeClass('highlightFormField');
    }


    jQuery('#simple-product-main-image').cycle({
        timeout: 0,
        pager: '#product-pager',
        speed: 0,
        pagerAnchorBuilder: function (idx, slide) {
            return '#product-pager li:eq(' + idx + ') a';
        },
        // override Cycle's default updateActivePagerLink function 
        updateActivePagerLink: function (pager, activeIndex) {
            jQuery(pager).find('li:eq(' + activeIndex + ')').addClass('activeLI').siblings().removeClass('activeLI');
        }
    });


    jQuery("#content input[type=text]").live('focus', HighlightFormField);
    jQuery("#content input[type=password]").live('focus', HighlightFormField);
    jQuery("#content select").live('focus', HighlightFormField);
    jQuery("#content textarea").live('focus', HighlightFormField);

    jQuery("#content input[type=text]").live('blur', UnhighlightFormField);
    jQuery("#content input[type=password]").live('blur', UnhighlightFormField);
    jQuery("#content select").live('blur', UnhighlightFormField);
    jQuery("#content textarea").live('blur', UnhighlightFormField);



    if (location.pathname == "/" || location.pathname == "/t-online-chocolate-shop.aspx") {

        jQuery("#menu-accordion h5:first-child").addClass("selected");

    }



    selected = '.selected';


    jQuery(".menu ul li a").each(function () {
        var td = jQuery(this).attr("href");
  
        if (td == location.pathname) {

            jQuery(this).parent().addClass("selected");


        }
    });

    jQuery(".menu ul li a").each(function () {
        var td = jQuery(this).attr("href");

        if (td == jQuery("a.SectionTitleText").attr("href")) {

            jQuery(this).parent().addClass("selected");
            selected = 0

        }
    });

    jQuery("#menu-accordion ul.bytype li a").each(function () {
        var td = jQuery(this).attr("href");

        if (td == jQuery("a.SectionTitleText").attr("href")) {

            jQuery(this).parent().addClass("selected");
            selected = 1

        }
    });

    jQuery("#menu-accordion ul.bybrand li a").each(function () {
        var td = jQuery(this).attr("href");

        if (td == jQuery("a.SectionTitleText").attr("href")) {
            jQuery(this).parent().addClass("selected");
            selected = 2

        }
    });

    jQuery("#menu-accordion ul.byoccasion li a").each(function () {
        var td = jQuery(this).attr("href");

        if (td == jQuery("a.SectionTitleText").attr("href")) {

            jQuery(this).parent().addClass("selected");
            selected = 3

        }
    });


    jQuery("#menu-accordion").show();

    jQuery("#menu-accordion").accordion({
        autoHeight: false,
        active: selected,
        navigation: true,
        collapsible: true,
        animated: 'fastslide',
        header: 'h5'

    });







    if (jQuery("a.SectionTitleText").attr("href"))

        var path = location.pathname;
    var home = "/";
    jQuery("a[href='" + [path || home] + "']").parents("li").each(function () {
        jQuery(this).addClass("selected");
    });



    jQuery('#slides div').cycle({
        speed: 4000,
        speedIn: 650,
        speedOut: 650,
        easeIn: 'jswing',
        easeOut: 'jswing',
        timeout: 10000,
        fx: 'scrollLeft' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });




    jQuery('#clickme').click(function (e) {
        e.preventDefault();
        jQuery('#note').slideToggle('slow', function () {
            // Animation complete.
        });
    });


    // jQuery('.shopping_cart table td:nth-child(3)').addClass('align-right');
    //  jQuery('.cart_items table td:nth-child(3) table td:nth-child(1)').addClass('align-right');

    //  jQuery('.shopping_cart table td:nth-child(2)').addClass('align-center');
    // jQuery('.cart_items table td:nth-child(2)').addClass('align-center');

    jQuery('.billing-info table td:nth-child(1)').addClass('col1');
    jQuery('.billing-info table td:nth-child(2)').addClass('col2');
    jQuery('.account-info table td:nth-child(1)').addClass('col1');
    jQuery('.account-info table td:nth-child(2)').addClass('col2');

    jQuery("#add").click(function () {
        var newQty = +(jQuery("input[maxlength=4]").val()) + 1;
        jQuery("input[maxlength=4]").val(newQty);
    });

    jQuery("#minus").click(function () {
        var newQty = +(jQuery("input[maxlength=4]").val()) - 1;
        if (newQty < 0) newQty = 0;
        jQuery("input[maxlength=4]").val(newQty);
    });


    // Cufon.replace('h1')('h2');
    //  Cufon.replace('#footer h5');
    // Cufon.replace('#welcome h5');
    // Cufon.replace('#join h5');




    jQuery(".fancybox").fancybox({
        'transitionIn': 'elastic',
        'speedIn': 400,
        'titleShow': true,
        'padding': 1,
        'titlePosition': 'over',
        'titleFormat': formatTitle



    });






});



