// JavaScript Document

// only for demo purposes
$.validator.setDefaults({
	submitHandler: function() {
		$("#gear").html('<p style="text-align:center; margin-top:100px;"><img src="images/loading.gif" alt="" /><br /><br />Submit,please wait... ...</p>');
		var str = $("form").serialize();
		$('#reply').slideUp(500);
		$('#gear').animate({opacity:1.0}, 510).fadeIn(1000);
		
		$.ajax({			   
			type: "POST",
			url: "reply.asp",
			data: str,
			success: function(html) {
				$('#gear').fadeOut(500);
				
				$('#reply').animate({opacity: 1.0}, 600).fadeIn(2000).html(html);
			}
		});
		
		return false;
	}
});
 
$().ready(function() {
	/*$("#form1").validate({
		errorLabelContainer: $("#form1 div.error")
	});*/
	
	var container = $('div.container');
	// validate the form when it is submitted
	var validator = $("#replyForm").validate({
		errorContainer: container,
		errorLabelContainer: $("ol", container),
		wrapper: 'li',
		meta: "validate"
	});
	
	$(".cancel").click(function() {
		replyForm.reset();						
		validator.resetForm();		
	});
	
	
	$("#paper1").click(function(){	
		document.replyForm.present.disabled	= true;	
		document.getElementById("present").style.backgroundColor='#ececec';
		document.getElementById("present").value='';
								});
	$("#paper2").click(function(){		
		document.replyForm.present.disabled	= false;
		document.getElementById("present").style.backgroundColor='#FFFFFF';
								});
});

$(document).ready(function() {
    $('#list3')
        .children('div').hide().end()
        .find('h4 a').click(function() {
            var $this = $(this);
            if ($this.hasClass('collapse')) {
                $this
                    .removeClass('collapse')
                    .addClass('expand')
                    .parent('h4').next('div:visible').slideUp('fast')
                    ;
                }
            else if ($this.hasClass('expand')) {
                $this
                    .removeClass('expand')
                    .addClass('collapse')                   
                    .parent('h4').next('div:hidden').slideDown('fast')
                    ;
                }
            else {
                alert("no class");
            }
        })
        ;
});

$(window).load(function(){
$("#loading").hide();
})
