MooTools.lang.setLanguage("de-DE");

window.addEvent('domready', function() {
    // bild-slider startseite
    if ($('slideshow')) {
        new NivooSlider($('slideshow'), {
            animSpeed: 750,
            effect: 'sliceDownRight',
            interval: 5000,
            orientation: 'vertical',
            slices: 15
        });
    }

	//floating tips startseite
	new FloatingTips('ul#services a', { offset: { y: 50 } }); // Top position is default

	// uhr    	
    if ($('clock')) {
    	updateClock.periodical(1000);
    }
    
    //webcam refresh
    if ($('monitor')) {
    	updateWebcam.periodical(5000);
    }
    
    // portfolio accordion
    if ($('accordion')) {
    	new Fx.Accordion($('accordion'), '#accordion h2', '#accordion .accordionContent', {
    		display: -1,
    		alwaysHide: true
    	});
    }
    
    	
    // google map
    if ($('map_sl')) {
        if (GBrowserIsCompatible()) {
            var map_sl = new GMap2(document.getElementById("map_sl"));
            map_sl.addControl(new GSmallMapControl());
            map_sl.setCenter(new GLatLng(49.16883, 7.0314), 15);
            var marker = new GMarker(new GLatLng(49.16883, 7.0314));
            map_sl.addOverlay(marker);
        }
    }

    if ($('map_lu')) {
        if (GBrowserIsCompatible()) {
            var map_lu = new GMap2(document.getElementById("map_lu"));
            map_lu.addControl(new GSmallMapControl());
            map_lu.setCenter(new GLatLng(49.668517, 6.113892), 15);
            var marker = new GMarker(new GLatLng(49.668517, 6.113892));
            map_lu.addOverlay(marker);
        }
    }
    
    // submit-buttons deaktivieren nach submit-event
    $$('form').each(function(el){
    	btn = el.getLast('input');
    	el.addEvent('submit', function(){
    		btn.setProperty('disabled', 'disabled');
    	});
    });
    
    // zeile des aktiven form-elements farblich hervorheben
    if ($('frm_kontakt')) {
	    $('frm_kontakt').getElements('input, textarea').each(function(el){
	    	el.addEvents({
	    		'focus': function(){
	    			el.getParent('li').toggleClass('active');
	    		},
	    		'blur': function(){
	    			el.getParent('li').toggleClass('active');
	    		}
	    	});
	    });
    }
    
});

// function zur aktualisierung der uhrzeit
function updateClock(el){
	var now = new Date();
	var strDate = now.format("%A, %d.%m.%Y");
	var strTime = now.format("%H:%M:%S");
	
	$('clock').innerHTML = "<span>"+strTime+" Uhr</span>"+strDate;
}

// funktion zur aktualisierung der webcam
function updateWebcam() {
	pic = $('monitor').getElement('img');
	now = new Date();
	pic.set('src', 'http://www.dos-com.de/MOBOTIX/test.jpg?'+now.getTime());
}

