function loadOver(){
	$(".loading").fadeOut(300);
	$(".loading").hide();
}
function printObj(obj){
	$('#printShow').html(obj.html());
	window.print();
}
function favorite(){
	addfavorite(window.location.href,document.title);
}
function addfavorite(sURL, sTitle){
   if (document.all){
      window.external.addFavorite(sURL,sTitle);
   }else if (window.sidebar){
      window.sidebar.addPanel(sTitle, sURL, "");
   }
}
function showdiv(id,obj){
	if(obj){
		var top=($(obj).offset().top-(-20))+'px';
		var left=$(obj).offset().left+'px';
		$('#'+id).css('position','fixed').css('left',left).css('top',top);
	}
	$('#'+id).show(300);
}
function hidediv(id){
	$('#'+id).hide(100);
}

//提交表单
function subForm(fid) {
	$('#' + fid).submit();
}
// 把表单变成可以提交用的params,不支持文件
function formToParam(form) {
	var params = {};
	$('#' + form + ' input').each( function() {
		if ($(this).attr('name')) {
			params[$(this).attr('name')] = $(this).val();
		}
	});
	$('#' + form + ' select').each( function() {
		if ($(this).attr('name')) {
			params[$(this).attr('name')] = $(this).val();
		}
	});
	$('#' + form + ' textarea').each( function() {
		if ($(this).attr('name')) {
			params[$(this).attr('name')] = $(this).val();
		}
	});
	$('#' + form + ' button').each( function() {
		if ($(this).attr('name')) {
			params[$(this).attr('name')] = $(this).val();
		}
	});
	return params;
}
// /////////////////////////////////后台部分////////////////////
/*
 * 根据值获得select的Text
 */
function selectText(obj) {
	var val = obj.val();
	var str = '';
	obj.find('option').each( function() {
		if ($(this).attr('value') == val)
			str = $(this).html();
	})
	return str;
}
/*
 * 设定修改表单的数据
 */
function editFunEmpty(obj,formid) {
	var fieldName = '';
	if(!formid) formid='';
	$(formid+':input').each( function() {
		fieldName = $(this).attr('name');
		if (fieldName && obj[fieldName] && !$(this).val()) {
			switch ($(this).attr('type')) {
			case 'radio':
				$(formid+':radio[name="'+fieldName+'"][value="'+obj[fieldName]+'"]').attr('checked', 'checked');
				break;
			case 'file':
			case 'checkbox':
				break;
			default:
				$(this).val(obj[fieldName]);
			}
		}
	})
	$(formid+':checkbox').each( function() {
		fieldName = $(this).attr('name').replace('[]','');
		var chkObj=$(this);
		var chkVal=obj[fieldName];
		$.each(chkVal,function (key,val){
			if(chkObj.val()==val){
				chkObj.attr('checked', 'checked');
			}
		})
	});
}
function editFun(obj,formid) {
	var fieldName = '';
	if(!formid) formid='';
	$(formid+':input').each( function() {
		fieldName = $(this).attr('name');
		if (fieldName && obj[fieldName]) {
			switch ($(this).attr('type')) {
			case 'radio':
				$(formid+':radio[name="'+fieldName+'"][value="'+obj[fieldName]+'"]').attr('checked', 'checked');
				break;
			case 'file':
			case 'checkbox':
				break;
			default:
				$(this).val(obj[fieldName]);
			}
		}
	});
	$(formid+':checkbox').each( function() {
		fieldName = $(this).attr('name').replace('[]','');
		var chkObj=$(this);
		var chkVal=obj[fieldName];
		$.each(chkVal,function (key,val){
			if(chkObj.val()==val){
				chkObj.attr('checked', 'checked');
			}
		})
	});
}
/*
 * 跳转到某个页面
 */
function go(url) {
	window.location.href = url;
}
function reload(){
	window.location.reload();
}

