var current_id = 0;





$(document).ready(function() {

    

    $(".faqs .answer").slideUp();

    $(".faqs .question").click(function(){
		
        var index = $(".faqs .question").index(this);

		$(".faqs .answer").eq(index).slideToggle();

    });

    $(".frm_schedule .btn-submit").click(function(){

        

        $.ajax({

          url: siteurl + "/wp-custom-ajax.php?trans=schedule&" + $('.frm_schedule').serialize(),

          success: function(data){ 

            $('.frm_schedule .error_container').html(data).fadeIn("slow",function(){

              $(this).delay(2000).fadeOut(); 

              if($(".hidden-success").attr("rel") == "true"){

                  $('.frm_schedule')[0].reset();

              }

               

            });

          }

        });

        

    });

    

//    function load_page(current_id){
//
//        $(".page-home .sidebar .menu li a").removeClass("active");
//
//        $(".page-home .sidebar .menu li a.menu-"+current_id).addClass("active");
//
//        $(".page-home .bullets .bullet").removeClass("active");
//
//        $(".page-home .bullets .bullet-"+current_id).addClass("active");
//
//        $(".page-home .content_nav .read_more").attr("href",$(".sidebar .menu li a.menu-"+current_id).attr("readmore_link"));
//
//        
//
//        $(".page-home .content").fadeOut("fast", function(){
//
//            $(this).html('<div style="padding: 10px;"><img src="'+siteurl+'/wp-content/themes/austin_eye/images/content_loader.gif" alt="" /> Loading...</div>')
//
//            $(this).fadeIn("fast",function(){
//
//                $.ajax({
//
//                  url: siteurl + "/page-ajax.php?id="+current_id,
//
//                  success: function(data){
//
//                      $(".page-home  .content").fadeOut(function(){
//
//                          $(this).html(data).fadeIn();
//
//
//
//                      });
//
//                      }
//
//                });
//
//            });
//
//        });
//
//    }

    

//    function load_nav_bullets(current_id){
//
//        
//
//    }



    

//    $(".page-home .sidebar .menu li a").click(function(){
//
//        current_id = $(this).attr("rel");
//
//        load_page(current_id);
//
//    });

    

    $('input[type="text"], textarea').focus(function(){

        if( $.trim($(this).val())  != ""){

            if( $.trim( $(this).attr('rel') ) == ""){

                $(this).attr('rel', $(this).val());                

            }

        }

        if( $.trim($(this).val())  == $(this).attr('rel')){

            $(this).val('');            

        }

    });

    

    

    $('input[type="text"], textarea').blur(function(){

        if( $.trim($(this).val()) == ""){

            $(this).val( $(this).attr("rel") );           

        }

    });

    //load_page(39);

	//click2call form submit
	$("form").submit(
		function(){
			var fID = $(this).attr("id");
			var _data = $(this).serialize() + "&ajax=yes";
			var _url = $(this).attr("action");
			var pform = $(this);
			$(".c_msg", pform)
			.css("display","none")
			.html("<p class='info'>Sending data. Please wait...</p>")
			.fadeIn("slow");
			
			jQuery.ajax({
			   type: "POST",
			   url: _url,
			   data: _data,
			   success: function(msg){
				    $(".c_msg", pform).html(msg)
					.delay(3000)
					.fadeOut("slow");
					
				  if(msg.indexOf("<!--RESET-->") > -1){
					   $("input[type=text], textarea").each(
							function(index,item){
								$(item).val($(item).attr("title"));
							}
					   );
				   }
			   }
			});
			return false;
		}
	);


});
