function openwin(winname)
{
	window.open(winname,'','directions=no,scrollbars=yes,resizable=yes,menubar=no,top=0,left=0,width=555,height=450');
}

function getActiveText()
{
	frmDiary.con.currPos=document.selection.createRange();
}

function insertText(str)
{
	try
	{
		if(frmDiary.con.currPos.text.length==0)
		{
			frmDiary.con.currPos.text=str
		}
		else
		{
			frmDiary.con.currPos.text=str.replace("把文字写在这里可看到效果",frmDiary.con.currPos.text)
		}
	}
	catch(e)
	{
		frmDiary.con.value+=str
	}
}

function addtag(tag,value)
{
	switch(tag)
	{
		case "color":
			insertText("[font color="+value+"]把文字写在这里可看到效果[/font]");
			break;
		case "img":
			insertText("[img]"+value+"[/img]");
			break;
		default:
			insertText("["+tag+"]把文字写在这里可看到效果[/"+tag+"]");
			break;
	}
}

function WriteDiary(nType)
{
	window.location.href="add"+nType+".asp"
}

function SetPictureLimit(sLimit)
{
	picture.innerHTML=sLimit;
}
	
function ShowPeitu(nPeitu,nArtid,sImageType)
{
	if(nPeitu==-1)
	{
		document.all("previewimg").src="systemimage/peitu"+nArtid+"."+sImageType;
		document.all("previewimg").width=150;
		document.all("previewimg").height=60;
	}
	else
		document.all("previewimg").src="systemimage/peitu"+nPeitu+"s.jpg"
}
	
function SwitchViewPass(nType)
{
	if(nType==0)
	{
		document.all("rdView")(0).checked=true
		document.all("spanviewpass").style.display="none";
	}
	else
	{
		document.all("rdView")(1).checked=true
		document.all("spanviewpass").style.display="";
	}
}
	
function SetCurrentXinQing(sXinQing)
{
	var xinqing=document.all("xinqing")
	for(var i=0;xinqing.options.length;i++)
	{
		if(xinqing.options[i].value==sXinQing)
		{
			xinqing.options[i].selected=true;
			return;
		}
	}
}
	
function SetCurrentWeather(sWeather)
{
	var weather=document.all("weather")
	for(var i=0;weather.options.length;i++)
	{
		if(weather.options[i].value==sWeather)
		{
			weather.options[i].selected=true;
			return;
		}
	}
}
	
function SetCurrentPosition(nPosition)
{
	document.all("rdPosition")(nPosition-1).checked=true
}

function SetCurrentPeitu(nPeitu)
{
	if(nPeitu!=-1)
		document.all("peitu").selectedIndex=nPeitu-1;
	else
		document.all("peitu").selectedIndex=0;
}

function InitPeitu(nPosition)
{
	//var va=new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
	//var ta=new Array("等待","等待","风雪","风雪","鲜花","鲜花","咖啡","咖啡","饰品","饰品","烛光","烛光","月色","月色","豆子","百花","海边","家室","汉堡","快餐","侯鸟","盼望","玫瑰","清爽","叶子","三叶","阳光","私语","水果","甜蜜");
	var va=new Array(16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
	var ta=new Array("百花","等待","等待","风雪","风雪","鲜花","鲜花","咖啡","咖啡","饰品","饰品","烛光","烛光","月色","月色","豆子","海边","家室","汉堡","快餐","侯鸟","盼望","玫瑰","清爽","叶子","三叶","阳光","私语","水果","甜蜜");
    var tbprompt="上下型(396X406)";
	var lrprompt="左右型(880X220)";
	var peitu=document.all("peitu");
	var op;
	while(peitu.options.length>0) 
	{
			peitu.options.remove(0);
	}
	switch(nPosition)
	{
		case 1:
		case 2:
			for(var i=0;i<va.length;i+=2)
			{
				op=document.createElement("OPTION");
				op.value=va[i];
				op.text=ta[i]+tbprompt;
				peitu.options.add(op);
			}
			break;
		case 3:
		case 4:
			for(var i=1;i<va.length;i+=2)
			{
				op=document.createElement("OPTION");
				op.value=va[i];
				op.text=ta[i]+lrprompt;
				peitu.options.add(op);
			}
			break;
	}
}

