/* Film browse functions. */

function ajaxLoadFilmQuotes(code, elToSwap) {

	var url = siteURL + '/films/browseajax'

	jQuery.ajax({ url: url,
		data: {'action': 'load_quotes', 'code' : code},
		type: 'post',
		success: function (responseText) {

			jQuery(elToSwap).html(responseText);

		}
	});

	jQuery(elToSwap).html(loadingGraphic);

}

function swapNanoBoxColor(color, elToSwap) {

	jQuery(elToSwap).css({backgroundImage: 'url(' + imgDir + '/common/films/bg_film_infobox_small_' + color + '.png)'});

}

//add code from filmsBrowseLayout to speedup page.
jQuery(document).ready(function() {

hs.graphicsDir			= '/skins/default/imgs/highslide/';
hs.outlineType			= 'drop-shadow';
hs.wrapperClassName	= 'draggable-header';
hs.showCredits			= false;
hs.anchor						= 'top left';
// Start Window Resize Mod
hs.addEventListener(window, 'resize', function() {
	var i, exp;
	hs.getPageSize();

	for (i = 0; i < hs.expanders.length; i++) {
		exp = hs.expanders[i];
		if (exp) {
			var x = exp.x,
				y = exp.y;

			// get new thumb positions
			exp.tpos = hs.getPosition(exp.el);
			x.calcThumb();
			y.calcThumb();

			// calculate new popup position
		 	x.pos = x.tpos - x.cb + x.tb;
			x.scroll = hs.page.scrollLeft;
			x.clientSize = hs.page.width;
			y.pos = y.tpos - y.cb + y.tb;
			y.scroll = hs.page.scrollTop;
			y.clientSize = hs.page.height;
			exp.justify(x, true);
			exp.justify(y, true);

			// set new left and top to wrapper and outline
			exp.moveTo(x.pos, y.pos);
		}
	}
});
// End Window Resize Mod
// A general function to close all expanders
hs.closeAll = function () {
   for (var i = 0; i < hs.expanders.length; i++) {
      var exp = hs.expanders[i];
      if (exp) exp.close();
   }
}
// If this is a HTML expander, close all other expanders
hs.Expander.prototype.onBeforeExpand = function() {
   if (this.isHtml) hs.closeAll();

	var i, exp;
	hs.getPageSize();

	for (i = 0; i < hs.expanders.length; i++) {
		exp = hs.expanders[i];
		if (exp) {
			var x = exp.x,
				y = exp.y;

			// get new thumb positions
			exp.tpos = hs.getPosition(exp.el);
			x.calcThumb();
			y.calcThumb();

			// calculate new popup position
		 	x.pos = x.tpos - x.cb + x.tb;
			x.scroll = hs.page.scrollLeft;
			x.clientSize = hs.page.width;
			y.pos = y.tpos - y.cb + y.tb;
			y.scroll = hs.page.scrollTop;
			y.clientSize = hs.page.height;
			exp.justify(x, true);
			exp.justify(y, true);

			// set new left and top to wrapper and outline
			exp.moveTo(x.pos, y.pos);
		}
	}
}

function swapNanoBoxColor(color, elToSwap) {
	jQuery(elToSwap).css({backgroundImage: 'url(' + imgDir + '/common/films/bg_film_infobox_small_' + color + '.png)'});
}

jQuery(document).ready(function() {

		jQuery('.category').mouseover(function() {
			jQuery(this).addClass('categoryHighlightOn');
		});
		jQuery('.category').mouseout(function() {
			jQuery(this).removeClass('categoryHighlightOn');
		});		

		jQuery('.filmsBrowseContent .promo .promoPositioning .search input.promoTextField').click(function() {
				jQuery(this).val('');    //change text field to empty on focus (aka click)
		});
});

});

//for filmbrowse menu bar
function filmMenuToggle(id){
	if (typeof $filmSidebarItems == 'undefined') $filmSidebarItems = jQuery('.sidebar .allItems');
	var curItem = jQuery(id);
	var curItemShown = curItem.css('display') == 'block';
	$filmSidebarItems.hide();
	if (curItemShown) {
		curItem.hide();
	} else {
		curItem.show();
	}
}

function displayHhofDVDBuyPopup(filmID, elToHide, code) {
	trackClick(siteURL + '/store/ajax/hhofdvdbuy/' + code);

	var t = this.title || this.name || null;
	var a = siteURL + '/store/ajax/hhofdvdbuy?filmID=' + filmID + '&width=430&height=240&closer=no';
	var g = this.rel || false;
	//document.getElementById('player').style.display='none'
	tb_show(t,a,g, elToHide);
}




