$(document).ready(function(){
	externalLinks();
	indexnews();
});
function externalLinks(){
	var _a = document.getElementsByTagName('a');
	var _c = window.location.href.split('/')[2];

	for(var i=0;i<_a.length;i++){
		// Links
		if(_a[i].href.indexOf(_c)==-1
		   && _a[i].href.indexOf('http')==0 && _a[i].href.length>0){
			_a[i].setAttribute('target','_blank');		// target
			_a[i].className +=' ext';					// class to add icon
			if(_a[i].title.length>0){
				//_a[i].title+=" ";
			}else{
				_a[i].title=_a[i].href;
			}
			_a[i].title+=' (Opens in a new window)';	// title
		}
		// PDF files
		if(_a[i].href.indexOf('.pdf')>0 && _a[i].href.length>0){
			_a[i].setAttribute('target','_blank');		// target
			_a[i].className +=' pdf';					// class to add icon
			//if(_a[i].title.length>0) _a[i].title+=' ';
			_a[i].title+=' (PDF Document)';				// title
		}
		if(_a[i].href=='#') _a[i].href='javascript:void(0);';
	}
}

function indexnews(){
	if($('.index #news .news')){
		$('.index #news ul.pn li.p a').click(function(){
			if($('.index #news .news .on').prev().length){
				$('.index #news .news .on').fadeOut(200).removeClass('on').prev().fadeIn(500).addClass('on');
			}else{
				$('.index #news .news li.on').fadeOut(200).removeClass('on');
				$($('.index #news .news li')[2]).fadeIn(200).addClass('on');
			}
			return false;
		});
		$('.index #news ul.pn li.n a').click(function(){
			if($('.index #news .news .on').next().length){
				$('.index #news .news .on').fadeOut(200).removeClass('on').next().fadeIn(500).addClass('on');
			}else{
				$('.index #news .news li.on').fadeOut(200).removeClass('on');
				$($('.index #news .news li')[0]).fadeIn(200).addClass('on');
			}
			return false;
		});
	}
}
function records(el){
	var _c=el.className;
	$('h3.tab').removeClass('on');
	$(el.parentNode).addClass('on');
	$('div.recordson').hide(0);
	$('div.'+_c).show(0).addClass('recordson');
	return false;
}