//Preload Images
var bannerImages=new Array();

preloadimages(
    IMG_URL+"banner1.png",
    IMG_URL+"banner2.png",
    IMG_URL+"banner3.png",
    IMG_URL+"banner4.png",
    IMG_URL+"banner5.png",
    IMG_URL+"banner6.png",
    IMG_URL+"bannertitle1.png",
    IMG_URL+"bannertitle2.png",
    IMG_URL+"bannertitle3.png",
    IMG_URL+"bannertitle4.png",
    IMG_URL+"bannertitle5.png",
    IMG_URL+"bannertitle6.png"
);

// Array of texts and indexes
var bannerTxt = { 
    "1" : {
     "index": "1", 
     "title": 'Travel Southeast Asia',
     "text" : "Fobotravel personally handpicks travel activities and packages from all around Southeast Asia. We pre-screen operators with responsible and sustainable operating practices and grade them according to the Fobo Rating Meter. Making a more informed decision can mean the difference between a fulfilling experience and a disappointing one."
    },
    "2": {
      "index": "2",
      "title": 'Fobotravel makes it fun + responsible + easy',
      "text" : "Travelling in a more eco-friendly and sustainable manner doesn't have to be difficult, boring or expensive. Look through our extensive list of handpicked activities and packages from Southeast Asia. We help you make a more knowledgeable decision when you travel."
    },
    "3" : {
      "index": "3",
      "title": 'Make a difference. Inspire Change.',
      "text" : "As more of us travel, tourism becomes a more powerful tool for tackling poverty. It provides jobs, support local businesses, and money for schools, hospitals and roads. Too often, the benefits of tourism bypass the poor, local communities in the developing world, with little profit staying in the country. Venture off the well-worn tourist trails to meet and trade with locals."
    },
    "4" : {
      "index": "4",
      "title": 'T.R.A.V.E.L Experience.',
      "text": "T - Teach, R - Recreation, A - Adventure, V - Volunteer, E - Eco - Conservation, L - Leisure and Culture. The travel operators we work with have, not only been in the industry for a long period of time, garnered much positive customer reviews and won a handful of awards along the way, they have also proven to do their bit for the local community and the environment they operate in."
    },
    "5" : {
      "index": "5",
      "title": 'Fobo Rating Meter',
      "text" : "At Fobotravel we strive to provide you with quality products from reputed Operators with excellent proven track records. We provide you with relevant and important information that will aid you in being a more responsible traveller and allow you opportunities to contribute back to the community you are visiting. "
    },
    "6" : {
      "index": "6",
      "title": 'Give back to the community',
      "text" : "Earth is our homeland. Give it the care and respect it deserves; learn about its environment and geography; spend time getting to know its people and their art, culture, history, and livelihoods. While you derive pleasure, knowledge, and understanding from your encounters, hold close the importance of preserving these treasures for those who may follow in your footsteps."
    }

};

var travel = ".menu .list a";
var travelIdx = 0;
var rotateInterval = "";

$(document).ready(function(){
    $(travel).click(
        function() {            
            var cat = $('.menu .list').index($(this).parent()) + 1;
            $(travel).parent().removeClass("selected");
            $(this).parent().addClass("selected");
            $("#bannerImgWrapper").hide();
            $("#bannerImgHolder").attr("src", IMG_URL + "banner"+bannerTxt[cat]["index"]+".png");            
            $("#bannerImgTitleHolder").attr("src", IMG_URL + "bannertitle"+bannerTxt[cat]["index"]+".png");            
            $("#bannerImgWrapper").fadeIn("slow");
            //$('#bannerTitle h2').text(bannerTxt[cat]["title"]);
            $('#bannerTitle p.bannerTxt').text(bannerTxt[cat]["text"]);
            travelIdx = cat-1;
            rotateInterval = clearInterval(rotateInterval);
            rotateInterval = setInterval(rotate, 15000);	
            return false;
        }
    );

    rotateInterval = setInterval(rotate, 15000);	
});


function rotate() {
    $(travel + " :eq("+(travelIdx+1)+")").trigger("click");
    //rotateInterval = setInterval(rotate, 5000);
    if(travelIdx == 5) travelIdx = -1;
}

function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
        bannerImages[i]=new Image();
        bannerImages[i].src=preloadimages.arguments[i];
    }
}

