Cufon.replace('.cufon');

function loadCommon()
{
	/*
	$("#modalLogin").dialog({
		autoOpen: false,
		bgiframe: true,
		width: 380,
		height: 395,
		modal: true,
		draggable: false,
		resizable: false
	});

	$("#modalRegistration").dialog({
		autoOpen: false,
		bgiframe: true,
		width: 380,
		height: 360,
		modal: true,
		draggable: false,
		resizable: false
	});
	*/	
	$("#modalFeedback").dialog({
		autoOpen: false,
		bgiframe: true,
		width: 380,
		height: 360,
		modal: true,
		draggable: false,
		resizable: false
	});
	
	$("#modalError").dialog({
		autoOpen: false,
		bgiframe: true,
		width: 380,
		height: 300,
		modal: true,
		draggable: false,
		resizable: false
	});
	
	$('#buttonSubmit').click( 
		function(e) {
			e.preventDefault();

			
			
			
			$.post('/search/feedback/create', { feedType: 	$('#feedType').val(), 
												feedSubject: 	$('#feedSubject').val(), 
												feedMessage: $('#feedMessage').val(),
												userAgent: navigator.userAgent,
												format: 'json'},
			  function(data){
			  	if(data.feedbackSaved==true)
			  	{
			  		$('#feedSubject').val('');
			  		$('#feedMessage').val('');
			  		/*
			  		$('#message_dialog').html('<p><span class=\'ui-icon ui-icon-circle-check\' style=\'float:left; margin:0 7px 50px 0;\'></span>Your feedback has been received by Zoombu.</p><p>Thank you for helping us improve our product.</p>');
			  		$('#message_dialog').dialog('open');
			  		$('#title').val('');
					$('#feedbacktext').val('');*/
			  	}
			  	else
			  	{
			  		showModalError("There was a problem submitting your feedback. Please check that the message is between 1 and 2000 characters long. Click the feedback button to try again.",'0');
			  	}
			  },'json');
			$('#modalFeedback').dialog('close');
		}
	);

	//$('#buttonLogin').click(function(){ $('#modalLogin').dialog('open'); });
	//$('#buttonRegistration').click(function(){ $('#modalRegistration').dialog('open'); });
	$('#buttonFeedback').click(function(){ $('#modalFeedback').dialog('open'); });
	$('#linkFeedback').click(function(){ $('#modalFeedback').dialog('open'); });
}

function showModalError(message,status)
{
	$('#modalErrorMessage').html(message);
	$('#modalErrorStatus').html(status);	
	$('#modalError').dialog('open');	
}

function hideModalError()
{
	$('#modalError').dialog('close');
}