function w_and_h(h,w){
	var bw=($(window).width()-200);
	var bh=($(window).height()-100);
	var left=((bw/2)-w)+'px';
	var top=((bh/2)-h)+'px';
	return [top,left];
}

layui.use(['element', 'layer', 'util'], function(){
	var element = layui.element
	,layer = layui.layer
	,util = layui.util
	,$ = layui.$;
	
	//头部事件
	util.event('lay-header-event', {
		
		//头部全屏事件
		fullscreen: function(othis){

			var element = document.documentElement;		// 返回 html dom 中的root 节点 <html>
			if(!$('body').hasClass('full-screen')) {
				$('body').addClass('full-screen');
				$('#alarm-fullscreen-toggler').addClass('active');
				// 判断浏览器设备类型
				if(element.requestFullscreen) {
					element.requestFullscreen();
				} else if (element.mozRequestFullScreen){	// 兼容火狐
					element.mozRequestFullScreen();
				} else if(element.webkitRequestFullscreen) {	// 兼容谷歌
					element.webkitRequestFullscreen();
				} else if (element.msRequestFullscreen) {	// 兼容IE
					element.msRequestFullscreen();
				}
			} else {			// 退出全屏
				$('body').removeClass('full-screen');
				$('#alarm-fullscreen-toggler').removeClass('active');
				//	退出全屏
				if(document.exitFullscreen) {
					document.exitFullscreen();
				} else if (document.mozCancelFullScreen) {
					document.mozCancelFullScreen();
				} else if (document.webkitCancelFullScreen) {
					document.webkitCancelFullScreen();
				} else if (document.msExitFullscreen) {
					document.msExitFullscreen();
				}
			}
		}

		//左侧菜单事件
		,LeftOpen: function(othis){
			$('.layui-logo').animate({ width:'50px' });
			$('.layui-side-left').animate(
				{ left:'0px', width:'50px' },
				function(){ 
							$('.layui-side-left').addClass('layui-side-w');
							$('.layui-side-left ul').css('height','50px');
							$('.layui-side-left .tq_nav ul .one').attr('class','');
							//$('.layui-logo img').animate({ left:'-30px',bottom:'-10px',width:'165px',height:'57px'});
							$('.layui-logo img').attr('src','/static/tqcms/img/logo1.png');
							$('.layui-logo img').css({'width':40,'left':3});
						  }
			);
			$('.layui-tags').animate({ left:'50px' });
			$('.layui-body').animate({ left:'50px' });
			$('.layui-layout-left').animate({ left:'50px' });
			$('.left_switch').attr('lay-header-event','LeftClose');
			$('.left_switch i').removeClass('layui-icon-shrink-right');
			$('.left_switch i').addClass('layui-icon-spread-left');
		}

		,LeftClose: function(othis){
			$('.layui-logo').animate({ width:'200px' });
			$('.layui-side-left').animate(
				{ left:'0px', width:'200px' },
				function(){ 
							$('.layui-side-left').removeClass('layui-side-w');
							$('.layui-side-left ul').css('height','37px');
							$('.layui-side-left .tq_nav ul > li').addClass('one');
							$('.layui-logo img').attr('src','/static/tqcms/img/logo.png');
							$('.layui-logo img').attr('style','');
						  }
			);
			$('.layui-tags').animate({ left:'200px' });
			$('.layui-body').animate({ left:'200px' });
			$('.layui-layout-left').animate({ left:'200px' });
			$('.left_switch').attr('lay-header-event','LeftOpen');
			$('.left_switch i').removeClass('layui-icon-spread-left');
			$('.left_switch i').addClass('layui-icon-shrink-right');
		}

		,menuRight: function(){
			layer.open({
				type: 1
				,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
				,area: ['260px', '100%']
				,offset: 'rt' //右上角
				,anim: 5
				,shadeClose: true
			});
		}

		,AdminEdit: function(){

			var index = layer.open({
				type: 2,
				area:["634px", "390px"],
				fixed: false,
				maxmin: false,
				content:'/admin/Admin/admin_edit',
				end: function(index,layero){
					layer.close(index);
					return false; 
				}  
			});
			layer.title('修改信息',index);
		}
	});



  
});