/* -------------------------------------------------------------------------
	Name: MovieProfitTools.js
	Desc: Designed to control most common tool functions.
	Author: Krystan Gontscharow - Internet Media Productions
	Dependencies:
		- mootools-release-1.11.js
------------------------------------------------------------------------- */

var MovieProfitsTools = new Class({
	options: {
		domain: 'http://tools.movieprofits.com/',
		toolform: 'toolNav',
		paths: {
			swf: 'flashplayers/',
			flv: 'media/',
			img: 'media/',
			motd: 'motd/',
			feeds: 'feeds/'
		},
		popup: {
			imgContainer: 'hover_image',
			boxContainer: 'hover_boxcover',
			imgClass: 'hover_image'
		},
		images: {
			large: {width: 400, height: 300},
			medium: {width: null, height: null},
			small: {width: null, height: null},
			thumbnail: {width: 120, height: 90},
			boxcover: {name: 'front_m', width: 180, height: 250}
		},
		accordionMenu: {
			show: 1, display: 1,
			opacity: false,
			onActive: function(element) { element.addClass('panelActive'); },
			onBackground: function(element) { element.removeClass('panelActive'); }
		}
	},

	initialize: function(options) {
		this.setOptions(options);
		window.MPT = this;
		window.addEvent('load', function(event) { window.MPT.loadingScreen.hide(); });
		// Loading Screen - Used during load/ajax requests.
		this.loadingScreen = $('loadingScreen');
		this.loadingScreen.effect = new Fx.Style(this.loadingScreen, 'opacity', {duration: 1000});
		this.loadingScreen.show = function() { if (this.getStyle('visibility') == 'hidden') this.effect.start(0,1); };
		this.loadingScreen.hide = function() { if (this.getStyle('visibility') == 'visible') this.effect.start(1,0); };
		// Popup Overlay Image - Thumbnail hover image. 
		this.popup = new Object();
		this.popup.show = function(imgSrc, boxSrc) { if ($type(imgSrc) != 'string' || (boxSrc && !$(window.MPT.options.popup.boxContainer)) || (boxSrc && imgSrc == boxSrc) || (boxSrc && $type(boxSrc) != 'string') || !$(window.MPT.options.popup.imgContainer)) return false; var winDims = window.getSize(); var eImgCont = $(window.MPT.options.popup.imgContainer); if (eImgCont.hasChildNodes()) eImgCont.getLast().remove(); eImgCont.setStyles({left: (winDims.size.x+winDims.scroll.x-window.MPT.options.images.large.width-12)+'px', top: (winDims.size.y+winDims.scroll.y-window.MPT.options.images.large.height-12)+'px'}); var newImage = new Image(window.MPT.options.images.large.width, window.MPT.options.images.large.height); newImage.className = window.MPT.options.popup.imgClass; newImage.src = imgSrc; eImgCont.adopt(newImage); eImgCont.setStyle('display', ''); if (!boxSrc) return true; var eBoxCont = $(window.MPT.options.popup.boxContainer); if (eBoxCont.hasChildNodes()) eBoxCont.getLast().remove(); eImgCont.setStyles({left: (winDims.size.x+winDims.scroll.x-window.MPT.options.images.thumbnail.width-12)+'px', top: (winDims.size.y+winDims.scroll.y-window.MPT.options.images.large.height-window.MPT.options.images.thumbnail.height-12)+'px'}); var newImage = new Image(window.MPT.options.images.thumbnail.width, window.MPT.options.images.thumbnail.height); newImage.className = window.MPT.options.popup.imgClass; newImage.src = boxSrc; eBoxCont.adopt(newImage); eBoxCont.setStyle('display', ''); return true; };
		this.popup.hide = function() { if ($(window.MPT.options.popup.imgContainer)) $(window.MPT.options.popup.imgContainer).setStyle('display', 'none'); else return false; if ($(window.MPT.options.popup.boxContainer)) $(window.MPT.options.popup.boxContainer).setStyle('display', 'none'); else return false; return true; };
	},
	
	gotoTool: function(index) {
		this.loadingScreen.show();
		$(this.options.toolform).submit();
	}
});
MovieProfitsTools.implement(new Options);
