﻿// JavaScript Document

function correctPNG() 
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText
			var imgAttribs = img.attributes;
			for (var j=0; j<imgAttribs.length; j++)
			{
				var imgAttrib = imgAttribs[j];
				if (imgAttrib.nodeName == "align")
				{
					if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
					if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
					break
				}
			}
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
window.attachEvent("onload", correctPNG);


//控制图片大小
var flag=false;
function DrawImage(ImgD,imageWidth,imageHeight) {
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= imageWidth/imageHeight){
     if(image.width>imageWidth){
     ImgD.width=imageWidth;
     ImgD.height=(image.height*imageWidth)/image.width;
     }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
     }
     }
    else{
     if(image.height>imageHeight){
     ImgD.height=imageHeight;
     ImgD.width=(image.width*imageHeight)/image.height;
     }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
     }
     }
    }
  }
  


//栏目切换
function nTabs(thisObj,Num){
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabObjmu = thisObj.parentNode.id;
	tabObjmu=tabObjmu.substring(0,tabObjmu.length);
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++) {
	  		if (i == Num) {
		             thisObj.className = "active"; 
			         document.getElementById(tabObjmu+"_Content"+i).style.display = "block";
	 		 }else{
				     tabList[i].className = "normal"; 
				     document.getElementById(tabObjmu+"_Content"+i).style.display = "none";
	                 }
	      } 
}




// 自动获取高度
var bodyObj;

function autoHeigh(){
       bodyObj = document.body;
	   ElementHeight1();
	   Bodyheight();
	   setInterval("Bodyheight();", 80);
}
function autoHeigh1(){
       bodyObj = document.body;
	   ElementHeight1();
	   Iframeheight();
	   setInterval("Iframeheight();", 80);
	   
}

function ElementHeight1(){  
    var tmpstr ="";   	
	var agt=navigator.userAgent.toLowerCase(); 
    var isopera = agt.indexOf('opera')!=-1?true:false;
    bodyElement = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body;
	
	
}


//iframe框宽度
function Iframeheight(){  

	var outline1 = document.getElementById("myIframe");
	outline1.style.height = ( bodyElement.clientHeight - 37 ) + "px";
	outline1.style.width = ( bodyElement.clientWidth - bodyElement.scrollLeft) + "px"

}

//内容框宽度
function Bodyheight(){ 

	var noline = document.getElementById("body");
	noline.style.height = ( bodyElement.clientHeight - 33 ) + "px";
	//noline.style.width = "100%";

}



//点击隐藏
function hidden(id){
    var obj = document.getElementById(id);
	   if (obj.style.display=='none'){
	    obj.style.display='block';
  		 }
       else{
		 obj.style.display='none';
		 }
}

					 
 
