$(function() {
	
	// $("a[rel]").overlay({
	// 	//expose: 'darkred',
	// 	expose: '#007EC7',
	// 	effect: 'apple',
	// 
	// 	onBeforeLoad: function() {
	// 		console.debug('load');
	// 		// grab wrapper element inside content
	// 		var wrap = this.getContent().find(".contentWrap");
	// 
	// 		// load the page specified in the trigger
	// 		wrap.load(this.getTrigger().attr("href"));
	// 	}
	// });
	
	//supersubs
	$("ul.sf-menu").supersubs({ 
        minWidth:    5,   // minimum width of sub-menus in em units 
        maxWidth:    12,   // maximum width of sub-menus in em units 
        extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                           // due to slight rounding differences and font-family 
    }).superfish();  // call supersubs first, then superfish, so that subs are 
                     // not display:none when measuring. Call before initialising 
                     // containing tabs for same reason.

	//superfish
	$('ul.sf-menu').superfish({
		pathClass:  'current',

		delay:       1000,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  true,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows
	}).find('ul').bgIframe({opacity:false}); 



	$("a[href^='http']").livequery(function() {$(this).attr('target','_blank');});
	$("a.external").livequery(function() {$(this).attr('target','_blank');});
	var smile_options = {
		beforeSubmit: function() {
			$("#SendSmileForm").fadeOut(1000, function() {
				// $('<h2 class="text"><strong>Sending...</strong></h2>').insertAfter($("#SendSmileForm")).hide().fadeIn(500);
			});
			
			
		},
		success: function(responseText) {
			$("#pp-smile h2").html('Your message has been sent!');
			$("#pp-smile p, #pp-smile form").remove();
			setTimeout(function() {
				tb_remove();
			}, 1000);
		}
	};
	$("#SendSmileForm").livequery(function() {
		$(this).ajaxForm(smile_options);
	});
	
	var quote_options = {
		beforeSubmit: function() {
			$("#SendQuoteForm").fadeOut(1000, function() {
				// $('<h2 class="text"><strong>Sending...</strong></h2>').insertAfter($("#SendSmileForm")).hide().fadeIn(500);
			});
		},
		success: function(responseText) {
			$("#pp-smile h2").html('Your quote has been sent!');
			$("#pp-smile p, #pp-smile form").remove();
			setTimeout(function() {
				tb_remove();
			}, 1000);
		}
	};
	$("#SendQuoteForm").livequery(function() {
		$(this).ajaxForm(quote_options);
	});
	
	var comic_options = {
		beforeSubmit: function() {
			$("#SendQuoteForm").fadeOut(1000, function() {
				// $('<h2 class="text"><strong>Sending...</strong></h2>').insertAfter($("#SendSmileForm")).hide().fadeIn(500);
			});
		},
		success: function(responseText) {
			$("#pp-smile h2").html('Your comic has been sent!');
			$("#pp-smile p, #pp-smile form").remove();
			setTimeout(function() {
				tb_remove();
			}, 1000);
		}
	};
	$("#SendComicForm").livequery(function() {
		$(this).ajaxForm(comic_options);
	});
	
	
	// $("#SendSmileForm").livequery("submit", function() {
	// 	$("#pp-smile h2").html('Your smile has been sent!');
	// 	$("#pp-smile p, #pp-smile form").remove();
	// 	setTimeout(function() {
	// 		tb_remove();
	// 	}, 1000);
	// 	
	// 	return false;
	// });
	$("#ContactAddForm").livequery("submit", function() {
		$("#pp-smile h2").html('Your message has been sent!');
		$("#pp-smile p, #pp-smile form").remove();
		setTimeout(function() {
			tb_remove();
		}, 1000);
		
		return false;
	});
	
	$("div#accordion dl").livequery(function() {
		$(this).accordion({
			active: false,
			header: 'div.header',
			collapsible: true
		});
	});

	$("form.to_do_item_check :checkbox").livequery("change", function(data) {
		var me = this;
		$(this).parent('form').ajaxSubmit(function(data) {
			$(me).parent('form').prev().prev().html(data);
		});
	});
})