var currentSlide;

(function($) {
	
$(document).ready(function() {

 $('#newsletter-form').ajaxForm( {
  target: '#ml_feedback',
  success: function() {
   $('#newsletter-form').resetForm();                           
  }
 });

 //payment_amount
 $("#payment_amount").keyup( function() {
  // check input ($(this).val()) for validity here
  var extra = Number($(this).val());
  if (isNaN(extra)) {
   extra = 0;
  }
  var total = extra+1000;
  $("#payment_total").html("= "+total);
 });

 var _hash = window.location.toString().split("favelapainting.com");
 //$("#debug").html(_hash[1]);
 if(_hash[1] == "/home" || _hash[1] == "/" || _hash[1] == "/twindex.php") {
 setInterval("slide()", 5000);     
 }

});

})(jQuery);

// clear / restore
function clearDefault(el) {
 if (el.defaultValue==el.value) el.value = "";
}

function putDefault(el) {
 if (el.value=="") el.value = el.defaultValue;
}

function slide() {
 if (!currentSlide) {
  nextSlide = $("#pushbox div:first").next().attr("id");
//  $("#pushbox div:first").removeClass("pushbox-show");
 } else {
  // alert(currentSlide+" "+$("#pushbox div:last").attr("id"));
  if(currentSlide == $("#pushbox div:last").attr("id")) {
   nextSlide = $("#pushbox div:first").attr("id");	
  } else {	
   nextSlide = $("#"+currentSlide).next().attr("id");
  }
  //currentSlide = nextSlide;
 }
 $("#"+nextSlide).css({opacity: 0.0});
 $("#"+nextSlide).addClass("pushbox-show");	
 $("#"+nextSlide).animate({opacity: 1.0}, 600, function() {
  $("#"+currentSlide).removeClass("pushbox-show");
  currentSlide = nextSlide;
  //$("#debug").html(currentSlide);
 });
 $("#"+currentSlide).animate({opacity: 0.0}, 600);
// if (currentSlide) {
  // $("#"+currentSlide).animate({opacity: 0.0}, 600);
// }

}
