var linkCustom={
	linkBlock:function(){
		myajax.ajaxlink("/servlet/wa/Channel?handle=linkBlock","","linkBlock",true);
	},
	
	del:function(linkCustomId){
		myajax.postJSON('/servlet/wa/Channel?handle=delLinkCustom','&linkCustomId='+linkCustomId,linkCustom.delCB,true);	
	},
	
	delCB:function(jsonData){
		linkCustom.linkBlock();
		alert(jsonData.msg);	
	},
	
	edit:function(linkCustomId){
		openBox('/servlet/wa/Channel?handle=editLinkCustom&linkCustomId='+linkCustomId,'修改网址',350,200,false);
	},
	
	add:function(){
		openBox('/servlet/wa/Channel?handle=addLinkCustom','添加网址',350,200,false);
	},
	
	addPost:function(){
		var theform=document.addLinkCustomForm;
		if(theform.name.value.trim()==""){
			alert("请输入网站名称！");
			theform.name.focus();
			return;
		}
		if(theform.url.value.trim()==""){
			alert("请输入网址！");
			theform.url.focus();
			return;
		}

		theform.Submit.disabled=true;
		myajax.submitformJSON("addLinkCustomForm",linkCustom.addPostCB,true);	
	},
	
	addPostCB:function(jsonData){
		alert(jsonData.msg);
		var theform=document.addLinkCustomForm;
		if(jsonData.flag==1){
			closeBox();
			linkCustom.linkBlock();
		}else if(jsonData.flag==2){
			alert("请输入网站名称！");
			theform.name.focus();
			theform.Submit.disabled=false;
		}else if(jsonData.flag==3){
			alert("请输入网址！");
			theform.url.focus();			
			theform.Submit.disabled=false;
		}else{
			closeBox();			
		}
	},
	
	editPost:function(){
		var theform=document.editLinkCustomForm;
		if(theform.name.value.trim()==""){
			alert("请输入网站名称！");
			theform.name.focus();
			return;
		}
		if(theform.url.value.trim()==""){
			alert("请输入网址！");
			theform.url.focus();
			return;
		}

		theform.Submit.disabled=true;
		myajax.submitformJSON("editLinkCustomForm",linkCustom.editPostCB,true);	
	},
	
	editPostCB:function(jsonData){
		alert(jsonData.msg);
		var theform=document.editLinkCustomForm;
		if(jsonData.flag==1){
			closeBox();
			linkCustom.linkBlock();
		}else if(jsonData.flag==2){
			alert("请输入网站名称！");
			theform.name.focus();
			theform.Submit.disabled=false;
		}else if(jsonData.flag==3){
			alert("请输入网址！");
			theform.url.focus();			
			theform.Submit.disabled=false;
		}else{
			theform.Submit.disabled=false;			
		}
	}
	
	
}
