// JavaScript Document
$(function(){
    // -------- start --------------------------------------------------------------
    //预加载图片
    var preLoadImgArray = new Array();
    preLoadImgArray[0] = '/skin/front/images/memberlogin_.png';
    //......
    
    var imgObj = new Image();
    for (var i = 0; i < preLoadImgArray.length; i++) {
        imgObj.src = preLoadImgArray[i];
    }
    
    //IE6 PNG 图片透明问题（IMG SRC）
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters)) {
        for (var j = 0; j < document.images.length; j++) {
            var img = document.images[j]
            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
                j = j - 1
            }
        }
    }
    
    
    
    //search box
    
    $(".searchbox th:first").css("background", "url(/skin/front/images/searchbg.jpg)").css("color", "#fff");
    $(".searchbox th").click(function(){
        var targetController = this.id;
        $(".searchbox th").css("background", "none").css("color", "#454545");
        this.style.background = 'url(/skin/front/images/searchbg.jpg)';
        this.style.color = '#fff';
        $("#serchBoxBt").unbind("click").click(function(){
            window.open("/" + targetController + "/index/search/" + $("#searchBoxInput").val())
        });
    });
    try {
        controller
    } 
    catch (e) {
        controller = null;
    }
    if (controller) {
        $(".searchbox th").each(function(){
            if (this.id == controller) {
                $(".searchbox th").css("background", "none").css("color", "#454545");
                this.style.background = 'url(/skin/front/images/searchbg.jpg)';
                this.style.color = '#fff';
                $("#serchBoxBt").unbind("click").click(function(){
                    window.open("/" + controller + "/index/search/" + $("#searchBoxInput").val())
                });
            }
        });
    }
    else {
        $("#serchBoxBt").click(function(){
            window.open("/" + $(".searchbox th:first").attr('id') + "/index/search/" + $("#searchBoxInput").val())
        });
    }
    //main menu
    var div=$('#whenover').css('visibility', 'visible').children().fadeTo(0,0);
    $('#whenover').children().each(function(){
		var divChild=$(this);
		var childSpan=divChild.children("span");
		divChild.hover(function(){
			//子菜单(span 标记)		
			if(childSpan[0] != undefined){
				childSpan.css('display','block');
				divChild.stop().fadeTo('', 1).css('height','100px');
				//setTimeout(function(){.fadeTo('',1)},300);
			}else{
				divChild.stop().fadeTo('', 1);
			}
			
			},function(){
				divChild.stop().fadeTo('', 0).css('height','60px');
				childSpan.css('display','none');
			}
		);
	});
	
	
    $('.searchbt').mouseover(function(){
        $(this).css('background', 'url(/skin/front/images/searchbt2.jpg) no-repeat')
    }).mouseout(function(){
        $(this).css('background', 'url(/skin/front/images/searchbt.jpg) no-repeat')
    });
    //login button
    $('#loginToMemberBt').mouseover(function(){
        $(this).css('background', 'url(/skin/front/images/memberlogin_.png)')
    }).mouseout(function(){
        $(this).css('background', 'url(/skin/front/images/memberlogin.jpg)')
    });
    //flash focus
    var flashFocus = $('flashFocus');
    $('flashFocus').media({
        'src': flashFocus.attr('src'),
        width: flashFocus.attr('width'),
        height: flashFocus.attr('height'),
        allowscriptaccess: 'always',
        allowfullscreen: 'true',
        quality: 'high',
        name: 'mymovie',
        id: 'mymovie',
        
        //flashvars:{pics:flashFocus.attr('pics'),links:flashFocus.attr('links'),texts:flashFocus.attr('titles'),borderwidth:flashFocus.attr('width'),borderheight:(flashFocus.attr('height')-flashFocus.attr('textHeight')),textheight:flashFocus.attr('textHeight')}
        flashvars: {
            pw: flashFocus.attr('width'),
            ph: flashFocus.attr('height'),
            Times: 4000,
            sizes: 14,
            umcolor: 16777215,
            bgnub: 0,
            btnbg: 14540001,
            hovercolor: 0,
            txtcolor: 16777215,
            txtLeft: 10,
            nubtouming: 100,
            hovertouming: 100,
            urls: flashFocus.attr('links'),
            titles: flashFocus.attr('titles'),
            imgs: flashFocus.attr('pics')
        }
    });
    
	//滚动内容
	var mover=$("#marqueener");
	if(mover.length){
		var i=0;
		var containner=mover.parent();
		var timer;
		var contentsHeight=containner[0].scrollHeight;
		
		mover.append(mover.html());
		containner.hover(
			function(){ 
				clearTimeout(timer);
			},
			function(){
				timer=setInterval(function(){
				if(containner.scrollTop()  < contentsHeight){
					containner.scrollTop(i++);
				  }else{
					clearTimeout(timer);
					i=0;
					containner.scrollTop(0);
					containner.trigger("mouseout");
					//arguments.callee();
			  }		
			  },50);
			}
		);
		containner.trigger("mouseout");
	}
    
    // -------- over --------------------------------------------------------------
});

