function $obj(id) {
	return document.getElementById(id);
}

function setButtonDisable(b,c){
	var d=$obj(b);
	if(d)if(!c&&arguments.length==2)window.setTimeout("setButtonDisable('"+b+"',false,0);",40);
	else{
		d.disabled=c;d=d.parentNode.parentNode;var e="";if(d.className.indexOf("minbtn-wrap")>-1)e="minbtn-disable";else if(d.className.indexOf("btn-wrap")>-1)e="btn-disable";
		if(e)c?addCssClass(d,e):removeCssClass(d,e)
	}
}

function noneblock(targetid){
	var ifview = document.getElementsByTagName("a");
    var target = document.getElementById(targetid);
	
	target.style.display = target.style.display == 'none' ? 'block' : 'block';
}

function CleanHtml(content)
{
  	content = content.replace(/<p>/gi,"\n\r");
	content = content.replace(/<br>/gi,"\n");
	content = content.replace(/&nbsp;/gi," ");
  	content = content.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
  	content = content.replace(/<\\?\?xml[^>]*>/gi, "") ;
  	content = content.replace(/o:/gi, "");
  	content = content.replace(/ /gi, " ");
	return content;
}

function AvatarSubmit()
{
	if(document.form1.mymps_member_logo.value=="")
	{
   		document.form1.mymps_member_logo.focus();
   		alert("请选择你要上传的文件！");
   		return false;
	}
}

function CertifySubmit()
{
	if(document.form1.certify_image.value=="")
	{
   		document.form1.certify_image.focus();
   		alert("请选择你要上传的文件！");
   		return false;
	}
}

function AlbumSubmit(){
	if(document.form1.title.value=="")
	{
   		document.form1.title.focus();
   		alert("相片标题不能为空！");
   		return false;
	} else if(document.form1.album_up.value==""){
   		document.form1.album_up.focus();
   		alert("请选择你要上传的文件！");
   		return false;
	}
}

function SeePic(img,f){
   if ( f.value != "" ) { img.src = f.value; }
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length-1;i++)
	{
		var e = form.elements[i];
		if( e.type == 'checkbox'){
			e.checked = ifcheck;
		}
	}
	ifcheck = ifcheck == false ? true : false;
}
function removeElement(obj){
	var text = $(obj).parent().text();
	text = text.substring(0,text.length-1);
	json = $("#currentClass").val();
	if(json){
		json = JSON.parse(json);
	}else{
		json={};
	}
	delete json[text];
	$("#currentClass").val( JSON.stringify(json) );
	$(obj).parent().remove();
}

function addClass(){
	var ele = $("#intName");
	var json = $("#currentClass").val();
	if(json){
		json = JSON.parse(json);
	}else{
		json={};
	}
	var input = ele.val();
	if(input){
		
		if(ele.parent().children().length>12){
			alert("最多只能添加12个分类");
			return false;
		}
		for(var i =0,allElement = ele.parent().children();i<allElement.length;i++){
			if(allElement[i].nodeName === "SPAN"){
				if(allElement[i].innerText==(input+"X")){
					alert("存在相同栏目名");
					return false;
				}
			}
		}
		var ele_span = $('<span class=mclass>'+input+'<span class=x title=删>X</span></span>');
		ele_span.insertBefore(ele);
		ele_span.find("span").click(function(){
			removeElement(this);
		});
		json[input]="";
		$("#currentClass").val( JSON.stringify(json) );
	}else{
		alert("请输入栏目名称");
	}
}
ifcheck = true;