$(function(){

	/**
	 *	電腦大補帖
	 */
	$(".knowledge_event").click(function(){
		if ($(this).parent().parent().find("div").css("display")=="none")
			$(this).parent().parent().find("div").css({display:"block"});
		else 
			$(this).parent().parent().find("div").css({display:"none"});
	});
	if ($(".knowledge_event").size()>0) {
		var i=0;
		$(".knowledge_event").each(function(i){
			if (i<3) {
				$(this).parent().parent().find("div").css({display:"block"});
				i++;
			}
		});
	}
	/*
	var flashvars = '';
	var params=new Object();
	params.wmode="transparent";
	var attributes = ''; 
	swfobject.embedSWF("templates/default/flash/banner.swf", "flash_website", "745", "146", "9.0.0", "js/swfobject/expressInstall.swf", flashvars, params, attributes);
	*/
	
	/**
	 *	上方banner輪撥
	 */
	var slideshow_data=[];
	$(".slideshow > a").each(function(){
		slideshow_data[slideshow_data.length]={
			src:$(this).find("img").attr("src"),
			href:$(this).attr("href"),
			alt:$(this).find("img").attr("alt")
		};
	});
    $('#banner').crossSlide({
		  sleep: 2,
		  fade: 1
		}, slideshow_data
	);

	/**
	 *	跑馬鐙
	 */
	$('.marquee').kxbdMarquee({
		isEqual:false,
		direction:'up',
		scrollDelay:50
	});
	
	/**
	 *	自動把字串多出來的字元變成... 用法:class="truncate" length="10"
	 */
	$(".truncate").each(function(){
		var _len=$(this).attr("length");
		var _txt=$(this).text();
		var _txt2=_txt.substring(0,_len);
		if (_txt!=_txt2)
			$(this).text(_txt2+'...');
	});

});

$(window).load(function(){
	if ($.browser.msie) {
		document.execCommand("BackgroundImageCache",false,true);
	}
});
/*
// 當網頁載入完
$(window).load(function(){
	var $win = $(window),
		$ad = $('#abgne_float_ad').css('opacity', 0).show(),	// 讓廣告區塊變透明且顯示出來
		_width = $ad.width(),
		_height = $ad.height(),
		_diffY = 20, _diffX = 20,	// 距離右及下方邊距
		_moveSpeed = 800;	// 移動的速度
 
	// 先把 #abgne_float_ad 移動到定點
	$ad.css({
		//top: $(document).height(),
		top: "40px",
		left: $win.width() - _width - _diffX,
		opacity: 1
	});
 
	// 幫網頁加上 scroll 及 resize 事件
	$win.bind('scroll resize', function(){
		var $this = $(this);
 
		// 控制 #abgne_float_ad 的移動
		$ad.stop().animate({
			//top: $this.scrollTop() + $this.height() - _height - _diffY,
			top:$this.scrollTop() + 40,
			left: $this.scrollLeft() + $this.width() - _width - _diffX
		}, _moveSpeed);
	}).scroll();	// 觸發一次 scroll()
 
	// 關閉廣告
	$('#abgne_float_ad .abgne_close_ad').click(function(){
		$ad.hide();
	});
});*/
