//$(document).ready(function(){
$(window).load(function(){

var el = $('#form_block_front');
var dh = $(document).height();
var hel = $('#form_block_front').height();
var phel = $('#content_section').height();
var ghel = (phel-hel)-10;

//alert(phel+'-'+hel+'='+ghel);

var elpos_original = el.offset().top;
$(window).scroll(function(){
    var elpos = el.offset().top;
    var windowpos = $(window).scrollTop();
    var windowheight = $(window).height();
    var finaldestination = windowpos;
    if(windowpos<elpos_original) {
        finaldestination = elpos_original;
        el.stop(true,false).css({'top':10});
        el.removeClass('tetap');
    } else if((dh - windowpos)<1300){
    	el.stop(true,false).css({'top':ghel});
    	el.removeClass('tetap');
    	} else {
        //el.stop(true,false).css({'top':finaldestination-elpos_original+10});
        //el.stop(true,false).css({'top':finaldestination-elpos_original+10});
        el.addClass('tetap');
    }
});

/*
var el = $('#form_block_front');
var top = el.offset().top - parseFloat(el.css('marginTop').replace(/auto/, 0));
  $(window).scroll(function (event) {
    var y = $(this).scrollTop();
    
    if (y >= top) {
      el.addClass('tetap');
      el.removeClass('mandeg');
    } if(y>1250){
    	el.removeClass('tetap');
    	el.addClass('mandeg');
    } else {
      el.removeClass('tetap');
      el.removeClass('mandeg');
    }
    
  });
*/
});
