var GALLERY_SCRIPT_ROOT = JESUS_SCRIPT_ROOT + 'gallery/';

$(document).ready(function() {
	$("#upload_toggle").css("cursor", "move");

	//
	// initialize star rating
	//
	$(".rating").each(function(i) {
		$("#jqrate_"+i).rating('', {url: GALLERY_SCRIPT_ROOT + 'rate/', maxvalue:5, increment:.5, curvalue:$("a.rated", this.parentNode).html()});
	});

	//
	// hide/unhide upload form
	//
	$("#upload_toggle").click(function() {
		$("#upload").show('slow');
		setTimeout(function() {$("#upload_toggle").hide('slow');}, 2000);
	});

	//
	// init jqm, add triggers for photos
	//
	$("#jqm").jqm({ajax: '@href', trigger: 'a.jqms'});
	$("#jqm").jqmAddTrigger('.jqmTrigger');
	$("#jqm").jqm({onShow: jqmShow()});
	$("#jqm").jqm({onLoad: jqmLoad()});

});


//
// set jqm window properties
//
var jqmShow = function() {
	var dwidth = $(document).width();
	var dheight = $(window).height();

	if (dwidth < 900) {
		dwidth = 900;
	}
	if (dheight < 600) {
		dheight = 600;
	}

	$(".jqmWindow").css('width', (dwidth-100)+'px')
			       .css('height', (dheight-60)+'px')
			       .css('position', 'absolute')
			       .css('top', '30px')
			       .css('left', '50px');
}

var jqmLoad = function() {
}

