﻿$(function(){
    var pageName=$('#hfPageName').val();
    if(pageName=='default.aspx'){$('#item1').addClass('selected');}
    if(pageName=='company.aspx'){$('#item2').addClass('selected');}
    if(pageName=='companynews.aspx'||pageName=='newsdetail.aspx'){$('#item3').addClass('selected');}
    if(pageName=='services.aspx'){$('#item4').addClass('selected');}
    if(pageName=='customer.aspx'){$('#item5').addClass('selected');}
    if(pageName=='projectworks.aspx'|| pageName=='projectworksdetail.aspx'){$('#item6').addClass('selected');}
    if(pageName=='fashionshow.aspx'|| pageName=='fashionshowdetail.aspx'){$('#item7').addClass('selected');}
    if(pageName=='resource.aspx'){$('#item8').addClass('selected');}
    if(pageName=='member.aspx'){$('#item9').addClass('selected');}
    if(pageName=='contact.aspx'){$('#item10').addClass('selected');}
    
    var nId=$.query.get('id');
    var cId=$.query.get('cid');
    
    if(nId>0){$('#Id'+nId).addClass('selected');}
    else{ if(!cId>0) $('.leftNav li:first-child').addClass('selected');}

    if(cId>0){$('#Id'+cId).addClass('selected');}
    else{ if(!nId>0) $('.leftNav li:first-child').addClass('selected');}
});

function change_ImgWidth(obj,width){
    var img=$(obj+' img');
    
    if(img.width()>width){
        var o_width=img.width();
        var o_height=img.height();
        var height=(o_height*width)/o_width
        img.width(width);
        img.height(height);
    }
}

if(navigator.userAgent.indexOf("MSIE")>-1){window.attachEvent("onload", correctPNG);};


// 显示顶部提示层
function showTop(obj, elementid,objleftoffset,objtopoffset, objwidth )
{
   var pos = $(obj).offset();
   var height=$(obj).height();
   var owidth=$('#dv_topmenu'+elementid).width();

   var left=parseInt(pos.left,10)+objleftoffset;
   var top = parseInt(pos.top,10)+objtopoffset+height;
   
   $('#dv_topmenu'+elementid).css('left',left);
   $('#dv_topmenu'+elementid).css('top',top);
   
   if(objwidth!=0){$('#dv_topmenu'+elementid).css('width',objwidth);}
   
   $('#dv_topmenu'+elementid).show();
   $('.tm').show();
}

// 显示顶部菜单分类
function showTopmenu(obj,id, objleftoffset,objtopoffset, objwidth){
    showTop(obj, id, objleftoffset,objtopoffset, objwidth )
}

function hideTop(id){
    $('#dv_topmenu'+id).hide();
}

// 移动到菜单上，依然显示顶部菜单分类
function showTopmenuOver(id){
     $('#dv_topmenu'+id).show();
}

// 隐藏顶部菜单分类
function hideTopmemu(id){
    $('#dv_topmenu'+id).hide();
}

function Addme(){ 
url = "http://www.qfsj.com"; //你自己的主页地址 
title = "庆丰企业"; //你自己的主页名称 
window.external.AddFavorite(url,title); 
}

function menuHover(eid,overId,outId){
    $("."+eid).hover( 
    function(){$(this).attr('src','/images/default/newsMenu'+overId+'.jpg');}, 
    function(){$(this).attr('src','/images/default/newsMenu'+outId+'.jpg')} 
    ); 
}
        
        
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
   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='scale');\"></span>"
   img.outerHTML = strNewHTML
   i = i-1
   };
   };
};
     
     
        //图片滚动列表 mengjia 070927
        var Speed_1 = 10; //速度(毫秒)
        var Space_1 = 20; //每次移动(px)
        var PageWidth_1 = 960 * 1; //翻页宽度
        var interval_1 = 5000; //翻页间隔
        var fill_1 = 0; //整体移位
        var MoveLock_1 = false;
        var MoveTimeObj_1;
        var MoveWay_1 = "right";
        var Comp_1 = 0;
        var AutoPlayObj_1 = null;
        function GetObj(objName) { if (document.getElementById) { return eval('document.getElementById("' + objName + '")') } else { return eval('document.all.' + objName) } }
        function AutoPlay_1() { clearInterval(AutoPlayObj_1); AutoPlayObj_1 = setInterval('ISL_GoDown_1();ISL_StopDown_1();', interval_1) }
        function ISL_GoUp_1() { if (MoveLock_1) return; clearInterval(AutoPlayObj_1); MoveLock_1 = true; MoveWay_1 = "left"; MoveTimeObj_1 = setInterval('ISL_ScrUp_1();', Speed_1); }
        function ISL_StopUp_1() {
            if (MoveWay_1 == "right") { return }; clearInterval(MoveTimeObj_1); if ((GetObj('ISL_Cont_1').scrollLeft - fill_1) % PageWidth_1 != 0) { Comp_1 = fill_1 - (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1); CompScr_1() } else { MoveLock_1 = false }
            AutoPlay_1()
        }
        function ISL_ScrUp_1() {
            if (GetObj('ISL_Cont_1').scrollLeft <= 0) { GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft + GetObj('List1_1').offsetWidth }
            GetObj('ISL_Cont_1').scrollLeft -= Space_1
        }
        function ISL_GoDown_1() { clearInterval(MoveTimeObj_1); if (MoveLock_1) return; clearInterval(AutoPlayObj_1); MoveLock_1 = true; MoveWay_1 = "right"; ISL_ScrDown_1(); MoveTimeObj_1 = setInterval('ISL_ScrDown_1()', Speed_1) }
        function ISL_StopDown_1() {
            if (MoveWay_1 == "left") { return }; clearInterval(MoveTimeObj_1); if (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1 - (fill_1 >= 0 ? fill_1 : fill_1 + 1) != 0) { Comp_1 = PageWidth_1 - GetObj('ISL_Cont_1').scrollLeft % PageWidth_1 + fill_1; CompScr_1() } else { MoveLock_1 = false }
            AutoPlay_1()
        }
        function ISL_ScrDown_1() {
            if (GetObj('ISL_Cont_1').scrollLeft >= GetObj('List1_1').scrollWidth) { GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft - GetObj('List1_1').scrollWidth }
            GetObj('ISL_Cont_1').scrollLeft += Space_1
        }
        function CompScr_1() {
            if (Comp_1 == 0) { MoveLock_1 = false; return }
            var num, TempSpeed = Speed_1, TempSpace = Space_1; if (Math.abs(Comp_1) < PageWidth_1 / 2) { TempSpace = Math.round(Math.abs(Comp_1 / Space_1)); if (TempSpace < 1) { TempSpace = 1 } }
            if (Comp_1 < 0) {
                if (Comp_1 < -TempSpace) { Comp_1 += TempSpace; num = TempSpace } else { num = -Comp_1; Comp_1 = 0 }
                GetObj('ISL_Cont_1').scrollLeft -= num; setTimeout('CompScr_1()', TempSpeed)
            } else {
                if (Comp_1 > TempSpace) { Comp_1 -= TempSpace; num = TempSpace } else { num = Comp_1; Comp_1 = 0 }
                GetObj('ISL_Cont_1').scrollLeft += num; setTimeout('CompScr_1()', TempSpeed)
            } 
        }
        function picrun_ini() {
            GetObj("List2_1").innerHTML = GetObj("List1_1").innerHTML;
            GetObj('ISL_Cont_1').scrollLeft = fill_1 >= 0 ? fill_1 : GetObj('List1_1').scrollWidth - Math.abs(fill_1);
            GetObj("ISL_Cont_1").onmouseover = function() { clearInterval(AutoPlayObj_1) }
            GetObj("ISL_Cont_1").onmouseout = function() { AutoPlay_1() }
            AutoPlay_1();
        } 
        
function play_video(width,height,file,emid,autostart,image)
{
    var s1 = new SWFObject("/js/flv/flvplayer_player.swf","ply",width,height,"9","#000000");
    s1.addParam("allowfullscreen","true");
    s1.addParam("allowscriptaccess","always");
	s1.addParam("menu","false");
    s1.addParam("wmode","opaque");
    s1.addParam("overstretch","fit");
	s1.addParam("flashvars","file="+file+"&autostart="+autostart+'&image='+image);
    s1.write(emid);
}
