function tourNumberRollovers()
{
	$("img#s1f1, img#s2f1, img#s3f1, img#s4f1").mouseover(function(){
		$(this).attr("src", "/images/feature-number-1-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/feature-number-1.png");
	});
	$("img#s1f2, img#s2f2, img#s3f2, img#s4f2").mouseover(function(){
		$(this).attr("src", "/images/feature-number-2-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/feature-number-2.png");
	});
	$("img#s1f3, img#s2f3, img#s3f3, img#s4f3").mouseover(function(){
		$(this).attr("src", "/images/feature-number-3-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/feature-number-3.png");
	});
	$("img#s1f4, img#s2f4, img#s3f4, img#s4f4").mouseover(function(){
		$(this).attr("src", "/images/feature-number-4-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/feature-number-4.png");
	});
}

function rememberMeCheck()
{
	$("a#remember-me-link").click(function(){
		if($("input#remember-me").attr("checked")==true)
		{
			$("input#remember-me").attr("checked", false);
		}
		else
		{
			$("input#remember-me").attr("checked", true);
		}
	});
	$("a#page-remember-me-link").click(function(){
		if($("input#page-remember-me").attr("checked")==true)
		{
			$("input#page-remember-me").attr("checked", false);
		}
		else
		{
			$("input#page-remember-me").attr("checked", true);
		}
	});
}

function iframeCloseRollover()
{
	$("a.close-iframe-btn").mouseover(function(){
		$(this).children().attr("src", "/images/close-iframe-btn-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/close-iframe-btn.png");
	});
	
	$("a.return-to-cb-btn").mouseover(function(){
		$(this).children().attr("src", "/images/return-to-cb-btn-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/return-to-cb-btn.png");
	});
}

function schoolSelectMenu()
{
	
	$("a.current-school").click(function(event){
		$("#school-selector").css("display", "block");
	});
	
	var sSConfig = {    
		 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 0, // number = milliseconds for onMouseOver polling interval    
		 over: sSOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 800, // number = milliseconds delay before onMouseOut    
		 out: sSOut // function = onMouseOut callback (REQUIRED)    
	};
	
	function sSOver(){ }
	
	function sSOut(){
		$("#school-selector").fadeOut("fast");
	}
	
	$("#school-selector").hoverIntent(sSConfig);
	
	$("#school-selector a").click(function(){
      $(this).animate({ backgroundColor: "white" }, 25, function(){
			$(this).animate({ backgroundColor: "#ebebeb" }, 25, function(){
					$(this).animate({ backgroundColor: "white" }, 25, function(){
							$(this).animate({ backgroundColor: "#ebebeb" }, 25, function(){
									$(this).children("img.school-select-status").fadeIn("fast");
								});
						});
				});
		});
    });

}



function addTalkBlogRollover()
{
	$(".add-talk a").mouseover(function(){
		$(this).children().attr("src", "/images/add-talk-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/add-talk.png");
	});
	$(".add-blog a").mouseover(function(){
		$(this).children().attr("src", "/images/add-blog-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/add-blog.png");
	});
}

function saySomethingControls()
{
	$("textarea.say-hello").focus(function(){
		if ($(this).attr("value") == "Say something...")
        {
        	$(this).attr("value", "");
        }									   
	});
	$("textarea.say-hello").blur(function(){
    	if ($(this).attr("value") == "")
        {
			$(this).attr("value", "Say something...");
        }
    });
}

function leaveReplyRollover()
{
	$("a.submit-reply").mouseover(function(){
		$(this).children().attr("src", "/images/leave-reply-btn-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/leave-reply-btn.png");
	});
	
	$("a.add-comment").mouseover(function(){
		$(this).children().attr("src", "/images/add-comment-btn-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/add-comment-btn.png");
	});
	
	$("#comment").focus(function(){
		if ($(this).attr("value") == "Post a comment...")
        {
        	$(this).attr("value", "");
			$(this).css("color", "#333333");
			
			$("#add-comment-btn").click(function(){
				if($("#comment").val() != "") {
					$('#comment-form').trigger('onsubmit');
					$("#add-comment-btn").unbind('click');
					$("#comment").css("color", "#bbbbbb");
					$("#comment").attr("value", "Post a comment...");
				}
			});
        }
	});
	$("#comment").blur(function(){
    	if ($(this).attr("value") == "")
        {
        	$(this).css("color", "#bbbbbb");
			$(this).attr("value", "Post a comment...");
			
			$("#add-comment-btn").unbind('click');
        }
    });
	
	$("#reply-form textarea").focus(function(){
		if ($(this).attr("value") == "Post a reply...")
        {
        	$(this).attr("value", "");
			$(this).css("color", "#333333");
			
			$("#add-reply-btn").click(function(){
				if($("#reply-form textarea").val() != "") {
					$('#reply-form').trigger('onsubmit');
					$("#add-reply-btn").unbind('click');
					$("#reply-form textarea").css("color", "#bbbbbb");
					$("#reply-form textarea").attr("value", "Post a reply...");
				}
			});
        }
	});
	$("#reply-form textarea").blur(function(){
    	if ($(this).attr("value") == "")
        {
        	$(this).css("color", "#bbbbbb");
			$(this).attr("value", "Post a reply...");
			
			$("#add-reply-btn").unbind('click');
        }
    });
}

function loginBarRollovers()
{	
	$("a.login").mouseover(function(){
		$(this).children().attr("src", "/images/lock-icon-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/lock-icon.png");
	});
}

function blogPostRollovers()
{
	$(".favorite-post").mouseover(function(){
		$(this).children().attr("src", "/images/favorite-ind-post-over.png");
	}).mouseout(function(){
		if($(this).attr("class") != 'favorite-post favorited'){ $(this).children().attr("src", "/images/favorite-ind-post.png"); }
	});
}

function homeRollovers()
{
	$("#join-top").mouseover(function(){
		$(this).children().attr("src", "/images/join-btn-over.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/join-btn.png");
	});
	
	$("img.join-banner").mouseover(function(){
		$(this).attr("src", "/images/join-banner-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/join-banner.png");
	});
	
	$("img.tour-banner").mouseover(function(){
		$(this).attr("src", "/images/tour-banner-over.png");
	}).mouseout(function(){
		$(this).attr("src", "/images/tour-banner.png");
	});
	
	$("a.follow-us").mouseover(function(){
		$(this).children().attr("src", "/images/twitter-button.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/twitter-button-dim.png");
	});
	
	$("a.fan-us").mouseover(function(){
		$(this).children().attr("src", "/images/facebook-button.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/facebook-button-dim.png");
	});
}

function gainPoint()
{
	$("#meta-points-gained").css("display", "block");
	$("#meta-points-gained").animate( {"marginTop": "-6px"}, 400, "easeOutQuad");
	$("#meta-points-gained").fadeOut(400, function(){
		$(this).css("marginTop", "0px");
	});
	$("#rt-point-score").css("display", "none");
	$("#rt-point-score").fadeIn(400);
}

function losePoint()
{
	$("#meta-points-lost").css("display", "block");
	$("#meta-points-lost").animate( {"marginTop": "6px"}, 400, "easeOutQuad");
	$("#meta-points-lost").fadeOut(400, function(){
		$(this).css("marginTop", "0px");
	});
	$("#rt-point-score").css("display", "none");
	$("#rt-point-score").fadeIn(400);
}

function editAvatar()
{
	$("div.profile-pic-hit-area").mouseover(function(){
		$(this).children(".edit-avatar").css("display", "block");
	}).mouseout(function(){
		$(this).children(".edit-avatar").css("display", "none");
	});
    
    $("a.cancel, a.done").mouseover(function(){
    	$(this).css("cursor", "pointer");
    });
    
    $("a.cancel").click(function(){
    	closeAvatarEditor();
    });
}

function removeActivityItemRollover()
{
	$(".activity-item").mouseover(function(){
		$(this).children("a.hide-activity-item").css("display", "block");
		if($(this).children("a.hide-activity-item").length)
		{
			$(this).children().children().children("img.story-thumb-small").css("opacity", ".1");
			$(this).children().children().children("img.story-thumb-small").css("filter", "alpha(opacity=10)");
			$(this).children().children("img.story-thumb-small").css("opacity", ".1");
			$(this).children().children("img.story-thumb-small").css("filter", "alpha(opacity=10)");
		}
	}).mouseout(function(){
		$(this).children("a.hide-activity-item").css("display", "none");
		$(this).children().children().children("img.story-thumb-small").css("opacity", "1");
		$(this).children().children().children("img.story-thumb-small").css("filter", "alpha(opacity=100)");
		$(this).children().children("img.story-thumb-small").css("opacity", "1");
		$(this).children().children("img.story-thumb-small").css("filter", "alpha(opacity=100)");
	});
}

function legal()
{
	$("a#TOS-link").click(function(){
		$(this).attr("class", "current");
		$("a#privacy-link").attr("class", "");
		$("#TOS").css("display", "block");
		$("#privacy-policy").css("display", "none");
		$("span.TOS-current").css("display", "inline");
		$("span.privacy-current").css("display", "none");
		
	});
	$("a#privacy-link").click(function(){
		$(this).attr("class", "current");
		$("a#TOS-link").attr("class", "");
		$("#TOS").css("display", "none");
		$("#privacy-policy").css("display", "block");
		$("span.TOS-current").css("display", "none");
		$("span.privacy-current").css("display", "inline");
	});
}

//edit in place controls
function editInfo()
{
	$("p.about-me, p.interests").mouseover(function(){
		$(this).css("background-color", "#f7f7f7");
		$(this).prev().children("div.edit-icon").css("display","block");
	}).mouseout(function(){
		$(this).css("background-color", "transparent");
		$(this).prev().children("div.edit-icon").css("display","none");
	});
	
	$("p.about-me").click(function(){
		$(this).css("display", "none");
		$("textarea.about-me").css("display","block");
		$("textarea.about-me").focus();
		$(this).prev().children("div.edit-controls").css("display","block");
	});
	
	$("p.interests").click(function(){
		$(this).css("display", "none");
		$("textarea.interests").css("display","block");
		$("textarea.interests").focus();
		$(this).prev().children("div.edit-controls").css("display","block");
	});
	
	$("a.cancel").click(function(){
		$(this).parent().css("display", "none");
		$("textarea.about-me, textarea.interests").css("display","none");
		$("p.about-me, p.interests").css("display","block");		 
	});
	
}

// tag/interest controls
function tagControls()
{    
    $("div.ind-tag, div.interest").mouseover(function(){
		$(this).children("div.tag-score").css("display", "block");
		$(this).children("a.ind-tag").css("background-color", "#33a6ff");
		$(this).children("a.ind-tag").css("color", "white");
	}).mouseout(function(){
		$(this).children("div.tag-score").css("display", "none");
		$(this).children("a.ind-tag").css("background-color", "transparent");
		$(this).children("a.ind-tag").css("color", "#999999");
	});
	
	$("div.add-tag").mouseover(function(){
		$(this).children().children("input").css("display", "block");
	}).mouseout(function(){
		if ($(this).children().children("input").attr("value") == "add tag...")
		{
			$(this).children().children("input").css("display", "none");
		}
	});
    
    $("div.add-interest").mouseover(function(){
		$(this).children().children("input").css("display", "block");
	}).mouseout(function(){
		if ($(this).children().children("input").attr("value") == "add interest...")
		{
			$(this).children().children("input").css("display", "none");
		}
	});

    $("a.add-tag, a.add-interest").click(function(){
        $(this).next().css("display", "block");
    });
    
    $("div.add-tag form input").focus(function(){
        if ($(this).attr("value") == "add tag...")
        {
            $(this).attr("value", "");
			$(this).css("color", "#333333");
        }
    });

    $("div.add-tag form input").blur(function(){
        $(this).css("display", "none");
        if ($(this).attr("value") == "")
        {
            $(this).attr("value", "add tag...");
			$(this).css("color", "#999999");
        }
    });
    
    $("div.add-interest form input").focus(function(){
		if ($(this).attr("value") == "add interest...")
		{
			$(this).attr("value", "");
			$(this).css("color", "#333333");
		}
	});
	
	$("div.add-interest form input").blur(function(){
		$(this).css("display", "none");
		if ($(this).attr("value") == "")
		{
			$(this).attr("value", "add interest...");
			$(this).css("color", "#999999");
		}
	});
    
    //remove interest control
	$("a.remove-interest").mouseover(function(){
		$(this).css("cursor", "pointer");
		$(this).children().attr("src", "/images/pink-x.png");
	}).mouseout(function(){
		$(this).children().attr("src", "/images/white-x.png");
	});
    
    //bump/dump tags
    $("a.tag-bump").mouseover(function(){
        $(this).css("cursor", "pointer");
        $(this).children().attr("src", "/images/comment-bump-over-pink.png");
    }).mouseout(function(){
        if( $(this).attr("class") != "tag-bump bumped" )
        {
        	$(this).children().attr("src", "/images/comment-bump.png");
        }
    });
    
    $("a.tag-dump").mouseover(function(){
        $(this).css("cursor", "pointer");
        $(this).children().attr("src", "/images/comment-dump-over-pink.png");
    }).mouseout(function(){
        if( $(this).attr("class") != "tag-dump dumped" )
        {
            $(this).children().attr("src", "/images/comment-dump.png");
        }
    });
}

function blogOverlayControls()
{	
	var blConfig = {    
		 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 0, // number = milliseconds for onMouseOver polling interval    
		 over: blOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: blOut // function = onMouseOut callback (REQUIRED)    
	};
	
	function blOver()
	{
		$(this).children("div.blog-profile-overlay").css('filter', 'alpha(opacity=50)');
		$(this).children("div.blog-profile-overlay").fadeIn(300);
		$(this).children().children("div.blog-score").animate( {"marginTop": "98px"},
														300, "easeOutQuad");
		$(this).children("div.favorite-rss").animate( {"marginTop": "147px"},
														 300, "easeOutQuad");
	}
	
	function blOut()
	{
		$(this).children().children("div.blog-score").animate( {"marginTop": "121px"},
														 300, "easeOutQuad");
		$(this).children("div.favorite-rss").animate( {"marginTop": "167px"},
														 300, "easeOutQuad");
		$(this).children("div.blog-profile-overlay").fadeOut(300);
	}
	
	$("div.blog-controls-mask").hoverIntent(blConfig);
    
}

function blogBumpDumpControls()
{
	$("a.blog-bump").mouseover(function(){
        $(this).children().attr("src", "/images/blog-bump-plus-over.png");
    }).mouseout(function(){
    if( $(this).attr("class") != "blog-bump bumped" )
    {
        $(this).children().attr("src", "/images/blog-bump-plus.png");
    }
    });
    
    $("a.blog-dump").mouseover(function(){
        $(this).children().attr("src", "/images/blog-dump-minus-over.png");
    }).mouseout(function(){
    if( $(this).attr("class") != "blog-dump dumped" )
    {
        $(this).children().attr("src", "/images/blog-dump-minus.png");
    }
    });
}

// bump/dump controls
function bumpDumpControls()
{
    $("a.bump").mouseover(function(){
        $(this).css("cursor", "pointer");
        if($(this).parent().attr("class") == "confirm-deny-controls")
		{
        	$(this).children().attr("src", "/images/bump-plus-talk-over.png");
        }else
        {
        	$(this).children().attr("src", "/images/bump-plus-over.png");
        }
    }).mouseout(function(){
    	if($(this).parent().attr("class") == "confirm-deny-controls")
		{
        	$(this).children().attr("src", "/images/bump-plus-talk.png");
        }else
        {
        	$(this).children().attr("src", "/images/bump-plus.png");
        }
    });
    
    $("a.dump").mouseover(function(){
        $(this).css("cursor", "pointer");
        if($(this).parent().attr("class") == "confirm-deny-controls")
		{
        	$(this).children().attr("src", "/images/dump-minus-talk-over.png");
        }else
        {
        	$(this).children().attr("src", "/images/dump-minus-over.png");
        }
    }).mouseout(function(){
    	if($(this).parent().attr("class") == "confirm-deny-controls")
		{
        	$(this).children().attr("src", "/images/dump-minus-talk.png");
        }else
        {
        	$(this).children().attr("src", "/images/dump-minus.png");
        }
    });
    
    $("a.bump").click(function(){
        $(this).parent().prev().children().children().children().fadeOut("normal");
    });
    
    $("a.dump").click(function(){
        $(this).parent().prev().children().children().children().fadeOut("normal");
    });
    
    //undo control
    $("a.undo").mouseover(function(){
        $(this).css("cursor", "pointer");
        $(this).children().attr("src", "/images/undo-btn-over.png");
    }).mouseout(function(){
        $(this).children().attr("src", "/images/undo-btn.png");			   
    });
}

// comment controls
function commentControls()
{
    $("a.expand-replies, a.collapse-replies").mouseover(function(){
        $(this).css("cursor", "pointer");
    });
    
    $("a.expand-replies").click(function(){
        $(this).parent().parent().next().slideDown("normal");
    });
    
    $("a.collapse-replies").click(function(){
        $(this).parent().parent().slideUp("normal");
    });
    
    //comment bump/dump controls
    $("a.comment-bump").mouseover(function(){
        $(this).css("cursor", "pointer");
        $(this).children().attr("src", "/images/comment-bump-over.png");
    }).mouseout(function(){
    if( $(this).attr("class") != "comment-bump bumped" )
    {
        $(this).children().attr("src", "/images/comment-bump.png");
    }
    });
    
    $("a.comment-dump").mouseover(function(){
        $(this).css("cursor", "pointer");
        $(this).children().attr("src", "/images/comment-dump-over.png");
    }).mouseout(function(){
    if( $(this).attr("class") != "comment-dump dumped" )
    {
        $(this).children().attr("src", "/images/comment-dump.png");
    }
    });
    
    $("a.comment-bump").click(function(){
        $(this).parent().next().fadeOut("normal",function () {
            $(this).fadeIn("fast");
        });
    });
    
    $("a.comment-dump").click(function(){
        $(this).parent().next().fadeOut("normal",function () {
            $(this).fadeIn("fast");
        });
    });
}

//blogwire expansion controls
function toggleSubFeed(ID) {
	if( $("#sub-feed-" + ID).css("display") == "none") {
		$("#additional-posts-btn-" + ID).attr("src", "/images/tiny-gray-triangle-down.png");
		$("#sub-feed-" + ID).slideDown();
	}else{
		$("#additional-posts-btn-" + ID).attr("src", "/images/tiny-dark-gray-triangle-right.png");
		$("#sub-feed-" + ID).slideUp();
	}
}

function showYearMenu() 
{
	$("#graduation-year").css("display", "block");
	if( $("#affiliation_Student_Student").attr('checked') ) {
		$("#graduation-year-student").css("display", "block");
		$("#graduation-year-alumni").css("display", "none");
	}else{
		$("#graduation-year-student").css("display", "none");
		$("#graduation-year-alumni").css("display", "block");
	}
}

function hideYearMenu()
{
	$("#graduation-year-student").css("display", "none");
	$("#graduation-year-alumni").css("display", "none");
	
}

$(document).ready(function()
{
	//image preloading
	guiImage1 = new Image(); 
	guiImage1.src = "/images/feature-number-1-over.png";
	guiImage2 = new Image(); 
	guiImage2.src = "/images/feature-number-2-over.png";
	guiImage3 = new Image(); 
	guiImage3.src = "/images/feature-number-3-over.png";
	guiImage4 = new Image(); 
	guiImage4.src = "/images/feature-number-4-over.png";
	guiImage5 = new Image(); 
	guiImage5.src = "/images/close-iframe-btn-over.png";
	guiImage6 = new Image(); 
	guiImage6.src = "/images/return-to-cb-btn-over.png";
	guiImage7 = new Image(); 
	guiImage7.src = "/images/add-talk-over.png";
	guiImage8 = new Image(); 
	guiImage8.src = "/images/add-blog-over.png";
	guiImage9 = new Image(); 
	guiImage9.src = "/images/leave-reply-btn-over.png";
	guiImage10 = new Image(); 
	guiImage10.src = "/images/lock-icon-over.png";
	guiImage11 = new Image(); 
	guiImage11.src = "/images/favorite-ind-post-over.png";
	guiImage12 = new Image(); 
	guiImage12.src = "/images/join-btn-over.png";
	guiImage13 = new Image(); 
	guiImage13.src = "/images/join-banner-over.png";
	guiImage14 = new Image(); 
	guiImage14.src = "/images/tour-banner-over.png";
	guiImage15 = new Image(); 
	guiImage15.src = "/images/twitter-button.png";
	guiImage16 = new Image(); 
	guiImage16.src = "/images/facebook-button.png";
	guiImage17 = new Image(); 
	guiImage17.src = "/images/pink-x.png";
	guiImage18 = new Image(); 
	guiImage18.src = "/images/comment-bump-over-pink.png";
	guiImage19 = new Image(); 
	guiImage19.src = "/images/comment-dump-over-pink.png";
	guiImage20 = new Image(); 
	guiImage20.src = "/images/blog-bump-plus-over.png";
	guiImage21 = new Image(); 
	guiImage21.src = "/images/blog-dump-minus-over.png";
	guiImage22 = new Image(); 
	guiImage22.src = "/images/bump-plus-talk-over.png";
	guiImage23 = new Image(); 
	guiImage23.src = "/images/bump-plus-over.png";
	guiImage24 = new Image(); 
	guiImage24.src = "/images/dump-minus-talk-over.png";
	guiImage25 = new Image(); 
	guiImage25.src = "/images/dump-minus-over.png";
	guiImage26 = new Image(); 
	guiImage26.src = "/images/undo-btn-over.png";
	guiImage27 = new Image(); 
	guiImage27.src = "/images/comment-bump-over.png";
	guiImage28 = new Image(); 
	guiImage28.src = "/images/comment-dump-over.png";
	guiImage29 = new Image(); 
	guiImage29.src = "/images/tiny-gray-triangle-down.png";
	guiImage30 = new Image(); 
	guiImage30.src = "/images/score-bg-minus1.png";
	guiImage31 = new Image(); 
	guiImage31.src = "/images/score-bg-plus1.png";
	guiImage32 = new Image(); 
	guiImage32.src = "/images/score-bg-talk-minus1.png";
	guiImage33 = new Image(); 
	guiImage33.src = "/images/score-bg-talk-plus1.png";
	guiImage34 = new Image(); 
	guiImage34.src = "/images/add-comment-btn-over.png";
	
	bumpDumpControls();
    blogBumpDumpControls();
	tagControls();
    blogOverlayControls();
    commentControls();
    //editInfo();
    removeActivityItemRollover();
	editAvatar();
	homeRollovers();
	blogPostRollovers();
	loginBarRollovers();
	leaveReplyRollover();
	saySomethingControls();
	addTalkBlogRollover();
	schoolSelectMenu();
	iframeCloseRollover();
	rememberMeCheck();
	
	$("#main-search input").focus(function(){
		if ($(this).attr("value") == "search")
        {
        	$(this).attr("value", "");
			$(this).css("color", "#f2f2f2");
        }									   
	});
	$("#main-search input").blur(function(){
    	if ($(this).attr("value") == "")
        {
        	$(this).css("color", "#999999");
			$(this).attr("value", "search");
        }
    });

	var popupDivWidth = $("img.avatar").width() + 20;
	$("div.crop-image-popup").css("width", popupDivWidth);
    
	$("input#user-uploaded").change(function(){
		$("#upload-blog-avatar").css("display", "block");
	});
	$("input#cb-screen-grab").change(function(){
		$("#upload-blog-avatar").css("display", "none");
	});
	
    //switch friends/followers/following
	$("a.friends, a.followers, a.following").mouseover(function(){
		$(this).css("cursor", "pointer");
	});
	
	$("a.friends").click(function(){
		$("a.followers").attr("class", "followers");
		$("a.following").attr("class", "following");
		$(this).attr("class", "friends current");
		$("div#friends, div#followers, div#following").css("display", "none");
		$("div#friends").fadeIn("normal");
	});
	
	$("a.followers").click(function(){
		$("a.friends").attr("class", "friends");
		$("a.following").attr("class", "following");
		$(this).attr("class", "followers current");
		$("div#friends, div#followers, div#following").css("display", "none");
		$("div#followers").fadeIn("normal");
	});
	
	$("a.following").click(function(){
		$("a.followers").attr("class", "followers");
		$("a.friends").attr("class", "friends");
		$(this).attr("class", "following current");
		$("div#friends, div#followers, div#following").css("display", "none");
		$("div#following").fadeIn("normal");
	});
    
    //login form actions
    $("input#email, input#ajax-email").focus(function(){
    	if ($(this).attr("value") == "username or email")
        {
        	$(this).attr("value", "");
        }
    });
    $("input#email, input#ajax-email").blur(function(){
    	if ($(this).attr("value") == "")
        {
        	$(this).attr("value", "username or email");
        }
    });
    
	//leave comment actions
	$("textarea.feed-reply-field").focus(function(){
    	if ($(this).attr("value") == "Type your reply.")
        {
        	$(this).attr("value", "");
        }
    });
    $("textarea.feed-reply-field").blur(function(){
    	if ($(this).attr("value") == "")
        {
        	$(this).attr("value", "Type your reply.");
        }
    });
	
    //TEMP
    $(this).keydown(function(e){
        if (e == null) { // ie
                keycode = event.keyCode;
        } else { // mozilla
                keycode = e.which;
        }
        if(keycode == 27){ // close
                top.tb_remove();
        }
	}); 

});	

function openAvatarEditor(avatarImage) {
	
	
	//destroy the image, and recreate it
	$("#cropbox").remove();
	$(".jcrop-holder").remove();
	var cropBoxImg = document.createElement("img");
	cropBoxImg.src = avatarImage;
	cropBoxImg.id = "cropbox";
	$("div.crop-image-popup").children("table").children().children().children().append(cropBoxImg);
	
	$('#cropbox').load(function(){
		var jcrop_api = $.Jcrop('#cropbox',{
				onSelect:showCoords, 
				bgColor: "black", 
				bgOpacity: .4, 
				aspectRatio: 165 / 126,
				allowSelect: false
				
		}); 
		
		// = $.Jcrop('#cropbox');
		var x = ($('#cropbox').width() / 2) - ( ($('#cropbox').width() * 0.75) / 2);
		var y = ($('#cropbox').height() / 2) - ( ($('#cropbox').height() * 0.56) / 2);
		var w = ($('#cropbox').width() / 2) + ( ($('#cropbox').width() * 0.75) / 2);
		var h = ($('#cropbox').height() / 2) - ( ($('#cropbox').height() * 0.56) / 2);
		jcrop_api.setSelect([ x, y, w, h ]);
		$('#cropbox').focus();
	});
	
	//alert("aa");
	tb_show(null, '#TB_inline?height=500&width=700&inlineId=av-editor&modal=true', false);
	$("#ajax-loader-light").css("display", "none");
    
	
}

function closeAvatarEditor() {
	//$("div.black-overlay").css("display", "none");
	//$("div.crop-image-popup").fadeOut();
	tb_remove();
}

function refreshProfileAvatarPreview(av1, av2) {
	//alert(av1 + " - " + av2);
	$("#preview").attr("src", av1);
	$("#preview").mouseover(function() { $("#preview").attr("src", av2); });
	$("#preview").mouseout(function() { $("#preview").attr("src", av1); });
}

function openPromptDialog(targetName) {
	$("#prompt-value").html(targetName);
}

// Our simple event handler, called from onChange and onSelect
// event handlers, as per the Jcrop invocation above
function showCoords(c) {
	jQuery('#x').val(c.x);
	jQuery('#y').val(c.y);
	jQuery('#x2').val(c.x2);
	jQuery('#y2').val(c.y2);
	jQuery('#w').val(c.w);
	jQuery('#h').val(c.h);
};

//comment expand collapse controls
function expandAllComments() {
	$('.comment-thread-replies').fadeIn();
	//hide dumped comments
	$(".reply-dumped").css("display", "none");
}

function collapseAllComments() {
	$('.comment-thread-replies').fadeOut();
}

function hideComment(commentID, threadLevel) {
	$("#comment-" + commentID).addClass("hidden-comment");
	if(threadLevel > 1) {
		$("#comment-" + commentID).removeClass("comment");
	}else{
		$("#comment-" + commentID).removeClass("comment sub");
	}
	
	$("#hidden-comment-tags-" + commentID).css("display", "block");
	
	
	$("#date-" + commentID).css("display", "none");
	$("#add-tag-" + commentID).css("display", "none");
	$("#comment-body-" + commentID).css("display", "none");
	$("#comment-thread-replies-" + commentID).css("display", "none");
	$("#c-tags-" + commentID).css("display", "none");
}

function showComment(commentID, threadLevel) {
	$("#comment-" + commentID).removeClass("hidden-comment");
	if(threadLevel > 1) {
		$("#comment-" + commentID).addClass("comment");
	}else{
		$("#comment-" + commentID).addClass("comment sub");
	}
	
	$("#hidden-comment-tags-" + commentID).css("display", "none");
	
	
	$("#date-" + commentID).css("display", "block");
	$("#add-tag-" + commentID).css("display", "block");
	$("#comment-body-" + commentID).css("display", "block");
	$("#c-tags-" + commentID).css("display", "block");
	//$("#comment-thread-replies-" + commentID).css("display", "block");
}

//schooool stuff
function switchSchool() {
	//alert($('#school-selecter').val());
	window.location = $('#school-selecter').val();
}

//block certain chars from inputs
function f(o){
	o.value=o.value.replace(/([^0-9A-Za-z-_])/g,'');
}
