$(function(){
	//Carousel
	$('#profile_videos_carousel').jcarousel();
	$('#profile_photos_carousel').jcarousel({visible: 5});
	$('#related_videos_carousel').jcarousel({visible: 6});
	
	//Accordion
	$('#video_detail_options').accordion({
		header: 'h3',
		autoHeight: false
	});	
	$('#contest_video_detail_options').accordion({
		header: 'h3',
		autoHeight: false
	});

	//Tabs
	$('#home_tabs').tabs();
	$('#account_information').tabs();
	$('#message_center').tabs();
	$('#contest_management').tabs();
	$('#tab_wrapper1').tabs();
	$('#tab_wrapper2').tabs();
	
	//Dialog
	//Add Sponsor Product
	$('#add_sponsor_product_form').dialog({
		autoOpen: false,
		title: 'Add Sponsored Product',
		modal: true,
		width: 400
	});	
	$('#add_product a').click(function(){
		$('#add_sponsor_product_form').dialog('open');
		return false;
	});	
	//Embed Video
	$('#embed_video_dialog').dialog({
		autoOpen: false,
		title: 'Embed Video',
		modal: true,
		width: 300,
		height: 60
	});	
	$('#embed_trigger a').click(function(){
		$('#embed_video_dialog').dialog('open');
		return false;
	});	
	//Flag Content
	$('#flag_content_dialog').dialog({
		autoOpen: false,
		title: 'Flag Inappropriate Content',
		modal: true,
		width: 320
	});	
	$('#flag_content_trigger a').click(function(){
		$('#flag_content_dialog').dialog('open');
		return false;
	});

	//Datepicker
	$('input.datepicker').datepicker();

	//Slideshow
	$('#slide_show > ul').slideShow({
		timeOut: 5000,
		speed: 500
	});
	
	//Lightbox
	$('ul.gallery a').lightBox();
	
	//Tooltips
	$('.contestprize').tooltip({
		effect: 'slide',
		position: 'center right',
		relative: true,
		offset: [0, 10]
	});
	
    $('.sponsoredproduct_left').tooltip({
		effect: 'slide',
		position: 'center left',
		offset: [0, -10]
	});
	
    $('.sponsoredproduct_right').tooltip({
		effect: 'slide',
		position: 'center right',
		offset: [0, 10]
	});
	
	//Overlay
	$('#video_player_holder a.overlay_trigger').overlay({
		// some expose tweaks suitable for modal dialogs 
		expose: { 
			color: '#000', 
			loadSpeed: 200, 
			opacity: 0.9 
		}, 
		absolute: true,
		top: 300,
		left: 280
	});
	
	$('#profile_widgets_wrapper a.overlay_trigger').overlay({
		// some expose tweaks suitable for modal dialogs 
		expose: { 
			color: '#000', 
			loadSpeed: 200, 
			opacity: 0.9 
		},
		absolute: true,
		top: 20,
		left: -100
	});
	
	$('select#theme_changer').change(function(){
		var selected_theme = 'images/tr/' + $(this).val() + '.png';
		$('#tss img').attr('src', selected_theme);
	});
});
