$(document).ready(function() {

	$('#cssdropdown li.headlink').hover(

	function() { $('ul', this).css('display', 'block'); },

	function() { $('ul', this).css('display', 'none'); });



	$('#contact-form-button').click(function() {

		$("#dialog-modal").dialog({

			height: 600,

			width: 500,

			modal: true,

			close: function(event, ui) {

				$("#contact-form").parent().removeClass("hide");

				$("#contact-form").children("fieldset").children("input[type='text'],textarea").val("");

				$(".contactform-success").addClass("hide");

				if(!$(".contactform-error").hasClass("hide"))

				{

					$(".contactform-error").addClass("hide");

				}

			}

		});

	});

	

	

	$("#contact-form, #ask-form").submit(function(event){ 

		

		var formWrap = $(this).parent();

		

		$(formWrap).addClass("hide");

		$(".loading").removeClass("hide");

		

		$.ajax({

				type: "POST",

				async: false,

				url: $(this).attr("action"),

				data: $(this).serialize(),

				error: function(xml,e){

					$(".loading").addClass("hide");

					//$(formWrap).addClass("hide");

					$(".contactform-error").removeClass("hide");

						

				},

				success: function(xml) {

					$(".loading").addClass("hide");

					//$(formWrap).addClass("hide");

					$(".contactform-success").removeClass("hide");

				},complete: function(xml){

					

				}

		});//end ajax

		

		

		event.preventDefault(); /* stop the default form submit */

		

	});//end contact submit

	

	

	$('#ask-eddie-button').click(function() {

		$("#dialog-modal-askeddie").dialog({

			height: 600,

			width: 500,

			modal: true,

			close: function(event, ui) {

				/*$("#ask-form").parent().removeClass("hide");

				$("#ask-form").children("fieldset").children("input[type='text'],textarea").val("");

				$(".contactform-success").addClass("hide");

				if(!$(".contactform-error").hasClass("hide"))

				{

					$(".contactform-error").addClass("hide");

				}

				*/

			}

		});

	});

	
	$('#uploadDogImageButton').click(function() {

		if($("#uploadImageContainer").hasClass("open"))
		{
		   $("#uploadImageContainer").slideUp("fast",function(ev){

			$(this).removeClass("open");
		   });
		}
		else
		{
		   $("#uploadImageContainer").slideDown("fast",function(ev){

			$(this).addClass("open");
		   });
		}
	});
	



});
