$(document).ready(function() {

$siteurl = "http://www.mdhomehealth.com";
$themeurl = $siteurl+"/wp-content/themes/mdhh";

jQuery.easing.def = 'easeInOutQuint'; //Define defualt easing method

$(".parent-link").click(function (z) {z.preventDefault();});

//       MENU

	var ftime = 360;
	
	$("#home").hover(
  function () {
    $("#home img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#home img").stop().animate({"opacity": "1"}, ftime);
  }
	);

	$("#about-us").hover(
  function () {
    $("#about-us img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#about-us img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#medical").hover(
  function () {
    $("#medical img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#medical img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#non-medical").hover(
  function () {
    $("#non-medical img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#non-medical img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#faqs").hover(
  function () {
    $("#faqs img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#faqs img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#employment").hover(
  function () {
    $("#employment img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#employment img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#contact-us").hover(
  function () {
    $("#contact-us img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#contact-us img").stop().animate({"opacity": "1"}, ftime);
  }
	);

//header


	function animate_q () {
	$("#questions").wait(1000).fadeIn(2000, function(){
	$("#questions p").wait(100).fadeIn(2000, function(){
	$("#questions").wait(1000).fadeOut(2000, function(){
	$("#questions p").wait(0, function(){animate_a ();});});});});
	}
	function animate_a () {
	$("#answers").wait(1000).fadeIn(2000, function(){
	$("#answers p").wait(100).fadeIn(2000, function(){
	$("#answers").wait(1000).fadeOut(2000, function(){
	$("#answers p").wait(0, function(){animate_q ();});});});});
	}

animate_q ();


//		employment drop downs

$("#click1").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show1").stop().show(650);},
  function (f) {f.preventDefault(); $("#show1").stop().hide(650);}
  );

$("#click2").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show2").stop().show(650);},
  function (f) {f.preventDefault(); $("#show2").stop().hide(650);}
  );
$("#click3").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show3").stop().show(650);},
  function (f) {f.preventDefault(); $("#show3").stop().hide(650);}
  );
$("#click4").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show4").stop().show(650);},
  function (f) {f.preventDefault(); $("#show4").stop().hide(650);}
  );
$("#click5").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show5").stop().show(650);},
  function (f) {f.preventDefault(); $("#show5").stop().hide(650);}
  );
$("#click6").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show6").stop().show(650);},
  function (f) {f.preventDefault(); $("#show6").stop().hide(650);}
  );
$("#click7").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show7").stop().show(650);},
  function (f) {f.preventDefault(); $("#show7").stop().hide(650);}
  );
$("#click8").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show8").stop().show(650);},
  function (f) {f.preventDefault(); $("#show8").stop().hide(650);}
  );
$("#click9").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show9").stop().show(650);},
  function (f) {f.preventDefault(); $("#show9").stop().hide(650);}
  );
$("#click10").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show10").stop().show(650);},
  function (f) {f.preventDefault(); $("#show10").stop().hide(650);}
  );
$("#click11").toggle(	//click on X to close form
  function (f) {f.preventDefault(); $("#show11").stop().show(650);},
  function (f) {f.preventDefault(); $("#show11").stop().hide(650);}
  );



// 		FORMS



$('#comments_c').focus(function() {$(this).animate({height: 144},650);});
$('#comments').focus(function() {$(this).animate({height: 144},650);});
$('textarea').focus(function() {$(this).animate({height: 144},650);});

$('#contact_form').submit(function (e) {		//contact form
e.preventDefault();
	var name = $("#name").val();  
        if (name == "") {  
      $("#nameL").css('color','#8f003a');  
      $("input#name").focus();  
      return false;  
    } 
	var city = $("#city").val();  
        if (city == "") {  
      $("#cityL").css('color','#8f003a');  
      $("input#city").focus();  
      return false;  
    }
	var state = $("#state").val();  
        if (state == "") {  
      $("#stateL").css('color','#8f003a');  
      $("input#state").focus();  
      return false;  
    }
	var zip = $("#zip").val();  
        if (zip == "") {  
      $("#zipL").css('color','#8f003a');  
      $("input#zip").focus();  
      return false;  
    }
	var tele = $("#tele").val();  
        if (tele == "") {  
      $("#teleL").css('color','#8f003a');  
      $("input#tele").focus();  
      return false;  
    }
	var email = $("#email").val();  
        if (email == "") {  
      $("#emailL").css('color','#8f003a');  
      $("input#email").focus();  
      return false;  
    }
	var contact = $("#contact").val();  
        if (contact == "") {  
      $("#contactL").css('color','#8f003a');  
      $("input#contact").focus();  
      return false;  
    }
	var ampm = $(".ampm:checked").val();  
	var start = $("#contact").val();  
        if (start == "") {  
      $("#contactL").css('color','#8f003a');  
      $("input#contact").focus();  
      return false;  
    }
	var tele2 = $("#tele2").val();
	var email2 = $("#email2").val();
	var bestdays ='';
	$(".dayx:checked").each(function(){bestdays = bestdays+$(this).val()+', ';});
	var city2 = $("#city2").val();
	var state2 = $("#state2").val();
	var zip2 = $("#zip2").val();
	var services ='';
	$(".snx:checked").each(function(){services = services+$(this).val()+', ';});
	var tasks ='';
	$(".htx:checked").each(function(){tasks = tasks+$(this).val()+', ';});
	var support ='';
	$(".ossx:checked").each(function(){support = support+$(this).val()+', ';});
	var skill ='';
	$(".ssx:checked").each(function(){skill = skill+$(this).val()+', ';});
	var programs ='';
	$(".spx:checked").each(function(){programs = programs+$(this).val()+', ';});
	var comments = $("#comments").val();
	var start_time = start+' '+ampm;
	var csz1 = city+', '+state+' '+zip;
	var csz2 = city2+', '+state2+' '+zip2;
		
		var himon_c;
		var himonf_c = $("#himon_c").val().toLowerCase();
		switch ($("#simgnum_c").val()) {
			case '0' : himon_c = "experienced"; break;
			case '1' : himon_c = "health"; break;
			case '2' : himon_c = "service"; break;
			case '3' : himon_c = "therapy"; break;
			case '4' : himon_c = "assistance"; break;
			case '5' : himon_c = "certified"; break;
			case '6' : himon_c = "care"; break;
			case '7' : himon_c = "skilled"; break;
		  }				
							   
	if (himonf_c == himon_c) {
	$("#sidebar_form").attr('disabled', 'true');
	

	var dataString = 'name=' + name + '&csz1=' + csz1 + '&tele=' + tele + '&tele2=' + tele2 + '&email=' + email + '&email2=' + email2 + '&bestdays=' + bestdays + '&start_time=' + start_time + '&csz2=' + csz2 + '&services=' + services + '&tasks=' + tasks + '&support=' + support + '&skill=' + skill + '&programs=' + programs + '&comments=' + comments;
	
	$('#submit-button').html('<strong style="margin-left:15px">Submitting form. Please wait.</strong>');
	$.ajax({
		type: "POST",
		url: $siteurl+"/post_contactform.php",
		data: dataString,
		success: function() { $('#cfields').slideUp(1450).html('<h4 style="margin-left:15px">Thank You! Your message was sent succesfully.</h4>').fadeIn(450); }
	});
	return false;
	}
	else {
			$('#himonchigaimasu_c').slideDown(200);
			 $("#clabel").css('color','#8f003a');
			$('#himon_c').focus();
			return false;}
			}
);

$('#sidebar_form').submit(function (e) {		//sidebar form
e.preventDefault();
	var name_c = $("#name_c").val();  
        if (name_c == "") {  
      $("#name_cL").css('color','#8f003a');  
      $("input#name_c").focus();  
      return false;  
    }  
	
	var tele_c = $("#tele_c").val();  
     if (tele_c == "") {  
      $("#tele_cL").css('color','#8f003a');  
      $("input#tele_c").focus();  
      return false;  
    }	

	var email_c = $("#email_c").val();  
        if (email_c == "") {  
      $("#email_cL").css('color','#8f003a');  
      $("input#email_c").focus();  
      return false;  
    }

	var start_c = $(".radios:checked").val();
        if (start_c == "undefined") {  
      $("#start_cL").css('color','#8f003a');  
      $("input#start_c").focus();  
      return false;  
    }
	
	var personalca ='';
	if (  ( $("#personalca:checked").val() ) == 'yes' ) {personalca='yes';} else {personalca='no';}
	var homemaker ='';
	if (  ( $("#homemaker:checked").val() ) == 'yes' ) {homemaker='yes';} else {homemaker='no';}
	var osnms = '';
	if (  ( $("#osnms:checked").val() ) == 'yes' ) {osnms='yes';} else {osnms='no';}
	var mss = '';
	if (  ( $("#mss:checked").val() ) == 'yes' ) {mss='yes';} else {mss='no';}
	var specprog = '';
	if (  ( $("#specprog:checked").val() ) == 'yes' ) {specprog='yes';} else {specprog='no';}

	var comments_c = $("#comments_c").val();
		
		var himon_c;
		var himonf_c = $("#himon_c").val().toLowerCase();
		switch ($("#simgnum_c").val()) {
			case '0' : himon_c = "experienced"; break;
			case '1' : himon_c = "health"; break;
			case '2' : himon_c = "service"; break;
			case '3' : himon_c = "therapy"; break;
			case '4' : himon_c = "assistance"; break;
			case '5' : himon_c = "certified"; break;
			case '6' : himon_c = "care"; break;
			case '7' : himon_c = "skilled"; break;
		  }				
							   
	if (himonf_c == himon_c) {
	$("#sidebar_form").attr('disabled', 'true');
	

	var dataString = 'name_c=' + name_c + '&email_c=' + email_c + '&tele_c=' + tele_c + '&start_c=' + start_c + '&personalca=' + personalca + '&homemaker='	+ homemaker + '&osnms=' + osnms + '&mss=' + mss + '&specprog=' + specprog + '&comments_c=' + comments_c;
	
	$('#submit-button').html("<strong>Submitting form. Please wait.</strong>");
	$.ajax({
		type: "POST",
		url: $siteurl+"/post_sidebarform.php",
		data: dataString,
		success: function() { $('#cfields').slideUp(1450).html("<h4>Thank You! Your message was sent succesfully.</h4>").fadeIn(450); }
	});
	return false;
	}
	else {
			$('#himonchigaimasu_c').slideDown(200);
			 $("#clabel").css('color','#8f003a');
			$('#himon_c').focus();
			return false;}
			}
);





$('#employment_form').submit(function () {		//sidebar form

	/*var name_c = $("#name_c").val();  
        if (name_c == "") {  
      $("#name_cL").css('color','#8f003a');  
      $("input#name_c").focus();  
      return false;  
    }  
	
	var address = $("#address").val();  
     if (address == "") {  
      $("#addressL").css('color','#8f003a');  
      $("input#address").focus();  
      return false;  
    }	

	var city = $("#city").val();  
        if (city == "") {  
      $("#cityL").css('color','#8f003a');  
      $("input#city").focus();  
      return false;  
    }
	var state = $("#state").val();  
        if (state == "") {  
      $("#stateL").css('color','#8f003a');  
      $("input#state").focus();  
      return false;  
    }
	var zip = $("#zip").val();  
        if (zip == "") {  
      $("#zipL").css('color','#8f003a');  
      $("input#zip").focus();  
      return false;  
    }
	var tele_c = $("#tele_c").val();  
        if (tele_c == "") {  
      $("#tele_cL").css('color','#8f003a');  
      $("input#tele_c").focus();  
      return false;  
    }
	var email_c = $("#email_c").val();  
        if (email_c == "") {  
      $("#email_cL").css('color','#8f003a');  
      $("input#email_c").focus();  
      return false;  
    }
	var start = $("#contact").val();  
        if (start == "") {  
      $("#contactL").css('color','#8f003a');  
      $("input#contact").focus();  
      return false;  
    }
	var ampm = $(".ampm:checked").val();  
     
	var method = $(".method:checked").val();  
        if (method == "") {  
      $("#methodL").css('color','#8f003a');  
      $("input.method").focus();  
      return false;  
    }
	var hear = $("#hear").val();  
        if (hear == "") {  
      $("#hearL").css('color','#8f003a');  
      $("input#hear").focus();  
      return false;  
    }
	var hours = $("#hours").val();  
        if (hours == "") {  
      $("#hoursL").css('color','#8f003a');  
      $("input#hours").focus();  
      return false;  
    }
	var years = $("#years").val();  
        if (years == "") {  
      $("#yearsL").css('color','#8f003a');  
      $("input#years").focus();  
      return false;  
    }
	var date = $("#date").val();  
        if (date == "") {  
      $("#dateL").css('color','#8f003a');  
      $("input#date").focus();  
      return false;  
    }*/
	
		var himon_c;
		var himonf_c = $("#himon_c").val().toLowerCase();
		switch ($("#simgnum_c").val()) {
			case '0' : himon_c = "experienced"; break;
			case '1' : himon_c = "health"; break;
			case '2' : himon_c = "service"; break;
			case '3' : himon_c = "therapy"; break;
			case '4' : himon_c = "assistance"; break;
			case '5' : himon_c = "certified"; break;
			case '6' : himon_c = "care"; break;
			case '7' : himon_c = "skilled"; break;
		  }				
							   
	if (himonf_c == himon_c) {

	return true; alert('sending');
	}
	else {
			$('#himonchigaimasu_c').slideDown(200);
			 $("#clabel").css('color','#8f003a');
			$('#himon_c').focus();
			return false;}
			}
);






    
}); //closing brackets

jQuery.extend( jQuery.easing,	//defualt easing script
{
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	}
});

$.fn.wait = function(time, type) {//delay function
time = time || 1000;
type = type || "fx";
return this.queue(type, function() {
var self = this;
setTimeout(function() {
$(self).dequeue();
}, time);
});
};
