$(document).ready(function() {

	$("#first-post-image").hover(
		function(){
			$("#first-post-title-background").animate({
				opacity: 0.99
			},350);
		},
		function(){
			$("#first-post-title-background").animate({
				opacity: 0.7
			},350);
		}
	);
		
	$(".recent-post-home").hover(
		function(){
			$(this).find('.overlay').fadeIn(200);
		},
		function(){
			$(this).find('.overlay').fadeOut(100);
		}
	);

	$(".unread").click(function(){
		var id = $(this).attr('id');
		var split_id = id.split('-');

		$(this).animate({
			backgroundColor: "#eeeeee"
		}, 250);
		$.ajax({
			url: "/account/viewalert/" + split_id[1],
			cache: false
		});
	});

	$(".facebook-login-button").click(function(){
		$('.fb_button_medium').click();
		return false;
	});


	$(".register-login").click(function(){

		if(window.locked != 1)
		{
			window.locked = 1;
			$('#popup-form').slideDown(300, function() {
			});
		}

		return false;
	});
	$("#close-button").click(function(){
		
		if(window.locked == 1)
		{
			window.locked = 0;
			$('#popup-form').slideUp(200, function() {

			});
		}
		
		return false;
	});
	$("#current-photos .star").live('click', function(){
		var str = $(this).attr('id');
		var photo_id = str.split('-');
		$(".star-selected").addClass('star');
		$(".star-selected").removeClass('star-selected');
		
		$(this).html('<img style="width:16px;height:16px;" src="/application/themes/desktopped/img/ajax-loader-black.gif"/>');
		$.ajax({
			url: "/setups/primary/"+photo_id[1],
			success: function(msg){
				$("#"+str).html('&nbsp;');
				$("#"+str).removeClass('star');
				$("#"+str).addClass('star-selected');
			}
		});
	});

	$(".editcaption").live('click', function(event) {
	    event.preventDefault();
	    event.stopPropagation();
		var src = $(this).parent().parent().find('img').attr('src');
		var caption = $(this).parent().parent().find('a.grouped_elements').attr('title');
		$("#caption-popup-photo").html('<img src="'+src+'"/>');
		$("#caption-photo-id").val(window.caption_id);
		$("#caption-text").html(caption);
		$("#caption-popup").slideDown(100, function(){$("#caption-text").focus();});
	});
	$("#caption-close-button").click(function(){
		$('#caption-popup').slideUp(100, function() {});
		return false;
	});

//	$('.delete').live('mouseover mouseout', function(event) {
//		if (event.type == 'mouseover') {
//			$(this).parent().parent().addClass('delete-hover');
//		} else {
//			$(this).parent().parent().removeClass('delete-hover');
//		}
//	});

	$('.delete').live('click', function(event) {
		return confirm('Are you sure?');
	});

	$(".success-close").click(function(){
		$(".success-box").slideUp(100);
	});
	$(".error-close").click(function(){
		$(".error-box").slideUp(100);
	});
	
	//Smooth scrolling within page anchors
    $('a[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}, 300);

                return false;

            }

        }

    });
});


function dropdown_computers(id)
{
	if($("#setup-computers-"+id).css('display') == 'none')
		$("#setup-computers-"+id).slideDown(100);
	else
		$("#setup-computers-"+id).slideUp(100);		
}
