function GetObject(URL)
{////根据URL得到文件类型

    var preview;	
	var a=URL.split(".");
	var Ext=a[a.length-1]
	Ext=Ext.toUpperCase();
	//alert(Ext);
	var mediaExt="WMV|WMA|MPG|MPEG|RM|RA|RMVB|ASF|ASX|AVI|MP3";
	var picExt="JPG|JPEG|GIF|PNG";	
	var flashExt="SWF";	
	if (mediaExt.indexOf(Ext)>=0)
	{
		preview="media";
		//alert(preview);
	}
			
	if (picExt.indexOf(Ext)>=0)
	{
		preview="img";
		//alert(preview);
	}
	
	if (flashExt.indexOf(Ext)>=0)
	{
		preview="flash";
		//alert(preview);
	}
	
	return preview;	
}

function openImg(URL)
{//编辑多媒体文件（图片，视频，Flash等）

	/*if (URL!=0)
	   {
		window.open(URL,'','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
		}*/
		//if (document.all.TitlePic.value!=0){
			//var arr = showModalDialog('preview.htm?preview=img&URL=' + document.all.TitlePic.value ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')
			//}
//			var arr = showModalDialog('preview.htm?preview=img&URL=' + URL ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')
			var preview;			
			preview=GetObject(URL);
			
			//var arr = showModalDialog('preview.htm?preview=img&URL=' + URL ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')
			var arr = showModalDialog('preview.htm?preview=' + preview + '&URL=' + URL ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')


}


function GetObjectHTML(URL)
{///根据URL文件返回相应的HTML
	var HTML;
	var preview;			
 	preview=GetObject(URL);
	
	switch (preview)
	{
	 case "img":
	    HTML='<img src="' + URL + '">';
	 	break;
	 case "media":
	    HTML="<EMBED id=video " ;
		HTML+="src='" + URL + "'";
		HTML+="type=audio/x-pn-realaudio-plugin autostart='true' controls='IMAGEWINDOW,ControlPanel,StatusBar' console='Clip1'  ShowStatusBar='1'></EMBED>";
	 	break;
	 case "flash":
	 	HTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="760" height="60">';
  		HTML+='<param name="movie" value="' + URL + '">'
  		HTML+='<param name="quality" value="high">';
  		HTML+='<embed src="' + URL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="760" height="60"></embed>'
		HTML+='</object>';
	    break;
	}
	return HTML;
}


function preview(HTML)
{
///预览编辑区

	var a=window.open('about:blank');
	
	a.document.write(HTML);
	a.document.close;


}


function GetLongLat(URL)
{//获取经纬度
			
			//var arr = showModalDialog('preview.htm?preview=img&URL=' + URL ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')
			var arr = showModalDialog(URL ,window,'dialogWidth:1024px;dialogHeight:750px;center:yes;help:no;resizable:yes;status:yes')

return arr;
}
function Dialog(URL,width,height)
{//对话框
			
			//var arr = showModalDialog('preview.htm?preview=img&URL=' + URL ,window,'dialogWidth:630px;dialogHeight:560px;center:yes;help:no;resizable:yes;status:yes')
			var arr = showModalDialog(URL ,window,'dialogWidth:'+ width +'px;dialogHeight:' + height + 'px;center:yes;help:no;resizable:yes;status:yes')

//return arr;
}

function GetMediaHTML(URL,width,height)
{///根据URL文件返回相应的HTML
	var HTML;
	var preview;			
 	preview=GetObject(URL);
	
	switch (preview)
	{
	 case "img":
	   // HTML='<img src="' + URL + '" width="' + width +'" height="' + height + '" border="0">';
	   HTML='<img src="' + URL + '"';
	   if(width>0)
		{HTML+=' width="' + width +'"';}
	  if(height>0)
		{HTML+=' height="' + height + '"';}	   
	  
	   HTML+=' border="0">';
		//if(width==0)
		//{HTML='<img src="' + URL + '" height="' + height + '" border="0">';}
		//if(height==0)
		//{HTML='<img src="' + URL + '" width="' + width +'" border="0" >';}
		
		
	 	break;
	 case "media":
	    HTML="<EMBED id=video " ;
		HTML+="src='" + URL + "'";
		if(width==0 ||height==0)
		{
			HTML+="type=audio/x-pn-realaudio-plugin autostart='true' controls='IMAGEWINDOW,ControlPanel,StatusBar' console='Clip1'  ShowStatusBar='1' ></EMBED>";
		}
		else
		{
			HTML+="type=audio/x-pn-realaudio-plugin autostart='false' controls='IMAGEWINDOW,ControlPanel,StatusBar' console='Clip1'  ShowStatusBar='1'  width='" + width +"' height='" + height + "'></EMBED>";
		}
	 	break;
	 case "flash":
	 	if(width==0)
		{width=height;}
		if(height==0)
		{height=width;}
	 	HTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width +'" height="' + height + '">';
  		HTML+='<param name="movie" value="' + URL + '">'
  		HTML+='<param name="quality" value="high">';
  		HTML+='<embed src="' + URL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="' + height + '"></embed>'
		HTML+='</object>';
	    break;
	}
	return HTML;
}



function GetMediaHTML2(URL,Link,width,height,border)
{///根据URL文件返回相应的HTML
	var HTML;
	var preview;			
 	preview=GetObject(URL);
	
	switch (preview)
	{
	 case "img":
	    //HTML='<a href="' + Link + '"><img src="' + URL + '" width="' + width +'" height="' + height + '" border="0"></a>';
		//if(width==0)
		//{HTML='<a href="' + Link + '"><img src="' + URL + '" height="' + height + '" border="0"></a>';}
		//if(height==0)
		//{HTML='<a href="' + Link + '"><img src="' + URL + '" width="' + width +'" border="0" ></a>';}
		
		HTML='<a href="' + Link + '"><img src="' + URL + '"';
	   if(width>0)
		{HTML+=' width="' + width +'"';}
	  if(height>0)
		{HTML+=' height="' + height + '"';}	   
	  
	   HTML+=' border="'+ border +'"></a>';

	 	break;
	 case "media":
	    HTML="<EMBED id=video " ;
		HTML+="src='" + URL + "'";
		if(width==0 ||height==0)
		{
			HTML+="type=audio/x-pn-realaudio-plugin autostart='true' controls='IMAGEWINDOW,ControlPanel,StatusBar' console='Clip1'  ShowStatusBar='1' ></EMBED>";
		}
		else
		{
			HTML+="type=audio/x-pn-realaudio-plugin autostart='false' controls='IMAGEWINDOW,ControlPanel,StatusBar' console='Clip1'  ShowStatusBar='1'  width='" + width +"' height='" + height + "'></EMBED>";
		}
	 	break;
	 case "flash":
	 	if(width==0)
		{width=height;}
		if(height==0)
		{height=width;}
	 	HTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width +'" height="' + height + '">';
  		HTML+='<param name="movie" value="' + URL + '">'
  		HTML+='<param name="quality" value="high">';
  		HTML+='<embed src="' + URL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="' + height + '"></embed>'
		HTML+='</object>';
	    break;
	}
	return HTML;
}


  function cutHTML(str)

        {

         //var pattern =/<(.[^>]*)>/
           var pattern =/<[^>]+>/
        while (str.search(pattern)>=0)//
        {

         str=str.replace(pattern,"");

        }
               
                return str

        }  
  
function LeftStr(str,len)
{
var str1 =str;
//String.prototype.lenB =function(){return   this.replace(/[^\x00-\xff]/g,"**").length;}  
str=cutHTML(str)
//var str2=str;
//document.all.titlebyte.innerText=" 标题共：" + str.lenB()/2 + "字。"
	if (getStrActualLen(str)>len-2)
		{
			//return getInterceptedStr(str,len) + ".."
		    return str1.replace(str,getInterceptedStr(str,len) + "..")
		}
		
		
	return str1
}

// 得到字符串的真实长度（双字节换算为两个单字节） 
function getStrActualLen(sChars) 
{ 
return sChars.replace(/[^x00-xff]/g,"xx").length; 
} 

// 截取固定长度子字符串 sSource为字符串iLen为长度 
function getInterceptedStr(sSource, iLen) 
{ 
if(sSource.replace(/[^x00-xff]/g,"xx").length <= iLen) 
{ 
return sSource; 
} 
var ELIDED = ""; 

var str = ""; 
var l = 0; 
var schar; 
for(var i=0; schar=sSource.charAt(i); i++) 
{ 
str += schar; 
l += (schar.match(/[^x00-xff]/) != null ? 2 : 1); 
if(l >= iLen - ELIDED.length) 
{ 
break; 
} 
} 
str += ELIDED; 

return str; 
} 