/* IDENTIFY START */
var identifier = 0;
   
/* DOM READY */
$(function() {
	/* initialize tb language */
	//if(!!tbLanguage) tb_language(tbLanguage);
	//if(!!tbWindowWidth) tb_windowWidth(tbWindowWidth);
	
	/* text resizing for accessability */
	$('.textSizeDown').hide();
	$('.textSizeUp').bind("click", function(){
		var fontSize = $('.fontScaler').css('font-size').replace('px', '');
		if(fontSize < 15){
			$('.fontScaler').css('font-size', '13px');
			$('.textSizeDown').show();
			$('.textSizeUp').hide();
		}
	});
	$('.textSizeDown').bind("click", function(){
		var fontSize = $('.fontScaler').css('font-size').replace('px', '');
		if(fontSize > 7){
			$('.fontScaler').css('font-size', '11px');
			$('.textSizeDown').hide();
			$('.textSizeUp').show();
		}
	});	
	/* external links */
	$('a[rel="external"]').attr('target', '_blank');
	
	/* popup links */
	$('a[rel="popup"]').click(function() {
		var name = $(this).attr('id');
		if(!name) {
			name = 'identifier_' + ++identifier;
			$(this).attr('id', name);
		}
		var width   = height = 650,
		    top     = left   = 0,
		    percent = 80;
		if(!!screen.width) {
			width = Math.ceil((screen.width / 100) * percent);
			left  = Math.ceil((screen.width - width) / 2);
		}
		if(!!screen.height) {
			height = Math.ceil((screen.height / 100) * percent); 
			top    = Math.ceil((screen.height - height) / 2);
		}
		window.open($(this).attr('href'), name, 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes');
		return false;
	});
	
	/* download links */
	$('a[rel="download"]').click(function() {
		var file = $(this).attr('href'),
		    ext  = file.split('.').pop().toLowerCase();
		if($.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) > -1) {
			window.open(file);
			return false;
		}
	});
	
	// methods for fontsize
	$('.smallFont').bind("click", function(){
		$('.fontScaler').css('font-size', '11px');
	});
	$('.mediumFont').bind("click", function(){
		$('.fontScaler').css('font-size', '13px');
	});
	$('.largeFont').bind("click", function(){
		$('.fontScaler').css('font-size', '16px');

	});
});