<?php if(!defined('HOST'))die('not access');?>
<script >
$(document).ready(function(){
	var c = {
		xuanzhi:'',
		init:function(){
			js.ajax(js.getajaxurl('getbeijing','{mode}','{dir}'),false,function(ret){
				c.showdata(ret.data);
			},'get,json');
		},
		showdata:function(das){
			var s='',s1='',da=das.rows;
			if(da)for(var i=0;i<da.length;i++){
				if(da[i]==das.dev){
					s1=this.showimg(da[i],'checked');
				}else{
					s+=this.showimg(da[i]);
				}
			}
			$('#showimg_{rand}').append(s1+s);
		},
		showimg:function(lj,cd2){
			if(!cd2)cd2='';
			return '<div style="width:100px;height:100px;overflow:hidden;border:1px #eeeeee solid;margin:10px;float:left"><label><div><img width="100%" src="'+lj+'"></div><input '+cd2+' type="radio" value="'+lj+'" name="beijingqie" onclick="benjiqhesst(this)"></label></div>';
		},
		qieces:function(lj){
			this.xuanzhi = lj;
			if(!get('mainindexhome'))return;
			get('mainindexhome').style.background='url('+lj+')';
		},
		saveqian:function(){
			if(!this.xuanzhi){
				js.msgerror('没有选中背景图片');return;
			}
			js.loading('保存中...');
			js.ajax(js.getajaxurl('savebeijing','{mode}','{dir}'),{value:this.xuanzhi},function(){
				js.msgok('保存成功');
			},'post');
		}
	}
	
	js.initbtn(c);
	c.init();
	
	benjiqhesst=function(o1){
		c.qieces(o1.value);
	}
	
	shangchuangimgss=function(){
		js.upload('_shangchuangimgs',{maxup:'1','title':'上传自定义背景图片',uptype:'jpg','urlparams':'noasyn:yes'});	
	}
	_shangchuangimgs=function(bda,xid){
		var f = bda[0];
		if(f){
			$('#addbnt{rand}').after(c.showimg(f.filepath));
		}
	}
});
</script>


<div>
<input class="btn btn-success" click="saveqian" value="保存背景" type="button">
<font color="gray">背景图片必须jpg格式，大小建议在：1500x1000以上，默认背景图片读取images/beijing目录下的jpg文件。</font>
</div>
<div class="blank10"></div>
<div id="showimg_{rand}" style="display:inline-block">
	<div class="cursor" id="addbnt{rand}" onclick="shangchuangimgss()" style="width:100px;height:100px;overflow:hidden;border:1px #eeeeee solid;margin:10px;float:left"><div><img width="100%" src="images/jia.png"></div></div>
</div>