// Text field label JavaScript
checkText = function(formField) {
	var formFieldValue = formField.value;
	var formFieldDefault = formField.title;
	if (formFieldValue == formFieldDefault) {
		formField.style.color ='#000';
		formField.value = "";
	}
	else if(formFieldValue == "") {
		formField.style.color ='#999';
		formField.value = formFieldDefault;
	}
}

setActive = function (formField) {
	formField.style.color = '#000';
}

chooseSection = function (section) {
	if (section) {
		var sectionID = "service_" + section;
		document.getElementById(sectionID).className = "on";
		alert("NOTE: " + sectionID + " selected.\nModify chooseSection() in common.js to add a \ncallback to save the selection to the server.");
	}
}

// Print popup window function
function popCoupon(elem) {
	newWindow = window.open(elem.href, 'name', 'width=665,height=295,menubar=1,scrollbars=1');
	if (window.focus)
		newWindow.focus();
	return false;
}

setRating = function (baseIndex, howMany, coupon_id) {
	var baseID = 'deal_' + baseIndex;
	var currRating = document.getElementById(baseID);
	howMany = parseInt(howMany);
	if (currRating) {
		currRating.style.width = howMany * 20 + "%";
		currRating.innerHTML = "Currently " + howMany + "/5 Stars.";
		RatingWebService.UpdateCouponRating(coupon_id, howMany);
		//alert("NOTE: Change the function setRating() in common.js \nto add a callback to save the rating to the server.")
	}
}

setExpectedUse = function (coupon_id, value) {
		RatingWebService.UpdateCouponExpectedUse(coupon_id, value);
}

setInterest = function (baseIndex, howMany, category_id) {
	var baseID = 'deal_' + baseIndex;
	var currRating = document.getElementById(baseID);
	howMany = parseInt(howMany);
	if (currRating) {
		currRating.style.width = howMany * 20 + "%";
		currRating.innerHTML = "Currently " + howMany + "/5 Stars.";
		RatingWebService.UpdateCategoryInterestLevel(category_id, howMany);
		//alert("NOTE: Change the function setRating() in common.js \nto add a callback to save the rating to the server.")
    }
}

setPurchaseHistory = function (category_id, value) {
		RatingWebService.UpdateCategoryPurchaseHistory(category_id, value);
}

