﻿// JavaScript Document
function DrawImage(ImgD,PicWidth,PicHeight){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  if(image.width/image.height>= PicWidth/PicHeight){ 
   if(image.width>PicWidth){
    ImgD.width=PicWidth; 
    ImgD.height=(image.height*PicWidth)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   ImgD.alt=""; 
  } 
  else{ 
   if(image.height>PicHeight){
    ImgD.height=PicHeight; 
    ImgD.width=(image.width*PicHeight)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   ImgD.alt=""; 
  } 
 }
}




//修正IE PNG透明
function loadPng(o){

	if(document.all){
	    try{
		    var img = o;
		    var imgName = o.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;
			    if (img.align == "left"){
				    imgStyle = "float:left;" + imgStyle;
				}
			    if (img.align == "right") {
			        imgStyle = "float:right;" + imgStyle;
			    }
			    if (img.parentElement.href) {
			        imgStyle = "cursor:hand;" + imgStyle ;
			    }   
			    var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>"; 
			    img.outerHTML = strNewHTML;
		    }
	    }catch (e){}
	}
}
function logoPng(o){
    if (document.all){
        var img = o;
        
	    var imgID = (img.id) ? "'" + img.id + "' " : "";
	    var imgClass = (img.className) ?  img.className : "";
	    var imgTitle = (img.title) ?  img.title  : img.alt ;
	    var imgStyle = "display:inline-block;" + img.style.cssText;
	    if (img.align == "left"){
		    imgStyle = "float:left;" + imgStyle;
		}
	    if (img.align == "right") { 
	        imgStyle = "float:right;" + imgStyle;
	    }
	    if (img.parentNode.href) {
	        imgStyle = "cursor:hand;" + imgStyle ;
	    }   
	    
        var pp = document.createElement("span");
        pp.id = imgID;
        pp.className = imgClass;
        pp.title = imgTitle;
        pp.style.width = img.width + "px";
        pp.style.height = img.height + "px";
        pp.style.display = "inline-block";
        pp.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='image')";

//        var tt = document.createTextNode("logo");
//        pp.appendChild(tt);
        document.getElementById("logoimg").replaceChild(pp,img); 
    }
}




//
function iconHandler(){
    var obj=new Array;
    var status = $("hidLayOutTag").value;
    switch (status){
        case "1":
            var col=cleanWhitespaces($("page1"));
            for (var c=0;c<col.length;c++){
                var temp_obj=cleanWhitespaces(col[c]);
                for(var t=0;t<temp_obj.length;t++){
                    obj.push(temp_obj[t]);
                }
            }
            
        break;
        case "2":
            obj=cleanWhitespaces($("father"));
        break
    }
    //console.log(obj);
    for(var i=0;i<obj.length;i++){
 
        obj[i].onmouseover=function(){
            var _obj=this.id+"_icon";
            if ($(_obj)!=undefined)
                $(_obj).style.display="inline-block";
        };
        obj[i].onmouseout=function(){
            var _obj=this.id+"_icon";
            if ($(_obj)!=undefined)
                $(_obj).style.display="none";
        }
    }
}




var isOpera = (navigator.userAgent.indexOf('opera') != -1);
var isIE = /msie/i.test(navigator.userAgent) && !isOpera;

if (isIE) {
    var version = parseFloat(navigator.appVersion.split("MSIE")[1]);
      if(version == 6){
        document.execCommand('BackgroundImageCache', false, true);
      }
}

/*首页搜索模块排版*/
function sAll(){
    if ($("sdlBox")){
        var sw = $("sdlBox").clientWidth;
        //alert(sw)
        var inputw = parseInt(sw)-123;
        $("txtKey").style.width=inputw+"px";
	}
}

function CStyle(element){
	return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
