(function($){
    /* 下拉框 */
    var selectObj = {
        selectWrap: $('.easysite-simulate-select'),
        selectOption: $('.easysite-select-option', this.selectWrap),
        init: function() {
            this.events();
        },
        showSelect: function(elem, opUl) {
            this.selectOption.hide();
            $('ul', this.selectOption).hide();
            elem.show();
            opUl.show();
        },
        selectedArea: function(elem, index, curOption, curUl) {
            var $simulateSelect = elem.parents('.easysite-simulate-select'),
                $headerInput = $('.easysite-header-input', $simulateSelect),
                $headerInputHidden = $('.easysite-header-input-hidden', $simulateSelect);

            curOption.hide();
            curUl.hide();
            $('li', curOption).removeClass('easysite-active').eq(index).addClass('easysite-active');
            $headerInput.val(elem.text());
            $headerInputHidden.val(elem.data('value'));
            $headerInput.trigger('blur');
        },
        events: function() {
            var that = this;
            $('.easysite-select-header', that.selectWrap).on('click', function(e) {
                e.stopPropagation();
                var $this = $(this),
                    $option = $this.parents('.easysite-simulate-select').find('.easysite-select-option'),
                    $opUl = $option.find('ul');
                that.showSelect($option, $opUl);
            });
            that.selectOption.on('click', 'li', function() {
                var $this = $(this),
                    index =  $this.index(),
                    $curSelOption = $this.parents('.easysite-select-option'),
                    $curUl = $('ul', $curSelOption);
                that.selectedArea($this, index, $curSelOption, $curUl);
            });
            $(document).on('click',function() {
                that.selectOption.hide();
            });
        }
    };
    selectObj.init();
    $('.easysite-td-row:even').css('background-color','#ffffff');
    $('.easysite-td-row:odd').css('background-color', '#f3f3f3');
})(jQuery);

function queryClick(url,form) {
	$("#"+form).attr("action",url);
	$("#"+form).submit();
}
//分页查询
function jumpToClick(totalPages,pageNo,jumpUrl,form){
    var turnPage=$("#turnPage").val();
    if($.trim(turnPage)==""){
  	  alert("不能为空");
  	  $("#turnPage").val(pageNo);
  	  return;
    }
    if(isNaN(turnPage)){//不为数字
  	  alert("不为数字");
  	  $("#turnPage").val(pageNo);
  	  return;
    }
    if(parseInt(turnPage)!=turnPage){
  	  alert("不是整数");
  	  $("#turnPage").val(pageNo);
  	  return;
    }
    if(parseInt(turnPage)>parseInt(totalPages)||parseInt(turnPage)<1){
	  alert("超出范围");
	  $("#turnPage").val(pageNo);
	  return;
     }
    jumpUrl=jumpUrl.replace("%1",turnPage);
    
    queryClick(jumpUrl,form);
}
