//移动端搜索窗口
//搜索框
function switchSearch()
{
	var sbox = $("#eSearchBox");
	if (sbox.is(":hidden"))
	{
		//sbox.show();
		sbox.slideDown();
    }
	else
	{
		//sbox.hide();
        sbox.slideUp();
    }
};﻿
(function($) {
	$.fn.asideUi = function(options) {
		var defaults = {
			size: '100%',
			hasmask: true,
			position: 'left',
			sidertime: 300
		};
		var val = $.extend(defaults, options);
		var obj = function() {},
			_self = this,
			thisMask = $("<div class='ui-aside-mask' ontouchmove='return false;'></div>"),
			thisCss = {},
			thisCss2 = {};
		thisCss[val.position] = '-' + val.size;
		this.css({
			'top': (val.position == "bottom") ? "auto" : 0,
			'bottom': 0
		});
		thisCss2[val.position] = 0;
		_self.css(thisCss);
		/*
		var startx, starty;
		
		 _self.bind("touchstart", function (events) {
            startY = events.originalEvent.changedTouches[0].pageY;
			//alert(startY);
        });
		 
		_self.bind("touchmove", function (e) {
            e.preventDefault();
			var endy = e.changedTouches[0].pageY;
			var scrollTop = $(this).scrollTop();
			 
			var they=8;//Math.abs(endy-startY);
			if(endy > startY)
			{
				//alert("下");
				$(this).scrollTop(scrollTop - they);
			}
			else
			{
				//alert("上");
				$(this).scrollTop(scrollTop + they);
			}
			//var ulheight = $(this).height();
			
			 //alert(scrollTop);
			// 
        });
		*/
		
		obj.toggle = function() {
			if(_self.hasClass('ui-aside-open')) {
				_self.removeClass('ui-aside-open');
				_self.animate(thisCss, val.sidertime);
				$('.ui-aside-mask').animate({
					'opacity': 0
				}, 100, function() {
					$(this).remove();
				});
			} else {
				_self.addClass('ui-aside-open');
				_self.animate(thisCss2, val.sidertime);
				if(val.hasmask) {
					$('body').append(thisMask);
					$(".ui-aside-mask").animate({
						'opacity': 1
					}, 100);
					thisMask.click(function() {	obj.toggle();});
				}
			}
		}
	/*
		thisMask.click(function() {
			obj.toggle();
		});
		*/

		return obj;
	};
})(window.Zepto || window.jQuery);

