$(document).ready(function(){
	
	if ($('a.lightbox').length > 0) {
		//$(".lightbox").lightbox();
		$('a.lightbox').fancybox({
			'zoomSpeedIn': 0,
			'zoomSpeedOut': 0,
			'overlayShow': true,
			'overlayOpacity': .85,
			'frameWidth': 509,
			'frameHeight': 381
		});
	};

	jQuery.fn.slideToggleUp = function(speed, easing, callback) {
	        var h = 0;
	        if(this.css('display') == 'none'){
	                this.css('display','inherit');
	                h = this.height() + parseInt(this.css('paddingTop')) +
	parseInt(this.css('paddingBottom'));
	                this.css('marginTop', -h);
	        }
	        h = this.height() + parseInt(this.css('paddingTop')) +
	parseInt(this.css('paddingBottom'));
	        return this.animate({marginTop: parseInt(this.css('marginTop')) < 0 ?
	0 : -h}, speed, easing, callback);
	};
	

	$("ul#accordion li div").hide();
	$("ul#accordion li a").click(function() {
		$(this).siblings('img').toggle();
		$(this).next().slideToggle();
		return false;
	});
	
	$("p.toexpand").hide();
	$("p.expand a").click(function() {
		$("p.toexpand").slideToggle("normal");
		return false;
	});
	
	function setText(current) {
		$('a.small').html('a');
		$('a.medium').html('a');
		$('a.large').html('a');
		
	 	$('a.'+current).html('<span class="hit">a</span>');
	}	

	// reset font size
	// small Font size
	$(".small").click(function(){
		$('html').css('font-size', 13);
		setText('small');
		return false;
	});

	// medium Font Size
	$(".medium").click(function(){
		//var currentFontSize = $('html').css('font-size');
		//var currentFontSizeNum = parseFloat(currentFontSize, 10);
		//var newFontSize = currentFontSizeNum*0.8;
		$('html').css('font-size', 15);
		setText('medium');
		return false;
	});
	
	// large Font Size
	$(".large").click(function(){
		//var currentFontSize = $('html').css('font-size');
		//var currentFontSizeNum = parseFloat(currentFontSize, 10);
		//var newFontSize = currentFontSizeNum*1.2;
		$('html').css('font-size', 17);
		setText('large');
		return false;
	});
	
	function externalLinks() {
	 if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("href") &&
	       anchor.getAttribute("rel") == "external")
	     anchor.target = "_blank";
	 }
	}
	externalLinks();

});