String.format = function(tmpl) {
	for(var i=1; i<arguments.length; i++) {
		re = new RegExp('\\\{' + (i-1) + '\\\}', 'gi');
		tmpl = tmpl.replace(re, arguments[i]);
	}
	return tmpl;
}

// Anchor link behavior
$(document).ready(function(){
	$('a[href^=#][href!=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 500); 
				return false;
			}
		}
	});
});

// Tabs behavior
$(document).ready(function() {
	$('.tabItem a[rel]').click(function(event) {
		if(!$(this.parentNode).hasClass('disabled')) {
			$('.tabItem a[rel]').each(function(index, node) {
				$(String.format('#{0}', $(node).attr('rel'))).hide();
			});
			$('.tabContent .act').addClass('pas');
			$('.tabContent .act').removeClass('act');
			
			$(String.format('#{0}', $(this).attr('rel'))).show();
			$(this.parentNode).removeClass('pas');
			$(this.parentNode).addClass('act');
		}
	});
	
	var a = $('.tabContent .act a[rel]');
	if(a.length == 0) a = $('.tabContent div:first a[rel]');
	a.click();
});

// PNG Fix for IE6-
$(document).ready(function(){
	if($.isFunction(jQuery.ifixpng)) {
		jQuery.ifixpng('/wp-content/themes/datingfactory/images/empty.gif');
		jQuery('img').ifixpng();
	}
});

$(document).ready(function(){
	SexyLightbox.initialize({
		imagesdir:		'/wp-content/themes/datingfactory/scripts/plugins/sexylightbox/sexyimages/',
		moveEffect:		'linear',
		resizeEffect:	'linear'
	});
});
