
ComicHouse.TritsRow = Class.create ({
	
	initialize: function(domRow, index, trits) {

		this.callback		= null;
		this.active			= false;
		this.domRow			= domRow;
		this.index			= index;
		this.trits			= trits;
		this.locale			= $('main').readAttribute('locale');
		this.mimetypehr 	= this.domRow.readAttribute('mimetypehr');	// now, it supports image, video, swf, flv
		this.item			= this.domRow.readAttribute('item');
		this.artworkid		= this.domRow.readAttribute('artworkid');
		this.domActive		= this.domRow.down('.activeElement');
		this.numberOverlay	= this.domRow.down('.numberOverlay');
		this.domA			= this.domRow.down('a');
		this.silent			= false;
		
		this.domA.removeAttribute('href');
		this.domA.setStyle({cursor:'pointer'});

		this.domImage = this.domA.down('img');
		
 		this.fileTarget = this.domA.readAttribute('fileTarget');

		this.fileTargetExtension = this.fileTarget.match(/\.(.{1,4})/)[1];
		
		this.isDisabled = (this.fileTarget.match(/disabled_img/))? true:false;
		
		this._wireEvtHandlers();
	},
	
	_wireEvtHandlers: function(){
		
		this.domRow.observe('click', this._setActive.bind(this));
		this.domRow.observe('custom:click', this._setActive.bind(this));
		this.domRow.observe('mouseover', this._showMouseOver.bind(this));
		this.domRow.observe('custom:mouseover', this._showMouseOver.bind(this));
		this.domRow.observe('mouseout', this._hideActive.bind(this));
		
	},
	
	_showMouseOver: function () {
		
		if (!this.trits.showHover) {return;}
		if (!ComicHouse.artCanvas.isReady()) {return;}

		if (!this.active) {
			
			this.domActive.src = 'nav/show.gif';
			this.domActive.style.visibility = 'visible';

		}

	},
	
	_hideActive: function () {

		if (!this.active) 
			this.domActive.style.visibility = 'hidden';

	},
	
	_setActive: function () {

		if (this.active) {return;}
		if (!ComicHouse.artCanvas.isReady()) {return;}
		
		this.trits.fireCallBacks(this);

		// unset current active row.
		if (this.trits.currentActive) {
			this.trits.currentActive.unSetActive();
		}
		this.trits.currentActive = this;
	
		if (!this.trits.preventDefault) {
						
			this.active = true;
			
			this.numberOverlay.setStyle({background: '#B11A3B'});
			
			if (!this.trits.isNews) {
				this.domActive.src = 'images/iselect/iselectOpenOverMouseOut.gif';
			}

			// in some cases, we don't want to load a movie
			if (this.trits.onlyLoadImages) {
				
				ComicHouse.artResourceLoader.setOnlyLoadImages();
	
			}
			
			// in iselect, there is not one urlToCurrentFolder.
			if (this.trits.page == 'iselect') {
				var urlcurrentfolder = this.domRow.readAttribute('portfoliodirectorypath');
			} else {
				var urlcurrentfolder = this.trits.path;	
			}
			
			if (!this.silent) {
				ComicHouse.artResourceLoader.load(this.locale, this.item, this.mimetypehr, urlcurrentfolder, this.artworkid, function(){this.trits.fireAfterLoadCallBacks(this);}.bind(this));
			}
			
			// remove existing subtrits.
			ComicHouse.subtritsNavigator.remove();
			
			// check for subtrits.
			if (this.trits.loadSubtrits && this.domRow.readAttribute('subtrits')) {

				var subtritses	= this.domRow.readAttribute('subtrits').evalJSON();
				ComicHouse.subtritsNavigator.setPath(urlcurrentfolder);
				ComicHouse.subtritsNavigator.setValues(subtritses);
				ComicHouse.subtritsNavigator.insert();
				
			}

		}
		
		
	},
	
	/*
	 * If true, click event won't load artwork.
	 */
	setSilent: function(bool) {
		this.silent = bool;
	},
	
	unSetActive: function() {
		
		this.numberOverlay.setStyle({background: '#FF5500'});
		this.domActive.style.visibility = 'hidden';
		this.domActive.src = 'nav/show.gif';
		this.active = false;
		
	},
	
	setCallBacks: function(callbacks) {
		this.callbacks = callbacks;
	},
	
	getImageSrc: function() {
		return this.domImage.src;
	},
	
	getDomRow: function () {
		return this.domRow;
	},

	getArtworkId: function () {
		return this.domRow.readAttribute('artworkid');
	},
	
	hideOverElement: function() {
		this.domActive.hide();
	},
	
	showOverElement: function() {
		this.domActive.show();
	},
	
	hideNumberOverlay : function(){
		this.domRow.down('.numberOverlay').hide();
	},
	
	showNumberOverlay : function(){
		this.domRow.down('.numberOverlay').show();
	}
	
	
});


ComicHouse.SubtritsNavigator = Class.create (LazzoBaseClass, {
	
	_init: function(){
		
		this.STATES				= {FREE:0,SELECTED:1};
		this.state				= this.STATES.FREE;
		this.subtritsNode		= new Element('div', {id:'subtritsen_top'});
		this.subtritsTextNode	= new Element('div', {id:'subtrits_text'}).update(ComicHouse.localizedText.subtritsNavText).hide();
		this.subtritsUlNode 	= new Element('ul');
		this.subtritsCount		= 0;
		this.subtritsNode.insert(this.subtritsUlNode);
		
		this._observe('artcanvas', this._initDependableLoaded.bind(this));
		this._observe('artcanvas-altered-height', this.setHeight.bind(this));
		
	},
	
	_initDependableLoaded: function() {
		
		if (!$('trits') || !$('art')) {
			this._fireEvent('subtritsnavigator');
			return;
		}
		
		
		$('main').insert({top:this.subtritsNode});
		$('main').insert({top:this.subtritsTextNode});
		
		this._fireEvent('subtritsnavigator');
		
	},
	
	_knightRider: function() {
		
		var isRunning = false; var counter = 0; var up = true;
		var frontElement = null; stopCounting = false;
		
		var move = function() {
				if (this.state == this.STATES.SELECTED) {
					isRunning = false;
					clearInterval(this.interval);
				} else {
					isRunning = true;
					
					beforeElement = this.subtritsUlNode.down('a', counter-1);
					frontElement = this.subtritsUlNode.down('a', counter);
					afterElement = this.subtritsUlNode.down('a', counter+1);				
					
					if (beforeElement && counter != this.subtritsCount && up) {
						beforeElement.removeClassName('selected');					
					}
	
					if (afterElement && counter != -1 && !up) {
						afterElement.removeClassName('selected');					
					}
					
					if (frontElement) {
						frontElement.addClassName('selected');
					}
					
					if (!stopCounting) {
						if (up) 
							counter++;
						else 
							counter--;
					}
						
					if (!stopCounting && counter+1 == this.subtritsCount) {
						stopCounting = true;
						setTimeout(function(){up = false; stopCounting = false;}, 200);
					} 
					
					if (!stopCounting && counter == 0) {
						stopCounting = true;
						setTimeout(function(){up = true; stopCounting = false;}, 3000);
					}
						
				}
			}.bind(this);
		
		var delayme = function(){
			this.interval = setInterval(move, 70);
		}.bind(this);
		delayme.delay(2);
		
		var mouseoverMethod = function() {
			if (isRunning) {
				this.subtritsUlNode.select('a').invoke('removeClassName', 'selected');
				isRunning = false;
				clearInterval(this.interval);
			}
		}.bind(this);
		
		this.subtritsUlNode.observe('mouseover', mouseoverMethod);
		this.subtritsUlNode.observe('custom:mouseover', mouseoverMethod);
	},
	
	setPath: function(path){
		this.path = path;
	},
	
	setValues:function(subtritses) {

		subtritses.each(function(artwork, index){
			this.subtritsCount++;
			
			var liNode	= new Element('li');
			var aNode	= new Element('a', {slot:artwork.slot}).update(String.fromCharCode(index+65));
			
			liNode.insert(aNode);
			this.subtritsUlNode.insert(liNode);
			
			var doLoadArtMethod = function() {
				if (!ComicHouse.artCanvas.isReady()) {return;}
				this.state = this.STATES.SELECTED;				
				ComicHouse.artResourceLoader.load(this.locale, artwork.slot, artwork.mimetypehr, this.path, artwork.artworkid);
				this.subtritsUlNode.select('a').invoke('removeClassName', 'selected');
				aNode.addClassName('selected');
			}.bind(this);
			
			aNode.observe('click', doLoadArtMethod);
			aNode.observe('custom:click', doLoadArtMethod);
			
		}.bind(this));
	},

	isVisible: function() {
		return this.subtritsTextNode.visible(); 
	},
	
	insert: function(){
		// calculate the left
		var width = this.subtritsCount * 17;
		var left = ((647 - (width)) / 2);
		this.subtritsNode.setStyle({left:left+'px'});
		
		// avoid flicker
		var f = function(){this.subtritsNode.show();this.subtritsTextNode.show();this._knightRider();}.bind(this); 
		f.delay(1.5);
		this._fireEvent('subtritsnavigator-loaded');
	},
	
	setHeight: function() {
		var h = ComicHouse.artCanvas.getHeight();
		h = -h/2;
		this.subtritsTextNode.setStyle({marginTop:h-20+'px'});
		this.subtritsNode.setStyle({marginTop:h+'px'});
		
	},
	
	remove: function() {
		clearInterval(this.interval);
		this.subtritsCount = 0;
		this.subtritsUlNode.update(); this.subtritsTextNode.hide();this.subtritsNode.hide();
	}
});
ComicHouse.subtritsNavigator = new ComicHouse.SubtritsNavigator();




ComicHouse.ArtResourceLoader = Class.create (LazzoBaseClass, {
	
	_init: function(){
		
		this.onlyLoadImages			= false;
		this.showCopyRight			= true;
		this.newHeight				= 0;
		
		this.loadCreditsAllLocales 	= false;
		this.checkLoopedStatus		= false;
		
	},
	
	_setPermaLink: function(locale, path, slot) {
		var permalinkurl = 'http://' + this.httphost + '/' + this.contextpath + locale + '/deeplink/' + path + '/' + slot;
		if (!this.permalink) {
			this.permalink		= new Element('a', {id:'permalink'}).update('permalink');
			this.permalinkclick	= new Element('div', {id:'permalinkclick'});
			var mainnavigation	= $('mainnavigation');
			mainnavigation.insert({after:this.permalinkclick});
			mainnavigation.insert({after:this.permalink});
			this.permalink.onclick = function(){return false;};	// prevent the link.
			this.permalink.observe('click', function(){
				this.permalinkclick.addClassName('clicked');
				return false;
			}.bind(this));
			$(document.body).observe('click', function(evt){
				if (evt.element() != this.permalinkclick && evt.element() != this.permalink) {
					this.permalinkclick.removeClassName('clicked');
				}
			}.bind(this));
		}
		this.permalink.writeAttribute('href', permalinkurl);
		this.permalinkclick.update(permalinkurl);
		
		
	},
	
	doCheckLoopedStatus: function(bool) {
		this.checkLoopedStatus = bool;
	},
	
	enableLoadCreditsAllLocales: function(){
		
		this.loadCreditsAllLocales = true;
		
	},

	disableLoadCreditsAllLocales: function(){
		
		this.loadCreditsAllLocales = false;
		
	},
	
	load: function(locale, slot, mimetypehr, path, artworkid, callback) {
		
		if (this.onlyLoadImages && (mimetypehr == 'video' || mimetypehr == 'flv' || mimetypehr == 'mp4' || mimetypehr == 'swf')) {
			return;
		}
		
		if (!this.editmode)
			this._setPermaLink(locale, path, slot);
		
		this.artworkid = artworkid;
		
		$$('#bio, #home, #webtour_logohome, #subtritsen, #subtritsen_staticportfolio_navtext, .hide_me').invoke('hide');

		ComicHouse.artCanvas.load();
		ComicHouse.quicktimeMovie.remove();
		ComicHouse.flvLoader.unload();

		if (this.checkLoopedStatus) {
			if (mimetypehr == 'video' || mimetypehr == 'flv' || mimetypehr == 'mp4' || mimetypehr == 'swf') {
				var loopedstatus = locale + '/' + path + '/' + slot + '/getitemloopedstatus';
				new Ajax.Request(loopedstatus, {onComplete: function(t){
					ComicHouse.loopController.setLooped(artworkid, t.responseText);
				}});	
			} else {
				ComicHouse.loopController.setGhost();
			}
		} 
		
		if (this.loadCreditsAllLocales) {
			var creditsaction = locale + '/' + path + '/' + slot + '/creditsalllocales';
			new Ajax.Request(creditsaction);
		}

		// hide iselectfunction, if any
		if ($('iselectfunctions')) {
			$('iselectfunctions').hide();
		}
		
		var action = locale + '/' + path + '/' + slot;
		
		// type of resource.
		// flash flv player or quicktine
		if (mimetypehr == 'flv' || mimetypehr == 'mp4' || mimetypehr == 'video' || mimetypehr == 'swf') {
			
			if (!this.onlyLoadImages) {
				
				// this returns outputs Javascript that's executed to load flv-player.
				new Ajax.Request(action, {onComplete: function(){ComicHouse.artCanvas.set(mimetypehr, true);}});
				
				// do the callback. this is onload, but there's no onload in this case. lame solution with delay
				if (callback)
					callback.delay(1);
				
			}
			
		} else {
			
			if (!this.showCopyRight) {
				action += '/nocopyright';
			}

			new Ajax.Updater('art', action,
			
				{
					onComplete: function(){
						
						ComicHouse.artCanvas.set(mimetypehr, !this.showCopyRight);
						
						if (callback)
							callback();
						
					}.bind(this)
				}
			
			);
			
			
		}
		
	},
	
	getLoadedArworkId: function(){
		
		return this.artworkid;
		
	},
	
	setShowCopyright: function(bool) {
		
		this.showCopyRight = bool;
		
	},
	
	setOnlyLoadImages: function() {
		
		this.onlyLoadImages = true;
				
	},
	
	unsetOnlyLoadImages: function() {
		
		this.onlyLoadImages = false;
				
	}
	
});
ComicHouse.artResourceLoader = new ComicHouse.ArtResourceLoader();


ComicHouse.FlvLoader = Class.create ({
	
	load: function(url) {
		
	    this.options = Object.extend({
	  		looped:'false',
	  		x:480,
	  		y:270
		}, arguments[1] || { });
	
	    var repeat		= (this.options.looped == 'false')? 'none':'always';
	    var icon		= (this.options.looped == 'false')? true:false;			// icon geeft buffer problemen
	    var controlbar	= (this.options.looped == 'false')? 'over':'none';
	    
		var basehref = $$('base')[0].readAttribute('href');
		
		var flashvars = {
			logo:basehref+'mediaplayer/skin/comichouse/blanklogo.png', 
			file:basehref+url,
			enablejs:true,
			autostart:true,
			screencolor:'#ffffff',
			bufferlength:2,
			repeat:repeat,
			width:this.options.x,
			height:this.options.y,
			icons:icon,
			controlbar:controlbar
		};

		var params = {
			wmode:'opaque',
			scale:'noscale',
			allowscriptaccess: 'always',
			allowfullscreen: 'true'
		};
		
		 var attributes = {
			name: 'comichouseflvplayer',
			id: 'comichouseflvplayer'
		 };

		
		var replaceNode = new Element('div', {id:'comichouseflvplayer'});
		ComicHouse.artCanvas.updateWithSWFFLVNode(replaceNode, this.options.y);		
		swfobject.embedSWF(basehref+'mediaplayer/skin/comichouse/CHPlayer.swf', 'comichouseflvplayer', this.options.x, this.options.y, "9", "expressInstall.swf", flashvars, params, attributes);
		
	},
	
	unload: function(){

		if (typeof $('art').sendEvent == 'function') {
			$('art').sendEvent("STOP");

		}
	}
	
	
});
ComicHouse.flvLoader = new ComicHouse.FlvLoader();




ComicHouse.Trits = Class.create (LazzoBaseClass, {
	
	_init: function() {
		
		this.currentActive		= null;
		this.callbacks			= {};
		this.afterLoadCallbacks	= {};
		this.preventDefault		= false;
		this.onlyLoadImages		= false;
		this.loadSubtrits		= true;
		this.showHover			= true;

		this._observe('subtritsnavigator', this._initDependableLoaded.bind(this));

	},

	_initDependableLoaded: function() {

		this.page = ($('imageCol'))? $('imageCol').getAttribute('whatpage'):''; 
		this.rows = $('trits').select('.thumbnailRow').map(function(domRow, index){var row = new ComicHouse.TritsRow(domRow, index, this); return row;}.bind(this)); 
	
		if (!this.editmode) {
			var attachCallbackInterval = setInterval(function(){
			
				if (typeof ComicHouse.scrollBars != 'undifined') {
				
					ComicHouse.scrollBars.get('imageCol').setCallBack(this.lazyLoadingTritsImages.bind(this));
					clearInterval(attachCallbackInterval);
					
				}
				
			}.bind(this), 100);
		}
	
		this._autofireDeeplink();
		
	},

	_autofireDeeplink: function() {
		var art = $('art');
		
		if (art && art.hasClassName('deeplinked') && art.readAttribute('artworkid')) {
			
			var id = art.readAttribute('artworkid');
			var row = $('trits').down('.thumbnailRow[artworkid='+id+']');

			// item could be part of a serie. Check all series and return the row if found.
			// this row is than used to fire click. For now, user must still navigatie to 'target' serie item
			if (!row) {
				var foundrow		= null;
				var slot			= null;
				var tritsrow		= null;
				var observer		= this._observe.bind(this);
				var stopObserver	= this._stopObserving.bind(this);
				this.rows.each(function(r, i) {
					var serie = r.domRow.readAttribute('subtrits');
					if (serie!=null) {
						
						serie = serie.evalJSON();
						
						serie.each(function(artworks) {
							if (artworks.artworkid == id) {
								slot = artworks.slot;
								foundrow = r.domRow;			
								throw $break;
							}
						});
						
						if (foundrow) {
							row = foundrow;
							// get the tritsrow object
							tritsrow = ComicHouse.trits.getTritsRows()[i];
							// set silent.
							if (tritsrow) tritsrow.setSilent(true);
							// attach observer
							observer('subtritsnavigator-loaded', function() {
								var clickthisnode = $('subtritsen_top').down('a[slot='+slot+']');
								if (clickthisnode) {
									Element.fire.delay(1.9, clickthisnode, 'custom:mouseover');
									Element.fire.delay(2, clickthisnode, 'custom:click');
								}
								stopObserver('subtritsnavigator-loaded');
							});
							
							throw $break;
						}
						
					}

				});
			} 
		
			if (row) {
							
					// scroll into view
					var imageCol = $('imageCol');
					var totalHeight = imageCol.scrollHeight - 100;

					var itemLocation = row.offsetTop;

					var percent = itemLocation / totalHeight;

					ComicHouse.scrollBars.get('imageCol').setValue(percent);
					// click event
					row.fire('custom:mouseover');
					row.fire('custom:click');
					// set active again
					if (tritsrow) tritsrow.setSilent(false);
					
					// load all images
					this.lazyLoadingTritsImages();

			}

		}
	},
	
	_reload: function(action, callback) {

		// lock editor
		ComicHouse.portfolioEditor.setDisable();
		
		// update complete trits
		new Ajax.Request(action, 
		{
			parameters:{editmode:this.editmode},
			method: 'post',
			onComplete: function(t){
			
				var html = t.responseText;		
				$('imageCol').remove();
				
				$('topCell').insert({after:html});
				
				/* anti cache measurement */
				var d = new Date();
				$('imageCol').select('.artLink img').each(function(image){image.src = image.src + '?' + d.getTime();});
				/* end anti cache measurement */
				
				this._initDependableLoaded();
	
				ComicHouse.scrollBars.get('imageCol').kill();
				ComicHouse.scrollBars.set('imageCol', new ComicHouse.Scrollblock($('imageCol'), {customClassName:'trits', offsetBy:{left:2,top:-28},leftAlign:false}));

				ComicHouse.portfolioEditor.unsetDisable();
				
				if (callback) {
					callback();
				}
				
			}.bind(this)
		});

	},
	
	/*
	 * Return ComicHouse.TritsRow objects
	 */
	getTritsRows: function() {
		return this.rows;
	},
	
	getRows: function(){
		
		return $('trits').select('.thumbnailRow');
		
	},
	
	getNodeByArtworkId: function(artworkid){
		
		return $('imageCol').down('div[artworkid='+artworkid+']');
		
	},
	
	reload: function(callback){

		var action = '/' + this.contextpath + 'resource/trits/' + this.path + '/get';
		this._reload(action, callback);
	},
	
	showDeleted: function(callback){
		
		var action = '/' + this.contextpath + 'resource/trits/' + this.path + '/trash';
		this._reload(action, callback);
		
	},
	
	unsetLoadSubtrits: function(bool){
		this.loadSubtrits = false;
	},	
	
	/*
	 * Set flag to disable artworkloading on  tritsitem click
	 */
	setPreventDefault: function(bool){
		c(bool)
		this.preventDefault = bool;
	},

	getPreventDefault: function(){
		return this.preventDefault;
	},
	
	addCallBack: function(name, callback){
		this.callbacks[name] = callback;
	},

	// these callbacks are called after (image) load.
	addAfterLoadCallBack: function(name, callback) {
		this.afterLoadCallbacks[name] = callback;
	},
	
	removeCallBack: function(name){
		this.callbacks[name] = function(){};
	},	

	removeAfterLoadCallBack: function(name){
		this.afterLoadCallbacks[name] = function(){};
	},	
	
	// fire with row being the clicked item
	fireCallBacks:function(row) {
		$H(this.callbacks).each(function(callbackobject){callbackobject[1](row);});
	},

	// fire with row being the clicked item
	fireAfterLoadCallBacks:function(row) {
		$H(this.afterLoadCallbacks).each(function(callbackobject){callbackobject[1](row);});
	},

	setOnlyLoadImages: function(bool){
		this.onlyLoadImages = bool;
	},
	
	setCustomScrollBar: function(bool) {

		if (bool) {
			$('imageCol').setStyle({overflow:'hidden', right:'0px',width:'100px'});
			ComicHouse.scrollBars.get('imageCol').showTrack();
		} else {
			ComicHouse.scrollBars.get('imageCol').hideTrack();						
			$('imageCol').setStyle({overflow:'auto', right:'-20px',width:'120px'});
		}

	},
	
	setShowHover: function(bool) {
		this.showHover = bool;
	},
	
	hideNumberOverlays : function(){
		this.setShowHover(false);
		this.rows.invoke('hideNumberOverlay');
	},
	
	showNumberOverlays : function(){
		this.setShowHover(true);
		this.rows.invoke('showNumberOverlay');
	},	
	
	getNumberOfThumbNails: function() {
		
		return $('trits').select('.thumbnailRow, .countuploadcompleted').length;
		
	},

	unsetActive: function() {
		
		if (this.currentActive) {
			this.currentActive.unSetActive();
		}
		
		ComicHouse.artCanvas.clear();
		
	},

	getScrollTop: function() {
		
		return $('imageCol').scrollTop;
		
	},
	
	lazyLoadingTritsImages: function() {
		
		if (!this.lazyLoadingFinished) {
			
			this.rows.each(function(row){
			
				var img = row.domRow.down('.artLink img');
				var src = img.readAttribute('tempsrc');
				if (src) {
					img.src = src;	
				}	
				
			});
		
			this.lazyLoadingFinished = true;
		
		}
		
	}

});
ComicHouse.trits = new ComicHouse.Trits();




ComicHouse.LoopController = Class.create (LazzoBaseClass, {
	
	_init: function() {
		
		this.artworkid = null;
		this.looped = false;
		this.ghost = false;
		
	},
	
	_setInterfaceState: function() {
		
		if (this.looped) {
			this.dominterface.addClassName('looped');
		} else {
			this.dominterface.removeClassName('looped');
		}
		
	},
	
	_setGhost: function(bool) {
		
		this.ghost = bool;

		if (this.ghost) {
			this.dominterface.setOpacity(0.3);
			this.dominterface.removeClassName('looped');
		} else {
			this.dominterface.setOpacity(1);
		}
	},
	
	_handleClick: function() {
		
		if (this.ghost) {return;}
		
		this.looped = (this.looped)? false:true;
		var looped = (this.looped)? '1':'0';
		
		this._setInterfaceState();
		
		new Ajax.Request(this.locale+'/edit/' + this.directory_id + '/artwork/'+this.artworkid+'/loop?looped='+looped);
		
	},
	
	createInterface: function() {
		
		this.dominterface = new Element('div', {id:'loopcontroller'}).update('loop').hide();
		$('portfolio_editor_6').insert({after:this.dominterface});
		
		this.dominterface.observe('click', this._handleClick.bind(this));
		this._setGhost(true);
		
		this._fireEvent('loopcontroller-interface-created');
		
	},
	
	showInterface: function() {
		this.dominterface.show();
	},

	hideInterface: function() {
		this.dominterface.hide();
	},

	setGhost: function() {
		this._setGhost(true);
	},
	
	// called by artowrkloader. sets the current server state.
	setLooped: function(artworkid, string) {
		
		this.artworkid = artworkid;
		this.looped = (string=='false')? false:true;
		this._setGhost(false);
		this._setInterfaceState();
		
	}
	
});
ComicHouse.loopController = new ComicHouse.LoopController();