
var animateBgEnabled = true;

function animateBg() {
    var bd = $("body");
    var dur = 20000;
    
    function animStep(now, fx) {
        if (fx.prop == "backgroundPositionLeft") {
            $(this).css({"backgroundPosition": now.toFixed(4) + "px 0"});
        }
    }
    
    function animToRight() {
    	if (!animateBgEnabled) return;
    	
        bd.animate({"backgroundPositionLeft": "918px"}, {
        "duration": dur, 
            "complete": animToLeft,
            "step": animStep
        });
    }
    
    function animToLeft() {
    	if (!animateBgEnabled) return;
    	
        bd.animate({"backgroundPositionLeft": "0px"}, {
        "duration": dur, 
            "complete": animToRight,
            "step": animStep
        });
    }
    
    animToRight();
}

function stopBgAnimation(btn) {
	btn = $(btn);
	if (animateBgEnabled) {
		animateBgEnabled = false;
		$("body").stop();
		btn.text("Animasyonu Başlat");
	} else {
		animateBgEnabled = true;
		animateBg();
		btn.text("Animasyonu Durdur");
	}

	return false;
}

function bindFormAcc() {
    var leftPanel = $("#left-panel");
    var acc = leftPanel.find(".form-acc");
    acc.find(".form-acc-title").click(function(e){
        var item = $(this).parent();
        var act = acc.find(".form-acc-active");
        
        item.find(".form-acc-content").slideDown(300, function(){
            item.addClass("form-acc-active");
        });
        
        act.find(".form-acc-content").slideUp(300, function(){
            $(this).parent().removeClass("form-acc-active");
        });
        
    });
}
