﻿// 颜色选择器
function foreColor(object_color)
{
  var tmp_object=eval(object_color);
  var arr = showModalDialog("function/select_color.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  //if (arr != null) tmp_object.style.backgroundColor=arr;
  if (arr != null) tmp_object.value=arr;
  //else Composition.focus();
}

//图片缩放工具
function image_sizeTool(obj,to_width,to_height){
  if((obj.width/to_width)>=(obj.height/to_height) && obj.width>to_width){
    obj.width=to_width;obj.height=obj.height*(to_width/obj.width);
  }else if((obj.width/to_width)<(obj.height/to_height) && obj.height>to_height){
    obj.height=to_height;obj.width=obj.width*(to_height/obj.height);
  }
}

function image_sizeTool_1(obj1,obj2,to_width,to_height){
  if((obj2.width/to_width)>=(obj2.height/to_height) && obj2.width>to_width){
    obj1.width=to_width;obj1.height=obj2.height*(to_width/obj2.width);
  }else if((obj2.width/to_width)<(obj2.height/to_height) && obj2.height>to_height){
    obj1.height=to_height;obj1.width=obj2.width*(to_height/obj2.height);
  }
}

//弹出窗口1
function Open_Window(href,width,height){
  window.open(href,'','width='+width+',height='+height+',left='+(screen.width-width)/2+',top=100,toolbar=no, menubar=no,scrollbars=no,resizable=no,location=no,status=no')
}

//弹出窗口2
function Open_Window_scroll(href,width,height){
  window.open(href,'','width='+width+',height='+height+',left='+(screen.width-width)/2+',top=100,toolbar=no, menubar=no,scrollbars=yes,resizable=no,location=no,status=no')
}

//截取区分中英文字符长度的子字符串（中文按2字符计算）
function leftStr(LengthStr_obj,LeftStr_num){
    var str = LengthStr_obj.replace(/([^\x00-\xff])/g,"\x00$1");
	var num = LeftStr_num;
    return (str.length<LeftStr_num)?LengthStr_obj:str.substring(0,LeftStr_num).replace(/\x00/g,'');
}

//取区分中英文字符长度（中文按2字符计算）
function LengthStr(LengthStr_obj){
	var str = LengthStr_obj.replace(/[^\x00-\xff]/g,"**");
	return (str.length);
}

function iframeResize(iframeName)
{
	var dyniframe   = null;
	var indexwin    = null;
	var iframeBase  = eval(iframeName);

	if (document.getElementById)
	{
		dyniframe       = document.getElementById(iframeName);
		indexwin        = window;
 
		if (dyniframe)
		{
			if (dyniframe.contentDocument){
				dyniframe.height = dyniframe.contentDocument.body.scrollHeight;
 
			}
			else if (dyniframe.document && dyniframe.document.body.scrollHeight)
			{
				iframeheight	= iframeBase.document.body.scrollHeight;
				dyniframe.height = iframeheight;
			} 
		}
	}
}

function write_message(dz1){
    window.open(dz1,'','width=500,height=325,top=100,left='+(this.screen.width-500)/2)
  }
function new_circletalk(str){
    window.open(str,'','width=500,height=375,top=100,left='+(this.screen.width-500)/2)
  }
  
Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

function collect(Fav,ty,id){
	var d = document;
	var f = {
		type:0,
		title:d.title,
		href:d.location.href,
		desc:(d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():''))
	};
	Object.extend(f,(typeof(Fav)=="object"?(Fav):{type:Fav}));
	var wee=CenterWindow('Member_favPage.asp?2id='+id+'&ftype='+ty+'&title='+escape(f.title)+'&url='+escape(f.href)+'&desc='+escape(f.desc),500,300);
	wee.focus();
}

/* 居中窗口 */
/* 打开一个新窗口，根据地址、宽度、高度，返回新窗口的句柄 */
function CenterWindow(href,width,height,w)
{
	if (!w) w="msgWindow";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var msgWindow = window.open(href,w , styleStr);
	return msgWindow;
}

//加载图片限制resizeimg(this,width,height)
function resizeimg(ImgD,iwidth,iheight)
{
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0)
     {
        if(image.width/image.height>= iwidth/iheight)
        {
            if(image.width>iwidth)
            {
                ImgD.width=iwidth;
                ImgD.height=(image.height*iwidth)/image.width;
            }
            else
            {
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
        else
        {
            if(image.height>iheight)
            {
               ImgD.height=iheight;
               ImgD.width=(image.width*iheight)/image.height;
            }
            else
            {
               ImgD.width=image.width;
               ImgD.height=image.height;
            }
        }

　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针
　　　　//ImgD.onclick = function() { window.open(this.src);} //点击打开大图片
　　　　if(navigator.userAgent.toLowerCase().indexOf("ie") > -1)
　　　　{ //判断浏览器，如果是IE
　　　　　　//ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开";
　　　　    ImgD.onmousewheel = function img_zoom() //滚轮缩放
　　　　    {
　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100;
　　　　　　　　zoom += event.wheelDelta / 12;
　　　　　　　　if(zoom> 0)　this.style.zoom = zoom + "%";
　　　　　　　　return false;
　　　　　   }
　　　  } 
　　　  else 
　　　  { //如果不是IE
　	　//ImgD.title = "点击图片可在新窗口打开";
　　　　}
    }
}

