

/**
* Extende the promo Javascript class with local functions.
* 
* Pre-requisites: 
*	- Load the main promo.js classfile first.
*	- Laod our jQuery bindText extension.
*/

/**
* Our main function for when working with resources.
*/
Promo.prototype.initResource = function() {

	//
	// Call our parent init function.
	//
	this.init();

	var obj = this.getObj();
	obj.setCustomTheaterId();

	$("[id='attrib[RefAVCProgramId]']").change(function() {
		obj.setCustomTheaterId();
		});

	//
	// Select multiple categories
	//
	$("[id='attrib-select[CategoryTag]']").bindText(
		"[id='attrib[CategoryTag]']", { "append": true }
		);

	$("[id='search-select[RefVODCategory]']").bindText(
		"[id='search[RefVODCategory]']"
		);

	$("[id='search-select[CategoryTag]']").bindText(
		"[id='search[CategoryTag]']", { "append": true }
		);

}

/**
* Show/hide our Custom Theater ID field accordingly.
*/
Promo.prototype.setCustomTheaterId = function() {

	var obj = this.getObj();
	var val = $("[id='attrib[RefAVCProgramId]']").val();
	var target = $("[id='attrib[RefVODTheaterId]']");

	if (val != "Hotmovies" && val != "Clips") {
		obj.old_val = target.val();
		target.val("Only needed for HotMovies or Clips");
		target.attr("disabled", true);

	} else {
		target.attr("disabled", false);
		target.val(obj.old_val);

	}

} // End of setCustomTheaterId()



