﻿function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (typeof element == 'string')
            element = document.getElementById(element);
        if (arguments.length == 1)
            return element;
        elements.push(element);
    }
    return elements;
}


function ShowOrHide(element) {

    if (($(element).style.display == '') || ($(element).style.display == 'none'))  {
        $(element).style.display = 'block';
        
    }
    else {
        $(element).style.display = 'none';
    
     }

 }

function ClipImageAndMove(obj,top,right,bottom,left) {
    //alert("rect(" + parseInt(top) + "px," + parseInt(right) + "px," + parseInt(bottom) + "px," + parseInt(left) + "px)");
    //$(obj).style.clip = "rect(" + parseInt(top) + "px," + parseInt(right) + "px," + parseInt(bottom) + "px," + parseInt(left) + "px)";
    $(obj).style.left = parseInt(-left)+"px";
    $(obj).style.top = parseInt(-top)+"px";
}

function ReSize(obj,iWidth,iHeight)
{
 	var OutHeight;// = $(obj).height;
	var OutWidth;// = $(obj).width;
	if (iWidth/iHeight >= $(obj).width/$(obj).height)
 	{
		OutHeight=iWidth/$(obj).width*$(obj).height;
		OutWidth=iWidth;
	}
 	else
	{ 
		OutHeight = iHeight;
		OutWidth = iHeight/$(obj).height*$(obj).width;
	}
	$(obj).height = parseInt(OutHeight);
	$(obj).width = parseInt(OutWidth);
	//alert(parseInt(OutWidth) + ":" + parseInt(OutHeight));
}

function ResizeAndClip(img,wdata,hdata)
{
    //$(img).style.display = "none";   
    
    ReSize(img, wdata, hdata);
	var tmpW = $(img).width;
	var tmpH = $(img).height;
    //alert("Test ["+tmpW+":"+tmpH+"]");
	ClipImageAndMove(img,tmpH/2-hdata/2,tmpW/2+wdata/2,tmpH/2+hdata/2,tmpW/2-wdata/2);
	//ClipImage(obj,0,160,160,0);
	//$(frame)
	//$(img).style.display = "block"; 
}


function Show(element) 
{
    $(element).style.display = "block";
}

function ShowAll()
{
    $('LeftMenuCompany').style.display = "block";
    $('LeftMenuParty').style.display = "block";
    $('LeftMenuNews').style.display = "block";
    $('LeftMenuProduct').style.display = "block";
    $('LeftMenuSupport').style.display = "block";
    $('LeftMenuCase').style.display = "block";
    $('LeftMenuHR').style.display = "block";
}
 
 
 
 
 
 
 // 说明：用 JavaScript 实现网页图片等比例缩放 
 // 整理：http://www.CodeBit.cn  
 function DrawImage(ImgD,FitWidth,FitHeight)
 {    
    var image=new Image();
    image.src=ImgD.src;
    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;             
            }
          }     
      }
 } 