/* Radio/Checkbox UI */
$('.radio').click(function() {
	$('input[type=radio]', this).attr('checked', 'checked');
	checkbox_ui($('input[type=checkbox]', this));
});

$('input[type=checkbox]').click(function() {
	checkbox_ui($(this));
});
	function checkbox_ui(checkbox) {
		if (checkbox.is(':checked')) {
			checkbox.removeAttr('checked');
		} else {
			checkbox.attr('checked', 'checked');
		}
	}

/* Back javascript button */
$('#back_button').click(function() {
	history.go(-1);
	return false;
});

/**
 * Modal
 */
$('#modal').jqm({
	ajax: '@href',
	ajaxText: 'Loading...',
	trigger: 'a.modal',
	toTop: true
});

/**
 * Media Share
 */
$("a[rel='fbpopup']").click(function () {
	make_popup($(this), 650, 350);
	return false;
});

$("a[rel='supopup']").click(function () {
	make_popup($(this), 750, 450);
	return false;
});

$("a[rel='dpopup']").click(function() {
	make_popup($(this), 800, 450);
	return false;
});

function make_popup(anchor, width, height) {
	var features = "height="+height+",width="+width+",scrollTo,resizable=1,scrollbars=1,location=0";
	newwindow=window.open(anchor.attr('href'), 'Popup', features);
}