/**
 *	Application Scripts for usecaseblog
 */
$(document).ready(function() {

	$('form').submit(function() {
		$('form input[type=submit]').attr('value', 'sending ...').attr('disabled','disabled');
		$('form input[type=submit]').addClass('loading');
	});
	
	// delete confirmation when in admin mode
	$('.deleteConfirm').each(function(index) {
		var url = $(this).attr('href');
		$(this).attr('href', '#');
		$(this).click(function() {
			$('body').dialog.confirm('confirm', 'Do you really want to delete this?', function(result) {
				if (result) {
					document.location.href = url;
				}
			});
			return false;
		});
	}); // deleteConfirm
	
	$('.toggleWorkDescription').click(function() {
		if ($('.workDescription').css('display') == 'block') {
			$(this).html('View Description');
		} else {
			$(this).html('Hide Description');
		}
		$('.workDescription').toggle();
	});
	// replace big headline with flash headline
	swfobject.embedSWF(
		document.WEBROOT + 'static/swf/headline.swf', 'headline', '610', '30', '9.0.0', 'expressInstall.swf', {
			string: $('#headline').html().replace(/\&amp;/, '%26'), underline: 1, bg: 'ffffff'
		}, { wmode: 'transparent' }
	);
	
	$('.thumbList .highlight').highlightlines({ justify: false });
	
	$('#NewsletterForm input').click(function() {
		if ($(this).val() === 'Your Email') {
			$(this).val('');
			$(this).addClass('active');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val('Your Email');
			$(this).removeClass('active');
		}
	});
	
});
