var Isfresh = 1;
function showFace()
{
    var imgpath = "/popface2/";
    face_1 = document.Form1.face1.value;
	face_2 = document.Form1.face2.value;
	face_3 = document.Form1.face3.value;
	face = imgpath+face_1+face_2+face_3+".gif";
	show_file2 = '<img src='+face+'>';
	document.all.show2.innerHTML=show_file2;
}

function PreFace(){
    var face_1=parseInt(document.all.face1.selectedIndex);
    var face_2=parseInt(document.all.face2.selectedIndex);
    var face_3=parseInt(document.all.face3.selectedIndex);
    if(face_3 > 0){
        document.all.face3.selectedIndex = face_3 -1
        showFace();
    }
    else{
        if(face_2 >0){
            document.all.face2.selectedIndex = face_2 -1
            document.all.face3.selectedIndex = 9
            showFace();
        }
        else{
            if(face_1 >0){
                document.all.face1.selectedIndex = face_1 -1
                document.all.face2.selectedIndex = 9
                document.all.face3.selectedIndex = 9
                showFace();
            }
        }
    }
}

function NextFace(){
    var face_1=parseInt(document.all.face1.selectedIndex,10);
    var face_2=parseInt(document.all.face2.selectedIndex,10);
    var face_3=parseInt(document.all.face3.selectedIndex,10);
    if(face_3 < 9){
        document.all.face3.selectedIndex = face_3 + 1
        showFace();
    }
    else{
        if(face_2 < 9){
            document.all.face2.selectedIndex = face_2 + 1
            document.all.face3.selectedIndex = 0
            showFace();
        }
        else{
            if(face_1 < 4){
                document.all.face1.selectedIndex = face_1 +1
                document.all.face2.selectedIndex = 0
                document.all.face3.selectedIndex = 0
                showFace();
            }
        }
    }
}

function preView(){
    var s = document.all.txtContent.value;
    s = s.replace(/&/ig,"&amp;") 
    s = s.replace(/>/ig,"&gt;") //>
    s = s.replace(/</ig,"&lt;") //<
    s = s.replace(/\t/ig,"&nbsp;&nbsp;&nbsp;") //Tab
    s = s.replace(/"/ig,"&quot;") //"
    s = s.replace(/'/ig,"&#39;") //'
    s = s.replace(/\r/ig,"") //回车是一个13+10
    s = s.replace(/\n\n/ig,"<P>") // 
    s = s.replace(/\n/ig,"<BR>") //换行
    s = s.replace(/\x20/ig,"&nbsp;") //空格 
    s = s.replace("\n","<br>");
    
	var re=/\[img\](.*?)\[\/img\]/gi;
	s = s.replace(re,"<div style='padding-top:6px;padding-bottom:6px'><img src='$1' border='0'></div>");
			
	re=/\[img=(.*?)\](.*?)\[\/img\]/gi;
	s = s.replace(re,"<div style='padding-top:6px;padding-bottom:6px'><a href='$1' target='_blank'><img src='$2' border='0'></a></div>")
	
	re = /\[url\](.*?)\[\/url\]/gi;
    s = s.replace(re,"<a href=$1 target=_blank>$1</a>");
    
    document.all.showContent.innerHTML=s
}

function InsertImage( ImageUrl,ReWriteImgShowUrl)
{
	if( window.opener !=null )
	{
		if( window.opener.Form1.txtContent != null )
		{
			window.opener.Form1.txtContent.value+="[img="+ReWriteImgShowUrl+"]"+ImageUrl+"[/img]";
			var s = window.opener.Form1.txtContent.value;
			s = s.replace(/&/ig,"&amp;") 
			s = s.replace(/>/ig,"&gt;") //>
			s = s.replace(/</ig,"&lt;") //<
			s = s.replace(/\t/ig,"&nbsp;&nbsp;&nbsp;") //Tab
			s = s.replace(/"/ig,"&quot;") //"
			s = s.replace(/'/ig,"&#39;") //'
			s = s.replace(/\r/ig,"") //回车是一个13+10
			s = s.replace(/\n\n/ig,"<P>") // 
			s = s.replace(/\n/ig,"<BR>") //换行
			s = s.replace(/\x20/ig,"&nbsp;") //空格 
			s = s.replace("\n","<br>");
		   
			var re=/\[img\](.*?)\[\/img\]/gi;
			s = s.replace(re,"<div style='padding-top:6px;padding-bottom:6px'><img src='$1' border='0'></div>");
			
			re=/\[img=(.*?)\](.*?)\[\/img\]/gi;
			s = s.replace(re,"<div style='padding-top:6px;padding-bottom:6px'><a href='$1' target='_blank'><img src='$2' border='0'></a></div>")
			
			re = /\[url\](.*?)\[\/url\]/gi;
			s = s.replace(re,"<a href=$1 target=_blank>$1</a>");
		    
		    var preViewDiv = window.opener.document.getElementById("showContent");
			preViewDiv.innerHTML = s;
			window.alert('插入完成,可以继续.');
		}
	}
}

function hyperlink() 
{	
	txt=prompt("超级链接的URL","http://");      
	if (txt!=null) 
	{
		if (txt=="") {
			AddTxt="[url]"+txt+"[/url]";
			AddText(AddTxt);
		} else {
			AddTxt="[url]"+txt+"[/url]";
			AddText(AddTxt);
		}         
	}
}

function AddText(NewCode) {
	document.all.txtContent.value+=NewCode;
	preView();
}

function ctlent(eventobject)
{
	if(event.ctrlKey && window.event.keyCode==13)
	{
		if(Isfresh  == 1)
		{
			this.document.Form1.btnSubmit1.click();
			Isfresh   = 2;
		}
		else
		{
			alert("正在处理，请等待跳转！");
		}
	}
}

function callpage(htmlurl) 
{ 
	var  newwin=window.open(htmlurl,"fevorites","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=10000,left=10000,width=1,height=1"); 
	newwin.focus(); 
	return false; 
} 

function UserCard(htmlurl) 
{ 
	var  newwin=window.open(htmlurl,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0,resizable=no,top=130,left=300,width=202,height=460"); 
	newwin.focus(); 
	return false; 
} 

function UpdateLeftList(objPram)
{
	return window.top.popforum.location='/List-1.html'+ objPram;
};

function setCtrl(ctrl) {
		switch (ctrl)
		{	
			case 'SWF':
				urlname="/images/swf.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:18;dialogTop:200;dialogLeft:260;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					//if (a.length==3) {
					//	AddTxt="\n\r[FLASH="+a[1]+","+a[2]+"]"+a[0]+"[/FLASH]\n\r";	
					    AddTxt="\n\r[FLASH]"+a+"[/FLASH]\n\r";
						AddText(AddTxt);	
					//}
				}
				break;
			case 'SHOCKWAVE':
				urlname="/images/swav.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					if (a.length==3) {
						AddTxt="\n\r[DIR="+a[1]+","+a[2]+"]"+a[0]+"[/DIR]\n\r";	
						AddText(AddTxt);	
					}
				}
				break;
			case 'QUICKTIME':
				urlname="/images/quicktime.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					if (a.length==3) {
						AddTxt="\n\r[QT="+a[1]+","+a[2]+"]"+a[0]+"[/QT]\n\r";	
						AddText(AddTxt);	
					}
				}
				break;
			case 'RM':
				urlname="/images/rm.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString()//.split('@@@');
					//if (a.length==3) {
					//	AddTxt="\n\r[RM="+a[1]+","+a[2]+"]"+a[0]+"[/RM]\n\r";
					    AddTxt="\n\r[RM]"+a+"[/RM]\n\r";
						AddText(AddTxt);
					//}
				}
				break;
			case 'MEDIA':	
				urlname="/images/media.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString()//.split('@@@');
					//if (a.length==3){
						//AddTxt="\n\r[MP="+a[1]+","+a[2]+"]"+a[0]+"[/MP]\n\r";
						AddTxt="\n\r[MP]"+a+"[/MP]\n\r";
						AddText(AddTxt);
					//}
				}
				break;
		}
}