function IncludeJS(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></script>'); 
}

/**
 * 计算字符串长度
 *
 *@param string sString 检测的字符串
 */
function JHshStrLen(sString)
{
   var sStr,iCount,i,strTemp ;

   iCount = 0 ;
   sStr = sString.split("");
    for (i = 0 ; i < sStr.length ; i ++)
     {
         strTemp = escape(sStr[i]);
          if (strTemp.indexOf("%u",0) == -1)
          {
              iCount = iCount + 1 ;
          }
          else
          {
              iCount = iCount + 2 ;
          }
      }

      return iCount ;
}

function checkAll(eName,obj){
	if (typeof(obj)=='string'){
		obj=document.getElementById(obj);
		obj.checked=!obj.checked;
		var	colInputs = obj.form.elements;
		var value=obj.checked;
	}else if (typeof(obj)=='object'){
		var	colInputs = obj.form.elements;//obj.form.getElementsByTagName("input");
		var value=obj.checked;
	}else{
		var	colInputs = document.getElementsByName(eName);
		var value=obj.checked;
	}
	
	for	(var i=0; i < colInputs.length; i++)
	{
		if (colInputs[i].name==eName&&colInputs[i].type =="checkbox"){
			colInputs[i].checked=value;
		}
		
	}
}
function confDel(pTips){
//'确定要删除此记录吗?'
	if(confirm(pTips))
	{
		return true;
	}else{
		return false;
	}
}
function CopyObj(oid) 
{ 
	var oControlRange = document.body.createControlRange(); 
	oControlRange.add(oid,0); 
	oControlRange.select(); 
	document.execCommand("Copy"); 
}
// 自动 COPY 代码开始
function findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function copyInput(ob,alt){
	var obj=findObj(ob); 
	if (obj) {
		obj.select();
		js=obj.createTextRange();
		js.execCommand("Copy");
		alt=(typeof(alt)=="undefined")?"复制成功！请直接在代码模式下粘贴！":alt;
		alert(alt);
			
	}

}

//调用：<img src="图片" onload="javascript:DrawImage(this)">
 function copyImg(url,alt){
	var content='';
	window.clipboardData.setData("Text","<img src='"+url+"' boder=0/>");
	alt=(typeof(alt)=="undefined")?"图片引用代码已经复制成功，请粘贴到你的宝贝描述的代码里":alt;
	alert(alt);
}

function copyUrl(url,alt){
	var content='';
	window.clipboardData.setData("Text",url);
	alt=(typeof(alt)=="undefined")?"图片链接地址复制成功，请粘贴到你编辑宝贝描述时的图片地址里":alt;
	alert(alt);	
}
function copyImgObj(imgId,alt) {
	//var oImg = document.createElement('img'); 
	//oImg.src = url;
	var oImg = document.getElementById(imgId);
	var ctrl = document.body.createControlRange(); 
	ctrl.addElement(oImg); 
	ctrl.execCommand('Copy');
	alt=(typeof(alt)=="undefined")?"图片已经复制成功，请直接粘贴到宝贝描述里":alt;
	alert(alt);
}

var flag=false;
function DrawImage(ImgD){
	var image=new Image();
	var iwidth = 100; //定义允许图片宽度，当宽度大于这个值时等比例缩小
	var iheight = 80; //定义允许图片高度，当宽度大于这个值时等比例缩小
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		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;
			}

			ImgD.alt=image.width+"×"+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.alt=image.width+"×"+image.height;
		}
	}
}

function confSubmit(pTips,frmSubmit){
	if(confirm(pTips))
	{
	   document.getElementById(frmSubmit).submit();
	}
}
function confSubmitUrl(pTips,frmSubmit,action){
	if(confirm(pTips))
	{
	   var frm= document.getElementById(frmSubmit);
	   frm.action=action;
	   frm.submit();
	}
}
function SubmitUrl(frmSubmit,action){
   var frm= document.getElementById(frmSubmit);
   frm.action=action;
   frm.submit();
}
function flashChecker()
{
    var hasFlash=0;             //是否安装了flash
    var flashVersion=0;            //flash版本
    var isIE=/*@cc_on!@*/0;      //是否IE浏览器

    if(isIE)
    {
        var  swf  = null;
        try{swf=  new  ActiveXObject('ShockwaveFlash.ShockwaveFlash');  }catch(e){}
        if(swf) {
            hasFlash=1;
            VSwf=swf.GetVariable("$version");
            flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]);        
        }
    }else{
        if (navigator.plugins && navigator.plugins.length > 0)
        {
            var swf= null;
            try{ swf=navigator.plugins["Shockwave Flash"]; }catch(e){}
            if (swf)
             {
                 hasFlash=1;
                var words = swf.description.split(" ");
                for (var i = 0; i < words.length; ++i)
                {
                    if (isNaN(parseInt(words[i]))) continue;
                    flashVersion = parseInt(words[i]);
                }
            }
        }
    }

    return {f:hasFlash,v:flashVersion};
}
function SetCookie(name, value) {  
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null && expires>=0) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null || expires < 0) ? ((expires==-1)?"; expires=-1":"") : ("; expires="+ expdate.toGMTString()))
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "");
}
