//-----------------------------------------------------------------------
/*二级折叠 设置折叠数量var number=8;
onclick=javascript:ShowTree(1)  href="javascript:void(null)"
id=Tid1*/
function Tree() {
var tre;
    for (i=1;i<=number;i++) {
        tre = eval('Tid' + i);
        tre.style.display = 'none';
    }
}
 
function ShowTree(i) {
    tre = eval('Tid' + i);
    if (tre.style.display == 'none') {
        Tree();
        tre.style.display = '';
    }
    else {
        tre.style.display = 'none';
    }
}
//-----------------------------------------------------------------------
//弹出指定大小窗体
function winPop(url, width, height)
{
  window.showModelessDialog(url,"",'dialogWidth=' + width + 'px; dialogHeight=' + height + 'px; resizable=no; help=no; status=no;resizable=0; help=0; scroll=0; status=0;'); 
}
//弹出指定大小居中页面
function winWin(Url,WindowName,Width,Height)
{
  window.open(Url,WindowName,'toolbar=0,location=0,maximize=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,top='+(screen.height-Height)/2+',left='+(screen.width-Width)/2+',width='+Width+',height='+Height);
}
//-----------------------------------------------------------------------
/*横向无缝滚动*/
function marqueex(dem,dem1,dem2)
{
var demo = document.getElementById(dem);
var demo1 = document.getElementById(dem1);
var demo2 = document.getElementById(dem2);

var speed=10;    //数值越大滚动速度越慢
demo2.innerHTML = demo1.innerHTML
Marquee();
var MyMar = setInterval(Marquee,speed);
demo.onmouseover = function(){clearInterval(MyMar)}
demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)}
}
function Marquee(){
    if(demo2.offsetWidth-demo.scrollLeft<=0)
        demo.scrollLeft-=demo1.offsetWidth
    else{
        demo.scrollLeft++
    }
}
//-----------------------------------------------------------------------
/*纵向无缝滚动*/
function marqueey(dem,dem1,dem2)
{
var demodiv = document.getElementById(dem);
var demotd1 = document.getElementById(dem1);
var demotd2 = document.getElementById(dem2);
var speed1=30;    //滚动速度值，值越大速度越慢
demotd2.innerHTML = demotd1.innerHTML    //克隆demotd2为demotd1
Marquee1();
var MyMar1 = setInterval(Marquee1,speed1);        //设置定时器
demodiv.onmouseover = function(){clearInterval(MyMar1)}    //鼠标经过时清除定时器达到滚动停止的目的
demodiv.onmouseout = function(){MyMar1 = setInterval(Marquee1,speed1)}    //鼠标移开时重设定时器
function Marquee1(){
    if(demotd2.offsetTop-demodiv.scrollTop<=0)    //当滚动至demotd1与demotd2交界时
        demodiv.scrollTop-=demotd1.offsetHeight    //demo跳到最顶端
    else{
        demodiv.scrollTop++
    }
}
function end()
{
	clearInterval(MyMar1);
}
function start()
{
    clearInterval(MyMar1);
	MyMar1 = setInterval(Marquee1,speed1);
}
}
//-----------------------------------------------------------------------
/*JS插入Flash*/
function mainFlash(pic_width,pic_height,imag,link,text){
var show_text=1;
var pic_width=pic_width;
var pic_height=pic_height;
var imag=imag;
var link=link;
var text=text;
var swf_height=show_text==1?pic_height+20:pic_height;
var pics="";
var links="";
var texts="";
for(var i=1; i<imag.length; i++){
	pics=pics+("|"+imag[i]);
	links=links+("|"+link[i]);
	texts=texts+("|"+text[i]);
}
pics=pics.substring(1);
links=links.substring(1);
texts=texts.substring(1);
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="'+ pic_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="flash/focus.swf">');
document.write('<param name="quality" value="high"><param name="wmode" value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor=000000&bgcolor=dddddd&button_pos=4&stop_time=3000">');
document.write('<embed src="flash/focus.swf" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor=000000&bgcolor=dddddd&button_pos=4&stop_time=3000" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');		
}
//------------------------------------------
var ImgObj=new Image();			//建立一个图像对象
var AllImgExt=".jpg|.jpeg|.gif|.bmp|.png|"//全部图片格式类型
var FileObj,ImgFileSize,ImgWidth,ImgHeight,FileExt,ErrMsg//全局变量 图片相关属性

//以下为限制变量
var AllowExt=".jar|.rar|.zip|"	//允许上传的文件类型 为无限制 每个扩展名后边要加一个"|" 小写字母表示
//var AllowExt=0
var AllowImgFileSize=70;		//允许上传图片文件的大小 0为无限制 单位：KB 
var AllowImgWidth=500;			//允许上传的图片的宽度为无限制 1单位：px(像素)
var AllowImgHeight=500;			//允许上传的图片的高度为无限制 1单位：px(像素)

function CheckProperty(obj)		//检测图像属性
{
  FileObj=obj;
  if(ErrMsg!="")			//检测是否为正确的图像文件　返回出错信息并重置
  {
    FileObj.outerHTML=FileObj.outerHTML;
    alert(ErrMsg);
    return false;			//返回
  }

  if(ImgObj.readyState!="complete")	//如果图像是未加载完成进行循环检测
  {
    setTimeout("CheckProperty(FileObj)",500);
    return false;
  }

  ImgFileSize=Math.round(ImgObj.fileSize/1024);//取得图片文件的大小
  ImgWidth=ImgObj.width			//取得图片的宽度
  ImgHeight=ImgObj.height;		//取得图片的高度

  if(AllowImgWidth!=0&&AllowImgWidth<ImgWidth)
    ErrMsg=ErrMsg+"\n图片宽度超过限制。请上传宽度小于"+AllowImgWidth+"px的文件，当前图片宽度为"+ImgWidth+"px";

  if(AllowImgHeight!=0&&AllowImgHeight<ImgHeight)
    ErrMsg=ErrMsg+"\n图片高度超过限制。请上传高度小于"+AllowImgHeight+"px的文件，当前图片高度为"+ImgHeight+"px";

  if(AllowImgFileSize!=0&&AllowImgFileSize<ImgFileSize)
    ErrMsg=ErrMsg+"\n图片文件大小超过限制。请上传小于"+AllowImgFileSize+"KB的文件，当前文件大小为"+ImgFileSize+"KB";

  if(ErrMsg!="")			//返回出错信息并重置
  {
    FileObj.outerHTML=FileObj.outerHTML;
    alert(ErrMsg);
  }
}

ImgObj.onerror=function(){ErrMsg='\n图片格式不正确或者图片已损坏!'}
function CheckExt(obj)
{ 
  ErrMsg=""
  FileExt=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();
  if(AllowExt!=0&&AllowExt.indexOf(FileExt+"|")==-1)	//判断文件类型是否允许上传
  {
    ErrMsg="该文件类型不允许上传。请上传 "+AllowExt+" 类型的文件，当前文件类型为"+FileExt;
    obj.outerHTML=obj.outerHTML;
    alert(ErrMsg);
    return false;
  }  
}
function CheckImgExt(obj)
{ 
  ErrMsg=""
  FileExt=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();
  if(AllImgExt!=0&&AllImgExt.indexOf(FileExt+"|")==-1)	//判断文件类型是否允许上传
  {
    ErrMsg="该文件类型不允许上传。请上传 "+AllImgExt+" 类型的文件，当前文件类型为"+FileExt;
    obj.outerHTML=obj.outerHTML;
    alert(ErrMsg);
    return false;
  }  

  //ErrMsg=""
//  FileExt=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();  
// if(AllImgExt.indexOf(FileExt+"|")!=-1)		//如果图片文件，则进行图片信息处理
//  {
//    ImgObj.src=obj.value;
//    CheckProperty(obj);
//    return false;
//  }
}