var DWObj = Class.create({
	initialize : function(options) {
		
		this.options = {
			//default settings; override when creating a new Filmstrip object
			title           : 'Doctor Who Video Player',
			keyword         : 'who_s4', //required
			templateName    : 'doctorwhos4', //required
			playerName      : 'doctorwhos4player', //required
			fsTarget		: 'fs1',
			fsWidth			: 576,
			fsHeight		: 160,
			thumbWidth		: 120,
			thumbHeight		: 90,
			thumbsPerSlide	: 4,
			thumbBorder     : '#210802', 
			thumbBorderHover: '#EDA738',
			duration        : 1,
			playerVersion   : 'olympicsLargeSingleClip',
			vidTarget       : 'videoBox',
			vidBgColor      : '#eeeeee',
			sorting			: 'descending',	//ascending, descending
			sortBy			: 'airdate'		//title, airdate
		}; Object.extend(this.options, options || {});
		
		QueryString.init();
		if(QueryString.hasQueryString()) {(QueryString.hasParameter('clipId')) ? this.clipId = QueryString.getParameter('clipId') : this.clipId = "";} else this.clipId = "";
		this.getData();
	},
	
	getData : function() {
		scope = this;
		(this.options.sorting == 'ascending') ? sorting = '&sortAscending=true' : sorting = '&sortDescending=true';
		new Ajax.Request('/tvarts/includes/Filmstrip/getPlaylist.php', {
			parameters: 'data='+escape('http://feeds.theplatform.com/ps/JSON/PortalService/1.0/getReleaseList?PID=6Zrum_sVvVFjfg2ZEZoC_J1VFToub0-T&query=UsagePlans|Open,CBC+Live+CBC+Arts+and+Entertainment&query=EncodingProfiles|flv&query=KeywordsSearch|'+this.options.keyword+'&field=added&field=approved&field=airDate&field=assetType&field=assetTypeID&field=author&field=bitrate&field=categories&field=categoryIDs&field=content&field=contentCustomData&field=contentID&field=contentOwner&field=contentType&field=copyright&field=delivery&field=encodingProfile&field=encodingProfileID&field=expirationDate&field=format&field=ID&field=keywords&field=language&field=lastModified&field=length&field=transcript&field=owner&field=PID&field=requestCount&field=server&field=serverID&field=description&field=size&field=thumbnailURL&field=title&field=transcriptURL&field=trueFormat&field=unapproveDate&field=URL&contentCustomField=hasBeenDistributed&contentCustomField=mitvAudioOnly&contentCustomField=mitvLiveURL&contentCustomField=mitvRecallReason&contentCustomField=mitvRecallTime&contentCustomField=mitvVideoLink0&contentCustomField=mitvVideoLink1&contentCustomField=mitvVideoLink2&contentCustomField=publishGroup&startIndex=1&endIndex=100&sortField='+this.options.sortBy+sorting),
			onSuccess: function(request) {
				scope.data = eval('('+request.responseText+')');
				if(scope.clipId == "" || scope.clipId == null) {scope.clipId = scope.data.items[0].contentID;}
				scope.start();
			}
		});
	},
	
	start : function() {
		var _o = this.options;
		document.location.hash = 'clipId=' + this.clipId;
		
		loadVideoPlayer(_o.templateName, _o.playerName, this.clipId, _o.vidBgColor, _o.playerVersion, _o.vidTarget);
	
		new Filmstrip(_o.fsTarget, {
			width: _o.fsWidth, 
			height: _o.fsHeight,
			thumbWidth: _o.thumbWidth,
			thumbHeight: _o.thumbHeight,
			thumbsPerSlide: _o.thumbsPerSlide,
			thumbBorder: _o.thumbBorder, 
			thumbBorderHover: _o.thumbBorderHover,
			duration: _o.duration,
			keyword: _o.keyword,
			target: _o.vidTarget,
			mavenSettings: {
				templateName: _o.templateName,
				playerName: _o.playerName,
				playerVersion: _o.playerVersion
			},
			source: this
		});
		
		//PLUCK SETTINGS
		$S.setVal("articleTitle",_o.title);
		$S.setVal("articleType","Related");
		$S.setVal("articleSection", null);
		$S.setVal("articleCategories", null); 
		$S.setVal("pModules",["p-comments"]);
		$S.setVal("cid","maven-"+this.clipId);
		//CBC.register({_name:'PLUCK',_class:PLUCK,_nameSpace: CBC.APP,_params:$S.getVal("pModules")});
		CBC.APP.PLUCK.Comments.getDataFromId('maven-'+this.clipId, {update_article:false});
	}
});
