
	$(document).ready(function()
	{

    $('ul#advertisings').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '74px'
		});

	
		$('#staf_btn,.staf_btn').click(function()
		{
			$('#staf').show();
			$('#staf').vCenter(); 
			return false;
		});
	
		$('#staf form').submit(function()
		{
			$('input, textarea', this).each(function()
			{
				if ($(this).val() == '') {
					$(this).addClass('empty');
				} else {
					$(this).removeClass('empty');
				}
			});

			$('input[name=s_email], input[name=r_email]').each(function()
			{
				if (!validateEmail(this)) {
					$(this).addClass('empty');
				} else {
					$(this).removeClass('empty');
				}
			});
			
			if ($("input", this).hasClass('empty')) return false;
			
			var formData = $(this).serialize();
			var siteUrl = location.href;

			$.ajax(
			{
				type: 'POST',
				url: '/ajax/staf.ajax.php',
				data: formData+'&siteUrl='+siteUrl,
				success: function(msg) {
					$('#staf ol').hide();
					$('#staf .sent').show();
				}
			});
			
			return false;
		});
	
		$('#staf .close').click(function()
		{
			$('#staf .sent').hide();
			$('#staf ol').show();
			$('input[type=text], textarea', '#staf form').val('');
			$('#staf').hide();
			return false;
		});
	});
	
	function validateEmail(elm)
	{
		regexp_mail = /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		return regexp_mail.test($(elm).val());
	}
