cpVideoplayer = function(id,videofile,type,w,h){
	this.name=id;
	this.videofile=videofile;
	this.h=h;
	this.w=w;
	if(type=='qt') this.video='<embed src="'+this.videofile+'" type="video/quicktime" pluginspace="http://www.apple.com/quicktime/download/" scale="TOFIT" autoplay="true" controller="true" name="movie1" height="'+this.h+'" width="'+this.w+'">';
	if(type=='flash') this.video='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="480" height="360" id="videoplayer2" align="middle">'+
		'<param name="flashVars" Value="VidName='+this.videofile+'" >'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="allowFullScreen" value="true" />'+
		'<param name="movie" value="pics/videoplayer2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />	<embed src="pics/videoplayer2.swf" quality="high" bgcolor="#000000" width="480" height="360" name="videoplayer2" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" flashVars="VidName='+this.videofile+'" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_de" />'+
		'</object>';
	this.init=function(){
		drawBGDiv(this.name+'BG');
		this.contentDiv=document.createElement("div");
		this.contentDiv.id=this.contentDiv.name=this.name+'contentDiv';
		this.contentDiv.style.zIndex='251';
		this.contentDiv.style.position='absolute';
		this.contentDiv.style.top=(Math.max(document.documentElement.scrollTop,document.body.scrollTop)) + ((document.documentElement.clientHeight-this.h)/2)-20+'px';
		this.contentDiv.style.left=((document.documentElement.clientWidth-this.w)/2)-2+'px';
		this.contentDiv.style.width=this.w+'px';
		this.contentDiv.style.padding='2px';
		this.contentDiv.style.background='#000000';
		document.getElementsByTagName('body')[0].appendChild(this.contentDiv);
		this.contentDiv.innerHTML=''+
			this.video+
			'<div onClick="cpVideoplayerItem[\''+this.name+'\'].close();" style="cursor:pointer;text-align:center;color:#aaaaaa; font-weight:bold; padding:2px;">close Video</div>';
		var self=this;
		if (document.addEventListener) { window.addEventListener("scroll", self.scroll=function(e) { self.scrollTo(); }, true); }
		else { window.attachEvent('onscroll', self.scroll=function(e) { self.scrollTo(); },true ) }
	}

	this.scrollTo=function(){
		this.contentDiv.style.top=(Math.max(document.documentElement.scrollTop,document.body.scrollTop)) + ((document.documentElement.clientHeight-this.h)/2)-20+'px';
	}

	this.close=function(){
		if (document.addEventListener) { window.removeEventListener("scroll", self.scroll, true); }
		else { window.detachEvent('onscroll', self.scroll,true ) }
		removeBGDiv(this.name+'BG');
		if(this.contentDiv!=null) document.getElementsByTagName('body')[0].removeChild(this.contentDiv);
		this.contentDiv=null;
		cpVideoplayerItem[this.name]=null;
	}

	this.init();
}


var cpVideoplayerItem=Array();

function addcpVideoplayer(id,videofile,type,w,h){
	if(cpVideoplayerItem[id]==null) {
		cpVideoplayerItem[id]=new cpVideoplayer(id,videofile,type,w,h);
	}
}
