$(document).ready(function() {
	
	$('.headerFade div:gt(0)').hide();
	setInterval(function(){
	  $('.headerFade div:first-child').fadeOut()
	     .next('div').fadeIn()
	     .end().appendTo('.headerFade');}, 
	4000);
	
	$('.sideFade div:gt(0)').hide();
	setInterval(function(){
	  $('.sideFade div:first-child').fadeOut()
	     .next('div').fadeIn()
	     .end().appendTo('.sideFade');}, 
	5000);
	
	$('.middleFade div:gt(0)').hide();
	setInterval(function(){
	  $('.middleFade div:first-child').fadeOut()
	     .next('div').fadeIn()
	     .end().appendTo('.middleFade');}, 
	6000);
	
	$('#reset').click(function(){
	  $(':input','#contactForm')
	 .not(':button, :submit, :reset, :hidden')
	 .val('')
	 .removeAttr('checked')
	 .removeAttr('selected');
	});
	
	$('#reset').click(function(){
	  $(':input','#tradeForm')
	 .not(':button, :submit, :reset, :hidden')
	 .val('')
	 .removeAttr('checked')
	 .removeAttr('selected');
	});
	
	$('#reset').click(function(){
	  $(':input','#orderForm')
	 .not(':button, :submit, :reset, :hidden')
	 .val('')
	 .removeAttr('checked')
	 .removeAttr('selected');
	});
	
	$('#contactSubmit').click(function(){
	  
	  var data = $('#contactForm').serialize();
	  $.ajax({
	    type: "POST",
	    url: "http://cartridgedisplays.com/wp-content/themes/tmb/process.php",
	    data: data,
	    success: function(msg){
	      $('.formResult').text(msg).fadeIn();
	    }
	  });
	  return false;
	});
	
	
	$('#tradeSubmit').click(function(){
	  
	  var data = $('#tradeForm').serialize();
	  $.ajax({
	    type: "POST",
	    url: "http://cartridgedisplays.com/wp-content/themes/tmb/processTrade.php",
	    data: data,
	    success: function(msg){
	      $('.formResult').text(msg).fadeIn();
	    }
	  });
	  return false;
	});
	
	$('#orderSubmit').click(function(){
	  
	  var data = $('#orderForm').serialize();
	  $.ajax({
	    type: "POST",
	    url: "http://cartridgedisplays.com/wp-content/themes/tmb/processOrder.php",
	    data: data,
	    success: function(msg){
	      $('.formResult').text(msg).fadeIn();
	    }
	  });
	  return false;
	});

	
	$('#passwordSubmit').click(function(){
	  
	  var data = $('#password').val();
	  $.ajax({
	    type: "POST",
	    url: "http://cartridgedisplays.com/wp-content/themes/tmb/tradepdf.php",
	    data: 'data=' + data,
	    success: function(msg){
	      $('.result').html(msg);
	    }
	  });
	  return false;
	});

	
	var myTarg = null;
	if(window.location.hash) {
		myTarg = window.location.hash;
		myTarg = myTarg.replace('#','');
		setTimeout(goToByScroll(myTarg), 1000);
	}
	
	function goToByScroll(id){
	     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
	}
	
	$('.childNav').parent().hide();

	$(".parentTrigger").click(function () {
	    $(this).nextUntil('li:not(:hidden)').show();
	    return false;
	});
	
});













