/**
 * @author rpf
 */
function contentElement(path, type, duration, width, height, flashvars, params, attributes){
	this.path = path;
	this.type = type;
	
	if (duration === undefined) {
		this.duration = 5000;
	}
	else {
		this.duration = duration;
	}
	
	if (width === undefined) {
		this.width = 0;
	}
	else {
		this.width = width;
	}
	
	if (height === undefined) {
		this.height = 0;
	}
	else {
		this.height = height;
	}
	
	if (flashvars === undefined) {
		this.flashvars = {};
	}
	else {
		this.flashvars = flashvars;
	}
	
	this.flashvars['duration'] = duration;
	
	if (params === undefined) {
		if (type == 'swf') {
			this.params = {
				wmode: "transparent"
			};
		}
		else {
			this.params = {};
		}
	}
	else {
		this.params = params;
	}
	
	if (attributes === undefined) {
		this.attributes = {};
	}
	else {
		this.attributes = attributes;
	}
}

var globalScope = new Array(); //IE setTimeout Workaround
function ieIntervalHandler( id, strFunc ){ //IE setTimeout Workaround
	var scope = globalScope[id];
	eval( "scope." + strFunc + "()" );
}

function homePage(contentFrameID){
	this.uniqueId = '8945619'; //IE setTimeout Workaround
	this.contents = new Array();
	this.contentLength = 0;
	this.currentContent = -1;
	this.contentFrame = document.getElementById(contentFrameID); //flashlayer.obj
	this.contentFrameImage = document.getElementById('container');
	this.contentFrameID = contentFrameID; //flashlayer
	
	this.addContent = function(path, type, duration, width, height, flashvars, params, attributes) {
		this.contentLength = this.contents.push(new contentElement(path, type, duration, width, height, flashvars, params, attributes));
	};
	
	this.runContent = function(){
		if (this.contentLength > 0) {
			this.currentContent = (this.currentContent + 1) < this.contentLength ? this.currentContent + 1 : 0;
			switch (this.contents[this.currentContent].type) {
				case 'img':
					this.runImage();
					break;
				case 'swf':
					this.runFlash();
					break;
			}
		}
	};
	
	this.runFlash = function(){
			this.contentFrame.style.display = "block";
			swfobject.embedSWF(this.contents[this.currentContent].path, 
			this.contentFrameID, 
			this.contents[this.currentContent].width, 
			this.contents[this.currentContent].height, 
			"8.0.0", false, 
			this.contents[this.currentContent].flashvars, 
			this.contents[this.currentContent].params, 
			this.contents[this.currentContent].attributes);
			
			this.contentFrameImage.style.backgroundImage = 'none';
			document.getElementsByTagName("body")[0].style.backgroundImage = 'none';		
	
			if( document.all ) //IE setTimeout Workaround
				{

					globalScope[ this.uniqueId ] = this;
					setTimeout( 'ieIntervalHandler("' + this.uniqueId + '","stopFlash")', this.contents[this.currentContent].duration );					
			}
			else
				{
			/* Mozilla */
					this.timer = setTimeout ( function( that ) { that.stopFlash(); }, this.contents[this.currentContent].duration, this );					
				}
	};
	
	
	this.runImage = function(){
		document.getElementById(this.contentFrameID).style.display = "none";
		this.contentFrameImage.style.backgroundImage = 'url('+this.contents[this.currentContent].path+')';		
		if( document.all ) //IE setTimeout Workaround
			{
				globalScope[ this.uniqueId ] = this;
				setTimeout( 'ieIntervalHandler("' + this.uniqueId + '","runContent")', this.contents[this.currentContent].duration );				
			}
		else
			{
		/* Mozilla */
				this.timer = setTimeout ( function( that ) { that.runContent(); }, this.contents[this.currentContent].duration, this );
			}		
	};
	
	this.stopFlash = function(){						
		this.obj = swfobject.getObjectById(this.contentFrameID);		
		if (this.obj) {				
			this.obj.fadeOut();			
			//alert("Fade out!");
		}		
	};
	this.animationDone = function(){
		//alert("Fade out!");
		this.runContent();
	}
}

var hp;