$(function() {
	$("#tweets").tweet({
		join_text: "",
		username: twitterlogin,
		avatar_size: 0,
		count: 5,
		auto_join_text_default: "", 
		auto_join_text_ed: "",
		auto_join_text_ing: "",
		auto_join_text_reply: "",
		auto_join_text_url: "",
		loading_text: "loading tweets..."
	});
	
	$("ul.sf-menu").superfish({
		delay: 500, // one second delay on mouseout
		animation: {opacity:'toggle', height:'show'}, // fade-in and slide-down animation
		speed: 500, // faster animation speed
		autoArrows: false, // disable generation of arrow mark-up
		dropShadows: false // disable drop shadows
	});
	
	$('.carousel').cycle({
        fx:     carousel_fx,
        timeout: 5000,
		pager: '#nav',
		next:   '#next, .carousel img', 
	    prev:   '#prev',
		before:  onBefore
	   // after:   onAfter 
    });
	
	function onBefore() { 
		$('#featured_title').html($(this).find("img").attr("alt"));
	}
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 15, /* padding for each side of the picture */
		opacity: 0.7, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
		hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
		modal: false, /* If set to true, only the close button will close the window */
		changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
		callback: function(){} /* Called when prettyPhoto is closed */
	});
	
	var tooltiptxt;
	var my_tooltip = $("#tooltip");
	$(".tooltip, .flickr_badge_image img").mouseover(function(){
		tooltiptxt = $(this).attr("title");
		$(this).removeAttr("title");
		my_tooltip.html(tooltiptxt);
		my_tooltip.css({opacity:0.9, display:"none"}).fadeIn(500);
	}).mousemove(function(e){
		var xx = e.pageX+20;
		var yy = e.pageY-5;
		//
		my_tooltip.css({left:xx, top:yy});
	}).mouseout(function(){
		my_tooltip.fadeOut(0);
		$(this).attr("title", tooltiptxt);
	});
	
	$('#header_search').each(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('rel'));
		}
	})
	.focus(function () {
		if ($(this).val() == $(this).attr('rel')) {
			$(this).val('');
		}
	})
	.blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('rel'));
		}
	});

});