var data1 = [];
function xxxxw(b){
    data1 = (b[1]+'').split(',');
}

/* HTML5 Placeholder jQuery Plugin - v2.1.0
 * Copyright (c) 2014 Mathias Bynens
 * 2014-12-29
 */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(b){var c={},d=/^jQuery\d+$/;return a.each(b.attributes,function(a,b){b.specified&&!d.test(b.name)&&(c[b.name]=b.value)}),c}function c(b,c){var d=this,f=a(d);if(d.value==f.attr("placeholder")&&f.hasClass(m.customClass))if(f.data("placeholder-password")){if(f=f.hide().nextAll('input[type="password"]:first').show().attr("id",f.removeAttr("id").data("placeholder-id")),b===!0)return f[0].value=c;f.focus()}else d.value="",f.removeClass(m.customClass),d==e()&&d.select()}function d(){var d,e=this,f=a(e),g=this.id;if(""===e.value){if("password"===e.type){if(!f.data("placeholder-textinput")){try{d=f.clone().attr({type:"text"})}catch(h){d=a("<input>").attr(a.extend(b(this),{type:"text"}))}d.removeAttr("name").data({"placeholder-password":f,"placeholder-id":g}).bind("focus.placeholder",c),f.data({"placeholder-textinput":d,"placeholder-id":g}).before(d)}f=f.removeAttr("id").hide().prevAll('input[type="text"]:first').attr("id",g).show()}f.addClass(m.customClass),f[0].value=f.attr("placeholder")}else f.removeClass(m.customClass)}function e(){try{return document.activeElement}catch(a){}}var f,g,h="[object OperaMini]"==Object.prototype.toString.call(window.operamini),i="placeholder"in document.createElement("input")&&!h,j="placeholder"in document.createElement("textarea")&&!h,k=a.valHooks,l=a.propHooks;if(i&&j)g=a.fn.placeholder=function(){return this},g.input=g.textarea=!0;else{var m={};g=a.fn.placeholder=function(b){var e={customClass:"placeholder"};m=a.extend({},e,b);var f=this;return f.filter((i?"textarea":":input")+"[placeholder]").not("."+m.customClass).bind({"focus.placeholder":c,"blur.placeholder":d}).data("placeholder-enabled",!0).trigger("blur.placeholder"),f},g.input=i,g.textarea=j,f={get:function(b){var c=a(b),d=c.data("placeholder-password");return d?d[0].value:c.data("placeholder-enabled")&&c.hasClass("placeholder")?"":b.value},set:function(b,f){var g=a(b),h=g.data("placeholder-password");return h?h[0].value=f:g.data("placeholder-enabled")?(""===f?(b.value=f,b!=e()&&d.call(b)):g.hasClass(m.customClass)?c.call(b,!0,f)||(b.value=f):b.value=f,g):b.value=f}},i||(k.input=f,l.value=f),j||(k.textarea=f,l.value=f),a(function(){a(document).delegate("form","submit.placeholder",function(){var b=a("."+m.customClass,this).each(c);setTimeout(function(){b.each(d)},10)})}),a(window).bind("beforeunload.placeholder",function(){a("."+m.customClass).each(function(){this.value=""})})}});


$(function() {
	$('input, textarea').placeholder(); // placeholder polyfill
        $("#fsearch").autocomplete({
                source: function(request, response) {
                    var site_id = 0;
                    var $inputSiteId = $('[name="hid"]');
                    if($inputSiteId.length != 0) {
                        site_id = $inputSiteId.val();
                    }
                    $.ajax({
                            url: search_url+'suggest.php',
                            dataType: "jsonp",
                            data: {
                                pos: 10,
                                name_startsWith: request.term,
                                site: site_id,
                                form_hash: $('[name="form_hash"]').val()
                            },
                            success: function(data) {
                                if(data.length == 0) {
                                    $("#fsearch").autocomplete('close');
                                }
                                response($.map(data['item'], function(item) {
                                            return {
                                                id: item[1],
                                                label: item[0],
                                                value: item[0]
                                            }
                                    }))
                            }
                    })
                },
                minLength: 3,
                open: function() {
                    
                },
                close: function() {
                },
                select: function(event, ui){

                    $.ajax({
                            url: search_url+'suggest_from_word.php',
                            dataType: "jsonp",
                            data: {
                                from_text: $('#fsearch').val(),
                                text: ui.item.label,
                                word_stat_id: ui.item.id
                            },
                            success: function(data) {
                                $('#fsearch').val(ui.item.label);
                                $('#form_search').submit();
                            }
                    });
                    return false;
                }
        });
});

function submitSearch(ob){
    if($('#fsearch').val().length>0)
        return true;
    else
        return false;
}

