// CUSTOM SCRIPT by iKarina & iGor - http://themeforest.net/user/iKarina
$(function(){
// HOVER ANIMATION FOR PORTFOLIO #3 TEMPLATE
	$('img.pf3link').mouseenter(function(){
		$(this).stop(true, false).animate({ opacity: "1" }, 200)
	})
	$('img.pf3link').mouseleave(function(){
			$(this).stop(true, true).animate({ opacity: "0.01" }, 200, fix);
			function fix() {
				if ($('img.pf3link').mouseleave) {
					$(this).animate({ opacity: "0.01" }, "fast")
				}
			}
	})
// ANIMATED TOOLTIPS
$(".tooltip").mouseenter(function(){
	var tt_title = $(this).attr("title");
	if (tt_title) {
		var tt_id = 'tt_id' + Math.floor(Math.random()*999);
		$(this).attr('title','');
		$("body").append('<div id="' + tt_id + '" class="tt_wrap"><div class="ttbox"><span>' + tt_title + '</span></div></div>');
		offset = $(this).offset();
		width = $(this).outerWidth() / 2;
		tt_left = offset.left - 90 + width;
		tt_top = offset.top - 250;
		tt_wrap_id = '#' + tt_id;
		var tt_box_id = tt_wrap_id + '> div';
		$(tt_wrap_id).css({left: tt_left, top: tt_top});
		$(tt_box_id).css({bottom:15, opacity:0}).animate({bottom:5, opacity:1}, 300);
	}
	$(this).mouseleave(function(){
		$(tt_box_id).stop().animate({bottom:30, opacity:0}, 150, rem);
			function rem() {
				$(this).parent().remove();
			}
		$(this).attr('title',tt_title);
	})
})
// MENU ROUNDED CORNERS for default WP3 menu
	$('div.menu ul ul li:first-child').addClass('li-first');
	$('div.menu ul ul li:last-child').addClass('li-last');
	$('div.menu ul ul ul li:first-child').addClass('li-first');
	$('div.menu ul ul ul li:last-child').addClass('li-last');
	$('div.menu ul ul').prev().addClass('a-level');
	$('div.menu ul ul ul').prev().removeClass('a-level');
// MENU ROUNDED CORNERS for custom WP3 menu
	$('ul.menu ul li:first-child').addClass('li-first');
	$('ul.menu ul li:last-child').addClass('li-last');
	$('ul.menu ul ul li:first-child').addClass('li-first');
	$('ul.menu ul ul li:last-child').addClass('li-last');
	$('ul.menu ul').prev().addClass('a-level');
	$('ul.menu ul ul').prev().removeClass('a-level');
// TOGGLE
	$('div.toggle').click(function () {
	$(this).next('div.toggle_content').toggle(250);
	});
	$('div.toggle').toggle(
	function () { $(this).css('background-position', 'left -68px'); },
	function () { $(this).css('background-position', 'left 12px'); }
	);
})
// DRAG A THUMBS ON THE FRONTPAGE
$(window).resize(function() {
	var $div = $('#layout');
	var $width = $div.outerWidth();
	var $left = ($width-940)/2;
	$('.featpic')
		.drag(function(ev){
			$(this).css({
				top: ev.pageY - 136 - 46,
				left: ev.pageX - $left - 41
			});
		});
});

