/**********************************************************************************
SLIDER: Used on
#destinations
_______________________________________________________________________________
Created by : BD / EF-Bangalore-INDIA  / 2009, Dec 14  @ Zurich,SWITZERLAND
Modified by: 
---------------------------------------------------------------------------------

*********************************************************************************/

var selected = '';
$j.fn.slideView = function(settings) {
    settings = $j.extend({
        easeFunc: 'easeInOutExpo',
        easeTime: 750
    }, settings);
    return this.each(function() {
        var container = $j(this);
        var widthItem = 700 + 20;
        var heightItem = 250;
        var countItem = container.find('li').size();
        var sliderWidth = widthItem * countItem;
        container.find('ul').css('width', sliderWidth);
        container.css('width', widthItem);
        container.css('height', heightItem);
        container.each(function(i) {
            $j('div#map a').each(function(e) {
                $j(this).bind('mouseover', function() {
                    $j('#' + selected).removeClass('selected');
                    $j('div#map img').attr('src', '/corporate/images/spot.gif');
                    var id = $j(this).parent().attr('id');
                    selected = id;
                    $j(this).parent().addClass('selected');
                    $j(this).parent().children('img').attr('src', '/corporate/images/spot-selected.gif');
                    var selectedItem = -(widthItem * e);
                    container.find('ul').animate({ left: selectedItem }, settings.easeTime, settings.easeFunc);
                    return false;
                });
            });
            $j('div#map img').each(function(e) {
                $j(this).bind('mouseover', function() {
                    $j('#' + selected).removeClass('selected');
                    $j('#' + selected).children('img').attr('src', '/corporate/images/spot.gif');
                    var id = $j(this).parent().attr('id');
                    selected = id;
                    $j(this).parent().addClass('selected');
                    $j(this).attr('src', '/corporate/images/spot-selected.gif');
                    var selectedItem = -(widthItem * e);
                    container.find('ul').animate({ left: selectedItem }, settings.easeTime, settings.easeFunc);
                    return false;
                });
                $j(this).bind('click', function() {
                    document.location.href = '/corporate/language-solutions/study-abroad/destinations/' + $j(this).parent().children('a').attr('href').toString();
                });
            });
            $j('#map ul li:first p').addClass('selected');
            var selected = $j('#map ul:first li:first p').attr('id').toString();
            //selected = $j($j('#map li:first p')).get(0);
        });
    });
};


$j(window).bind("load", function() {
    $j("#destination-puffs puffs spot:first").css('border-color', 'red');
    $j("#destination-puffs").slideView();
    if ($j.browser.msie && $j.browser.version == "6.0") {
        $j('div#map .button').each(function(e) {
            //alert(parseInt($j(this).css('top')) - 25);
            //$j(this).css('top', (parseInt($j(this).css('top')) - 25).toString() + 'px');
            //$j(this).css('left', (parseInt($j(this).css('left')) + 15).toString() + 'px');
        });
        $j('div#map img').each(function(e) {
            //alert(parseInt($j(this).css('top')) - 25);
            //$j(this).css('top', (parseInt($j(this).css('top')) + 25).toString() + 'px');
            //$j(this).css('left', (parseInt($j(this).css('left')) - 15).toString() + 'px');
            $j(this).attr('src', '/corporate/images/spot.gif');
        });
    }
});