	//$.validator.setDefaults({ submitHandler: function() { alert("submitted!"); } });
	$(document).ready(function() 
	{

		$("#contact_form").validate(
		{
			rules: 
			{
				name: "required",
				email: 
				{
					required: true,
					email: true
				},
				phone: 
				{
					required: true
				},
				department: 
				{
					required: true
				},
				message: 
				{
					required: true
				}
			},
			messages: 
			{
				//name: "Lütfen isminizi giriniz",
				name: "",
				email: 
				{
					//required: "Lütfen geçerli e-posta adresi giriniz",
					//email: "geçersiz adres"
					required: "",
					email: ""

				},
				phone: 
				{
					required: ""
				},
				department: 
				{
					required: ""
				},
				message: 
				{
					required: ""
				}
			},
			submitHandler: function() 
			{
				$("#contactmsgbox").removeClass().addClass('contactmessagebox').text('İşleminiz sürüyor, lütfen bekleyin..').fadeIn(1000);
				//alert("Correct captcha!");
				//return false; //not to post the  form physically		
				
			$.post("scripts/contact_form.php",
			{ 	
							name:$('#name').val(),
							email:$('#email').val(),
							//newsletter:$("input[@name=newsletter]:checked").val(),
							phone:$('#phone').val(),
							department:$('#department').val(),
							message:$('#message').val(),
							rand:Math.random() 
			} ,
				function(data)
				{

					if(data=='yes') //if correct 
					{
						$("#contactmsgbox").fadeTo(200,0.1,function()  //start fading the messagebox
						{ 
						//add message and change the class of the box and start fading
						$(this).html('Kaydınız tamamlandı.').addClass('contactmessageboxok').fadeTo(900,1,
						function()
						{ 
							document.location='index.php';
						});
						});
					}
					else 
					{
						$("#contactmsgbox").fadeTo(200,0.1,function() //start fading the messagebox
						{ 
							//add message and change the class of the box and start fading
							$(this).html('Kaydınızda sorun oluştu.').addClass('contactmessageboxerror').fadeTo(900,1);
						});		
					}
				
				});
			return false; //not to post the  form physically

			}
		});
	});

