$(function() { 
	$('#slideShow').cycle({
		fx: 'scrollHorz',
		next: '#next',
		prev: '#prev'
	});
	
	$('a.login').click(function(e) {
		//showLoginSubscribeDialog(e, this.href, "The FiFi Report is a witty, weekly, online fix of fabulous fashion, hot finds, outrageous gossip & all things groovy!");	
		//return false;
        return true;
	});
	
	$("#search.login").submit(function() {
		//var s = $("#s").val();
		//showLoginSubscribeDialog(null, "/index.php?s=" + s, "Looking for <strong>" + s + "</strong>? You'll need to sign in first I'm afraid! Not a member yet? Registering is so easy and you get access to all my lovely tips, gossip and news!");
		//return false;
        return true;
	});
	
	$("#closeLoginModal").click(function() {
		$('#loginModal').hide("slow");
		$('embed').css('visibility', 'visible');
		$(".overlay").hide();
		return false;
	});
	
	$(".menu > li").hover(function() {
		$(this).addClass("hover");						   
	}, function () {
		$(this).removeClass("hover");						   
	});
	
	$("#addComment").click(function() {
		$("#commentform").show("slow");
		return false;
	});
	
	$("#subscribe").click(function() {
		$("#loginModalForm").attr("action", "/fifi-login.php?action=register");
	});
	
});

function showLoginSubscribeDialog(e, href, message)
{
	$("#loginMessage").html(message);
	
	// getting height and width of the message box
	var height = $('#loginModal').height();
	var width = $('#loginModal').width();
	
	// calculating offset for displaying popup message
	leftVal = e ? e.pageX - (width / 2) : ($(window).width() / 2) - (width / 2);
	topVal = e ? e.pageY - (height / 2): ($(window).height() / 2) - (width / 2);
	if ( topVal < 10 ) topVal = 10;
	topVal = topVal + "px";
	leftVal = leftVal + "px";
	
	// change the redirect to value in the form so the user gets redirected where
	// they clicked once they've logged in
	$("#redirect_to").attr("value", href);
	
	// show the popup message and hide with fading effect
	$('#loginModal').css({left:leftVal,top:topVal}).show("slow");
	$('embed').css('visibility', 'hidden');
	$(".overlay").show();
}