function initTooltip() {
	var _slideSpeed = 300;
	if (!$('div.link-tooltip').length) {
		_tip = $('body').append('<div class="link-tooltip"><div class="tooltip-inner"></div></div>');
	}
	_tip = $('div.link-tooltip');
	_tipcontent = _tip.find(" > div");

	$("a.tooltip").each(function(){
		var _parent = $(this);
		var _tooltip = _tip;
		var _offset = _parent.offset();
		var _hovering = false;
		_tooltip.css({opacity:0});
		var _ttext = $(this).attr("title");
		$(this).attr("title","");

		if(_tooltip.length) {
			$(this).hover(function(e){
				_tipcontent.html(_ttext);
				_hovering = true;
				if(_hovering) {
					_tooltip.css({left:_offset.left+10,top:_offset.top+30});
					_parent.css({position:"relative"});
					_tooltip.css({opacity:0});
					_tooltip.stop().show().animate({opacity: 1}, _slideSpeed, false);
				}
			},function(){
				_hovering = false;
				_tooltip.stop().animate({opacity: 0}, _slideSpeed, false, function(){
					_parent.css({position:"static"});
				});
			});

		}
	});
}

$(document).ready(function(){
	// init slideshow
	$('div.slide-show').slideShow({
		slideEl:'.slide-show-wrapper > ul li',
		numElementLink:'ul.pagenator a',
		linkNext:'a.next',
		linkPrev:'a.prev',
		autoSlideShow:true,
		switchTime:3000,
		duration:750,
		event:'click'
	});

	// init slider
	$(document).ready(function(){
		$('div.gallery-wrapper').galleryScroll({
			btPrev: 'a.btn-prev',
			btNext: 'a.btn-next',
			holderList: 'div',
			scrollElParent: 'ul.main-slider',
			scrollEl: 'li.item',
			slideNum: false,
			duration : 1000,
			step: false,
			circleSlide: true,
			disableClass: 'disable',
			funcOnclick: null
		});
	});

	// init tooltip
	initTooltip();
});

// External Links
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";
 }
}
window.onload = externalLinks;