/* 
 * Dorian Knoblauch
 * Netbeans 7.0 on MacBook Pro
 */
                      

function initialize() {
    var latlng = new google.maps.LatLng(52.60728, 13.326391);
    var myOptions = {
        zoom: 15,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        disableDefaultUI: true
    };
    var map = new google.maps.Map(document.getElementById("minimap"), myOptions);
    var image = 'bilder/map_icon_v2.png';
    var myLatLng = new google.maps.LatLng(52.60728, 13.326391);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });
}

function now() {
    return (new Date).getTime();
}
jQuery.fx.prototype.custom = function( from, to, unit ) {
    this.startTime = now();
    this.start = from;
    this.end = to;
    this.unit = unit || this.unit || "px";
    this.now = this.start;
    this.pos = this.state = 0;

    var self = this;
    function t( gotoEnd ) {
        return self.step(gotoEnd);
    }

    t.elem = this.elem;

    if ( t() && jQuery.timers.push(t) && !jQuery.fx.prototype.timerId ) {
        //timerId = setInterval(jQuery.fx.tick, 13);
        jQuery.fx.prototype.timerId = setInterval(jQuery.fx.tick, 70);
    }
}
$(document).ready(function(){
    $("#status").load("twitter.php?status");
    $("#twitter").load("twitter.php?num=3");
    
    //moveTrain();
    $('#eisenbahn').click(function(){
        moveTrain();
        moveBaeume_1();
        //moveBaeume_2();
        moveBaeume_3();
        moveWolken();
        moveRail(); 
    });
});
            
function moveTrain() {
    // Setup
    var train =$('#eisenbahn');           
                
    //train.css('background-position', '0% 0px');
                
    train.animate({
        backgroundPosition: '30% 0px'
    }, 15000, 'linear', function() {
        //   moveTrain();
        });
}
            
function moveRail() {
    // Setup
    var rail =$('#schiene');           
                
    rail.css('background-position', '0px 0px');
                
    rail.animate({
        backgroundPosition: '-100% 0px'
    }, 25000, 'linear', function() {
        moveRail();
    });
}
            
function moveBaeume_1() {
    // Setup
    var baeume_1 =$('#baeume_1');           
                
    baeume_1.css('background-position', '2000px 0px');
                
    baeume_1.animate({
        backgroundPosition: '-1299px 0px'
    }, 80000, 'linear', function() {
        moveBaeume_1();
    });
}
            
//function moveBaeume_2() {
//    // Setup
//    var baeume_2 =$('#baeume_2');           
//                
//    baeume_2.css('background-position', '3000px 0px');
//                
//    baeume_2.animate({
//        backgroundPosition: '-1191px 0px'
//    }, 140000, 'linear', function() {
//        moveBaeume_1();
//    });
//}
function moveBaeume_3() {
    // Setup
    var baeume_3 =$('#baeume_3');           
                
    baeume_3.css('background-position', '0px 0px');
                
    baeume_3.animate({
        backgroundPosition: '-100% 0px'
    }, 140000, 'linear', function() {
        moveBaeume_3();
    });
}
function moveWolken() {
    // Setup
    var cloud =$('#wolken');           
                
    cloud.css('background-position', '2500px 0px');
                
    cloud.animate({
        backgroundPosition: '-1287px 0px'
    }, 110000, 'linear', function() {
        moveWolken();
    });
}



