function DrawImage(ImgD,iwidth,iheight){
    var image=new Image();
    var s = {};
    image.src=ImgD.attr("src");
    if(image.width>0 && image.height>0){
        if(image.width/image.height>= iwidth/iheight){
            if(image.width>iwidth){
				s.width = iwidth;
				s.height = (image.height*iwidth)/image.width;
            }else{
				s.width = image.width;
				s.height = image.height;
            }
        }else{
            if(image.height>iheight){
            	s.width = (image.width*iheight)/image.height;
				s.height = iheight;
            }else{
                s.width = image.width;
				s.height = image.height;
            }
        }
        ImgD.attr("width",s.width);
        ImgD.attr("height",s.height);
    }
    return s;
};
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var g_ClassID = "",g_ClassID2 = "";
function getSmallClass(){
    var ClassID = $.url.attr("path");
    ClassID = ClassID.split(".")[0];
    var ClassID2 = ClassID.split(",");ClassID2 = ClassID2[ClassID2.length-2];
    ClassID2 = g_ClassID2 || ClassID2;
    ClassID = ClassID.substring(ClassID.lastIndexOf(",")+1,ClassID.length);
    ClassID = g_ClassID || parseInt(ClassID);
    var OBJTD = $("#Class"+ClassID);
    $("#Class"+ClassID).show(200);
    OBJTD.html("<ul><li>Loading...</li></ul>");
    $.getJSON("/Script/ajax.asp?act=getsmallclass&classid="+ClassID,function(Json){
        var temp = "<ul>";
        if(Json.error!=0){
            temp += "<li>"+Json.error+"</li>";
        }else{
            var Data = Json.data;
            for(var key=0;key<Data.length;key++){
               temp += "<li id='small"+Data[key].classid+"'><a href='/products,"+encodeURIComponent(Data[key].classname)+",1,"+Data[key].classid+","+ClassID+".html' title='"+Data[key].classname+"'>"+Data[key].classname+"</a></li>";        
            };
        };
        temp += "</ul>";
        OBJTD.html(temp);
        //ClassID2
        $("#small"+ClassID2+">a").css({"color":"#CC020E","font-weight":"bold"})
    })
};


var G_Num = null;
function checkmenu(ID,over){
    if(!ID)ID=1;
    if(over){
        $("#Image"+ID).attr("src","/images/top_0"+ID+".gif");
    }else{
        if(ID==G_Num)return;
        $("#Image"+ID).attr("src","/images/top1_0"+ID+".gif");
    };
};
//topImg
function checktopImg(ID){
    if(!ID)ID = 1;
    $("#topImg").html("<img src='/flash/"+ID+".jpg' width='980' height='351'>");
};
function checkPic(){
    var linkArr = ["index","about","products","news","quality","production","contact"];
    var url = $.url.attr("path").toLowerCase();
    url = (url=="/"?"index":url);
    for(var ii=0;ii<linkArr.length;ii++){
        if(url.indexOf(linkArr[ii])!=-1){
            G_Num = ii+1;
            break;
        }
    };
    if(G_Num)checkmenu(G_Num,1);
    checktopImg(G_Num);
};

$(function(){
    $("#menu td a").each(function(ii){
        $(this).bind("mouseover",function(){
            checkmenu(ii+1,1);
        }).bind("mouseout",function(){
            checkmenu(ii+1);
        })    
    });
    checkPic();
})

