﻿function ActiveXIsInstalled(sName )
{
try {
var comActiveX = new ActiveXObject(sName);
} catch (e) {
return false;
}
return true;
}

function WritePDFObject(w , h,url){
	if(!w) w="985";
	if (!h) w="600";
	var s="";
	if (ActiveXIsInstalled("AcroPDF.PDF")==false){
		 document.write("您要浏览的组件还没有安装请点击下面链接进行下载并安装：<br/><a href='" + url + "' target='_blank'>下载组件</a>");
		 return false ;
	}
  s="<object classid='clsid:CA8A9780-280D-11CF-A24D-444553540000' id='Pdf1' width='" + w + "' height='" + h + "'  >";
  s+="<param name='_Version' value='327680'>";
  s+="<param name='_ExtentX' value='2646'>";
  s+="<param name='_ExtentY' value='1323'>";
  s+="<param name='_StockProps' value='0'>";
  s+="<param name='SRC' value='PDF/2009年安健环年报(厂外).pdf'>";
s+="</object>";
 document.write(s);
 return true;
}
function SearchNews(Page,kind,key){

	var s= Page + "?Kind=" + kind + "&SearchKey=" + key + "#news_title";
	location.href=s;
}




function DrawImage(ImgD, FitWidth, FitHeight) {
    var image = new Image();
    image.src = ImgD.src; 

    if (!FitHeight) {
        if (image.width > FitWidth) { ImgD.width = FitWidth; return; }
    }


    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= FitWidth / FitHeight) {
            if (image.width > FitWidth) {
                ImgD.width = FitWidth;
                ImgD.height = (image.height * FitWidth) / image.width;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > FitHeight) {
                ImgD.height = FitHeight;
                ImgD.width = (image.width * FitHeight) / image.height;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
 ImgD.style.display="block";
} 

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function SelectTabImg (t,index,tbl){

	if (!t || isNaN(index)  || !tbl  ) return;

	for	(var i=0;i<t.length;i++){
		t[i].src=t[i].bg1;	
		tbl[i].style.display="none";
	}

	t[index].src=t[index].bg2;

	tbl[index].style.display='block';
	
}

function MoveRightPic(t){
if (!t) return;
 var d=document.all.tdPhoto;
 var iPos=parseInt(t.tag);

//alert(iPos);
 if ( iPos-3<0)  return;
 if (! d[iPos]) return;
 d[iPos].style.display="none";
 
 d[iPos-3].style.display="";

	t.tag=iPos-1;
	var a =document.all.aLeft

	a.tag=iPos-3;
	 
}


function MoveLeftPic(t){
if (!t) return;
 var d=document.all.tdPhoto;
 var iPos=parseInt(t.tag);
//alert(iPos);
 if (d.length<= iPos+3)  return;
 d[iPos].style.display="none";
 d[iPos+3].style.display="";
	t.tag=iPos+1;
	var a =document.all.aRight
	a.tag=iPos+3;
	
}

function MoveFlash(){

var d=document.all.apDiv1;
var t=document.all.tdFlash;
var sPageName=window.location.href;

var isIndex=sPageName.toLowerCase().indexOf("index.asp")>-1 || sPageName.substring(sPageName.length-1,sPageName.length )=="/" || sPageName.toLowerCase().substring(sPageName.length-3,sPageName.length)==".cn" 
 

var iTop,tHead;

if (isIndex==true){
	tHead=document.all.tHead;
	iTop=pageY(tHead);
	 d.style.top=iTop+70;
	
	}
 
d.style.left=pageX(t);




}

var LastIndex=0;
function ShowTabGroup(d,index,bg,Selectedimg,img1,p,C1,C2){

if (!d || isNaN(index) || !bg || !Selectedimg || !img1 || !p || !C1 || !C2) return false;
var s;
if (LastIndex==index) return;
LastIndex=index;
if (d.length==0) return ;
for	(var i=0;i<d.length;i++){
	 d[i].style.display='none';
	 bg[i].background='images/' + img1;
	 s=p[i].innerText;
	p[i].innerHTML="<span class='" + C1 + "' >" + s +"</span>"
}
	d[index].style.display='';
	bg[index].background='images/' + Selectedimg;
	s=p[index].innerText;
	p[index].innerHTML="<span class='" + C2 +"'>" + s +"</span>"
}

function ShowDiv(c,url){
		if (!c) return;
	
	
		var d=document.all;


			if (!url)url=d.iColorSize.src

					d.iColorSize.src=url;
		
		if (c.style.display==''){
			c.style.display='none';
		}
		else{
			
			
			c.style.display='';

		}
		
}


function pageX(elem){

    return elem.offsetParent?(elem.offsetLeft+pageX(elem.offsetParent)):elem.offsetLeft;

}

function pageY(elem){

    return elem.offsetParent?(elem.offsetTop+pageY(elem.offsetParent)):elem.offsetTop;

}


		   
function InsertHTML(id,s){
        	
         var div=document.all["div" + id];
		 if (div){
		    // alert(div.innerHTML + "<BR>" + div.outerHTML);
		     div.innerHTML=div.innerHTML + s;
		 }
}


var flag=false;

function SelectAll(t){
     var d=document.all
	 
      for (var i=0 ;i<document.all.length;i++){
	       if(d[i].id.substring(0,3)=='chk') {
		        if (d[i].parentElement.style.display!='none'){
					d[i].checked=t.checked;
				}
		        
		   }	  
	  }
	  
}




function checkSelected(){
     var d=document.all,t =false;
	 
      for (var i=0 ;i<document.all.length;i++){
	       if(d[i].id.substring(0,3)=='chk') {
		        if (d[i].parentElement.style.display=='none'){
				     t=false;
					 break;				
				}
		        if (d[i].checked==true){
					 t=true;
					 break;
					 }
		   }	  
	  }
	  if (t==true) {
	  	d.cmdDel.disabled=false;
		}
	  else{
	   		d.cmdDel.disabled=true;
	  }
	    d.selectAll.disabled= !document.all.showall.checked;
}

	function showAll(){
 var d=document.all;

 for (var i=0;i<d.length;i++){

         if (d[i].id.length>3 ){
		 
		     if (d[i].id.substring(0,3)=="col"){
			 
			    if (document.all.showall.checked==true){
				    d[i].style.display="";
					
				}
				else{
				     d[i].style.display="none";
					;
				}
			 }
		 }
 }

}
function changeColor(t){
var d=document.all;
if (t==d["imgUP"]){
	    t.src="images/upcolor.gif";
	    d["imgDown"].src="images/downgreay.gif"
	}
else{
      t.src="images/downcolor.gif";
	  d["imgUP"].src="images/upGreay.gif";
}

}
function orderBy(s){
//alert(s);
   if (s.length==0) return;
    d=document.all
	if (d["imgUP"].src.indexOf("images/upcolor.gif")>-1) {
	    s=location.pathname + "?"+ s +"&OrderKind=0";
		//alert(s)
	   location.href=s
	   
	}
    else{
	  s=location.pathname + "?"+ s +"&OrderKind=1";
	//  alert(s);
	    location.href=s
	}
   
}

function showPic(s,sleft){
var d=document.all[s];

if (sleft==undefined){sleft="100";}

if (d){
    d.style.left=sleft
	d.style.top=(document.body.scrollTop +event.clientY - 150).toString();
    d.style.display="";
   }
}

function hidePic(s){
var d=document.all[s];
if (d){
    d.style.display="none"
   }
}

function drawimg(){
for (var i=0;i<=document.all.length;i++){
    if (document.all[i]){
        if (document.all[i].tagName=="IMG" && document.all[i].id.substring(0,3)=="img")
	        DrawImage(document.all[i]);
	} 
}
}


function doSearch(sParameter,url){
  var kind=  document.all("kind").value
  var key=document.all("key").value
  
  if (kind.length==0 || key.length==0) return;
  if (url==undefined)  url= geturl();
  location.href=url + "?kind="  + kind + "&key=" + key + sParameter
}

function doaction(kind,id,file,ColName){
var s
if (!ColName) ColName="";
if (file ==undefined) file="Sys_ModuleKind_action.asp?"
if (kind.length==0) return ;

           form1.action=file + "action=" + kind + "&id=" + id+ "&ColName=" + ColName
		   form1.submit();

}

function checkall() {
  var input = document.getElementsByTagName("INPUT");
  for(i=0;i<input.length;i++)
  {
      if(input[i].type == "checkbox" ){	     
	     if (input[i].id !="chkall" && document.all("chkall").checked==true && input[i].id.substring(0,3) =="chk"  ){
               input[i].checked =true;
    		   input[i].value="1";}
		  else if (input[i].id !="chkall" && document.all("chkall").checked==false ){
		         input[i].checked =false;
    		     input[i].value="0";
 			} 
       }
  }
}

function geturl(){
var port="",url
if (location.port.length!=0) port=location.port + ":"
url=location.protocol + "//" + location.host + port + location.pathname
return  url;
}
function Search(url){
var kind,key
if (url.length>0) 
url=geturl() + "?" + url ;
else 
     url=geturl() + "?" ;
     kind=document.all["cobKind"].value
     key=document.all["txtKey"].value
if ( kind.length==0 ) return;
location.href=url + "&kind=" + kind + "&key=" + key
}

