$(document).ready(function() {
			// Weird css corrections
			/*
			if ($.browser.OS() == "Windows") {
				$(".content_head h2").css("bottom", "-5px");
			}
			*/
			
			// Top bar left text
			var text = Array("Oh, you figured out that you can click on this?", "Congrats", "Hope you enjoy the site :D", "Okay, no more", "", "", "I said no more!", "", "", "LAST ONE!", "WHY ARE YOU STILL CLICKING!?");
			var curar = 0;
			
			$("#updates").click(function() {
				if (curar < text.length) {
					$("#updates .update").fadeOut(100, function() {
							$(this).empty();
							$(this).append(text[curar]).fadeIn(100);
							curar++;
							if (curar == text.length) {
								$("#updates").css("background", "none");
							}
					});
				} else {
					$("#updates").css("background", "none");
				}
			 });
			
			// Nav animation
			$("#nav li").hover(function() {
		$(this).stop(false, false).animate({backgroundPosition: "50% -20px"}, 1000, "easeOutQuad", function() {
									$(this).css("background-position", "50% -20px;");
			});	
			}, function() {
		$(this).stop(false, false).animate({backgroundPosition: "50% -135px"}, 250, "easeInQuad", function() {
									$(this).css("background-position", "50% 135px;");
			 });	
		});	
			
			
			// Shoutbox
			
			$("#shout").submit(function() {
										
				if (($("#shout_name").val() != "") && ($("#shout_msg").val() != "")) {
					$("#shout input").each(function() {
						$(this).attr("disabled", true);								
					});
						 $.post("shout.php",{    
								name: $("#shout_name").val(),    
								msg: $("#shout_msg").val(),    
								meth: "jq",    
								sub: true
							  }, function(xml) {    
							addMessage(xml);    
						  });    
				} else {
					$("#shouttable td.input").each(function() {
						$(this).css("border", "2px solid #FF0000");
					});
				}
			 return false;    

			});  
			
			function addMessage(response) {
				if (response == "done") {
					$("#shouts tr:first").before("<tr><td class=\"sh_name\">" + $("#shout_name").val() + "</td><td>" + $("#shout_msg").val() + "</td></tr>");
					$("#shout input").each(function() {
						$(this).val("").attr("disabled", false);								
					});
					change_hello();
					$("#shoutform").slideUp();
					$("#shout_done").fadeIn();
				}
			}
			
			function change_hello() {
			// Shoutbox hellos
			var hellos = Array("dire bonjour", "say hello", "sige goddag", "decir hola", "merhaba demek", "posiada komentarzy");
			var newhello = hellos[Math.floor(Math.random()*(hellos.length))];
			$("#shouthead").empty().append(newhello);
			}
			
			$("#shouthead").click(change_hello);
			
		$("#shout_q a").hover(function() {
			$("#exp").stop(true, true).fadeIn();							 
		});
		
		$("#shout_done").mouseleave(function() {		 
			$("#exp").stop(true, true).delay(500).fadeOut();	
		});
		
		$("#exp").hover(function(event) {
			$("#exp").stop(true, true).fadeIn();							 
								 });
		
		$("#shout_done").click(function() {
			return false;
		});
		
		$("#about_imgs img").click(function() {
			$("#about_imgs").prepend($(this));										
		});
		
		$("#about_pnav .arrow").click(function() {
				if ($(this).attr("class") == "arrow right") {
					$("#about_imgs").append($("#about_imgs img:first"));
				} else if ($(this).attr("class") == "arrow left") {
					$("#about_imgs").prepend($("#about_imgs img:last"));
				}
		});
		
	/*setInterval(function() {
		$("#about_imgs").append($("#about_imgs img:first"));
    }, 250);
	*/
	
		// Portfolio
		$("a.entry_link").each(function() {
			/*if ($.browser.msie() == true) {
				if ($.browser.version.number() > 7 ) {
					$(this).after("<div class=\"fade\"></div>");
				}
			} else {
				$(this).after("<div class=\"fade\"></div>");
			}*/
			$(this).after("<div class=\"fade\"></div>");
		});
		
		$(".port_container").hover(function() {
			$(this).children(".fade").stop(true, true).fadeOut();
			$(this).children(".desc_back").stop(true, true).delay(150).animate({top: "75px"}, 500, "easeOutBack");
		}, function() {
			$(this).children(".fade").stop(true, true).fadeIn();
			$(this).children(".desc_back").stop(true, true).animate({top: "200px"}, 350, "easeInBack");
		});
		
		$(".port_container").click(function() {
			var id = $(this).attr("id");
			window.location = "portfolio.php?id=" + id;
		});
		
		$(".desc_back").click(function() {
			var id = $(this).prev(".port_container").attr("id");
			window.location = "portfolio.php?id=" + id;
		});

});
