﻿/// <reference path="jQuery/jquery-1.3.2-vsdoc2.js" />

function OpenPopupWindow(theURL, winName) {
	window.open(theURL, winName, 'scrollbars=yes,width=580,height=600');
	return false;
}

var currentRating;
function InitialiseStars(rating) {
	currentRating = rating;
	DefaultRating();
	// highlight all the stars up to the one currently hovering over
	$('.rate_stars A').mouseenter(function() {
		$(this).addClass('ison').prevAll().addClass('ison').end().nextAll().removeClass('ison');
	});
	// set the rating back to the default
	$('.rate_stars A').mouseleave(function() {
		DefaultRating();
	});
}

function DefaultRating() {
	$('.rate_stars A:lt(' + currentRating + ')').addClass('ison');
	$('.rate_stars A:gt(' + (currentRating - 1) + ')').removeClass('ison');
}

function ClickStar(rating, photo) {
	$.getJSON('services/add_rating.aspx', { r: rating, p: photo, rnd: Math.random }, function(data) {
		var isOk = (data && data.response == 'OK');
		if (isOk) {
			alert('thank you for rating this photo')
		}
		else {
			alert(data.response)
		}
	});
	return false;
}

function InitialValue(ele, val) {
	$(ele).val('').blur(function() {
		if ($(this).val() == '') {
			$(this).val(val);
		}
	});
}
