$(document).ready(function() {
	$('#feedbackpopup').dialog({ autoOpen: false, title: 'Feedback', resizable: false, width: 360, 
								buttons: {
									'Send': function() { sendFeedback($('#feedbackmessage').val()); resetFeedbackForm(); $(this).dialog('close'); },
									'Cancel': function() { resetFeedbackForm(); $(this).dialog('close'); }
								},
								close: function() { resetFeedbackForm(); }
	});
	$('#feedbacklink').click(function() {
		$('#feedbackpopup').dialog('option', 'position', [$('#feedbacklink').offset().left - $('#feedbackpopup').dialog('option', 'width') + 25, $('#feedbacklink').offset().top + 25]);
		$('#feedbackpopup').dialog('open');
	});
});

function sendFeedback(feedback)
{
	if (feedback.length > 0)
		$.ajax({
			type: "GET",
				url: "email.php?mode=feedback&message=" + escape(feedback) + sid,
				success: function(msg) { if (msg.length > 0) alert(msg); }
		});
}

function resetFeedbackForm()
{
	$('#feedbackmessage').val('');
}

function staticPopup(page)
{
	window.open('static.php?page=' + page + '&frame=false', '', 'scrollbars=yes,toolbar=no,menubar=no,resizable=no,width=720,height=520,top=40,left=40');
}

function updateStyle(className, element, value)
{
	var cssRules;
	if (document.all)
		cssRules = 'rules';
	else if (document.getElementById)
		cssRules = 'cssRules';

	for (var S = 0; S < document.styleSheets.length; S++)
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
			if (document.styleSheets[S][cssRules][R][cssRules])
			{
				for (var M = 0; M < document.styleSheets[S][cssRules][R][cssRules].length; M++)
					if (document.styleSheets[S][cssRules][R][cssRules][M].selectorText == className)
					{
						document.styleSheets[S][cssRules][R][cssRules][M].style[element] = value;
						return;
					}
			}
			else if (document.styleSheets[S][cssRules][R].selectorText == className)
			{
				document.styleSheets[S][cssRules][R].style[element] = value;
				return;
			}
}