﻿// CE_Editor 图片
    function callInsertImage(CE_Editor,InputName) 
    {  
			var editor1 = document.getElementById(CE_Editor);
            editor1.FocusDocument();  
            var editdoc = editor1.GetDocument();  
            editor1.ExecCommand('new');
            editor1.ExecCommand('ImageGalleryByBrowsing');
            InputImage(CE_Editor,InputName);
            document.getElementById(InputName).focus(); 
    }    
    
    function InputImage(CE_Editor,InputName)
    { 
		var editor1 = document.getElementById(CE_Editor);
        var editdoc = editor1.GetDocument();  
        var imgs = editdoc.getElementsByTagName("img");
        
        if(imgs.length>0)  
        {	
             document.getElementById(InputName).value = imgs[imgs.length-1].src;
        }  
        else
        {
			setTimeout(InputImage(CE_Editor,InputName),500); 
        }  
    }  
    //文件
 function callInsertDocument(CE_Editor,InputName) 
    {  
			var editor1 = document.getElementById(CE_Editor);
            editor1.FocusDocument();  
            var editdoc = editor1.GetDocument();  
            //editor1.ExecCommand('new');
            editor1.ExecCommand('insertdocument');;
            InputDocument(CE_Editor,InputName);
            document.getElementById(InputName).focus(); 
    }    
    
    function InputDocument(CE_Editor,InputName)
    { 
		var editor1 = document.getElementById(CE_Editor);
        var editdoc = editor1.GetDocument();  
        var links = editdoc.getElementsByTagName("a");
        if(links.length>0)  
        {	document.getElementById(InputName).value = links[links.length-1].href;
        }  
        else
        {
			setTimeout(InputDocument(CE_Editor,InputName),500); 
        }  
    }       
function GetFileName(Str)
{
    var arr,count;
    arr=Str.split('/');
    count=arr.length-1;
    alert(arr[count]);
    return arr[count];
}
var flag=false;
function DrawImage(ImgD,int_width,int_height){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= int_width/int_height){
			if(image.width>int_width){ 
				ImgD.width=int_width;
				ImgD.height=(image.height*int_width)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			//ImgD.alt=image.width+"×"+image.height; 不提示
		}
		else{
			if(image.height>int_height){ 
				ImgD.height=int_height;
				ImgD.width=(image.width*int_height)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			//ImgD.alt=image.width+"×"+image.height; 不提示
		}
	}
} 