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() {
	$('ul.tabs li a[rel]').click(function(event) {
		if(!$(this).hasClass('disabled')) {
			$('ul.tabs li a[rel]').each(function(index, node) {
				$(String.format('#{0}', $(node).attr('rel'))).hide();
			});
			$('ul.tabs li.selected').removeClass('selected');
			
			$(String.format('#{0}', $(this).attr('rel'))).show();
			$(this).parents('li').addClass('selected');
		}
	});
	
	var a = $('ul.tabs li.selected a[rel]');
	if(a.length == 0) a = $('ul.tabs li: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();
	}
});

// Use Lightbox Image preview
/*
$(document).ready(function(){
	$('a[rel*=lightbox]').lightBox({
		imageLoading:			'/wp-content/themes/datingfactory/scripts/plugins/lightbox/images/lightbox-ico-loading.gif',
		imageBtnPrev:			'/wp-content/themes/datingfactory/scripts/plugins/lightbox/images/lightbox-btn-prev.gif',
		imageBtnNext:			'/wp-content/themes/datingfactory/scripts/plugins/lightbox/images/lightbox-btn-next.gif',
		imageBtnClose:			'/wp-content/themes/datingfactory/scripts/plugins/lightbox/images/lightbox-btn-close.gif',
		imageBlank:				'/wp-content/themes/datingfactory/scripts/plugins/lightbox/images/lightbox-blank.gif'
	});
});
*/
$(document).ready(function(){
	SexyLightbox.initialize({
		imagesdir:		'/wp-content/themes/datingfactory/scripts/plugins/sexylightbox/sexyimages/',
		moveEffect:		'linear',
		resizeEffect:	'linear'
	});
});
