// JavaScript Document
$(document).ready(function(){
	$('#droping-curtain').aviaSlider({	blockSize: {height: 'full', width:40},
			display: 'topleft',
			transition: 'drop',
			betweenBlockDelay:80,
			animationSpeed: 800,
			switchMovement: true,
			slideControlls: 'items',
			appendControlls: '.aviaslider'
			});	
	
	
	function clear_form_elements(ele) {

    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).attr("value","");
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
	$(".error").html("");
	$(".styled_textbox").removeClass("valid");

}

	
	
	$(".make_a_comment").click(function(){
		
		clear_form_elements((".feedback_form"));
		$("#note").html("");
		$title = $(this).attr("title");
		$("#blog_title").attr("value", $title);
		$(".make_a_comment").css("display", "block");
		$(".form_wrapper").css("display", "none");
		$("#fields").css("display", "block");
		$(this).next(".form_wrapper").css("display", "block");
		$(this).next(".form_wrapper").append($(".comment_box"));
		$(".comment_box").css("display", "block");
		$(this).hide();
	});
	
	
	
	$(".feedback_form").validate({
		   onkeyup:false,
		   rules:
		   {
				your_name_text:
				{
					required:true
				},
				your_email_text:
				{
					required:true,
					email:true
				},
				message_text:
				{
					required:true
				}
		   },
		   messages:
		   {
				your_name_text:
				{
					required: "*"
				},
				your_email_text:
				{
					required: "*",
					email: "invalid email address"
				},
				message_text:
				{
					required: "*"
				}
			}
		});
	
	
	
		//submit feedback
		$(".feedback_form").submit(function(){
		
			var str = $(this).serialize();	
			  $(".loading").css("display","block");
			   $.ajax({
			   type: "POST",
			   url: "process_contact.php",
			   data: str,
			   success: function(msg){
					
				$("#note").ajaxComplete(function(event, request, settings){
				
				if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
				{
					result = '<div class="success">Thank you for your comment. This commment will display only after the administrator approval.</div>';
					
					$("#fields").hide();
					
				}
				else if(msg == 'FINE') // Message Sent? Show the 'Thank You' message and hide the form
				{
					result = '<div class="success">Thank you for your message.</div>';
					
					$("#fields").hide();
					
				}
				else
				{
					result = msg;
					$("#fields").css("display", "block");
				}
				$(".loading").css("display","none");
				$(this).html(result);
		
		});
		
		}
		
		 });
		
		return false;
		
		});
})
