function newWebsite(demo) {
	ins="<div>shū rù wǎng zhàn de yù míng:<br />";
	ins+="e.g. <b>www.yoursitename.com</b>";
	ins+="<div class='failedinput'>";
	ins+="<input type='text' id='urlInput' class='largeinput' onkeydown='return checkDomainValid(event,addWebsite)' onkeyup='validDomain(this)' />";
	ins+="<div id='urlInputAlert' class='alert'></div>";
	ins+="<div id='urlWarning'></div>";
	ins+="</div>";
	ins+="<center><div class='buttonDiv' onclick='";
	if (demo) {
		ins+="startFadeDown();removeTheNode(\"dialog\");";
	}else{
		ins+="addWebsite()";
	}
	ins+="' id='addButton'>tiān jiā</div></center>";
	ins+="</div>";
	startFadeUp();
	pasteRawHTML(returnRoundedBox('dialog','tiān jiā wǎng zhàn',ins,false,10,400,null,true,false),document.body);
	centerObject(objid('dialog'));
	//fadeinobject(objid('dialog'),0,100,null,5);
	objid('urlInput').focus();
}
function validDomain(srcObj) {
	err="";
	domain=srcObj.value;
	domain=domain.replace(/^[a-z]*:\/\//i,'');
	domain=domain.replace(/^www\./i,'');
//	ds=domain.split('/');
//	if (ds.length>1) domain=ds[0];
	if (domain!=srcObj.value) srcObj.value=domain;
	dom=new RegExp(/^[a-zA-Z0-9-\.]*\.[a-zA-Z0-9-]{2,6}$/);
	if (!dom.test(domain)) err="bù shì yǒu xiào de yù";
	setInnerHTML(srcObj.id+"Alert",err);
	if (err=="") {
		srcObj.parentNode.className="normalinput";
		aObj = new JSONscriptRequest('http://bannerpanel.net/dns.php?domain='+domain+'&callback=domainExist');
		aObj.buildScriptTag();
		aObj.addScriptTag();
		//sendPostRequest('/dns.php','domain='+dom,domainExist);
		return true;
	}else{
		srcObj.parentNode.className="failedinput";
		return false;
	}	
}
function cw(msg) {
	return window.confirm(msg);
}
function domainExist(reply) {
	if (reply["exists"]=="1") {
		setInnerHTML("urlInputAlert","yù míngDNS jì lù zhōng zhǎo dào");
		objid("urlInput").parentNode.className="normalinput";
	}else{
		objid("urlInput").parentNode.className="failedinput";
		setInnerHTML("urlInputAlert","zhōng zhǎo bù dào yù deDNS jì lù");
	}
	//setInnerHTML("urlWarning","<div class='warning'>zhòng yào de shì， wǎng yù shì zhèng què de， jí shǐ méi yǒu zhù cè， yīn wèi zhǐURL jiāng bèi guò lǜ， què bǎo zhǐ yǒu nín jiè shào héng fú guǎng gào</div>");
}
function addWebsite() {
	ip=objid("urlInput");
	if (ip.value!="") {
		add=false;
		if (ip.parentNode.className=="failedinput") {
			if (window.confirm("nín què dìng yào tiān jiā "+ip.value+"?")) add=true;
		}else{
			add=true;
		}
		if (add) {
			vars='cmd=addwebsite&url='+ip.value;
			showLoading(ip.parentNode.parentNode,"Adding "+ip.value+"...");
			sendPostRequest('/index.php',vars,receivedSectionContent);
		}
	}
}
var holderSizes=[[728,90],[468,60],[234,60],[125,125],[120,240],[120,90],[120,60],[88,31],[300,250],[250,250],[240,400],[336,280],[180,150],[425,600],[425,500],[425,425],[160,600],[120,600]];
function newholder(srcObj,webid,domain) {
	ins="<div class='normalinput' id='holderform'>tiān jiā chí yǒu rén <b>"+domain+"</b>...<br />";
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>míng zì</b>";
	ins+="<div class='indent'>";
	ins+="<input type='text' id='holdername' maxlength=50 style='width:250px' />";
	ins+="</div>";
	ins+="</div>";
	
	sel="<div class='revealContainer' style='float:right;margin-top:20px'><div>biāo zhǔn chǐ cùn&nbsp;<img src='/"+imgfolder+"/drop.gif' align='absmiddle' /></div>";
	sel+="<div class='revealObject' style='width:120px;text-align:center;max-height:150px;overflow-y:auto'>";
	for(s=0;s<holderSizes.length;s++) {
		sel+="<div class='dropitem' onclick='setSizes("+holderSizes[s][0]+","+holderSizes[s][1]+")'>"+holderSizes[s][0]+" x "+holderSizes[s][1]+"</div>";
	}
	sel+="</div></div>";
	ins+=sel;
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>kuān dù</b>";
	ins+="<div class='indent'>";
	ins+="<div onclick=\"if (objid('fixedWidth').style.display=='none') toggleExpansion('fixedWidth',false,true,'rangeWidth:0:1')\" class='textLink'>gù dìng kuān dù</div>";
	ins+="<div id='fixedWidth'><div class='indent'><input id='widthpoint' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> px</div></div>";
	ins+="<div onclick=\"if (objid('rangeWidth').style.display=='none') toggleExpansion('rangeWidth',false,true,'fixedWidth:0:1')\" class='textLink'>fàn wéi kuān</div>";
	ins+="<div id='rangeWidth' style='display:none'><div class='indent'><input id='widthmin' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> zhì <input id='widthmax' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> px</div></div></div>";
	ins+="</div>";
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>gāo dù</b>";
	ins+="<div class='indent'>";
	ins+="<div onclick=\"if (objid('fixedHeight').style.display=='none') toggleExpansion('fixedHeight',false,true,'rangeHeight:0:1')\" class='textLink'>gù dìng gāo dù</div>";
	ins+="<div id='fixedHeight'><div class='indent'><input id='heightpoint' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> px</div></div>";
	ins+="<div onclick=\"if (objid('rangeHeight').style.display=='none') toggleExpansion('rangeHeight',false,true,'fixedHeight:0:1')\" class='textLink'>gāo dù fàn wéi</div>";
	ins+="<div id='rangeHeight' style='display:none'><div class='indent'><input id='heightmin' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> zhì <input id='heightmax' value='' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' /> px</div></div></div>";
	ins+="</div>";
	
	ins+="<div style='margin-top:10px'>";
	ins+="<div class='alert' id='submiterror'></div>";
	if (webid==0) {
		ins+="<center><div class='buttonDiv' onclick='startFadeDown();removeTheNode(\"dialog\");' id='addButton'>tiān jiā</div></center>";
	}else{
		ins+="<center><div class='buttonDiv' onclick='addHolder("+webid+")' id='addButton'>tiān jiā</div></center>";
	}
	ins+="</div>";
	ins+="</div>";
	startFadeUp();
	pasteRawHTML(returnRoundedBox('dialog','tiān jiā héng fú qū',ins,false,10,400,null,true,false),document.body);
	centerObject(objid('dialog'));
	//fadeinobject(objid('dialog'),0,100,null,5);
}
function setSizes(w,h) {
	objid('widthpoint').value=objid('widthmin').value=objid('widthmax').value=w;
	objid('heightpoint').value=objid('heightmin').value=objid('heightmax').value=h;
}
function addHolder(webid) {
	widths=[0,0];
	heights=[0,0];
	if (objid('fixedWidth').style.display=="none") {
		widths=[objid('widthmin').value*1,objid('widthmax').value*1];
	}else{
		widths=[objid('widthpoint').value*1,objid('widthpoint').value*1];
	}
	if (objid('fixedHeight').style.display=="none") {
		heights=[objid('heightmin').value*1,objid('heightmax').value*1];
	}else{
		heights=[objid('heightpoint').value*1,objid('heightpoint').value*1];
	}
	nom=objid("holdername").value;
	err=new Array();
	if (nom=="") err.push("dìng yì yī gè qū yù míng chēng de qí zhì");
	if (widths[1]<widths[0]) err.push("zuì dà kuān dù dī yú zuì dī");
	if (heights[1]<heights[0]) err.push("zuì gāo gāo dù bù dī yú zuì dī");
	if (widths[0]==0 || widths[1]==0 || heights[0]==0 || heights[1]==0) err.push("nín yǐ jīng wú xiào chǐ cùn");
	if (err.length>0) {
		setInnerHTML("submiterror",err.join("<br />"));
	}else{
		setInnerHTML("submiterror","");
		vars="cmd=addholder&width="+widths.join(",")+"&height="+heights.join(",")+"&name="+nom+"&websiteid="+webid;
		showLoading(objid("holderform"),"tiān jiā "+nom+"...");
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}
}
function newBanner(demo) {
	if (demo) {
		bannerEditor(0,true);
	}else{
		bannerEditor(0);
	}
}
var uploadDisplay=null;
var uploader=null;
function uploadBanner(ref) {
	ins="";
	if (ref>0) {
		ins+="Shàng chuán wénjiàn de yīgè xīn de qízhì";
	}else{
		ins+="Shǒuxiān, shàng chuán yīgè wénjiàn, nǐ de qízhì...";
	}
	maxfiles=1;
	handle="bannerUploaded";
	if (ref>0) handle="bannerUpdated";
	//toInsert=embeduploader("gallerytype=banner&ref="+ref,handle,maxfiles);
	toInsert="<center><div id='flashUploader'></div></center>";
	toInsert+="<div id='uploaderDiv'></div>";
	toInsert+="<center><button id='uploadbutton' class='buttonDiv' style='display:none' onclick='uploader.start()'>upload</button></center>";
	h=(maxfiles*50)+20+25;
	//toInsert="<div style=\"width:300px;height:"+h+"px;overflow:hidden;margin:0px auto\">"+toInsert+"</div>";
	ins+=toInsert;
	if (dv=objid("uploaddialog")) {
		setInnerHTML(dv,ins);
	}else{
		startFadeUp();
		t="Shàng chuán qízhì";
		pasteRawHTML(returnRoundedBox('dialog',t,"<div id='uploaddialog'>"+ins+"</div>",false,10,380,null,true,false),document.body);
		centerObject(objid('dialog'));
	}
		
	uploadDisplay=new uploadDisplay_class(handle);
	uploader=new uploader_class({
		quantity:"1",
		progressHandler:"uploadDisplay.progress",
		selectHandler:"uploadDisplay.selected",
		completeHandler:"uploadDisplay.completed",
		destination:"/upload.php",
		target:"banner",
		ref:ref,
		name:"uploaderObject",
		container:'flashUploader',
		swf_url:'/bpskin/uploader.swf',
		buttonimage:"/bpskin/browse.png",
		cookie:'user'
	});
}
function bannerUpdated() {
	removeTheNode("dialog");
	startFadeDown();
}
function bannerUploaded() {
	showLoading(objid("uploaddialog"),"Tíqǔ xìnxī...");
	sendPostRequest('/index.php','cmd=getUploadInfo',receivedSectionContent);
}
var bannereditid=0;
function bannerEditor(id,demo) {
	bannereditid=id;
	ins="<div class='normalinput' id='bannerform'>";
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>míng zì</b>";
	ins+="<div class='indent'>";
	ins+="<input type='text' id='bannername' maxlength=100 style='width:250px' value='"+((id>0)?"zài rù zhōng":"wú")+"' />";
	ins+="</div>";
	ins+="</div>";
	
	
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>fēn lèi</b>";
	ins+="<div class='indent'>";
	ins+="<div class='revealContainer'><input type='text' id='bannercat' maxlength=100 style='width:250px' value='biāo zhǔn' />";
	ins+="<div class='revealObject' style='width:250px'>";
	if (demo) bannercats=['mine','others','standard'];
	for(i=0;i<bannercats.length;i++) {
		ins+="<div class='dropitem' onclick=\"objid('bannercat').value='"+bannercats[i]+"';\">"+bannercats[i]+"</div>";
	}
	ins+="</div></div>";
	ins+="</div>";
	ins+="</div>";
	
	
	ins+="<div class='indent' style='margin-top:5px'>";
	ins+="<b>deHTML</b>";
	ins+="<div class='indent'>";
	ins+="<textarea id='bannerhtml'>"+((id>0)?"zài rù zhōng":"")+"</textarea>";
	ins+="</div>";
	ins+="</div>";
	
	ins+="<div style='margin-top:10px'><center>";
	ins+="<div class='alert' id='submiterror'></div>";
	ins+="<div id='bannerbutton'>";
	ins+="<div class='buttonDiv' onclick='addBannerNext(";
	if (demo) ins+="true";
	ins+=")' id='addButton'>xià yī gè</div>";
	ins+="</div>";
	ins+="</center></div>";
	
	ins+="</div>";
	if (!objid("blackbox")) startFadeUp();
	t="tiān jiā qí zhì";
	if (id>0) t="qí zhì biān jí";
	pasteRawHTML(returnRoundedBox('dialog',t,ins,false,10,380,"previewContainer",true,false),document.body);
	centerObject(objid('dialog'));
	//fadeinobject(objid('dialog'),0,100,null,5);
	if (id>0) sendPostRequest('/index.php','cmd=loadBannerData&bannerid='+id,receivedSectionContent);
}
var bannermaxsize=[0,0];
var demo=false;
function addBannerNext(d) {
	demo=d;
	removeTheNode("previewContainer");
	bannermaxsize=[0,0];
	html=objid("bannerhtml").value;
	img=/<img/im;
	obj=/<object/im;
	if (obj.test(html)) {
		wx=/width\=[\D]?([\d]*)(?=[\D]*)/gim;
		w=html.match(wx);
		if (w) {
			for(i=0;i<w.length;i++) {
				f=w[i].replace(/width\=[\D]?/i,'');
				if (bannermaxsize[0]<f) bannermaxsize[0]=f;
			}
		}
		hx=/height\=[\D]?([\d]*)(?=[\D]*)/gim;
		h=html.match(hx);
		if (h) {
			for(i=0;i<h.length;i++) {
				f=h[i].replace(/height\=[\D]?/i,'');
				if (bannermaxsize[1]<f) bannermaxsize[1]=f;
			}
		}
		showAddBannerButton();
		// regex match dimensions of object
	}else if (img.test(html)) {
		showLoading(objid("bannerbutton"),"tí qǔ qí zhì...");
		html=html.replace(/<img/i,"<img onload='imgloaded()' ");
		ins="<div style='position:absolute;top:0px;visibility:hidden' id='previewContainer'><table cellpadding=0 cellspacing=0><tr><td id='bannerpreview'>"+html+"</td></tr></table></div>";
		pasteRawHTML(ins,document.body);
	}else{
		dropThisMessage("zhǎo bù dào chǐ cùn");
	}
}
function imgloaded() {
	var t=setTimeout("gotBannerSize()",200)
}
function gotBannerSize() {
	imgs=objid("previewContainer").getElementsByTagName("IMG");
	for(i=0;i<imgs.length;i++) {
		srcObj=imgs[i];
		w=srcObj.clientWidth;
		h=srcObj.clientHeight;
		if (w>bannermaxsize[0]) bannermaxsize[0]=w;
		if (h>bannermaxsize[1]) bannermaxsize[1]=h;
	}
	showAddBannerButton(demo);
}
function showAddBannerButton() {
	ins="<div class='buttonDiv' onclick='addBannerNext()' id='addButton'>chóng xīn jiǎn chá</div>";
	ins+="<div style='margin:5px 20px'>";
	ins+="què bǎo yǐ xià de chǐ cùn shì zhèng què de， rán hòu bǎo cún...<br />";
	ins+="<input value='"+bannermaxsize[0]+"' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' id='bannerWidth' />&nbsp;x&nbsp;<input value='"+bannermaxsize[1]+"' type='text' onkeydown='return checkNumericOnly(event,null)' maxlength=4 style='width:50px' id='bannerHeight' /> xiàng sù";
	ins+="</div>";
	if (demo) {
		ins+="<div class='buttonDiv' onclick='startFadeDown();removeTheNode(\"dialog\")' id='saveButton'>bǎo cún</div>";
	}else{
		ins+="<div class='buttonDiv' onclick='saveNewBanner()' id='saveButton'>bǎo cún</div>";
	}
	setInnerHTML("bannerbutton",ins);
}
function saveNewBanner() {
	nom=objid("bannername").value;
	w=objid("bannerWidth").value*1;
	h=objid("bannerHeight").value*1;
	cat=objid("bannercat").value;
	thehtml=objid("bannerhtml").value;
	if (nom!="wú" && nom!="" && w>0 && h>0 && cat!="" && thehtml!="") {
		vars="cmd=addBanner&name="+encodeUpload(nom)+"&category="+encodeUpload(cat)+"&code="+encodeUpload(thehtml)+"&width="+w+"&height="+h;
		if (bannereditid>0) vars+="&bannerid="+bannereditid;
		removeTheNode("previewContainer");
		showLoading(objid("bannerbutton"),"bǎo cún qí zhì...");
		//alert(vars);
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}else{
		err=new Array();
		if (nom="untitled" || nom=="") err.push("nín bì xū mìng míng nǐ de qí zhì");
		if (w<1) err.push("nín de qí zhì kuān dù shàng wèi què dìng");
		if (h<1) err.push("nín de qí zhì de gāo dù shàng wèi què dìng");
		if (cat=="") err.push("qí zhì lèi méi yǒu bèi dìng yì");
		if (thehtml=="") err.push("qí zhì deHTML shàng wèi què dìng");
		if (err.length>0) {
			dropThisMessage(err.join("<br />"));
		}
	}
}
function loadmanageHolder(id) {
	setInnerHTML("wideblock",basicBlock("héng fú qū yù jīng lǐ","<div id='placeholdermanager'><center><img src='/"+imgfolder+"/loading.gif' /></center></div>","100%"));
	vars="cmd=loadmanageHolder&holderid="+id;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function loadStatsHolder(id) {
	setInnerHTML("wideblock",basicBlock("héng fú fāng miàn de tǒng jì","<div id='placeholdermanager'><center><img src='/"+imgfolder+"/loading.gif' /></center></div>","100%"));
	vars="cmd=loadStatsHolder&holderid="+id;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function loadmanageBanner(id) {
	setInnerHTML("wideblock",basicBlock("qí zhì jīng lǐ","<div id='placeholdermanager'><center><img src='/"+imgfolder+"/loading.gif' /></center></div>","100%"));
	vars="cmd=loadmanageBanner&bannerid="+id;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function loadstatisticsBanner(id) {
	setInnerHTML("wideblock",basicBlock("qí zhì tǒng jì","<div id='placeholdermanager'><center><img src='/"+imgfolder+"/loading.gif' /></center></div>","100%"));
	vars="cmd=loadstatisticsBanner&bannerid="+id;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function showClicks() {
	setInnerHTML("wideblock",basicBlock("Banner clicks","<div id='placeholdermanager'><center><img src='/"+imgfolder+"/loading.gif' /></center></div>","100%"));
	vars="cmd=loadClicks";
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function attachBanner(srcObj,bid,hid,attach) {
	srcObj.parentNode.innerHTML="<em>"+(attach?"fù jiā":"shān chú")+"...</em>";
	vars="cmd=attachBanner&bannerid="+bid+"&holderid="+hid+""+(attach?"&attaching=1":"");
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function attachToHolder(srcObj,bid,hid,attach) {
	srcObj.parentNode.innerHTML="<em>"+(attach?"fù jiā":"shān chú")+"...</em>";
	vars="cmd=attachBanner&bannerid="+bid+"&holderid="+hid+"&"+(attach?"attaching=1&":"")+"bannermanager=1";
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function removeHolder(srcObj,hid) {
	srcObj.parentNode.innerHTML="<em>shān chú...</em>";
	vars="cmd=removeHolder&holderid="+hid;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function basicBlock(header,content,width) {
	reply="<table cellpadding=0 cellspacing=0";
	if (width!=null && width!="") reply+=" style='width:"+width+"'";
	reply+=">";
	if (header=="" || header==null) {
		reply+="<tr><td class='tl'>&nbsp;</td><td class='t'>&nbsp;</td><td class='tr'>&nbsp;</td></tr>";
		reply+="<tr><td class='l'>&nbsp;</td><td class='c'>"+content+"</td><td class='r'>&nbsp;</td></tr>";
		reply+="<tr><td class='bl'>&nbsp;</td><td class='b'>&nbsp;</td><td class='br'>&nbsp;</td></tr>";
	}else{
		if (imgfolder=="malskin") {
			reply+="<tr><td class='tl'>&nbsp;</td><td class='t'>&nbsp;</td><td class='tr'>&nbsp;</td></tr>";
			reply+="<tr><td class='l'>&nbsp;</td><td class='h'>"+header+"</td><td class='r'>&nbsp;</td></tr>";
		}else{
			reply+="<tr><td class='hl'>&nbsp;</td><td class='h'>"+header+"</td><td class='hr'>&nbsp;</td></tr>";
		}
		reply+="<tr><td class='l'>&nbsp;</td><td class='c' style='padding-top:4px'>"+content+"</td><td class='r'>&nbsp;</td></tr>";
		reply+="<tr><td class='bl'>&nbsp;</td><td class='b'>&nbsp;</td><td class='br'>&nbsp;</td></tr>";
	}
	reply+="</table>";
	return reply;
}
function moveProportion(srcObj,e,id) {
	loc=eventLocation(e);
	dragoffsetx=loc[0]-getLeft(srcObj);
	if (dragoffsetx<6) dragoffsetx=6;
	if (dragoffsetx>106) dragoffsetx=106;
	val=dragoffsetx-6;
	if (!objid("slider")) {
		ins="<div id='slider'><span id='propval'></span></div>";
		pasteRawHTML(ins,objid("slideContainer"+id));
	}
	slider=objid("slider");
	slider.style.left=(dragoffsetx-4)+"px";
	objid("propval").innerHTML=val;	
}
function setProportion(srcObj,e,id) {
	loc=eventLocation(e);
	dragoffsetx=loc[0]-getLeft(srcObj);
	if (dragoffsetx<6) dragoffsetx=6;
	if (dragoffsetx>106) dragoffsetx=106;
	val=dragoffsetx-6;
	if (id=="0") {
		p=srcObj.parentNode;
		for(k=0;k<p.childNodes.length;k++) {
			if (p.childNodes[k].className=="slideon") p.childNodes[k].style.width=(val+6)+"px";
			if (p.childNodes[k].className=="slideoff") p.childNodes[k].style.width=(106-val)+"px";
		}
	}else{
		srcObj.parentNode.innerHTML="<img src='/"+imgfolder+"/slidersaving.gif' />";
		vars="cmd=setProportion&displayid="+id+"&value="+val;
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}
}
function preview(bannerid,w,h) {
	startFadeUp();
	ins="<div id='bannerpreview' style='width:"+w+"px;height:"+h+"px'><table cellpadding=0 cellspacing=0><tr><td style='vertical-align:middle;text-align:center'><img src='/"+imgfolder+"/loading.gif' /></td></tr></table></div>";
	dw=26;
	if (imgfolder=='malskin') dw=30;
	pasteRawHTML(returnRoundedBox('dialog','qí zhì yù lǎn',ins,false,10,w+dw,null,true,false),document.body);
	centerObject(objid('dialog'));
	fadeinobject(objid('dialog'),0,100,null,5);
	vars="cmd=preview&bannerid="+bannerid;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function editBanner(bannerid) {
	bannerEditor(bannerid);
}
function deleteObject(srcObj,websiteid,holderid,bannerid) {
	vars="";
	if (websiteid) {
		if (window.confirm("shān chú cǐ wǎng zhàn？")) vars+="cmd=removeObject&websiteid="+websiteid;
	}
	if (holderid) {
		if (window.confirm("shān chú zhè fāng miàn de？")) vars+="cmd=removeObject&holderid="+holderid;
	}
	if (bannerid) {
		if (window.confirm("shān chú zhè miàn qí zhì？")) vars+="cmd=removeObject&bannerid="+bannerid;
	}
	if (vars!="") {
		srcObj.parentNode.innerHTML="shān chú...";
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}
}
function logoff(src) {
	src.innerHTML="dēng chū...";
	var vars="cmd=logout";
	sendPostRequest("/index.php",vars,logoutReceived);
}
function logoutReceived(reply) {
	window.location="/";
}
function setLanguage(code) {
	objid("languageSelector").innerHTML="<div class='selected'><img src='/miniflags/"+code.toUpperCase()+".png' align='absmiddle' /> zài rù zhōng...</div>";
	vars='cmd=setLanguage&newlanguage='+code;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function displayRotate() {
	objid('rotateBox').className=((objid('rotateminutes').style.display=="none")?"rotateon":"rotateoff");
	if (objid('rotateminutes').style.display=="block") {
		hid=objid('holderidfield').value;
		objid('rotateValue').value='0';
		vars='cmd=setrotate&holderid='+hid+'&rotatevalue=0&reply=none';
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}
	toggleExpansion('rotateminutes',false,true,'');
}
function setrotate() {
	hid=objid('holderidfield').value;
	vars='cmd=setrotate&holderid='+hid+'&rotatevalue='+objid('rotateValue').value;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function blockDomain(id,hid,block) {
	objid("block"+id).innerHTML="<em>"+(block?"zǔ sè":"jiě fēng")+"...</em>";
	vars='cmd=blockDomain&dib='+id+'&holderid='+hid+'&block='+block;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function loadCodes(hid) {
	showLoading(objid("codeblock"),"zài rù zhōng...");
	sendPostRequest('/index.php','cmd=loadCode&holderid='+hid,receivedSectionContent);
}
function displayClipboard() {
	var flashvars = {};
	var params = {};
	params.menu = "false";
	params.allowScriptAccess = "sameDomain";
	params.swliveconnect = "true";
	params.wmode = "transparent";
	params.bgcolor = "#ffffff";
	var attributes = {};
	attributes.id = "clipboardswf";
	attributes.name = "clipboardswf";
	swfobject.embedSWF("/"+imgfolder+"/clipboard.swf", "flashclip", "330", "50", "9.0.0","expressInstall.swf", flashvars, params, attributes);
}
function getToCopy() {
	return objid('theHTML').value;
}
function callFunction(func,vars) {
	vars="cmd="+func+vars;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
function setBubble(e,txt) {
	if (!bubbles) {
		objid('bubblecontent').innerHTML=txt;
		b=objid('bubble');
		b.style.display='block';
		moveBubble(e);
	}
}
function moveBubble(e) {
	if (!bubbles) {
		b=objid('bubble');
		loc=eventLocation(e);
		b.style.left=(loc[0]-88)+"px";
		b.style.top=(loc[1]-b.clientHeight-10)+"px";
	}
}
function clearBubble() {
	objid('bubble').style.display='none';
}
function sysObject(srcObj,hid,sys) {
	sendPostRequest('/index.php','cmd=sysHolder&holderid='+hid+'&sys='+sys,receivedSectionContent);
}
function processEmails(from) {
	subj=encodeUpload(objid("emailsubject").value);
	cont=encodeUpload(objid("emailcontent").value);
	if (objid("adminonly").checked) from+='&admin=1';
	sendPostRequest('/index.php','cmd=processEmails&subject='+subj+'&content='+cont+'&from='+from,receivedSectionContent);
}
function updateUpload(srcObj,id) {
	warn="";
	w=objid("bannerwidth").value*1;
	h=objid("bannerheight").value*1;
	u=objid("bannerurl").value;
	dom=new RegExp(/^[a-zA-Z]*:\/\/[a-zA-Z0-9-\.]+/);
	if (!dom.test(u)) warn+="<div>Quèbǎo nín de mùbiāo wǎngzhǐ shì yǒuxiào de</div>";
	if (w<1) warn+="<div>Kuāndù sìhū bìng méiyǒu yǒuxiào</div>";
	if (h<1) warn+="<div>Gāodù sìhū bìng méiyǒu yǒuxiào</div>";
	objid("updatewarning").innerHTML=warn;
	if (warn=="") {
		srcObj.parentNode.innerHTML="Gēngxīn...";
		vars='cmd=updateUpload&fileid='+id+'&width='+w+'&height='+h+'&url='+encodeUpload(u);
		sendPostRequest('/index.php',vars,receivedSectionContent);
	}
}
function toggleBubbles(srcObj) {
	bubbles=1-bubbles;
	srcObj.src='/'+imgfolder+'/bubble'+(bubbles?"on":"off")+'.png';
	vars="cmd=setbubble&value="+bubbles;
	sendPostRequest('/index.php',vars,receivedSectionContent);
}
