﻿function isobj(id){if(typeof(id)=="object"){return true;}else{return false;}}
function getid(id){if(isobj(id)){return id;}else{return document.getElementById(id);}}$=getid;  
function menuitemclass(o,type)
{
    var classname=type==1?"item1":"item";
    o=getid(o);
    o.className=classname;
}
function tourl(url)
{
    location.href=url;
}
function setimagesize(ImgD,width,height)
{ 
var image=new Image();
image.src=getid(ImgD).src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= width/height){
if(image.width>width){  
ImgD.width=width;
ImgD.height=(image.height*width)/image.width;
}else{
ImgD.width=image.width;  
ImgD.height=image.height;
}
}else{
if(image.height>height){  
ImgD.height=height;
ImgD.width=(image.width*height)/image.height;     
}else{
ImgD.width=image.width;  
ImgD.height=image.height;
}
}
}
}
function createHttpRequest()
{
    var xmlHttp;
    if(window.ActiveXObject)
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        if(window.XMLHttpRequest)
        {
            xmlHttp=new XmlHttpRequest();
        }
    }
    return xmlHttp;
}
function geturlcontent(url)
{
    var myhttp=createHttpRequest();
    myhttp.open("GET",url,false);
    myhttp.send();
    if(myhttp.status==200)
    {
        return myhttp.responseText;
    }
    else
    {
        return "";
    }
}
function PutNewsHits(id)
{
    var value=geturlcontent("jsdata.aspx?t=newshits&id="+id+"&r="+(new Date()));
    //setTimeout("document.write("+value+")",2000);
    setTimeout("getid('newshits').innerText='"+value+"';",500);
}
function setdefault(o,url)
{
    o.style.behavior='url(#default#homepage)';
    o.setHomePage(url);
}
var menus={
//"submenu1":"<a href=\"AboutUs.asp\">关于我们</a><br>"+
//"<a href=\"Product.asp\">产品展示</a><br>"+
//"<a href=\"Contactus.asp\">联系我们</a><br>"+
//"",
//"submenu2":"<a href=\"AboutUs.asp\">关于我们2</a><br>"+
//"<a href=\"Product.asp\">产品展示2</a><br>"+
//"<a href=\"Contactus.asp\">联系我们2</a><br>"+
//""
};
var topmenu=new TopMenu();
function ShowTopMenu(k,o,w)
{
if(!w)w=0;
var obj=getid(k);
var content=obj?obj.innerHTML:"";
topmenu.show(o,content,w);

}
function HideTopMenu()
{
topmenu.hidden();
}
function TopMenu()
{
}
TopMenu.prototype.show=function(control,str)
{
var xy=this.getAbsPoint(control);
this.menu=getid("TopMenuSub");
this.menutitle=getid("TopMenuSubTitle");
this.menu.style.display="";
this.menutitle.innerHTML=str;
this.menu.style.left=xy.x+20;
this.menu.style.top=xy.y+control.offsetHeight;
}
TopMenu.prototype.hidden=function()
{
this.menu.style.display="none";
}
TopMenu.prototype.getAbsPoint = function (e)
{
e=getid(e);
var x = e.offsetLeft;
var y = e.offsetTop;
while(e = e.offsetParent){
    x += e.offsetLeft;
    y += e.offsetTop;
}
return {"x": x, "y": y};
}
function menudivinit()
{
temp="";
temp+="<div id=\"TopMenuSub\" style=\"position: absolute; display: none; z-index: 10000;";
temp+="\" onmouseover=\"this.style.display='';event.cancelBubble=true;\"";
temp+="onmouseout=\"HideTopMenu();\">";
temp+="<div id=\"TopMenuSubTitle\">";
temp+="</div>";
temp+="</div>";
getid("bottomdiv").innerHTML=temp;
}


