
function mycarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function(){	
   
	$("#login_but").click( function() {
		$("#loginform").fadeIn('slow');
	} );
	$("#loginform .close").click( function() {
		$("#loginform").fadeOut('slow');
	} );
	
    
	$(".register_but").click( function() {
		$("#registerform").fadeIn('slow');
	} );
	$("#registerform .close").click( function() {
		$("#registerform").fadeOut('slow');
	} );
	$("#registerform form").submit(function(){
		$("#registerform .message").empty();
		$.post("http://www.crackgreg.com/functions/register.php",{
					login: $("#registerform .login").val(),
					email: $("#registerform .email").val(),
					password: $("#registerform .password").val(),
					action: "register"
				}, function(xml) {
			$("#registerform .login").empty();
			$("#registerform .email").empty();
			$("#registerform .password").empty();
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#registerform .message").prepend("<p class"+$("kind",message).text()+"'>"+$("info",message).text()+"</p>");
			});
		});
		return false;
	});
    
    
	$("#edit_account_but").click( function() {
		$("#editaccountform").fadeIn('slow');
        $("#editaccountform .prof_user_score").empty();
        $("#editaccountform .prof_user_picsnumb").empty();
        
		$.post("http://www.crackgreg.com/functions/show_account.php",{
					action: "show_account"
				}, function(xml) {
            $("#editaccountform .prof_user_score").prepend($("prof_user_score",xml).text());
            $("#editaccountform .prof_user_picsnumb").prepend($("prof_user_picsnumb",xml).text());
		});
        
		return false;
	
	} );
	$("#editaccountform .close").click( function() {
		$("#editaccountform").fadeOut('slow');
	} );
    
    
	$("#upload_image_but").click( function() {
		$("#imageuploadform").fadeIn('slow');
	} );
	$("#imageuploadform .close").click( function() {
		$("#imageuploadform").fadeOut('slow');
	} );
    
    
	$("#post_comment_but").click( function() {
		$("#postcommentform").fadeIn('slow');
	} );
	$("#postcommentform .close").click( function() {
		$("#postcommentform").fadeOut('slow');
	} );
	$("#postcommentform form").submit(function(){
		$("#postcommentform .message").empty();
		$.post("http://www.crackgreg.com/functions/comment.php",{
					comment: $("#postcommentform .comment").val(),
					picnicename: $("#postcommentform .picnicename").val(),
					action: "postcomment"
				}, function(xml) {
			$("#postcommentform .comment").empty();
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#postcommentform .message").prepend("<p class"+$("kind",message).text()+"'>"+$("info",message).text()+"</p>");
			});
		});
		return false;
	});
    
    
	$("#abuse_but").click( function() {
		$("#abuseform").fadeIn('slow');
	} );
	$("#abuseform .close").click( function() {
		$("#abuseform").fadeOut('slow');
	} );
	$("#abuseform form").submit(function(){
		$("#abuseform .message").empty();
		$.post("http://www.crackgreg.com/functions/abuse.php",{
					login: $("#abuseform .login").val(),
                    email: $("#abuseform .email").val(),
                    abusemessage: $("#abuseform .abusemessage").val(),
					picid: $("#abuseform .picid").val(),
					action: "postabuse"
				}, function(xml) {
			$("#abuseform .comment").empty();
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#abuseform .message").prepend("<p class"+$("kind",message).text()+"'>"+$("info",message).text()+"</p>");
			});
		});
		return false;
	});


	$("#impr_but").click( function() {
    	$("#impressumform #impressum").load('http://www.crackgreg.com/functions/show_impressum.php', function(){
			$("#impressumform").fadeIn('slow');
		});
		
	} );
	$("#impressumform .close").click( function() {
		$("#impressumform").fadeOut('slow');
	} );
	$("#impressumform form").submit(function(){
		$("#impressumform .message").empty();
		$.post("http://www.crackgreg.com/functions/impressum.php",{
					name: $("#impressumform .name").val(),
                    email: $("#impressumform .email").val(),
                    imprmessage: $("#impressumform .imprmessage").val(),
					action: "postimpr"
				}, function(xml) {
			$("#impressumform .comment").empty();
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#impressumform .message").prepend("<p class"+$("kind",message).text()+"'>"+$("info",message).text()+"</p>");
			});
		});
		return false;
	});



	$("#content #imageid img").click( function() {
   		$("#content #imageid").toggleClass("image");
	} );
    
    
	$(".show_account_but").click( function() {
		$("#show_account").fadeIn('slow');
		$("#show_account #prof_user_login").empty();
        $("#show_account #prof_user_registered").empty();
        $("#show_account #prof_user_page").empty();
        $("#show_account #prof_user_icq").empty();
        $("#show_account #prof_user_score").empty();
        $("#show_account #prof_user_picsnumb").empty();
        $("#show_account #prof_user_avatar_img").empty();
        $("#show_account #prof_user_favlink").empty();
        $("#show_account #prof_user_uploads").empty();
        $("#show_account h2").empty();
       
        var str = $(this).attr("class");

		$.post("http://www.crackgreg.com/functions/show_account.php",{
					account: str,
					action: "show_account"
				}, function(xml) {
			$("#show_account #prof_user_login").prepend($("prof_user_login",xml).text());
            $("#show_account #prof_user_registered").prepend($("prof_user_registered",xml).text());
            $("#show_account #prof_user_page").prepend($("prof_user_page",xml).text());
            $("#show_account #prof_user_icq").prepend($("prof_user_icq",xml).text());
            $("#show_account #prof_user_score").prepend($("prof_user_score",xml).text());
            $("#show_account #prof_user_picsnumb").prepend($("prof_user_picsnumb",xml).text());
            $("#show_account #prof_user_avatar_img").prepend("<img alt='"+$("prof_user_login",xml).text()+"s Avatar' title='Avatar of "+$("prof_user_login",xml).text()+"' src='"+$("prof_user_avatar_link",xml).text()+"' />");
            $("#show_account #prof_user_favlink").prepend("<a title='Visit "+$("prof_user_login",xml).text()+"s favorites' rel='nofollow' href='http://www.crackgreg.com/show-favorites/"+$("prof_user_nice",xml).text()+"/'>Visit "+$("prof_user_login",xml).text()+"s Favorites</a>");
            $("#show_account #prof_user_uploads").prepend("<a title='Visit "+$("prof_user_login",xml).text()+"s uploads' rel='nofollow' href='http://www.crackgreg.com/show-uploads/"+$("prof_user_nice",xml).text()+"/'>Visit "+$("prof_user_login",xml).text()+"s Uploads</a>");
            $("#show_account h2").prepend("Profile of: "+$("prof_user_login",xml).text());
		});
        
		return false;
	} );
	$("#show_account .close").click( function() {
		$("#show_account").fadeOut('slow');
	} );


	$("#show_scorelist_but").click( function() {
		$("#show_scores").fadeIn('slow');
		$("#show_scores table").empty();
		$.post("http://www.crackgreg.com/functions/show_scorelist.php",{
					action: "show_score"
				}, function(xml) {
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#show_scores #scores table").append("<tr><td>"+$("rank",message).text()+"</td><td>"+$("login",message).text()+"</td><td>"+$("score",message).text()+"</td><tr>");
			});
		});
        $.post("http://www.crackgreg.com/functions/show_discusslist.php",{
					action: "show_discussed"
				}, function(xml) {
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#show_scores #discussed table").append("<tr><td>"+$("rank",message).text()+"</td><td>"+$("login",message).text()+"</td><td>"+$("score",message).text()+"</td><tr>");
			});
		});
        $.post("http://www.crackgreg.com/functions/show_uploads_and_cmts.php",{
					action: "show_uploads_and_cmts"
				}, function(xml) {
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#show_scores #mostactive table").append("<tr><td>"+$("rank",message).text()+"</td><td>"+$("login",message).text()+"</td><td>"+$("score",message).text()+"</td><tr>");
			});
		});
        $.post("http://www.crackgreg.com/functions/show_get_uploads_and_cmts_last_win.php",{
					action: "show_uploads_and_cmts"
				}, function(xml) {
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#show_scores #mostactive_last table").append("<tr><td>"+$("rank",message).text()+"</td><td>"+$("login",message).text()+"</td><td>"+$("score",message).text()+"</td><tr>");
			});
		})
		return false;
	} );
	$("#show_scores .close").click( function() {
		$("#show_scores").fadeOut('slow');
	} );


	$("#add_fav_but").click( function() {
    	$("#add_to_favs").fadeIn('slow');
    	$("#add_to_favs #message").empty();
		$.post("http://www.crackgreg.com/functions/add_rem_fav.php",{
					imagenicename: js_imagenicename,
					action: "add_to_fav"
				}, function(xml) {
            $("#add_to_favs #message").prepend($("message",xml).text());
		});
        
		return false;
	} );
	$("#add_to_favs .close").click( function() {
		$("#add_to_favs").fadeOut('slow');
	} );
    
    
	$("#showmenu").click( function() {
		$("#sidebar").slideToggle("normal",function () {
        	$("#imageGrid").toggleClass("imagegridclass");
		});
	} );


    jQuery('#mycarousel').jcarousel({
		vertical: true,
        auto: 6,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });


});
