// Lime Functions

$(document).ready(function(){
    $('#example1').bxSlider({
        mode: 'fade',
        auto: 'true',
        speed: 1500,
        pause: 8000,
        wrapper_class: 'example1_container'
    });
});

$(document).ready(function(){
    $(".row, .row2, rowSmall, .row3, .row4").hover(function() {
        $(this).stop().animate({
            backgroundColor: "#F2F9CA"
        }, 800);
    },function() {
        $(this).stop().animate({
            backgroundColor: "#FDFFEE"
        }, 800);
    });
}); 

function transitionDiv(fromdiv, todiv, opt_callback) {
    $('#' + fromdiv).fadeOut('fast', function() {
        $('#' + todiv).fadeIn('fast', function() {
            if (opt_callback) {
                opt_callback();
            }
        });
    });
}

function changeColor(fromdiv, todiv) {
    $('#' + fromdiv).css("background-color","#D6E984");
    $('#' + todiv).css("background-color","#666665");
}

function first() {
    transitionDiv('secondEntry', 'firstEntry', function() {	});
    changeColor('activity', 'speciality');
}

function second() {
    transitionDiv('firstEntry', 'secondEntry', function() {	});
    changeColor('speciality', 'activity');
}

$(function() {
    $("#slider").slider({
        value:500,
        min: 500,
        max: 5000,
        step: 500,
        slide: function(event, ui) {
            $("#budgetL").val( ui.value);
        }
    });
    $("#budgetL").val( $("#slider").slider("value"));
});

$(function() {
    $("#slider2").slider({
        value:0,
        min: 1,
        max: 31,
        step: 1,
        slide: function(event, ui) {
            $("#amount2").val('*' + ui.value);
        }
    });
    $("#amount2").val('*' + $("#slider2").slider("value"));
});

$(function() {
    $("#datepicker").datepicker();
});

$(function() {
    //run the currently selected effect
    function runEffect(){
        //get effect type from
        var selectedEffect = "drop";
			
        //most effect types need no options passed by default
        var options = {};
        //check if it's scale, transfer, or size - they need options explicitly set
        if(selectedEffect == 'scale'){
            options = {
                percent: 0
            };
        }
        else if(selectedEffect == 'size'){
            options = {
                to: {
                    width: 450,
                    height: 50
                }
            };
        }
			
        //run the effect
        $(".callMe").toggle(selectedEffect,options,500);

    };
		
    //set effect from select menu value
    $(".button").click(function() {
        runEffect();
        return true;
    });
	
});

$(function() {
    $("button, input:submit, a", ".demo").button();
		
    $("a", ".demo").click(function() {
        return false;
    });
});

function loadCities(id, s) {
    $.ajax({
        url : "loadCities.jsp?s="+s+"&cid="+id,
        type: 'post',
        success:function(r){
            document.getElementById("dest").innerHTML = r;
            if(s == 1){
                doSearch();
            }
        }
    });
}
function loadActivity(id, s) {
    $.ajax({
        url : "loadActivities.jsp?s="+s+"&aid="+id,
        type: 'post',
        success:function(r){
            document.getElementById("act").innerHTML = r;
            if(s == 1){
                doSearch();
            }
        }
    });
}

function doSearch() {
    var a = "loadSearch.jsp?country="+document.searchForm.country.value;
    a += "&destination="+document.searchForm.destination.value;
    a += "&type="+document.searchForm.type.value;
    a += "&activity="+document.searchForm.activity.value;
    a += "&budget="+document.searchForm.budget.value;
    a += "&all=1";
    $.ajax({
        url : a,
        type: 'post',
        success:function(r){
            document.getElementById("searchFound").innerHTML = r;
        }
    });
}
