// JavaScript Document

/* ===============================================
  
  按鈕的檔名，請在名稱後面加上_on; 例如:  「xx.jpg」→「xx_on.jpg」
=============================================== */
function initRollOverImages(){
	var image_cache = new Object();
	$("img.rover,input.rover").each(function(i){
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_ro;
		$(this).hover(function(){
			if(!$(this).hasClass("active")){this.src = imgsrc_ro;}
		},function(){
			if(!$(this).hasClass("active")){this.src = imgsrc;}
		});
	});
}

$(document).ready(function(){initRollOverImages();});


/* ===============================================
  
  gotop
=============================================== */
$(function(){
	// 幫 a.gotoTOP 加上 click 事件
	$('a.gotoTOP').click(function(){
		// 讓捲軸用動畫的方式移動到 0 的位置
		var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
		$body.animate({
			scrollTop: 0
		}, 800);
 
		return false;
	});
});

/* ===============================================
  
  變換product item底色
=============================================== */
$(function(){
		//當滑鼠滑入時將div的class換成item_over
		$('.item').hover(function(){
				$(this).addClass('item_over');		
			},function(){
				//滑開時移除item_over樣式
				$(this).removeClass('item_over');	
			}
		);
	});

/* ===============================================
  
  變換news line底色
=============================================== */
$(function(){
		//當滑鼠滑入時將div的class換成item_over
		$('.newsLine').hover(function(){
				$(this).addClass('newsLine_over');		
			},function(){
				//滑開時移除item_over樣式
				$(this).removeClass('newsLine_over');	
			}
		);
	});

/* ===============================================
  
  變換event box底色
=============================================== */
$(function(){
		//當滑鼠滑入時將div的class換成item_over
		$('.eventBox').hover(function(){
				$(this).addClass('eventBox_over');		
			},function(){
				//滑開時移除item_over樣式
				$(this).removeClass('eventBox_over');	
			}
		);
	});

/* ===============================================
  
  變換banner 300x100
=============================================== */
$(function(){
		$('.round').hover(function(){
				$(this).addClass('round_over');		
			},function(){
				$(this).removeClass('round_over');	
			}
		);
	});
	
	
/* ===============================================
  
  變換blogger底色
=============================================== */
$(function(){
		$('.bYellow').hover(function(){
				$(this).addClass('bYellow_over');		
			},function(){
				$(this).removeClass('bYellow_over');	
			}
		);
		$('.bPurple').hover(function(){
				$(this).addClass('bPurple_over');		
			},function(){
				$(this).removeClass('bPurple_over');	
			}
		);
		$('.bOrange').hover(function(){
				$(this).addClass('bOrange_over');		
			},function(){
				$(this).removeClass('bOrange_over');	
			}
		);
		$('.bBlue').hover(function(){
				$(this).addClass('bBlue_over');		
			},function(){
				$(this).removeClass('bBlue_over');	
			}
		);
		$('.bRed').hover(function(){
				$(this).addClass('bRed_over');		
			},function(){
				$(this).removeClass('bRed_over');	
			}
		);
		$('.bGreen').hover(function(){
				$(this).addClass('bGreen_over');		
			},function(){
				$(this).removeClass('bGreen_over');	
			}
		);
	});

/* ===============================================
  
  展開TVC
=============================================== */
$(document).ready(function() {
 //Hide (Collapse) the toggle containers on load
	$(".TVC").hide();
 // toggles the slickbox on clicking the noted link  
  	$('.btnTVC').click(function() {
    $('.TVC').fadeToggle('slow');
    return false;
  });
});


/* ===============================================
  
  select box
=============================================== */
$(function(){
		$('.myselectbox').selectbox();
	});


/* ===============================================
  
  fancy box
=============================================== */
$(document).ready(function() {
	$("a.largeNewsPhoto").fancybox({
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'titlePosition'	: 'inside'
			});
	$(".openTVC").fancybox({
				'width'				: 480,
				'height'			: 360,
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
});


/*
$(document).ready(function(){	
	$(".slider").easySlider();
});
*/

