$(document).ready(function() {
  
  $('div#p-about').hide();
  $('div#p-info').hide();
  $('div#p-contact').hide();
  $('div#p-services').show();
  $('div#p-testimonials').hide();
  
  $('div.service-box').hide()
  $('div#fullInspection').show();
  
  $('div#loginBox').hide();
  $('span.loading').hide(); 
  
  $('a.services-type').click(function() {
  	var link = $(this).attr('rel');
  	$('div.service-box').fadeOut(100);
  	$('div#'+link).fadeIn(1000);
  	return false;
  });
  
  
  $('a#servicesLink').click(function() {
    $('div#p-testimonials').hide();
    $('div#p-about').hide();
    $('div#p-info').hide();
    $('div#p-contact').hide(); 
    $('div#p-services').fadeIn(1000); 
	return false;
  });
    
  $('a#aboutLink').click(function() {
    $('div#p-testimonials').hide();
	$('div#p-services').hide();
    $('div#p-info').hide();
    $('div#p-contact').hide();
    $('div#p-about').fadeIn(1000); 
	return false;
  });
  
  $('a#infoLink').click(function() {
    $('div#p-testimonials').hide();
    $('div#p-about').hide();
    $('div#p-services').hide();
    $('div#p-contact').hide();
    $('div#p-info').fadeIn(1000);  
	return false;
  });
  
  $('a#contactLink').click(function() {
    $('div#p-testimonials').hide();
    $('div#p-about').hide();
    $('div#p-info').hide();
    $('div#p-services').hide();
    $('div#p-contact').fadeIn(1000);
	return false;
  });
  
  $('a.contactLink').click(function() {
    $('div#p-testimonials').hide();
    $('div#p-about').hide();
    $('div#p-info').hide();
    $('div#p-services').hide();
    $('div#p-contact').fadeIn(1000);
	return false;
  });
  
  $('a#testimonialLink').click(function() {
	$('div#p-contact').hide();
    $('div#p-about').hide();
    $('div#p-info').hide();
    $('div#p-services').hide();
    $('div#p-testimonials').fadeIn(1000);
	return false;
  });
  
  /*
  $('a#preListLink').click(function() {
	$('div#fullInspection').hide();
	$('div#moveIn').hide()
	$('div#o-zonation').hide();
	$('div#preInspection').fadeIn(1000);
	return false;
  });
  
  $('a#fullInspectionLink').click(function() {
	$('div#preInspection').hide();
	$('div#moveIn').hide()
	$('div#o-zonation').hide();
	$('div#fullInspection.').fadeIn(1000);
	return false;
  });
  
  $('a#moveInCertified').click(function() {
	$('div#preInspection').hide();
	$('div#fullInspection').hide();
	$('div#o-zonation').hide();
  $('div#moveIn').fadeIn(1000);
  });

  $('a#ozonation').click(function() {
	$('div#preInspection').hide();
	$('div#fullInspection').hide();
	$('div#moveIn').hide();
  $('div#o-zonation').fadeIn(1000);
  });
  */

  $('form#sendMessage').submit(function() {
  if(($('input#name').val()) == "") {
    alert("Please Enter A Username.");
  }
  else if(($('input#email').val()) == "") {
    alert("Please Enter An Email Address");
  }
  else if(($('input#h-phone').val()) == "") {
    alert("Please Enter In A Phone Number.");
  }
  else if(($('textarea#message').val()) == "") {
    alert("Please Enter In A Description Of The Request");
  }
  else {
 	$('span.loading').fadeIn(1000);
	var nameF = $('input#name').val();
	var emailF = $('input#email').val();
	var phoneF = $('input#h-phone').val();
	var cellF  = $('input#a-phone').val();
	var messageF = $('#message').val();
  
	$.post("../libs/sendMail.proc.php",
	{ name: nameF, email: emailF, phone: phoneF,cell: cellF, message: messageF },
   	function(data){
		if(data=='1') {
			$('span.loading').fadeOut(500);
			setTimeout(function() { $('p.msgBox').html('Message Successfully Delivered.') }, 600);
			$('p.msgBox').fadeIn(1000);
			setTimeout(function() { 
			$('p.msgBox').fadeOut(1000)}, 5000);
			$('form#sendMessage').reset();
		}
		else {
			$('span.loading').fadeOut(500);
			setTimeout(function() { $('p.msgBox').html('Message Could Not Be Delivered. Please Try Again.') }, 600);
			$('p.msgBox').fadeIn(1000);
			setTimeout(function() { 
			$('p.msgBox').fadeOut(1000)}, 5000);
		}
	}
	);
	}
	return false;
	});

});