jQuery(document).ready(function(){
    var availableTags = [
			"ActionScript",
			"AppleScript",
			"Asp",
			"BASIC",
			"C",
			"C++",
			"Clojure",
			"COBOL",
			"ColdFusion",
			"Erlang",
			"Fortran",
			"Groovy",
			"Haskell",
			"Java",
			"JavaScript",
			"Lisp",
			"Perl",
			"PHP",
			"Python",
			"Ruby",
			"Scala",
			"Scheme"
		];
        var to_config = {
            minLength: 1,
            appendTo: "#pfs_form",
            url:'search.php',
            onSelect:function(){
                    alert(this.ac.val())
            }
	};
	/*jQuery("#pfs_to").autocomplete(to_config);    */
        jQuery("#pfs_to").autocomplete("<?php echo add_query_arg('get_my', 'terms', home_url()); ?>",
                {
                width: 260,
                matchContains: true,
                selectFirst: false,
                multiple: true
            });

    
	jQuery(".pfs-post-link").click(function(){
		var $box = jQuery(this).siblings('div');
		if ('relative' == jQuery(this).parents('article').css('position')) {
			var top = 0;
			var diff = jQuery(this).parents('article').offset();
			var left = ( jQuery(window).width() - $box.width() )/2 - diff.left;	
		} else {
			var top = 90;
			var left = ( jQuery(window).width() - $box.width() )/2;
		}
		if (top<0) top = 50;
		$box.css({top:top+"px",left:left+"px"}).show();
	});
	jQuery(".closex").click(function(){
		jQuery(this).parent().hide();
	});
    /*jQuery("form.pfs").submit(function() {
        alert(jQuery("form.pfs").serialize());
        jQuery(this).ajaxSubmit({            
            type: "POST",
            url: jQuery(this).attr('action'),
            dataType:'json',
            data: jQuery("form.pfs").serialize(),
            beforeSend: function(){
                //jQuery('.pfs-post-form #post').val('posting...');
                jQuery('#header-bottom').val('posting...');
            },
            complete: function(request, textStatus, error) {
                data = jQuery.parseJSON(request.responseText);
                if (data && data.error) {
                	alert(data);
                    jQuery('#pfs-alert').addClass('error').html('<p>'+data.error+'</p>').show();
                    jQuery('.pfs-post-form #post').val('Post');
                } else {
                    jQuery('form.pfs').reset();
                    location.reload();
                }
            }
        });
        return false;
    });*/
});
