


function TeaserItemD(tobj) {
		
	var self = this;
	
	var teaserObj = tobj;
	var view = teaserObj.getView();
	var x=0;
	var y=0;
	var width = 0;
	var height = 0;
	var opacity = 1;
	
	
	var border = 0;
	var borderColor = "#cccccc";
	
	var scallSet = 90;
	var contentArray = null;
	
	var div = null;
	var contId = null;
	var shadow = null;
	
	
	var movingIn = false;
	var inMove = false;
	var detailsIsShow = false;
	var isFade = false;
	
        var onclickAction = null;

	var shadowImg = null;
	
	var index = null;
	
	this.getContId = function() {
            return contId;
        }


	this.isDetailsShow = function() {
		return detailsIsShow;
	}
		
	
	this.setIndex = function(i) {
		index = i;
	}
	
	this.getIndex = function() {
		return index;
	}
	
	this.setOpacity = function(o) {
		opacity = o;
	}
	
	this.getX = function() {
		return x;
	}
	
	this.getY = function() {
		return y;
	}
	
	this.getWidth = function() {
		return width;
	}
	
	this.getHeight = function() {
		return height;
	}
	
	this.setXY = function(xs,ys) {
		x = xs;
		y = ys -150;
                if(div!=null) {
                    new Effect.Morph(div, {style: 'left:'+x+'px; top:'+y+'px'});
                }
	}
	
	this.setSize = function(w, h) {
		width = w;
		height = h;		
	}
	
	this.setContent = function(arr) {
		contentArray = arr;		
	}
	
	this.getContent = function() {
		return contentArray;
	}
	
	this.setShadowImage = function(img) {
		shadowImg = img;
	}
	
	this.setBorder = function(px, color) {
		borderColor = color;
		border = px;
	}
	
	this.getBorder = function() {
		return border;
	}

        this.setSmallView = function() {
            div.style.width = width+"px";
            div.style.height = height+"px";
            div.innerHTML = '<img src="'+contentArray[2]+'" />';

        }
	
	this.init = function() {

            div = document.createElement("div");
            var id = document.createAttribute("id");
            contId = Math.round( Math.random()*100000000000 );
            id.nodeValue = "item_"+contId;
            div.setAttributeNode(id);

            view.appendChild(div);
            div = $("item_"+contId);

            div.style.position = "absolute";
            div.style.top = y+"px";
            div.style.left = x+"px";
            div.style.zIndex = "2";
            div.style.width = width+(border*2)+"px";
            div.style.height = height+(border*2)+"px";
            div.style.cursor = "pointer";


            //div.onmouseover = overActions;
            //div.onmouseout = outActions;
            div.onclick = function() {
                try{ onclickAction(); }catch(e){ }
                
                window.location.href = contentArray[3];
                
                //alert('1');
                //teaserContLoader.loadContent('/Style Library/ESS/player.html?video='+contentArray[3]+'&color='+contentArray[4]+'', 512, 319, 'iframe', null, true, null, null, null, 160);
            }; //downActions;


            var w = Math.round( (width/100)*scallSet);
            var h = Math.round( (height/100)*scallSet);

			var ps = Math.round( (10/100)*scallSet);


            div.hide();	
            div.innerHTML +=    '<div id="title_'+contId+'" class="teaserMovieTitle " style="display:none; font-size:'+Math.round( (12/100)*scallSet)+'px; width:'+Math.round( (195/100)*scallSet)+'px; left:'+Math.round( (15.5/100)*scallSet)+'px; top:'+Math.round( (128/100)*scallSet)+'px;" >'+contentArray[5]+'</div>'+
            					//'<img title="'+contentArray[5]+'" id="item_play_'+contId+'" style="position:absolute; top:'+Math.round(62/100*scallSet)+'px; left:'+Math.round(120/100*scallSet)+'px; z-index:30;" width="'+Math.round(40/100*scallSet)+'" height="'+Math.round(40/100*scallSet)+'" src="/Style Library/ESS/img/layout/play.png"/>'+  
            					//'<img unselectable="on" id="item_backg_'+contId+'" src="'+contentArray[1]+'" style="position:absolute; top:0px left:0px;" width="'+Math.round( (273/100)*scallSet)+'" height="'+Math.round( 167/100*scallSet)+'"/>'+
            					'<span id="item_play_'+contId+'"></span><span id="item_backg_'+contId+'"></span>' + 
                                '<img unselectable="on" style="padding:'+border+'px; position:absolute; top:'+ps+'px; left:'+ps+'px; z-index:11;" id="bild_'+contId+'" src="'+contentArray[0]+'" width="'+w+'" height="'+h+'"/>';

            if(navigator.appVersion.match(/MSIE/)) {
                div.show();
            }else {
                setTimeout(function() {

                        if(opacity<1) {
                                Effect.Appear(div, {to: opacity});
                        }else {
                                Effect.Appear(div);
                        }

                }, Math.round(Math.random()*1000) );
            }
	}

	
	this.overActions = function() {overActions();}
	function overActions() {
		if(detailsIsShow==true) return;
		
		teaserObj.moveOutAll();
		
		if(movingIn == true || inMove == true) {
			return;
		}
		
		
		movingIn = true;
		inMove = true;
		
		
		
		div.style.zIndex = 12;
		if(shadowImg!=null) {
			new Effect.Parallel([
			                     new Effect.Scale('bild_'+contId, 105, {scaleFrom:100}),
			                     new Effect.Scale(div, 105, {scaleFrom:100}),
			                     new Effect.Scale($('shadow_'+contId).firstChild, 110)
			                     ],
			                     
			                     {duration: 0.1} );
		}else {
			new Effect.Parallel([
			                     new Effect.Scale('bild_'+contId, 105, {scaleFrom:100}),
			                     new Effect.Scale(div, 120, {scaleFrom:100})
			                     ],
			                     
			                     {duration: 0.1} );
		}
		
		if(opacity < 1) {
			//new Effect.Opacity(div, { from: opacity, to: 1.0, duration: 0.1 });
		}
		
		
		setTimeout(function() {
			inMove = false; 
		}, 120);
				
	}
	
	this.outActions = function() {outActions();}
	function outActions() {
		if(detailsIsShow==true) return;
		
		if(inMove==true || movingIn==false) return;
		
		inMove = true;
		div.style.zIndex = 11;
		
		var zoomTo = 95;
		var zooFrom = 105;
		if(border > 0) {
			zoomTo = zoomTo - (border*4);
			zooFrom = zooFrom - (border*4);
		}
		
		
		if(shadowImg!=null) {
			new Effect.Parallel([
			                     new Effect.Scale('bild_'+contId, zoomTo, {scaleFrom:zooFrom}),
			                     new Effect.Scale($('shadow_'+contId).firstChild, 91),
			                     new Effect.Scale(div, 95, {scaleFrom:zooFrom})
			                     ],
			                     
			                     {duration: 0.1} );
		}else {;
			new Effect.Parallel([
			                     new Effect.Scale('bild_'+contId, zoomTo, {scaleFrom:zooFrom}),
			                     new Effect.Scale(div, 95, {scaleFrom:zooFrom})
			                     ],
			                     
			                     {duration: 0.1} );			
		}
		
		if(opacity < 1) {
			new Effect.Opacity(div, {from: 1.0, to: opacity, duration: 0.1});
		}	
		
		setTimeout(function() {
			movingIn = false; 
			inMove = false;
		}, 120);
	}	
	
	
	function downActions() {
		if(inMove) return;
		
		if(detailsIsShow==true) {
			//self.animateOut();
			teaserObj.closeDetails();			
		}else{
			teaserObj.openDetails(self);
		}
	}
	
	
	this.fadeOut = function() {
		isFade = true;
		Effect.Fade(div, {duration: 0.3});
	}
	
	this.fadeIn = function() {
		if(isFade == true)
			Effect.Appear(div, {duration: 0.3});
	}	
	
	
	this.animateInTo = function(x,y, w, h) {
		outActions();
		setTimeout(function() {
			detailsIsShow = true;
			inMove = true;
			div.style.zIndex = "31";
			new Effect.Parallel([
			                     	new Effect.Morph(div, {style: 'top: '+y+'px; left: '+x+'px; height: '+h+'px; width: '+w+'px;'} ),
			                     	new Effect.Morph("bild_"+contId, {style: 'height: '+h+'px; width: '+w+'px; '} )
			                    ],
			                    {duration: 0.8} );
			
			setTimeout(function() {
				inMove = false;
			}, 820);
		},150);
	}
	
	this.animateOut = function() {
		detailsIsShow = false;
			
		inMove = true;
		
		div.style.zIndex = "10";
		new Effect.Parallel([
								new Effect.Morph('item_play_'+contId, {style: 'top:0px;'}),
		                     	new Effect.Morph(div, {style: 'top: '+y+'px; left: '+x+'px; height: '+height+'px; width: '+width+'px;'} ),
		                     	new Effect.Morph("bild_"+contId, {style: 'height: '+height+'px; width: '+width+'px; '} )
		                    ],
		                    {duration: 0.8} );
		
		setTimeout(function() {
			inMove = false;
		}, 820);
	}
	
	
	this.removeItem = function() {
		if(!navigator.appVersion.match(/MSIE/)) this.fadeOut();
		setTimeout(function() { 
			div.parentNode.removeChild(div);	 
		},1000);
	}
	
	
	this.scallItem = function(proz) {
		scallSet = proz;
		
		w = Math.round( (width/100)*proz);
		h = Math.round( (height/100)*proz);
		var ps = Math.round( (10/100)*scallSet);
		

                if(div!=null) {
                    
                    
			new Effect.Parallel([
								 new Effect.Morph('title_'+contId, {style: 'font-size:'+Math.round( (12/100)*scallSet)+'px; width:'+Math.round( (195/100)*scallSet)+'px; left:'+Math.round( (15.5/100)*scallSet)+'px; top:'+Math.round( (128/100)*scallSet)+'px;'}),
								 new Effect.Morph('item_play_'+contId, {style: 'top:'+Math.round(62/100*scallSet)+'px; left:'+Math.round(120/100*scallSet)+'px; height:'+Math.round(40/100*scallSet)+'px; width:'+Math.round(40/100*scallSet)+'px;'}),
			                     new Effect.Morph('item_backg_'+contId, {style: 'width:'+Math.round( 273/100*scallSet)+'px; height:'+Math.round( 167/100*scallSet)+'px'} ),
			                     new Effect.Morph('bild_'+contId, {style: 'width:'+w+'px; height:'+h+'px; top:'+ps+'px; left:'+ps+'px;'} )
			                     ],
			                     {duration: 0.6} );               
                }
	}

        this.setOnClickAction = function(func) {
            onclickAction = func;
        }
}
