$(pageInit);

function media(url, width, height, autoPlay)
{
	var myJsVal = "";

	if(url == "http://" || url == "")
	{
		myJsVal = "";
	}
	else if(url.lastIndexOf(".flv") > 0)
	{
		myJsVal+="<div>";
		myJsVal+="<embed width=\""+ width +"\" height=\""+ height +"\" loop=\"true\" play=\"true\" quality=\"high\" flashvars=\"file="+ url +"&amp;autostart="+ autoPlay +"\" allowfullscreen=\"true\" type=\"application/x-shockwave-flash\" src=\"files/common/flvplayer.swf\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>";
		myJsVal+="</div>";
	}
	else if(url.lastIndexOf(".rm") > 0)
	{
		myJsVal+="<div>";
		myJsVal+="<object mediatype=\"0\" width=\""+ width +"\" height=\""+ height +"\" classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\">";
		myJsVal+="<param name=\"src\" value=\""+ url +"\" \/>";
		myJsVal+="<param name=\"autostart\" value=\""+ autoPlay +"\" \/>";
		myJsVal+="<param name=\"loop\" value=\"true\" \/>";
		myJsVal+="<param name=\"menu\" value=\"false\" \/>";
		myJsVal+="<\/object>";
		myJsVal+="</div>";
	}
	else
	{
		myJsVal+="<div>";
		myJsVal+="<object mediatype=\"0\" width=\""+ width +"\" height=\""+ height +"\" codebase=\"http:\/\/microsoft.com\/windows\/mediaplayer\/en\/download\/\" classid=\"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6\">";
		myJsVal+="<param name=\"url\" value=\""+ url +"\" \/>";
		myJsVal+="<param name=\"autostart\" value=\""+ autoPlay +"\" \/>";
		myJsVal+="<param name=\"loop\" value=\"true\" \/>";
		myJsVal+="<param name=\"menu\" value=\"false\" \/>";
		myJsVal+="<\/object>";
		myJsVal+="</div>";
	}
	return myJsVal;
}

function iframe(url, width, height)
{
	var myJsVal = "";

	if(url == "http://" || url == "")
	{
		myJsVal = "";
	}
	else
	{
		myJsVal = "<iframe border=\"0\" frameborder=\"0\" framespacing=\"0\" style=\"width:"+ width +"px; height:"+ height +"px\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"auto\" src=\""+ url +"\" vspale=\"0\" name=\"iframe\" id=\"iframe\"><\/iframe>";
	}
	return myJsVal;
}

function pageInit()
{
	//编辑器
	var allPlugin={
		Video:{c:'xheBtnMedia',t:'视频',s:'ctrl+m',h:1,e:function(){
			var _this=this;
			var jTest=$('<div>视频文件： <input type="text" id="xheMediaSrc" value="http://" class="xheText" /></div><div>宽度高度： <input type="text" id="xheMediawidth" style="width:40px;" value="480" /> x <input type="text" id="xheMediaheight" style="width:40px;" value="400" /></div><div>自动播放： <input type="checkbox" id="xheMediaplay"></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>');
			if(_this.settings.upMediaUrl)
				_this.uploadInit($('#xheMediaSrc',jTest),_this.settings.upMediaUrl,_this.settings.upMediaExt);
			var jSave=$('#xheSave',jTest);
			jSave.click(function(){
				_this.loadBookmark();
				_this.pasteHTML(media($('#xheMediaSrc',jTest).val(),$('#xheMediawidth',jTest).val(),$('#xheMediaheight',jTest).val(),$('#xheMediaplay',jTest).attr("checked")));
				_this.hidePanel();
				return false;	
			});
			_this.showDialog(jTest);
		}},

		Iframe:{c:'xheBtnIframe',t:'网页',s:'ctrl+i',h:1,e:function(){
			var _this=this;
			var jTest=$('<div>网页文件： <input type="text" id="xheIframeSrc" value="http://" class="xheText" /></div><div>宽度高度： <input type="text" id="xheIframewidth" style="width:40px;" value="480" /> x <input type="text" id="xheIframeheight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>');
			var jSave=$('#xheSave',jTest);
			jSave.click(function(){
				_this.loadBookmark();
				_this.pasteHTML(iframe($('#xheIframeSrc',jTest).val(),$('#xheIframewidth',jTest).val(),$('#xheIframeheight',jTest).val()));
				_this.hidePanel();
				return false;	
			});
			_this.showDialog(jTest);
		}},

		Word:{c:'xheBtnWord',t:'导入word',s:'ctrl+w',e:function(){
			var _this=this;
			_this.saveBookmark();
			_this.showIframeModal('导入word',"{editorRoot}xheditor_plugins/word/word.aspx",function(v){
				_this.loadBookmark();
				_this.pasteHTML(v);
				},320,200);
		}},
		
		uploadAll:{c:'xheuploadAll',t:'图片：showIframeModal (Ctrl+7)',s:'ctrl+7',e:function(){
			var _this=this;
			_this.showIframeModal('上传文件', "{editorRoot}xheditor_plugins/multiupload/multiuploadadd.aspx?type=image&uploadurl={editorRoot}xheditor_plugins/multiupload/upload.aspx%3Ftype%3Dimage&ext=图片文件(*.jpg;*.jpeg;*.gif;*.png;*.bmp;)",function(v){
				_this.loadBookmark();
				var urlall = "";
				for(i=0; i<v.length; i++)
				{
					urlall += "|" + v[i].url;
				};
				$(".urlall").val(urlall.substring(1));
				},320,200);
		}}
	};

	if($(".Editor").length != 0)
		$('.Editor').xheditor({plugins:allPlugin,width:'80%', height:'240',internalScript:true,tools:'Source,Preview,Fullscreen,|,Cut,Copy,Paste,Pastetext,|,Blocktag,Fontface,FontSize,|,FontColor,BackColor,|,Bold,Italic,Underline,Strikethrough,/,SelectAll,Removeformat,|,Align,List,Outdent,Indent,|,Link,Unlink,Anchor,|,Img,Flash,Video,Word,Iframe,Table,|,About',upLinkUrl:"!{editorRoot}xheditor_plugins/multiupload/multiupload.aspx?type=file&uploadurl={editorRoot}xheditor_plugins/multiupload/upload.aspx%3Ftype%3Dfile&ext=附件文件(*.gif;*.jpg;*.bmp;*.png;*.zip;*.rar;*.txt;*.doc;*.pdf;*.xls;*.ppt;*.swf;*.htm;*.html)",upImgUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.aspx?type=image&uploadurl={editorRoot}xheditor_plugins/multiupload/upload.aspx%3Ftype%3Dimage&ext=图片文件(*.jpg;*.jpeg;*.gif;*.png;*.bmp;)',upFlashUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.aspx?type=flash&uploadurl={editorRoot}xheditor_plugins/multiupload/upload.aspx%3Ftype%3Dflash&ext=Flash动画(*.swf)',upMediaUrl:'!{editorRoot}xheditor_plugins/multiupload/multiupload.aspx?type=media&uploadurl={editorRoot}xheditor_plugins/multiupload/upload.aspx%3Ftype%3Dmedia&ext=多媒体文件(*.wmv;*.flv;*.rm;*.avi;*.wma;*.mp3;*.mid)'});
	if($(".EditorBasic").length != 0)
		$('.EditorBasic').xheditor({skin:'vista',width:'80%', height:'120',tools:'Cut,Copy,Paste,Pastetext,|,Fontface,FontSize,|,FontColor,BackColor,|,Bold,Italic,Underline,Strikethrough,|,Align,List,Outdent,Indent,About'});

}