function externalLinks(){
	/*
	if(!document.getElementsByTagName){
		return
	}
	var c=document.getElementsByTagName("a");
	for(var b=0;b<c.length;b++){
		var a=c[b];
		if(a.getAttribute("href")&&a.getAttribute("rel")=="external"){
			a.target="_blank"
		}
	}
	*/
		$('a[href^="http://"]').not('[href^="http://'+location.hostname+'"]').each(function() {			

			var imgObject = new Image(),
				nowElt = this,
				nowEltOfJq = $(nowElt);	
			var anchorTitle = nowEltOfJq.attr('title');	
			
			if(nowEltOfJq.children().length==0) {
				if(typeof(anchorTitle)=='undefined') anchorTitle = nowEltOfJq.html();	
			}
			 			
			var newAnchorTitle = anchorTitle+'(另開新視窗)';			
			nowEltOfJq.attr('title', newAnchorTitle);
			nowEltOfJq.attr('target', '_blank');		
		});	
};

$(document).ready(function(){

	$('ul.list>li>span').click(function(){
		$(this).nextAll('ul').toggle(100,function(){
			if($(this).css('display')=='none') {
				$(this).parent().children('img').show();
				$(this).parent().find('.toggleFlag').html('+');
			}
			else {
				$(this).parent().children('img').hide();
				$(this).parent().find('.toggleFlag').html('-');	
			}			
		});

	});
	
	$('#banner').css({'z-index':'500'});	
	$('div.sub').css({'z-index':'-10000','display':'block'});
	
	var hideNaviCourseImg = false;
	var eltOfNaviCourse = $('div.sub dl.list');
	var naviCourseNum = eltOfNaviCourse.size();
	var naviCourseNumMod = naviCourseNum%4;
	if(naviCourseNumMod==0 || naviCourseNumMod==3) hideNaviCourseImg = true;
	if(naviCourseNumMod< 3 )
	{
		navCourseKey1 = naviCourseNum-2;
		
		if(navCourseKey1%4 == 0) navCourseKey2 = navCourseKey1 -1;
		else navCourseKey2 = navCourseKey1 +1;
		
		eltKey1 = eltOfNaviCourse.eq(navCourseKey1 -1 );
		heightKey1 = eltKey1.height();
		topKey1 = eltKey1.offset().top;
		
		eltKey2 = eltOfNaviCourse.eq(navCourseKey2 -1 );
		heightKey2 = eltKey2.height();
		topKey2 = eltKey2.offset().top;	
		
		naviCourseImgTop = $('div.sub ul.etc').offset().top;
		
		if(topKey1+heightKey1>naviCourseImgTop || topKey2+heightKey2> naviCourseImgTop)	 hideNaviCourseImg = true;
		
	}
	
	/*if( hideNaviCourseImg ) $('div.sub ul.etc').hide();
	else $('div.sub ul.etc').show();*/
	//alert($('dl.list').eq(1).height());
	$('div.sub').css({'z-index':'','display':''});
	$('#banner').css({'z-index':''});	
	//alert('test');
	
	

});


