// vim: set tabstop=4 shiftwidth=4 foldmethod=marker :
/**
 * @globals url_media, url_main
 */
//alert(document.compatMode);
// {{{ ensureElementFromObject(el,again)
/**
 * Fix bug where code gets smashed in exploder
 */
function ensureElementFromObject(el, again)
{
    if (!window.attachEvent) { return; } //if not IE6 return
    if((el.getAttribute('elementFromObject') != 'true') || (again == true)) { 
        for(property in Object) { el[property] = Object[property]; }
        el.setAttribute('elementFromObject','true');
    }
}
// }}}
// {{{ plaxoAnimiating
/**
 * animation lockout
 */
var plaxoAnimating = false;
// }}}
// {{{ plaxoFortune
var plaxoFortune = {
    // - fortunes {{{
    fortunes: {
        f0_0: {
            name:   'Persistence',
            caption:'Nothing in this world can take the place of persistence. --Calvin Coolidge',
            body:   'You never stop until the job is done. May you be persistent in all your endeavors this year.',
            width:  586,
            height: 307,
            id:     54518
        },

        f0_1: {
            name:   'Style',
            caption:'In matters of grave importance, style, not sincerity, is the vital thing. --Oscar Wilde',
            body:   'It seems like everything you do, you do with inimitable grace. Happy New Year!',
            width:  586,
            height: 307,
            id:     60111
        },
        f1_0: {
            name:   'Friendship',
            caption:'The language of friendship is not words but meanings. --Henry David Thoreau',
            body:   'Friendship of the kind we share can sustain one through all life\'s worries and cares. Happy New Year!',
            width:  586,
            height: 307,
            id:     54431
        },
        f1_1: {
            name:   'Laughter',
            caption:'He who laughs last probably didn\'t get the joke. --Helen Giangregorio',
            body:   'In the new year, may you find that it\'s not as important to have the last laugh as it is just to laugh often. Happy New Year!',
            width:  586,
            height: 307,
            id:    54434 
        },
        f1_2: {
            name:   'Curiosity',
            caption:'It is a miracle that curiosity that survives formal education. --Albert Einstein',
            body:   'Curiosity killed the cat, but for a while I was the prime suspect. Have a happy and curious New Year!',
            width:  586,
            height: 307,
            id:     54453 
        },
        f2_0: {
            name:   'Love',
            caption:'Gravitation cannot be held responsible for people falling in love. --Albert Einstein',
            body:   'May you experience love and other falling sensations in the new year!',
            width:  586,
            height: 307,
            id:     54427
        },
        f2_1: {
            name:   'Kindness',
            caption:'The language the deaf can hear and the blind can see. --Mark Twain',
            body:   'Wishing you a year filled with joy, happiness, and many random acts of kindness. Happy New Year!',
            width:  586,
            height: 307,
            id:     54455
        },
        f3_0: {
            name:   'Courage',
            caption:'The best way out is always through. --Robert Frost',
            body:   'No matter what life throws at you, you have the courage to keep on going. Have a great New Year!',
            width:  586,
            height: 307,
            id:     57799
        },
        f3_1: {
            name:   'Humility',
            caption:'To become truly great, one has to stand with people, not above them. --Charles de Montesquieu',
            body:   'Here\'s to a leader who stands shoulder to shoulder with those at their side. Happy New Year!',
            width:  586,
            height: 307,
            id:     54523
        },
        f3_2: {
            name:   'Leadership',
            caption:'Remember the difference between a boss and a leader; a boss says "Go!" - a leader says "Let\'s go!" --E.M. Kelly',
            body:   'You are always an inspiration. I\'d follow you anywhere.',
            width:  600,
            height: 321,
            id:     61039
        },
        f4_0: {
            name:   'Travel',
            caption:'The World is a book, and those who do not travel read only a page. --St. Augustine',
            body:   'May the road rise to meet you, May the wind always be at your back, May the sun shine warm upon your face.',
            width:  586,
            height: 307,
            id:     54450
        },
        f4_1: {
            name:   'Teamwork',
            caption:'T E A M = Together Everyone Achieves More',
            body:   'It is amazing how much you can accomplish when it doesn\'t matter who gets the credit. Here\'s to our team in the new year!',
            width:  586,
            height: 307,
            id:     54459
        },
        f5_0: {
            name:   'Giving',
            caption:'There is no happiness in having or in getting, but only in giving. --Henry Drummond',
            body:   'Giving is an art in which you have attained virtuosity. Happy New Year!',
            width:  586,
            height: 307,
            id:     54429
        },
        f5_1: {
            name:   'Patience',
            caption:'Patience is the companion of wisdom. --St. Augustine',
            body:   'Patience is a virtue which you possess in abundance. May the new year bring you good fortune!',
            width:  586,
            height: 307,
            id:     54433
        },
        f5_2: {
            name:   'Peace',
            caption:'Peace starts with a smile. --Mother Teresa',
            body:   'May your days be filled with peace. And smiles.',
            width:  586,
            height: 307,
            id:     54454
        },
        f6_0: {
            name:   'Creativity',
            caption:'I shut my eyes in order to see. --Paul Gauguin',
            body:   'You inspire those around you with your creative vision. May your new year be filled with limitless creative energy!',
            width:  586,
            height: 307,
            id:     54435
        },
        f6_1: {
            name:   'Health',
            caption:'The first wealth is health. --Ralph Waldo Emerson',
            body:   'This year I\'m going to change the spare tire. Health and happiness in the new year.',
            width:  586,
            height: 307,
            id:     54451 
        },
        f6_2: {
            name:   'Strength',
            caption:'Don\'t pray for lighter burdens, but for stronger backs.',
            body:   'Weakness is just not you. You go the extra mile every year. Happy 2007!',
            width:  586,
            height: 307,
            id:     60219
        },
        f7_0: {
            name:   'Success',
            caption:'The greatest barrier to success is the fear of failure. --Sven Goran Eriksson',
            body:   'For most people, success is fickle. For you, success is a deeply ingrained habit. Here\'s to another successful New Year!',
            width:  586,
            height: 307,
            id:    54428 
        },
        f7_1: {
            name:   'Growth',
            caption:'The universe is full of magical things patiently waiting for our wits to grow sharper. --Eden Phillpotts',
            body:   'May the new year be full of abundance and happiness.',
            width:  586,
            height: 307,
            id:     54448
        },
        f8_0: {
            name:   'Indulge',
            caption:'Anyone who lives within their means suffers from a lack of imagination. --Oscar Wilde',
            body:   'This year, go ahead and indulge a little -- you deserve it! Happy New Year!',
            width:  586,
            height: 307,
            id:     54516
        },
        f8_1: {
            name:   'Humor',
            caption:'A sense of humor is just common sense, dancing. --Clive James',
            body:   'Save some time for a good laugh this year! Happy New Year!',
            width:  586,
            height: 307,
            id:     55101
        },
        f8_2: {
            name:   'Toughness',
            caption:'A nation does not have to be cruel to be tough. --Franklin D. Roosevelt',
            body:   'Some people are tough as nails. You put the nails to shame. Happy New Year!',
            width:  600,
            height: 321,
            id:     60198
        },
        f9_0: {
            name:   'Friendship',
            caption:'Two friends, two bodies with one soul inspir\'d --Alexander Pope',
            body:   'You never have to remind others of your friendship with words -- you show them with your actions. Wishing you a happy New Year!',
            width:  586,
            height: 307,
            id:     54519
        },
        f9_1: {
            name:   'Honesty',
            caption:'A lie may take care of the present, but it has no future.',
            body:   'Honestly speaking, you are a person of great kindness and impeccable integrity. Wishing you a great new year!',
            width:  600,
            height: 321,
            id:     61036
        }
    },
    // }}}
    // - flipZ {{{
    /**
     * starting z-index
     */
    flipZ: 7,
    // }}}
    // - maps {{{
    /**
     * Number of fortunes for a given card #
     */
    maps: [2,3,2,3,2,3,3,2,3,2],
    // }}}
    // - backWidths {{{
    /**
     * back side image widths
     */
    backWidths:  [135,161,139,135,152,143,146,135,135,141],
    // }}}
    // - backHeights {{{
    /**
     * back side image heights
     */
    backHeights: [185,192,195,188,197,196,193,193,186,195],
    // }}}
    // - hand {{{
    hand: [],
    // }}}
    // {{{ - shuffleDeck()
    shuffleDeck: function()
    {
        this.hand = [];
        // generate unique backsides {{{
        for (var i=0; i<6; ++i) {
            do {
                var unique_card = true;
                var card_num = Math.floor(Math.random()*5)*2; //only select evens
                if (i % 2 == 0) { ++card_num; } //only select odds
                for (var j=0; j<i; ++j) {
                    if (this.hand[j] == card_num) { unique_card = false;  break; }
                }
            } while (!unique_card);
            this.hand[i] = card_num;
        }
        // }}}
        // select fortune in backside {{{
        for (i=0; i<6; ++i) {
            this.hand[i] = this.hand[i] + '_' + Math.floor(Math.random()*this.maps[this.hand[i]]);
        }
        // }}}
    },
    // }}}
    // {{{ - dealHand()
    dealHand: function()
    {
        plaxoAnimating = true;
        for (var i=0; i<6; ++i) {
            // set card properties 
            var flip_value = this.hand[i];
            var back_value = flip_value.substring(0,1);
            var image_obj = document.getElementById('card_pos_'+i);
            image_obj.style.display = 'none';
            image_obj.src = url_media + 'im/ny/back/'+back_value+'.png';
            image_obj.dimW = this.backWidths[back_value];
            image_obj.dimH = this.backHeights[back_value];
            image_obj.style.width = image_obj.dimW + 'px';
            image_obj.style.height = image_obj.dimH + 'px';
            image_obj.flipped = false; //zero out flip state
            image_obj.number = back_value;
            image_obj.pos = i;
            image_obj.fortune = this.fortunes['f'+flip_value];
            image_obj.fortune.imgIdx = flip_value;
            image_obj.outImage = new Image();
            image_obj.outImage.src = url_media+'im/ny/back/'+back_value+'.png';
            image_obj.overImage = new Image();
            image_obj.overImage.src = url_media+'im/ny/back_hov/'+back_value+'.png';
            image_obj.flipImage = new Image();
            image_obj.flipImage.src = url_media+'im/ny/flip/'+flip_value+'.png';
            image_obj.flipOverImage = new Image();
            image_obj.flipOverImage.src = url_media+'im/ny/flip_hov/'+flip_value+'.png';
            image_obj.setAttribute('alt', 'card back #'+image_obj.number);
            image_obj.setAttribute('title', 'Click to reveal fortune for this card.');
            image_obj.style.display = 'block';
            image_obj.setAttribute('class', 'card'); //massive strangness in exploder
        }
        //alert(image_obj.parentNode.innerHTML);
        pngfix();
        // TODO: preload images?
        this.animateDeal();
    },
    // }}}
    // {{{ - animateDeal()
    animateDeal: function()
    {
        document.getElementById('card_action').style.zIndex = 0; //send action to back
        // display hand
        var anim_objs = [];
        for (var i=0; i<6; ++i) {
            anim_elem = document.getElementById('card_pos_'+i);
            anim_elem.style.zIndex = 6-i;
            anim_elem.style.opacity = 0;
            anim_elem.style.visibility = 'visible';
            //if (!window.XMLHttpRequest) { //Exploder having trouble with opacity
            //Exploder having trouble with opacity and opacity animations
            if (navigator.appName == "Microsoft Internet Explorer") {
            //if (false) {

                anim_objs[i] = new YAHOO.util.Anim(anim_elem, { top:{from:-500,to:0}},1.5);
            } else {
                anim_objs[i] = new YAHOO.util.Anim(anim_elem, { top:{from:-500,to:0}, opacity:{from:0,to:1,by:.004} },1.5);
            }
        }
        this.flipZ = 7; //reset flip zindex counter
        anim_objs[5].onComplete.subscribe(function() {
            card_action_to_front();
            plaxoAnimating = false;
        }); //bring action to front after animate
        for (i=0; i<6; ++i) {
            anim_objs[i].animate();
        }
        /* */
    },
    // }}}
    // {{{ - clearHand()
    clearHand: function()
    {
        plaxoAnimating = true;
        // hide hand
        var returns = [];
        for (var i=0; i<6; ++i) {
            //document.getElementById('card_pos_'+i).style.visibility = 'hidden';
            var anim_elem = document.getElementById('card_pos_'+i);
            //if (!window.XMLHttpRequest) { //Exploder having trouble with opacity
            //Exploder having trouble with opacity and opacity animations
            if (navigator.appName == "Microsoft Internet Explorer") {
                returns[i] = new YAHOO.util.Anim(anim_elem, { top:{from:0,to:250} });
            } else {
                returns[i] = new YAHOO.util.Anim(anim_elem, { top:{from:0,to:250}, opacity:{from:1,to:0,by:.004} });
            }
        }
        return returns;
    }
    // }}}
};
// }}}
// {{{ - init_fortunes()
init_fortunes = function()
{
    // bind actions to cards {{{
    for (var i=0; i<6; ++i) {
        var el = document.getElementById('card_pos_'+i);
        ensureElementFromObject(el);
        inherits(el,plaxoCard);
    }
    // }}}
    plaxoFortune.shuffleDeck();
    plaxoFortune.dealHand();
}
// }}}
YAHOO.util.Event.addListener(window, 'load', init_fortunes);
// {{{ plaxoCard
function plaxoCard()
{
}
// {{{ - fadeShow()
plaxoCard.prototype.fadeShow = function(fadeObj,showObj)
{
    var fade_opacity = fadeObj.style.opacity;
    showObj.style.opacity = 0;
    showObj.style.display = 'block';
    //fadeObj.style.opacity = 1.0;
    if (fade_opacity != 0) { // don't bother animating if it isn't faded
        var first_anim = new YAHOO.util.Anim(fadeObj, { opacity:{from:1.0,to:0} }, .5);
        first_anim.animate();
    }
    var second_anim = new YAHOO.util.Anim(showObj, { opacity:{from:0,to:1.0} }, .5);
    second_anim.onComplete.subscribe(function() { //finish flip
        fadeObj.style.display = 'none';
        plaxoAnimating = false; // done animating
    });
    second_anim.animate();
}
// }}}
// {{{ - showFortune()
plaxoCard.prototype.showFortune = function()
{
    var fortune_obj = document.getElementById('main_display_fortune');
    var fortune_img = document.getElementById('fortune_img');
    var fortune_link = document.getElementById('fortune_link');
    var tmp_img = new Image();

    tmp_img.src = url_media+'im/ny/fortunes/' + this.fortune.imgIdx + '.gif';
    fortune_img.style.width = this.fortune.width + 'px';
    fortune_img.style.height = this.fortune.height + 'px';
    fortune_img.src = tmp_img.src;
    fortune_img.setAttribute('alt',this.fortune.name.toUpperCase() +':'+ this.fortune.caption +'. '+this.fortune.body);
    fortune_link.href = 'customize.php?filters=88&imgId='+this.fortune.id+'&card_url='+encodeURIComponent(url_main+'click?key=ecard_newyearslanding&src=ecard_newyearsfortunecard')+'&card_title_text='+encodeURIComponent('Send a good fortune to a friend');
    fortune_link.setAttribute('title','Send a '+ this.fortune.name +' fortune eCard to a friend.');

    this.fadeShow(document.getElementById('main_display_find'),fortune_obj);
}
// }}}
// {{{ - hideFortune()
plaxoCard.prototype.hideFortune = function()
{
    this.fadeShow(document.getElementById('main_display_fortune'),document.getElementById('main_display_find'));
}
// }}}
// {{{ - onmouseover()
plaxoCard.prototype.onmouseover = function()
{
    if (plaxoAnimating) { return; } // lock out when animating
    if (this.flipped) {
        this.src = this.flipOverImage.src;
    } else {
        this.src = this.overImage.src;
    }
    pngfix();
}
// }}}
// {{{ - onmouseout()
plaxoCard.prototype.onmouseout = function()
{
    if (plaxoAnimating) { return; } // lock out when animating
    if (this.flipped) {
        this.src = this.flipImage.src;
    } else {
        this.src = this.outImage.src;
    }
    pngfix();
}
// }}}
// {{{ - onclick()
plaxoCard.prototype.onclick = function()
{
    if (plaxoAnimating) { return; } // lock out when animating
    plaxoAnimating = true;
    this.style.zIndex = plaxoFortune.flipZ++; // bring to front...
    if (this.flipped) {
        // stay flipped
        this.showFortune(); //this will remove lock-out
    } else {
        // flip to reveal {{{
        this.flipped = true;
        var img_obj = this;
        var dimW = img_obj.dimW;
        var xpos = 10 + (img_obj.pos * 124);
        //var xpos = img_obj.style.left;
        var first_anim = new YAHOO.util.Anim(this, { width:{from:dimW,to:0}, left:{from:xpos,to:xpos+dimW/2} }, .1);
        first_anim.onComplete.subscribe(function() { //finish flip
            img_obj.src = img_obj.flipImage.src;  
            img_obj.setAttribute('alt', 'card flipped: '+img_obj.fortune.name);
            img_obj.setAttribute('title', 'Click to show eCard for '+img_obj.fortune.name+' fortune.');
            var second_anim = new YAHOO.util.Anim(img_obj, { width:{from:0,to:dimW}, left:{from:xpos+dimW/2,to:xpos} }, .1);
            second_anim.onComplete.subscribe(function() {
                img_obj.showFortune(); //this will remove lock-out
                });
            pngfix();
            second_anim.animate();
            });
        first_anim.animate();
        // }}}
    }
    document.getElementById('card_action').hasPicked(); //activate new deal action
    return false;
}
// }}}
// }}}
// {{{ plaxoCardAction
function plaxoCardAction()
{
}
// {{{ - newHand()
plaxoCardAction.prototype.newHand = function()
{
        this.picked = false;
        this.setAttribute('alt', 'Pick a card. Any Card.');
        this.setAttribute('title', 'Pick a card. Any Card.');
        var anim_objs = plaxoFortune.clearHand();
        anim_objs[5].onComplete.subscribe(init_fortunes);
        for (var i=0; i<6; ++i) {
            anim_objs[i].animate();
        }
}
// }}}
// {{{ - hasPicked()
plaxoCardAction.prototype.hasPicked = function()
{
        if (this.picked) { return; } //don't bother if already showing "new hand..."
        this.picked = true;
        this.src = this.hand.src;
        pngfix();
}
// }}}
// {{{ - onmouseover()
plaxoCardAction.prototype.onmouseover = function()
{
    if (plaxoAnimating) { return; } //lockout when animating
    if (this.picked) {
        this.src = this.handOver.src;
    } else {
        this.src = this.pickOver.src;
    }
    pngfix();
}
// }}}
// {{{ - onmouseout()
plaxoCardAction.prototype.onmouseout = function()
{
    if (plaxoAnimating) { return; } //lockout when animating
    if (this.picked) {
        this.src = this.hand.src;
    } else {
        this.src = this.pick.src;
    }
    pngfix();
}
// }}}
// {{{ - onclick()
plaxoCardAction.prototype.onclick = function()
{
    if (plaxoAnimating) { return; } //lockout when animating
    if (this.picked) {
        this.newHand();
        this.picked = false;
        this.src = this.pick.src;
        pngfix();
    //} else { // Bug #14691
        //alert('Pick a card below to find a fortune');
    }
}
// }}}
// }}}
// {{{ init_card_action()
init_card_action = function()
{
    var action_obj = document.getElementById('card_action');
    ensureElementFromObject(action_obj);
    action_obj.picked = false;
    action_obj.pick = new Image();
    action_obj.pick.src = url_media+'im/ny/actions/pick.png';
    action_obj.pickOver = new Image();
    action_obj.pickOver.src = url_media+'im/ny/actions/pick_hov.png';
    action_obj.hand = new Image();
    action_obj.hand.src = url_media+'im/ny/actions/new_hand.png';
    action_obj.handOver = new Image();
    action_obj.handOver.src = url_media+'im/ny/actions/new_hand_hov.png';
    inherits(action_obj,plaxoCardAction);
}
// }}}
// {{{ card_action_to_front()
card_action_to_front = function()
{
    document.getElementById('card_action').style.zIndex = 10000;
}
// }}}
YAHOO.util.Event.addListener(window, 'load', init_card_action);
// {{{ loadInitialItems*(type,args)
/**
 * Custom inital load handler. Called when the carousel loads the initial
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadInitHandler
 *
 * Fetch twice the number for caching. images are create once.
 */
var loadInitialItemsNy = function(type, args) {
    var start = args[0]; var last = args[1]; 
    makeRequest(this, 'ajax/get_thumbnails.php', 88, start, (last-start+1) * 2);
};
// }}}
// {{{ loadNextTimes*(type,args)
/**
 * Custom load next handler. Called when the carousel loads the next
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadNextHandler
 */
var loadNextItemsNy = function(type, args) {  
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 88, start, (last-start+1) * 2); }
};
// }}}
// {{{ loadPrevItems*(type,args)
/**
 * Custom load previous handler. Called when the carousel loads the previous
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadPrevHandler
 */
var loadPrevItemsXmas = function(type, args) {
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 15, start, (last-start+1) * 2); }
}
var loadPrevItemsChan = function(type, args) {
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 26, start, (last-start+1) * 2); }
}
var loadPrevItemsSg = function(type, args) {
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 57, start, (last-start+1) * 2); }
}
var loadPrevItemsKwan = function(type, args) {
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 38, start, (last-start+1) * 2); }
}
var loadPrevItemsNy = function(type, args) {
    var start = args[0]; var last = args[1]; var alreadyCached = args[2];
    if(!alreadyCached) { makeRequest(this, 'ajax/get_thumbnails.php', 88, start, (last-start+1) * 2); }
}
// }}}
// {{{ handlePrevButtonState(type,args)
/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 */
var handlePrevButtonState = function(type, args) {

    var enabling = args[0];
    var leftImage = args[1];
    if(enabling) {
        leftImage.src = url_media+'im/ny/arrow/left.gif';  
    } else {
        leftImage.src = url_media+"im/com/sp.gif"; 
    }
};
// }}}
// {{{ showButtons(idExt)
var showButtons = function(idExt) {
    YAHOO.util.Dom.setStyle("next-arrow-"+idExt, "visibility", "visible");
    YAHOO.util.Dom.setStyle("prev-arrow-"+idExt, "visibility", "visible");
};
// }}}
// {{{ pageLoad()
/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'dhtml-carousel-*'.) See the
 * HTML code below.
 */
var pageLoad = function() 
{
    var carousel = new YAHOO.extension.Carousel("dhtml-carousel-ny", 
        {
            numVisible:        4,
            animationSpeed:    .4,
            scrollInc:         3,
            loadInitHandler:   loadInitialItemsNy,
            prevElementID:     "prev-arrow-ny",
            nextElementID:     "next-arrow-ny",
            loadNextHandler:   loadNextItemsNy,
            loadPrevHandler:   loadPrevItemsNy,
            prevButtonStateHandler:   handlePrevButtonState,
            autoPlay:           15000
        }
    );
    carousel.holiday='ny';
};
// }}}
YAHOO.util.Event.addListener(window, 'load', pageLoad);
// {{{ handleSuccess(callbackResponse)
/**
 * Called via the YUI Connection manager (see makeRequest).
 */
var handleSuccess = function(callbackResponse)
{
    var start = callbackResponse.argument[0];
    var numResults = callbackResponse.argument[1];
    var carousel = callbackResponse.argument[2];
    if(callbackResponse.responseText !== undefined) {
        var theTrip = eval( '(' + callbackResponse.responseText + ')' );
        for(var i=0; i< theTrip.length; i++) {
            carousel.addItem(start+i, fmtTripInnerHTML(theTrip[i]));
        }
        showButtons(carousel.holiday);
     }
};
// }}}
// {{{ fmtTripInnerHtml(result)
/**
 * Since carousel.addItem uses an HTML string to create the interface
 * for each carousel item, this method takes an individual trip plan
 * result and cobbles together HTML for the innerHTML argument.
 */
var fmtTripInnerHTML = function(result) {
    var tripInnerHTML = '<a href="customize.php?imgId=' + result.id + '&filters=15"><img src="' + result.location + '" alt="' + result.alt + '"/></a>';
    return tripInnerHTML;
    
};
// }}}
// {{{ handleFailure(o)
var handleFailure = function(o)
{
     var result = o.status + " " + o.statusText;
     alert("Transaction failed.  The error is: " + result);
};
// }}}
// {{{ makeRequest(carousel, url, query, start, numResults) 
/**
 * A utility function for invoking the YUI connection manager (Ajax)
 * with a URL that matches the Yahoo! developer network Trip Planner
 * APIs (see: http://developer.yahoo.com/travel/tripservice/V1/tripSearch.html)
 *
 * The callback object is the configuration object for the YUI Connection
 * manager. If this is successful, the 'handleSuccess' function is called.
 */
var makeRequest = function(carousel, url, query, start, numResults)
{
    var params = '?return=json&qual=png&showFree=1&filters=' + query + '&startId=' + start + '&limit=' + numResults;
    var callback =
    {
        success: handleSuccess,
        failure: handleFailure,
        argument: [start, numResults, carousel]
    };
    
    var sUrl = url + params; 
    YAHOO.util.Connect.asyncRequest("GET", sUrl, callback, null);
};
// }}}
