$(function() {

	// Get Tweets
	$(".tweet").tweet({
        username: "blushbeautypdx",
        join_text: "auto",
        avatar_size: 32,
        count: 3,
        auto_join_text_default: "we said,",
        auto_join_text_ed: "we",
        auto_join_text_ing: "we were",
        auto_join_text_reply: "we replied to",
        auto_join_text_url: "we were checking out",
        loading_text: "loading tweets..."
    });

	// the product container needs a class for different view types
	$('.SI-partial-target').bind('viewchange', function(event, viewType, oldViewType) {
		$(this)
			.removeClass(oldViewType + '-view')
			.addClass(viewType + '-view');
	});

	// close wishlist context dialogs when a product gets added
	$(document).delegate('.si-wishlist-add-form', 'addtowishlist', function() {
		$(this).parents('.ui-context-dialog').contextDialog('close');
	});

	function init(target) {
		// initialize all input with hints
		$('input:text', target).hint();
		
		// initialize generic toggles
		$('a.toggle', target).toggler({
			activeClass	: 'active',
			closeClass	: 'close'
		});
		
		// initialize context dialogs
		$('.context-dialog', target).contextDialog();
		
		// initialize sliders
		$('.callout-products', target).itemSlider();
		
		// initialize zebra striping on tables and lists
		$('table tr:even', target).addClass('stripe');
	}
	
	// make sure ui widgets get initialized when elements get added to the dom
	$(document).bind('render', function(event) {
		init(event.target);
	});
	
	// initialize ui widgets on the initial page load
	init(document);
	
	// initialize menu dropdowns (this takes a long time, so do it after the rest of the JS has initialized)
	$('#main-nav > ul').dropDown({ arrows:true });
});

